EEPROM, LCD Menu's and what not! Brains required!

rs2845

Senior Member
Hello all,

Been meaning to ask a few questions for a while but sixth form has started to get even more intense. Lovely.

In whatever free time I have I work on the alarm system I am (slowly) building. I have a few questions about different elements such as the LCD menu system, entering text and storing/ transferring ASCII data to/from numerous picaxe chips.

I have a touchscreen serial LCD display that has onboard flash storage where I have saved my menu options. These are called up with hex values alongside a hex value being returned for each individual button press. Question: could I use the ASCII command to send the desired hex commands to the display? I've been using puTTY at the minute. Not tried with a picaxe as of yet.

Okay.. now the real puzzlers..! Does anyone have any ideas about creating a structured menu to allow a user to navigate through the options either by the pressing of 5 tactile buttons (up, down, left, right, enter) or by touch screen presses? Im guessing I'll need to use IF statements and GO TO commands for each menu option in the picaxe code. Any code that has been used in the past I can analyse?

Second question- how can I use a 3x3 keypad to input text to the screen? Transmitting display to the text requires a preset serial command (set values at the start and end, and a string value which is the text I.e- AA 29 *text string goes here* FF C3 C0 C3 CC). Would the text need to be programmed into the relevant EEPROM data location or lookup table and then be somehow inserted or called from the hex commands going to the display?

Finally, how would I even consider storing data such as:

32 individual zone labels (40 char length)
10+ individual device labels (40 char length)

I know that 1 byte equals one letter or space but what sort of structure would I need to implement for the picaxe that would also facilitate re-write and calling from various software functions such as the display?

Should I consider getting an I2C EEPROM? Ideally I'd like to use a 40X2 to store this data but a separate EEPROM would be fine. I need something that can be re-written to with the 3x3 keypad or even by a PC terminal.

I've found some content on the forum in terms of EEPROM data etc but I can't seem to fully understand or figure out solutions myself. Especially with the sending and storing of text in the eeprom and then showing it on the display.

Thankyou all in advanced!
 

inglewoodpete

Senior Member
Using the internal EEPROM is simple although it is a quite limited in size.

Once you get the hang of it, using external EEPROM is relatively simple too. External EEPROM can be i2c or SPI. My personal experience has been with i2c and you will find many examples: search for 24LC256 or 24LC512 - these are chips commonly used with PICAXEs.

If you want to edit text strings in EEPROM (local or external memory), I would suggest you copy the (existing) string into RAM or an area of scratchpad RAM and do the editing there, saving the finished text to EEPROM once you are finished with it. Obviously, if adding a new string, just prefill the RAM area with blanks ($20). The 3x3-keypad makes it relatively easy to edit the buffer by using the left and right buttons to select the position and the up and down buttons to scroll through the letters of the alphabet.

I recently finished an menu system for an LCD-with-keypad combo from DealExtreme. I'll try to post the code later today when I get home. It is important to structure your application carefully and logically to keep the code as simple as possible. Having said that, if you get to see my code, you will see that it is still not simple! It is not something for a beginner, but your post reads as if you have some experience with hardware and programming.
 

rs2845

Senior Member
Thankyou very much for your informative reply :) really appreciate it.

I will definitely look into the external EEPROM I think because I'd rather have one high capacity EEPROM instead of mixing it around different picaxe chips. I'm sure I'll get used to how that works eventually.

With regards to posting the menu code- that would be fantastic as I can read it and see why certain commands etc were used.

I guess I must come across as quite knowledgable. I'm always thinking about various areas of my project and know what areas I will need assistance with before I sit down with a picaxe chip as I get stressed when I don't see results..! The menu structure and EEPROM has thrown me a little and I know that I'd need some help with this.

Any code or info you supply will be so helpful.

Meanwhile I will see what other capacity I2C eeproms Microchip manufacture.
 

inglewoodpete

Senior Member
I'll try to post a copy of the code over the weekend. I've got family visiting from overseas at the moment, so my priorities are all over the place! Stay tuned.
 

rs2845

Senior Member
Honestly it's nice enough for you to offer your support!

Whenever you get time...no rush at all!
Have a great weekend.. Thankyou :)
 

inglewoodpete

Senior Member
A menu-based PICAXE application

Attached is a menu-based program that I wrote recently.

The program revolves around a series of menus, each menu dictates how the key presses are interpretted. All resolved keypresses are treated as Events. Since the application is a timer, the timer expiries are also treated as events. The key to the menu-driven structure is the series of LookUp commands in the AnalyseEvent subroutine, which takes the input events and outputs Actions and/or New Menu requests.

  • This code was written for the DealExtreme combination LCD/Keypad fitted to the PICAXE AXE401 Shield
  • The application is a timer with a single relay output. The 'on' or 'off' times can be adjusted and saved in EEPROM.
  • Since the application was written for the PICAXE Shield, I have used Shield-style pin names (S.xx), where possible.
  • The keypad is a resistor ladder connected to pin iKPad - 5 keys (North/South/East/West + "Select/Centre")
  • The output to the LCD uses a 4-wire data bus + Register Select + Enable wires. Refer to the pin mapping.
  • The timer interrupt (every 100mS) reads the the keypad. All reading of the Keypad is via a single ReadADC command.
  • The timer is used to read long-held keys. This results in 10 possible key values - 2 for each key.
  • The interrupt routine stores any RESOLVED key presses in variable bKBDValue
  • When the program's main loop wants to change the status of the keypad bits, it MUST temporarily disable interrupts.
  • Apart from initialisation (subroutines InitLCD and LoadSpecialChars), the output to the LCD hardware is ONLY done through subroutine Cmd2LCD (LCD Commands) / Chr2LCD (Characters).
I am a computer programmer by profession, which possibly explains why it is structured the way it is! The program's structure may be a bit challenging for a beginner. In order to get a better understanding of it, I suggest that you print a hard copy of it and then work your way through the hard copy, marking additional notes and comments on the copy to help you understand it.

I use symbols extensively, with the prefix characters of the symbols indicating the symbol "type":
  • i - input pin
  • o - output pin
  • t - bit variable
  • b - byte variable
  • w - word variable
  • c - constant
  • r - RAM pointer (address)
  • e - EEPROM
  • tmr - timer related
  • msk - bit mask
  • flg - flag mask

Happy exploring!
 

Attachments

Top