Re: Moving menu down in LCD
In very rough syntax:
Code:
VV var byte[6] ‘ number of values in VV byte array
work var byte ‘ work variable
index var byte ‘ first counter
indexb var byte ‘ second counter
selected var byte ‘ selected array index
lcdline var byte ‘ lcd line address
‘
selected = 0 ‘ reset selection for startup
‘
‘ reset and init lcd here
‘
cycle:
‘
‘write lcd display
for index = 0 to 3 ‘ one less than the number of lcd lines
‘
gosub get line ‘ get lcd line address
work = VV[index]
LCDOUT $FE,lcdline,[“V”,#selected,” “,”value = “,#work]
‘
if index = 1 then
LCDOUT “<-“ ‘ print arrow on second line
endif
‘
next index
‘
‘ check button here somehow
if buttonpressed = 1 then
gosub rotatearray
endif
‘
‘
goto cycle
‘
‘
getline:
lookup index,[$80,$C0,$94,$D4],lcdline
return
‘
rotatearray: ' bitwise rotate array right eight times
for indexb = 0 to 5
@ rrf _VV+7 ,F ;
@ rrf _VV+6 ,F ;
@ rrf _VV+5 ,F ;
@ rrf _VV+4 ,F ;
@ rrf _VV+3 ,F ;
@ rrf _VV+2 ,F ;
@ rrf _VV+1 ,F ;
@ rrf _VV+0 ,F ;
@ bcf _VV+7 ,7 ;clear MSB
next indexb
return
‘
Re: Moving menu down in LCD
Thank you Art, I will try and report back on Monday.
Re: Moving menu down in LCD
I see errors (late at night). In the last asm routine bitwise rotate
should be index = 0 to 7 (not 0 to 5),
and I did not increment the “selected” value.
Code:
IF button presses = 1 then
‘should also include
selected = selected + 1
if selected > 5 then
selected = 0
endif
gosub rotatearray
endif
The selected value tells you what sensor you’re looking at while you’re pointed at zero.
The first thing you should do is learn to start counting from zero like all computers and programming languages do.
Then only when it comes to displaying something like “sensor 0 is reading 32 degrees” to the Humans,
is the point you increment everything by 1 to make it readable to the outside world of Humans.
1 Attachment(s)
Re: Moving menu down in LCD
Thank you Art, but rotatearray is not working for me.
To simplify the question, I used text on the left side as: V1, V2, V3 but actually they are different strings, that is what creates the problem.
1.MY FIRST VARIABLE=20
================
2.SECOND VALUE =25
3.THIRD ONE =30
4.DIFFERENT >40
5.FIFTH VAR =50
================
6.SIXTH VAR =60
Since I can only show 4 lines on the LCD, when the user presses DOWN button I need to know the following:
selected_variable: Which variable is the user currently on (in the above example: 4)
first_line_displayed: Which lines should be displayed OR which line should be on the top (in the above example: 2)
Here is a table I created:
Attachment 7981
Dark grey is the currently selected variable
Light grey are displayed in the LCD
Based on this table:
first_line_displayed = selected_variable - 2
IF (selected_variable - 2 <= 0) THEN first_line_displayed = 1
IF (selected_variable = max_number_of_variables) THEN first_line_displayed = selected_variable - 3
This very simple method works for display purposes. However, the problem is I cannot form a loop to go through all 8 (or less/more) variables and display only the ones that should be played based on the table above (and on the correct place). Can you help me form such a loop?
Re: Moving menu down in LCD
I think that Select and Case will work:
DG=Dark Grey number
LSD = Line Start Display
MNV = Max Number of Variables
Select case DG
Case is < 4
LSD = 1 : GOSUB Display
Case is 4 to MNV - 1 'MNV calculated or hard coded. Only first 3 and last one are special cases.
LSD = DG - 2 : GOSUB Display
Case = MNV
LSD = MNV - 3: GOSUB Display
End select
Display:
For LP = LSD to LSD + 3
DIPLAY LINE LP
NEXT LP
Return