Datasheet

Jon Waddington
21
2 : text.str(string($0A,7,$0B,5,"1."))
text.str(string($0A,7,$0B,7,"2."))
text.str(string($0A,7,$0B,9,"> "))
text.str(string($0A,7,$0B,11,"4. "))
3 : text.str(string($0A,7,$0B,5,"1."))
text.str(string($0A,7,$0B,7,"2."))
text.str(string($0A,7,$0B,9,"3 "))
text.str(string($0A,7,$0B,11,"> "))
code := wait
if ((code => 1) & (code =< 4)) 'if number of item is pressed
sel := code - 1 'move cursor to item
if (code == up) 'if up is pressed
++sel 'increment 'sel'
if sel == 4 'wrap 'sel' to 0
sel := 0
if (code == down) 'if down is pressed
sel := --sel <# 3 'decrement 'sel' and wrap to 3
code := 0
case sel 'enter item
0 : HomeAutomation
1 : Temperature
2 : X10Setup
3 : Settings
The code begins by clearing the screen and showing the time and date. The menu is
then shown with the title at the top and a numbered list of items below it. A case
statement uses the “sel” variable to place the cursor on the relevant item. When a
number from one to four is pressed, the “sel” variable is changed accordingly and the
cursor moves. When the up or down button is pressed, “sel“ is incremented or
decremented, moving the cursor. “sel” also wraps around, meaning that if it is
incremented above 3, it becomes 0 and if it is decremented below 0, it becomes 3.
Hence the cursor reaches the bottom and emerges from the top and vice versa.