I am aiming to use an 18F452 to create a device that is controlled via a menu on an LCD screen. I have worked out all the "levels" of the menu I wish to have, and I am going to use 4 SPST momentary on switches for navigation (Up Level, Next, Previous, and Enter). Being unfamiliar with GCBASIC, I want to ask a couple questions based on some problems I've already ran into:
1) Can I highlight text on an LCD screen to show which option is currently selected? If so, how?
2) How do I make the program wait until a key is pressed? Is there a "Wait until one key is pressed" command?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) The highlight effect could be accomplished by writing special characters
to the LCD screen. For instance you could make an up arrow(by choosing which pixels to be dark). And when a button press is detected then a new special character could be loaded that showed the up arrow with the pixels inverted.
2) You could create a Do Loop which checks for the four button presses and then calls a subroutine to start some code and perhaps even bring up a new menu. Assuming that your buttons are set up like the MCLR/Reset button then:
#define Up PortB.0
#define Next PortB.1
#define Down PortB.2
#define Enter PortB.3
Dir PortB In
...
...
Do
If Up Off Then UpSub
If Next Off Then OffSub
If Down Off Then DownSub
If Enter Off Then EnterSub
Loop
...
...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you! Logically a menu is getting rather confusing, I may have more questions on how to set up a menu system later, but for now I'll just tinker around.
Can I send special characters as you stated to the LCD with GCBASIC? If so, how?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To write a custom character, you'll need something like this program which draws a line on the LCD:
'LCD settings go here
Dim TempArray(10)
CLS
'Create custom character and send to LCD
TempArray() = 0, 1, 1, 1, 1, 1, 1, 0 'Bitmap to send, each value is a line
LCDCreateChar 0, TempArray()
'Display custom character 0
LCDWriteChar 0
The LCDWriteChar routine can be used to write any character to the LCD - to send a letter, number or symbol, just use the ASCII value. The lowest values (0, 1, etc, not sure how many) all correspond to custom characters.
So that method is for one column, right? If I wanted to make an H, I would need at least three more TempArrays(), for just that one letter. I haven't gotten a firm grasp yet of the abilities of the microcontroller, so maybe it can handle it with no problems/lag. Just an awful lot of code! :P
I've noticed a lot of things missing from the Documentation, is there a more complete BASIC documentation out there online that would help me get better at the GCBASIC flavor?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am aiming to use an 18F452 to create a device that is controlled via a menu on an LCD screen. I have worked out all the "levels" of the menu I wish to have, and I am going to use 4 SPST momentary on switches for navigation (Up Level, Next, Previous, and Enter). Being unfamiliar with GCBASIC, I want to ask a couple questions based on some problems I've already ran into:
1) Can I highlight text on an LCD screen to show which option is currently selected? If so, how?
2) How do I make the program wait until a key is pressed? Is there a "Wait until one key is pressed" command?
1) The highlight effect could be accomplished by writing special characters
to the LCD screen. For instance you could make an up arrow(by choosing which pixels to be dark). And when a button press is detected then a new special character could be loaded that showed the up arrow with the pixels inverted.
2) You could create a Do Loop which checks for the four button presses and then calls a subroutine to start some code and perhaps even bring up a new menu. Assuming that your buttons are set up like the MCLR/Reset button then:
#define Up PortB.0
#define Next PortB.1
#define Down PortB.2
#define Enter PortB.3
Dir PortB In
...
...
Do
If Up Off Then UpSub
If Next Off Then OffSub
If Down Off Then DownSub
If Enter Off Then EnterSub
Loop
...
...
Thank you! Logically a menu is getting rather confusing, I may have more questions on how to set up a menu system later, but for now I'll just tinker around.
Can I send special characters as you stated to the LCD with GCBASIC? If so, how?
To write a custom character, you'll need something like this program which draws a line on the LCD:
'LCD settings go here
Dim TempArray(10)
CLS
'Create custom character and send to LCD
TempArray() = 0, 1, 1, 1, 1, 1, 1, 0 'Bitmap to send, each value is a line
LCDCreateChar 0, TempArray()
'Display custom character 0
LCDWriteChar 0
The LCDWriteChar routine can be used to write any character to the LCD - to send a letter, number or symbol, just use the ASCII value. The lowest values (0, 1, etc, not sure how many) all correspond to custom characters.
You'll need the newest version of GCBASIC to compile this code. You can download this from http://gcbasic.sourceforge.net/newfiles/update.zip
So that method is for one column, right? If I wanted to make an H, I would need at least three more TempArrays(), for just that one letter. I haven't gotten a firm grasp yet of the abilities of the microcontroller, so maybe it can handle it with no problems/lag. Just an awful lot of code! :P
I've noticed a lot of things missing from the Documentation, is there a more complete BASIC documentation out there online that would help me get better at the GCBASIC flavor?