|
|
View previous topic :: View next topic |
Author |
Message |
cbarberis
Joined: 01 Oct 2003 Posts: 172 Location: Punta Gorda, Florida USA
|
Question on handling LCD menu data |
Posted: Tue Mar 07, 2006 5:21 pm |
|
|
I have done some searches on menu AND lcd and did not find an answer to some of my questions, So I thought I would pose this to some of the very competent people in this forum.
I am working on a laboratory temperature controller that is capable of running 10 user programed temperature programs with up to four cycles or steps for each program. I have already done a similar thing in the past, but without all of these added program menu pages, so it is not easy to adapt what I had done in the past with this new requirement.
every program contains four pages with a set temperature XXX deg C and lapse time in HH:MM each of these parameters are stored in EEPROM data memory (PIC18F4620) so the user can call any of the programmed sequences. Luckily, all the data is in a single byte int, except temp is a signed 8 bit int. All this information is displayed on a 4X20 alphanumeric LCD and I use four keys for input (Select, up, down and enter)
ie;
**********************************************************
PROG: Pr01 STEP: n
Temp: xxx deg C
Time: xx Hr xx Min
STOP___ NEXT___ PAUSE___
*********************************************************
where x or n is a displayed settable and readable variable and Pr01 is the page prog name
I guess my question to all of you is basically; what is the best and cleanest method to do this in terms of handling the data and handling the menu tree. I have done something similar but much simpler in the past, but perhaps not very elegant. Any creative suggestions are greatly appreciated.
For data handling, I though of using an enumerated progname and then have a simple structure that contains the temp, time in hrs and time in min, create 10 instances of this with four instances each or 40 sets, something like this: ?????
typedef struct ProgSeq{
signed int8 TempSet;
unsigned int8 TimeHRS;
unsigned int8 TimeMin; };
struct ProgSeq Pr00[4],Pr01[4],Pr02[4],Pr03[4],Pr04[4],Pr05[4],Pr06[4],Pr07[4],Pr08[4],Pr09[4]; |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 08, 2006 4:26 am |
|
|
As shown, your typedef an structure declarations are wrong. A 'typedef', creates a synonym for the type following it, so the typedef (if done right), already includes the 'struct' declaration. The simple answer to the rest though, is why not just use a two dimensional array?.
So:
Code: |
typedef struct {
signed int8 TempSet;
unsigned int8 TimeHRS;
unsigned int8 TimeMin;
} Prog_Seq;
//This creates a new data 'type', called 'Prog_seq', which is a structure
//containing the times.
Prog_Seq programs[4][10];
//This generates a variable 'programs', containing 40 (4*10) Prog_Seq structures.
|
This makes it easy to access each of the four sub times, for each program, and the ten programs.
The values are accessed as:
programs[n1][n2].TempSet
etc..
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|