I really like that idea of having an ipod scroll. The one thing that most people over look with the different scroll macros is that the speed can be changed and tuned for an individual person. If you like a certain macro but the speed isn't right, things can be adjusted to make it perfect.
I liked the ipod idea so much I decided to write my version of it. For most people it might be a little too fast but it can be fixed and I will explain how in this post.
To understand how to change the speed we need to understand the Scroll Function and it's parameters.
Scroll(UandD, RandL, delay)
UandD: number of scroll commands to send. Higher values scroll faster, 1 is the default.
>0 (positive) and scroll up
<0 (negative) and scroll down
RandL: number of left and right scroll commands to send. (Not used in this macro)
delay: time in milliseconds between scroll commands. Larger values result in slower scrolling
For smoother scrolling I usually leave all the default values of each parameter and change just the delay. To change the speed you need to change all the places it occurs in the code. I have highlighted them blue. Just change the number higher or lower until you get the results you like.
The Code:
//Created By Kimo
THREAD Profile
VAR W
VAR X
VAR Y
VAR Z
VAR Direction
VAR Speed
Start:
W = 0
X = 0
Y = 0
Z = 0
Direction = 0
Speed = 1
WaitForButton(Button, ButtonMask)
SetLeds(1, 0)
SetLeds(2, 0)
SetLeds(3, 0)
StopMotionReport()
CheckX:
IF Xmikeys > 0 THEN
X = 1
GOTO CheckY
ELSEIF Xmikeys < 0 THEN
X = - 1
GOTO CheckY
ELSEIF Xmikeys == 0 THEN
GOTO CheckX
FI
CheckY:
IF Ymikeys > 0 THEN
Y = 1
GOTO CheckStart
ELSEIF Ymikeys < 0 THEN
Y = -1
GOTO CheckStart
ELSEIF Ymikeys == 0 THEN
GOTO CheckY
FI
CheckStart:
IF (X == 1 AND Y == 1) THEN
Z = 1
GOTO CheckXAgain
ELSEIF (X == 1 AND Y == -1) THEN
Z = 2
GOTO CheckXAgain
ELSEIF (X == -1 AND Y == -1) THEN
Z = 3
GOTO CheckXAgain
ELSEIF (X == -1 AND Y == 1) THEN
Z = 4
GOTO CheckXAgain
FI
CheckXAgain:
IF Xmikeys > 0 THEN
X = 1
GOTO CheckYAgain
ELSEIF Xmikeys < 0 THEN
X = - 1
GOTO CheckYAgain
ELSEIF Xmikeys == 0 THEN
Speed = 1
GOTO CheckXAgain
FI
CheckYAgain:
IF Ymikeys > 0 THEN
Y = 1
GOTO CheckChange
ELSEIF Ymikeys < 0 THEN
Y = -1
GOTO CheckChange
ELSEIF Ymikeys == 0 THEN
Speed = 1
GOTO CheckYAgain
FI
CheckChange:
IF (X == 1 AND Y == 1) THEN
W = 1
GOTO CheckMotion
ELSEIF (X == 1 AND Y == -1) THEN
W = 2
GOTO CheckMotion
ELSEIF (X == -1 AND Y == -1) THEN
W = 3
GOTO CheckMotion
ELSEIF (X == -1 AND Y == 1) THEN
W = 4
GOTO CheckMotion
FI
CheckMotion:
IF Z == 1 THEN
IF W == 1 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 2 THEN
Direction = -1
GOTO Scrolling
ELSEIF W == 3 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 4 THEN
Direction = 1
GOTO Scrolling
FI
ELSEIF Z == 2 THEN
IF W == 1 THEN
Direction = 1
GOTO Scrolling
ELSEIF W == 2 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 3 THEN
Direction = -1
GOTO Scrolling
ELSEIF W == 4 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
FI
ELSEIF Z == 3 THEN
IF W == 1 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 2 THEN
Direction = 1
GOTO Scrolling
ELSEIF W == 3 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 4 THEN
Direction = -1
GOTO Scrolling
FI
ELSEIF Z == 4 THEN
IF W == 1 THEN
Direction = -1
GOTO Scrolling
ELSEIF W == 2 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
ELSEIF W == 3 THEN
Direction = 1
GOTO Scrolling
ELSEIF W == 4 THEN
IF Direction != 0 THEN
Scroll((Direction),0,(100/Speed))
GOTO CheckXAgain
ELSEIF Direction == 0 THEN
GOTO CheckXAgain
FI
FI
FI
Scrolling:
Scroll((Direction),0,(100/Speed))
IF Speed < 4 THEN
Speed = Speed + 1
GOTO Check
ELSEIF Speed == 4 THEN
GOTO Check
FI
Check:
IF ((GetButtonState & ButtonMask) != Button)
GOTO Exit
ELSEIF ((GetButtonState & ButtonMask) == Button)
W = 0
X = 0
Y = 0
Z = Z + Direction
IF Z <= 0 THEN
Z = 4
ELSEIF Z > 4 THEN
Z = 1
FI
GOTO CheckXAgain
FI
Exit:
RestartMotionReport()
SetLeds(1, 1)
SetLeds(2, 1)
SetLeds(3, 1)
GOTO Start
END