Menu help
Moderators: David Barker, Jerry Messina
Menu help
Does anyone have a sample of "menu" code which will help me getting started on this GLCD project. I will have 3 buttons (up, down, select) to control the menu. I have attached a picture of an example of what I'm looking for.
- Attachments
-
- menu1.png (41.06 KiB) Viewed 10575 times
Re: Menu help
Hello,
as I have already answered take a look here first
http://www.sfcompiler.co.uk/wiki/pmwiki ... MenuModule
and then replace the various LCD.WriteAt (x, y) with the GLCD.WriteAt (x, y).
Clearly a routine specific to your query involves writing one or more routines ex-novo, but the starting point is definitely something existing and functioning.
A button provides the use of a bit of a port type PORTA.0 of which first have to make bit in input with :
Given that most of the gates are no pull-up (apart from the PORTB) need to put a resistor of 10KOhm to VCC while the button must close the pin to ground.
The reading the PORTA.0 can do with a
and you will need to bring a form of anti-bounce if you want to press the button repeatedly with a routine that checks the status for several times and consider it valid only the first one state of hold..
as I have already answered take a look here first
http://www.sfcompiler.co.uk/wiki/pmwiki ... MenuModule
and then replace the various LCD.WriteAt (x, y) with the GLCD.WriteAt (x, y).
Clearly a routine specific to your query involves writing one or more routines ex-novo, but the starting point is definitely something existing and functioning.
A button provides the use of a bit of a port type PORTA.0 of which first have to make bit in input with :
Code: Select all
IN (PORTA.0)
Given that most of the gates are no pull-up (apart from the PORTB) need to put a resistor of 10KOhm to VCC while the button must close the pin to ground.
The reading the PORTA.0 can do with a
Code: Select all
IF PORTA.0 = 0 THEN
' Key is pressed
END IF
Code: Select all
// Declarations
Private Dim lastP As Boolean
Private Dim testP As Integer
// SUB area
Public Function IsPressed() As Boolean
result = false
If testP>100 Then // only after 100 from-caller cycles do a pression test
If PORTA.0 = %0 Then
If lastP = false Then // only at first non-press to press condition accept the new state
lastP = true
result = true
End If
Else
lastP = false
End If
testP = 0
Else
Inc(testP)
End If
End Function
// in Main program:
lastP = false
testP = 0
While True
IF IsPressed() Then
// Key is pressed only every 100 While cycles
End IF
End While
Re: Menu help
The LCD menu module you are referring to is for 4 line character LCD, quite different than a GLCD. Although I am very new to programming, I don't believe this will help me.
Re: Menu help
An LCD needs to specify the row and column, and is comparable to a GLCD with the difference that the position is indicated by location of the pixel where x is a byte from 0 to 127 (or 191) whereas for y, always a byte value, from 0 to 63.
With x = 0 and y = 0 that corresponds to the upper left.
Due to the font that is used, to place a string to the LCD at the first line and first column is to take into account the height of the font and position themselves accordingly (eg 0,10).
Another difference is the deletion of a row where you have to delete the actual writing area using a filled rectangle with a PEN 0 on the area.
The routines written by David contain functions that allow you to calculate the exact size of what is written on the GLCD but then we need to understand what you want to display .. the writing source that involves too many variables and many attempts before a result is considered "acceptable" .
A word of advice if you want to get answers you'll have to break down "the problem" in different "sub-problems" and then ask your questions here as to each individual problem almost certainly at least one of us can give you one or more solutions.
With x = 0 and y = 0 that corresponds to the upper left.
Due to the font that is used, to place a string to the LCD at the first line and first column is to take into account the height of the font and position themselves accordingly (eg 0,10).
Another difference is the deletion of a row where you have to delete the actual writing area using a filled rectangle with a PEN 0 on the area.
The routines written by David contain functions that allow you to calculate the exact size of what is written on the GLCD but then we need to understand what you want to display .. the writing source that involves too many variables and many attempts before a result is considered "acceptable" .
A word of advice if you want to get answers you'll have to break down "the problem" in different "sub-problems" and then ask your questions here as to each individual problem almost certainly at least one of us can give you one or more solutions.
Re: Menu help
I've spend some time utilizing parts of the LCD module and have most of what I want working except for one thing, which I can't figure out.
I can enter the menu mode by pressing any button.
I can manuver throught and out of menu mode.
However
I cannot move my selection arrow up to the second line in any menu. I have attached a screen capture showing how far up I can move in menu mode. All else works fine.
Can someone take a look.
The main program to compile is RYMAIN.BAS
I have also included a Proteus 8 file for simulation.
I can enter the menu mode by pressing any button.
I can manuver throught and out of menu mode.
However
I cannot move my selection arrow up to the second line in any menu. I have attached a screen capture showing how far up I can move in menu mode. All else works fine.
Can someone take a look.
The main program to compile is RYMAIN.BAS
I have also included a Proteus 8 file for simulation.
- Attachments
-
- menu.rar
- files
- (36.59 KiB) Downloaded 275 times
-
- screen capture
- menu.png (33.73 KiB) Viewed 10518 times
Re: Menu help
Hello,
first I can not find the definition for the inputs of the three buttons ..
in main program some like this :
first I can not find the definition for the inputs of the three buttons ..
in main program some like this :
Code: Select all
...
SetAllDigital // Turn off analogue functions - set MCU pins as digital
//USART.SetBaudrate(br19200)
input(UpButton)
input(DownButton)
input(SelectButton)
GLCD.Cls()
...
Re: Menu help
They are there..
Dim UpButton As PORTC.0
Dim DownButton As PORTC.2
Dim SelectButton As PORTC.1
.
.
.
If UpButton = 0 Then
Inc(UpButtonCount) // Check each button and if a button is pressed then increase that button's counter by 1
ElseIf DownButton = 0 Then
Inc(DownButtonCount)
ElseIf SelectButton = 0 Then
Inc(SelectButtonCount)
Are you able to run Proteus? If so..compile RYmain.bas and use that hex in the pic182525..and run emulation.
EndIf
Dim UpButton As PORTC.0
Dim DownButton As PORTC.2
Dim SelectButton As PORTC.1
.
.
.
If UpButton = 0 Then
Inc(UpButtonCount) // Check each button and if a button is pressed then increase that button's counter by 1
ElseIf DownButton = 0 Then
Inc(DownButtonCount)
ElseIf SelectButton = 0 Then
Inc(SelectButtonCount)
Are you able to run Proteus? If so..compile RYmain.bas and use that hex in the pic182525..and run emulation.
EndIf
Re: Menu help
OK.. this is a declaration
.. but this set port as input ..
or is the same with alias with
No I don't have proteus.
From what I see you have problems once the first row to move to the second and you are taken to the last, while pressing the select button will change the menu properly. Is there anything on the index of the row that does not convince me. You have created a variable to store the YPos that works for viewing option but maybe has some problems on the slider.
I think that you have used for the buttons a circuit different to the original (buttons on PORTC and not PORTB) and the key is pressed when the buttons are equal at 0. In the source of Andy0 keys are pressed when level is 1.
In your source you have to change the line where test keys not pressed from
to this
I do not know if this is enough to run everything else but it certainly is wrong.
Surely, the fact to test incorrectly the condition of "not pressed" triggers a series of problems including the resetting of the variables debounce. At the only one push of a "Down" without debouncing the button you are not sure to request only one MoveDown (), and since the lines are only 4, you are at the last option without realizing it.
I'm sorry but I have broken down the original version of the module and I preferred to generalize the procedure by placing the ability to place the menu at will.
Now in your main program can set mnuXPos, mnuYPos, mnuYStep and mnuXCurs with
.. by default menu is draw at x=20,y=10 with line spacing of 10 and the cursor is draw at x=10
The following is a generalization of the module ..
Code: Select all
Dim UpButton As PORTC.0
Code: Select all
INPUT(PORTC.0)
Code: Select all
INPUT(UpButton)
From what I see you have problems once the first row to move to the second and you are taken to the last, while pressing the select button will change the menu properly. Is there anything on the index of the row that does not convince me. You have created a variable to store the YPos that works for viewing option but maybe has some problems on the slider.
I think that you have used for the buttons a circuit different to the original (buttons on PORTC and not PORTB) and the key is pressed when the buttons are equal at 0. In the source of Andy0 keys are pressed when level is 1.
In your source you have to change the line where test keys not pressed from
Code: Select all
...
ElseIf (PORTB And %01110000) = 0 Then
' all buttons pin are grounded and other pin of PORTB ar masked by AND
Inc (NoButtonCount)
EndIf
...
Code: Select all
...
ElseIf (PORTC And %00000111) = 7 Then
' all buttons pin are at +5V and other pin of PORTC are masked by AND
Inc (NoButtonCount)
EndIf
...
Surely, the fact to test incorrectly the condition of "not pressed" triggers a series of problems including the resetting of the variables debounce. At the only one push of a "Down" without debouncing the button you are not sure to request only one MoveDown (), and since the lines are only 4, you are at the last option without realizing it.
I'm sorry but I have broken down the original version of the module and I preferred to generalize the procedure by placing the ability to place the menu at will.
Now in your main program can set mnuXPos, mnuYPos, mnuYStep and mnuXCurs with
Code: Select all
Initialise(pItemActionEvent As TEvent,
XMnuPos As Byte = 20,
YMnuPos As Byte = 10,
YMnuStep As Byte = 10,
XMnuCurs As Byte = 10
The following is a generalization of the module ..
Code: Select all
Module RYMenu
Include "glcd"
#ifdef MenuDataModule
Include MenuDataModule
#else
#error "No MenuDataModule defined in main program"
#endif
#option Menu_LCDLines = 4 'Number of lines on LCD display
#option Menu_ShowMenuTitle = True 'Display Menu Name at top of screen?
#option Menu_ShowScrollIndicators = True 'Show up and down scroll indicators?
#option Menu_ScrollWrapping = False 'Scroll wraps from top to bottom?
#option Menu_PointerCharacter = 126 'Character used as pointer
#if Menu_LCDLines = 1 And Menu_ShowMenuTitle = True
#error "Cannot show menu titles on 1 line LCD"
#endif
Type TEvent = Event()
Private Const
LCDLines As Byte = Menu_LCDLines,
PointerCharacter As Byte = Menu_PointerCharacter
#If Menu_ShowScrollIndicators = True
'Character definitions for Up Arrow and Down Arrow scroll indicators
Private Const ScrollIndicators(16) As Byte=($04,$0E,$1F,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$1F,$0E,$04)
Private Const UpArrow = 0
Private Const DownArrow = 1
#EndIf
Private Dim FItemActionEvent As TEvent 'Holds pointer to event code in main
'program which is run when an "action"
'menu item is selected
Private Dim PointerPosition As Byte 'Position of pointer character (0 = 1st)
Private Dim PointerLine As Byte 'Actual LCD line of pointer
Private Dim ScrollPosition As Byte 'Number of lines the menu is scrolled by
Private Dim CurrentMenu As Byte 'Index number of current menu
Private Dim ParentID As Byte 'Index number of parent of current menu
Private Dim FirstItemNumber As Byte 'First item number for current menu
Private Dim LastItemNumber As Byte 'Last item number for current menu
Public Dim SelectedMenuItem As Byte 'Index number of selected menu item
'===============================================================================
'Name: DrawMenu(pMenuNumber as byte)
'Purpose: Draws current menu, scrolled by ScrollPosition amount
'
Private Dim
xPos As Byte,
yPos As Byte,
yStep As Byte,
xCurs As Byte
Dim LineNumber As Byte 'Line number of LCD to write at
Private Function GetYPos(p As Byte = 0) As Byte
If p<>0 Then
result = (p - 1) * yStep
Else
result = (LineNumber - 1) * yStep
End If
End Function
Private Sub DrawMenu()
Dim ItemNumber As Byte 'Index of menu item number to write
#If Menu_ScrollWrapping = True
Dim ItemsDrawn As Byte
ItemsDrawn = 0
#EndIf
'LCDI2C.Cls
GLCD.Cls(1)
LineNumber = 1
ItemNumber = FirstItemNumber + ScrollPosition
#If Menu_ShowMenuTitle = True
' LCDI2C.WriteConstStringAt(1, 1, mnuMenuName(CurrentMenu))
GLCD.WriteStr(xPos, GetYPos() , mnuMenuName(CurrentMenu))
LineNumber = 2
#Endif
Repeat
'LCDI2C.WriteConstStringAt(LineNumber, 2, mnuItemName(ItemNumber))
GLCD.WriteStr(xPos, GetYPos() , mnuItemName(ItemNumber))
Inc(LineNumber)
Inc(ItemNumber)
#If Menu_ScrollWrapping = True
Inc(ItemsDrawn)
If ItemNumber > LastItemNumber Then
ItemNumber = FirstItemNumber
EndIf
Until LineNumber > LCDLines Or ItemsDrawn > LastItemNumber - FirstItemNumber
#Else
Until LineNumber > LCDLines Or ItemNumber > LastItemNumber
#EndIf
#If Menu_ShowScrollIndicators = True
#If Menu_ScrollWrapping = True
#If Menu_ShowMenuTitle = True
If LastItemNumber - FirstItemNumber > LCDLines - 1 Then
'LCD.WriteAt(LCDLines, 1, DownArrow)
GLCD.WriteAt(xCurs, GetYPos(LCDLines) , DownArrow)
'LCD.WriteAt(2, 1, UpArrow)
GLCD.WriteAt(xCurs, GetYPos(2) , UpArrow)
#Else
If LastItemNumber - FirstItemNumber > LCDLines Then
'LCD.WriteAt(LCDLines, 1, DownArrow)
GLCD.WriteAt(xCurs, GetYPos(LCDLines) , DownArrow)
'LCD.WriteAt(1, 1, UpArrow)
GLCD.WriteAt(xCurs, GetYPos(1) , UpArrow)
#EndIf
EndIf
#Else
If ItemNumber - 1 < LastItemNumber Then
'LCDI2C.WriteAt(LCDLines, 1, DownArrow)
GLCD.WriteAt(xCurs, GetYPos(LCDLines) , DownArrow)
EndIf
If ScrollPosition > 0 Then
#If Menu_ShowMenuTitle = True
'LCDI2C.WriteAt(2, 1, UpArrow)
GLCD.WriteAt(xCurs, GetYPos(2) , UpArrow)
#Else
'LCDI2C.WriteAt(1, 1, UpArrow)
GLCD.WriteAt(xCurs, GetYPos(1) , UpArrow)
#EndIf
EndIf
#EndIf
#EndIf
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: DrawPointer(pOldPosition as byte)
'Purpose: Deletes pointer at pOldPosition and draws pointer at PointerPosition
'Notes: When pointer is at first menu item on screen, PointerPosition = 0
' Pointer character determined by option "Menu_PointerCharacter",
' default = 126 (right arrow)
Private Sub DrawPointer(pOldPosition As Byte)
'Actual LCD line which pointer is drawn on depends on whether
'Menu_ShowMenuTitle is enabled or not
#If Menu_ShowMenuTitle Then
PointerLine = PointerPosition + 2
'LCDI2C.WriteAt(pOldPosition + 2, 1, " ")
'LCDI2C.WriteAt(PointerLine, 1, PointerCharacter)
GLCD.WriteAt(xCurs, GetYPos(pOldPosition + 2) , " ")
GLCD.WriteAt(xCurs, GetYPos(PointerLine) , PointerCharacter)
#Else
PointerLine = PointerPosition + 1
'LCDI2C.WriteAt(pOldPosition + 1, 1, " ")
'LCDI2C.WriteAt(PointerLine, 1, PointerCharacter)
GLCD.WriteAt(xCurs, GetYPos(pOldPosition + 1) , " ")
GLCD.WriteAt(xCurs, GetYPos(PointerLine) , PointerCharacter)
#EndIf
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: ShowMenu(pMenuNumber as byte = 0)
'Purpose: Display specified menu on LCD
Public Sub ShowMenu(pMenuNumber As Byte = 0)
'Reset scroll and pointer positions
ScrollPosition = 0
PointerPosition = 0
CurrentMenu = pMenuNumber
ParentID = mnuParentMenuID(CurrentMenu)
FirstItemNumber = mnuMenuItemStart(CurrentMenu)
LastItemNumber = mnuMenuItemEnd(CurrentMenu)
DrawMenu
DrawPointer(0)
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: MoveDown()
'Purpose: Move pointer to next menu item, scrolling the menu if necessary
Public Sub MoveDown()
Dim CanScroll As Boolean
'First, determine if the menu can be scrolled down and set CanScroll -
'
' If Scroll Wrapping Not Enabled: Menu may only be scrolled down if the
' number of menu items left to display won't fit on the number of
' available LCD lines
'
' Note: Number of available lines depends on whether Menu_ShowMenuTitle is
' enabled or not
'
' If Scroll Wrapping Enabled: Can always scroll down
#If Menu_ScrollWrapping = False
CanScroll = False
#If Menu_ShowMenuTitle = True Then
If FirstItemNumber + ScrollPosition + LCDLines - 2 < LastItemNumber Then
CanScroll = True
EndIf
#Else
If FirstItemNumber + ScrollPosition + LCDLines - 1 < LastItemNumber Then
CanScroll = True
EndIf
#EndIf
#Else
CanScroll = True
#EndIf
'Scroll the menu if the following conditions exist -
'
' Menu can be scrolled down and pointer is on or below the second last
' line of the display
' OR
' Menu can be scrolled down and pointer is on the last menu item - this
' allows scroll wrapping
If (PointerLine >= LCDLines - 1 Or PointerPosition = LastItemNumber - FirstItemNumber) And CanScroll = True Then
Inc(ScrollPosition)
#If Menu_ScrollWrapping = True
'If scroll wrapping and we've scrolled to the bottom then start again at
'the top
If ScrollPosition > (LastItemNumber - FirstItemNumber) Then
ScrollPosition = 0
EndIf
#EndIf
DrawMenu()
DrawPointer(PointerPosition)
'If not scrolling the menu then move the pointer down if the following
'conditions exist -
'
' Pointer is not on the last line of the display
' AND
' Pointer isn't on the last menu item
ElseIf PointerLine < LCDLines And PointerPosition + FirstItemNumber + ScrollPosition < LastItemNumber Then
Inc(PointerPosition)
'Fix to ensure Up Arrow scroll indicator is shown on smaller displays
'when pointer moves down from top line
#If (Menu_LCDLines < 4 Or Menu_ScrollWrapping = True) And Menu_ShowScrollIndicators = True
DrawMenu()
DrawPointer(PointerPosition)
#Else
DrawPointer(PointerPosition - 1)
#EndIf
End If
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: MoveUp()
'Purpose: Move pointer to previous menu item, scrolling menu if necessary
Public Sub MoveUp()
'Routine decides whether to scroll the menu up or just move the pointer up
'depending on the current state:
'
'If there is a free LCD line above the pointer (i.e. one that doesn't have
'the menu title or a scroll indicator in it then move the pointer up;
'
'Otherwise, if the menu can be scrolled (either because scroll wrapping is
'on or because the current scroll position > 0) then scroll the menu up;
'
'If the menu can't be scrolled then move the pointer up, overwriting any
'scroll-up indicator. (If necessary, re-draw the scroll-down indicator).
#If Menu_ShowMenuTitle = True
#If Menu_ShowScrollIndicators = True
If PointerLine > 3 Then
#Else
If PointerLine > 2 Then
#EndIf
Dec(PointerPosition)
DrawPointer(PointerPosition + 1)
#If Menu_ScrollWrapping = True
Else
If ScrollPosition > 0 Then
Dec(ScrollPosition)
Else
ScrollPosition = LastItemNumber - FirstItemNumber
EndIf
DrawMenu()
DrawPointer(PointerPosition)
EndIf
#Else
ElseIf ScrollPosition > 0 Then
Dec(ScrollPosition)
DrawMenu()
DrawPointer(PointerPosition)
ElseIf PointerLine > 2 Then
Dec(PointerPosition)
#If Menu_LCDLines < 4 And Menu_ShowScrollIndicators = True
DrawMenu()
DrawPointer(PointerPosition)
#Else
DrawPointer(PointerPosition + 1)
#EndIf
EndIf
#EndIf
#Else
#If Menu_ShowScrollIndicators = True
If PointerLine > 2 Then
#Else
If PointerLine > 1 Then
#EndIf
Dec(PointerPosition)
DrawPointer(PointerPosition + 1)
#If Menu_ScrollWrapping = True
Else
If ScrollPosition > 0 Then
Dec(ScrollPosition)
Else
ScrollPosition = LastItemNumber - FirstItemNumber
EndIf
DrawMenu()
DrawPointer(PointerPosition)
EndIf
#Else
ElseIf ScrollPosition > 0 Then
Dec(ScrollPosition)
DrawMenu()
DrawPointer(PointerPosition)
ElseIf PointerLine > 1 Then
Dec(PointerPosition)
#If Menu_LCDLines < 4 And Menu_ShowScrollIndicators = True
DrawMenu()
DrawPointer(PointerPosition)
#Else
DrawPointer(PointerPosition + 1)
#EndIf
EndIf
#EndIf
#EndIf
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: Back()
'Purpose: Show parent of current menu
Public Sub Back()
ShowMenu(ParentID)
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: SelectItem()
'Purpose: Carries out action of selected menu item. If menu item opens
' another menu then that menu is drawn. If menu item is an 'action'
' item then the event in the main program which handles the action is
' called
Public Sub SelectItem()
Dim ItemAction As Byte
SelectedMenuItem = FirstItemNumber + ScrollPosition + PointerPosition
#If Menu_ScrollWrapping = True
If SelectedMenuItem > LastItemNumber Then
SelectedMenuItem = SelectedMenuItem - (LastItemNumber - FirstItemNumber) - 1
EndIf
#EndIf
ItemAction = mnuItemAction(SelectedMenuItem)
If ItemAction = 255 Then
ParentID = CurrentMenu 'Means 'back' command will return to correct menu
FItemActionEvent() 'Call event handler in main program
Else
ShowMenu(ItemAction)
EndIf
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Name: Initialise(pItemActionEvent as TEvent)
'Purpose: Sets name of main program event handler and loads custom scroll
' characters into LCD
Public Sub Initialise(pItemActionEvent As TEvent,
XMnuPos As Byte = 20,
YMnuPos As Byte = 10,
YMnuStep As Byte = 10,
XMnuCurs As Byte = 10 )
xPos = XMnuPos
yPos = YMnuPos
yStep = YMnuStep
xCurs = XMnuCurs
FItemActionEvent = pItemActionEvent
' #If Menu_ShowScrollIndicators = True Then
' LCDI2C.Write(ScrollIndicators)
' #EndIf
End Sub
Last edited by Coccoliso on Thu Nov 13, 2014 9:22 am, edited 2 times in total.
Re: Menu help
I have changed the [ ElseIf (PORTC And %00000111) = 7 Then ] line, compiled and ran it in Proteus. Everything works just as before including the single problem I had as descried early of not being able to scroll back up to the upper most line.
As per you suggestion I will try to clean up the code and get rid of components that I will not need/use. It will take me some time to this since I'm very new to programming.
As per you suggestion I will try to clean up the code and get rid of components that I will not need/use. It will take me some time to this since I'm very new to programming.
Re: Menu help
Hello,
There are overwritten, look at the post above.
The easiest thing in these cases is to start from the original module and just worry about calling the write of the GLCD without altering the logic of the module (which clearly works).
In order not to get lost in ruminations should not affect the calculation of the current line and the current position is why I used the function GetYPos () and moved the variable LineNumber from the sub to the module making it pseudo "static".
If you find GLCD.Cls (1) change them to GLCD.Cls () .. I'm used to using the S1D13700 LCD and sometimes I run away the layers that the KS0108 has not.
There are overwritten, look at the post above.
The easiest thing in these cases is to start from the original module and just worry about calling the write of the GLCD without altering the logic of the module (which clearly works).
In order not to get lost in ruminations should not affect the calculation of the current line and the current position is why I used the function GetYPos () and moved the variable LineNumber from the sub to the module making it pseudo "static".
If you find GLCD.Cls (1) change them to GLCD.Cls () .. I'm used to using the S1D13700 LCD and sometimes I run away the layers that the KS0108 has not.
Re: Menu help
Everything I need is working great!! I did need to change GLCD.Cls () as you mentioned. Thanks very much for your help. I will now be able to continue with the other portion of this project.
Re: Menu help
I don't quite understand how to set the Y position of the menu. If I change YMnuPos As Byte = 20 to YMnuPos As Byte = 50 .... there is no change in the menu's Y position. If I change XMnuPos the X position of the menu will change as expected.
Re: Menu help
As you can see from the source YPos is set by Initialize SUB by the value YMnuPos passed as a parameter.
I can not test the code because not have hardware and ISIS to do it so, since it is the GetYPos () to do whatever on Y position can try sum YPos at the GetYPos() result ..
I can not test the code because not have hardware and ISIS to do it so, since it is the GetYPos () to do whatever on Y position can try sum YPos at the GetYPos() result ..
Code: Select all
Private Function GetYPos(p As Byte = 0) As Byte
If p<>0 Then
result = yPos + (p - 1) * yStep
Else
result = yPos + (LineNumber - 1) * yStep
End If
End Function
Re: Menu help
Regarding testing..I sent you PM