Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Coding a push button on PIC18

Status
Not open for further replies.
Maybe best to start your own topic rather than dredge up a 4 year old thread.
 
Maybe so..but I did an 18 Menu Tree system using just 2 buttons in asm and a 4 Digit LED display. Some menus had over 6 sub items.
I still have the code, but it became a bit complex along the way. Still works though and I have it simulated in Proteus.
 
Actually mine will be less complicated, but i would like to code in C for PIC.

I need to build a menu tree system managed with 3 buttons
There will be 4 mains selections and each would have 1 sub choice.
 
Actually mine will be less complicated, but i would like to code in C for PIC.

I need to build a menu tree system managed with 3 buttons
There will be 4 mains selections and each would have 1 sub choice.

Why do you need the mains selections, if each have only 1 sub choice?
 
Actually mains selections will be titles only.
Once on of those will be entered it will possible to change a setting in there ( increase or decrease a value )
 
Actually mains selections will be titles only.
Once on of those will be entered it will possible to change a setting in there ( increase or decrease a value )

Ok, I get the point when I read your first post (post #20).
Menu system in C is a good project. It would make a good article in the https://www.electro-tech-online.com/forums/code-repository.73/ section, but it would have to a well designed and easy to scale module. I could help, but I don't have much free time now.. Maybe you should google around first and study the codes you find.

Your menu is very simple, so maybe you don't want to go with "too fancy" C-code.. depending how familiar you are with C.
 
The method I used was based on flags. Then there is a call routine for each menu display which detects the flags and displays the appropriate 'main menu' text. The left/right scroll buttons cause a variable to count up/down for all menus. Changing this variable DISPLAYS the different main menu items. Using indirect addressing for the text, and assigning a known max. text size (an offset (multiplied by the menu item #) that u add to the start address of the menu text items which selects the correct text.) makes it scalable.

An ENTER press here selects the current menu ...flags it and then displays the submenu item list that works the same way as the main menu, and so forth as deep a menu tree as u like.
Clicking the 'ENTER' key again flags the submenu item as active and this changes the display to the item setting/value which flashes. The left/right keys now alter the 'value' here and the ENTER key accepts it and assigns it to the correct variable (based on which menuitem & sub menuitem is currently selected, I used indirect addressing here again) AND bounces the display 'upward' back to the last submenu text item. I use a longpress of the 'ENTER' key to climb the menu tree right back out of the menu, step by step and a short press to descend it or 'select' as described.
 
That sounds quite good Mosaic. It would be great if you could post the menu-system with code (maybe to the Code Repository). You could simplify and strip down the code, so that the main idea is highlighted.. would be helpful to many. And many here could suggest further improvements.

EDIT: Mosaic, did you do the menu in ASM? Maybe that is not so helpful then.. but your description of the system was quite good. Do you mind if I try to replicate that in C.. could be helpful to many.
 
Last edited:
The menu code needs extensive modularization to be published. It was built on the fly for an app and has a lot of bank and page switching tricks going on with PCLATH manipulations and so forth. It's what you'd call spaghetti code....
I can think about doing it in C as a project and publishing that, Mister T seems to be on that trail now.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top