Jump to content
Sign in to follow this  

Data table in C2C

Recommended Posts


Firstly, apologies for the length of this post. (I just previewed it!).


I have a little project on the go, I have built the prototype based on a PIC16F877A with an LCD display amongst other things.


I am writing a menu system for the software and have a flexible design idea but I am struggling with the C code. (I am a visual basic man - anyone offering to write a compiler for the PIC? :)


OK as brief as I can.


top menu has menu number 00, 10, 20, 30 and going right from 30 goes to menu 00 and left from 00 goes to 30. (a cylindrical effect).

some menus go down, so 00 can go down to 01, and then down to 02. 01 goes left to 83 (an action) and right to 84 (an action). get the drift?

I chose 8x for the actions so we can test bit 7. This limits us to 127 menus/submenus/actions.

FF indicates no action.

NOTE: Only left or right are used to run a process. and as we know all processes when designing this, we can use a switch statement to call the relevant process based on the number we grab from the table.



I intend to store the configuration of the menu like this.

menu, Up, Dn, Rt, Lt    (current menu , up, down,right, left)

e.g  (all in hex .)

00 FF 01 10 30  <--- menu 00, no up,  dn=01, rt=10, lt=30

01 00 02 83 84  <--- menu 01, up=00, dn=02, rt=83, lt=84

02 01 03 FF 85  <--- menu 02, up=01, dn=03, rt=none, lt=85

and so on.

There will also be a menu string listing something like these with menu number, text, 0x00 to terminate.

00 Main 00

01 Config 00

02 Setup 00

03 Schedule 00

04 .....

FF 00 00    <-- end of menu


I have written some pseudo code, and started the C, but I am struggling with how to setup the data stuff.


Pseudo Code.

1. Set current menu=00

2. Load Menu data for current option (menu, up,dn,rt,lt)

3. Display menu text (name) and options for up, dn, rt, lt.

4. wait at step 4 until keypress (do interrupts as needed)

5. if option chosen is an FF function (none) goto 4.

6. if key=left or right and bit7 of option=1 call process listed

7. it wasn't an action, so get the new menu number and go to step no. 2



Any ideas.

(incidentally if anyone is intested I am designing/writing a home control system, based on X10 and probably using some of their protocols. I will be publishing this all to the web as I go along)

(Anyone want to join me on this project?).



Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...