PDA

View Full Version : Menu Code Example, 5 buttons, LCD



vamtbrider
- 6th December 2010, 21:04
I have been reading a lot of examples from these forums over the past year and learning a lot about PICS and programming using PIC BASIC so I thought I would try to contribute.

Here is a base program I use for projects that require a lot of menus to configure variables. This is just the shell but it works 'as is' for demonstration purposes. It is easily expandable too.

This code was developed on an 18F4550 using the microchip USB HID bootloader and DT_INTS. So you may have to make some changes if you are not using the bootloader.

The DT_INTS is only used to flash an led and drive some example code for two count down timers.

To build the menus I typically make a diagram like the one attached. Then code it out as in the example.

Most of my projects use 5 pushbuttons; Menu, Plus, Minus, Enter and Reset. So this example is based on those buttons.

The code is pretty well commented so I will leave out re-writing the details here.

If anyone has ideas on how to make this code smaller, run faster, etc. I would be interested.

The first time I made a program with menus like this was using assembly. It took days. With PBP it took about 20 minutes. If I get some time over the holiday I may try and write a VB program that would generate code based on a menu structure you input (that's on the wish list with many other items) to speed up making menus.

Enjoy and I look forward to some feedback.

-Tom
4985
4984

Ioannis
- 8th December 2010, 10:38
Hi Tom.

Good idea to have a framework for the Menu system. I was thinking fr many months to do it, but postponed for various reasons.

I could not read all your code yet. It is really too long!

But your idea to have a VB program do it is great.

If I may suggest to include user defined names for the menus instead of menu_c etc.

Also the size of the LCD so that mssages are trimmed to the selected LCD module.

Ioannis

bcd
- 24th December 2010, 09:19
I was just struggling with a menu system and how to define the multiple arrays.

My application is to have a remote PIC connected over a SPI link and the master then sends the config and text for the menu to the display/switches pic on startup. This means a generic display PIC and any changes needed can be done with a simple firmware update to the master processor using a bootloader.

Its a bit simpler due to using 4 x 7seg LEDs for the menu system, but the needs of multiple options still exists.

Also like the cool LCD image generation tool. On the same website there are some 7 seg LED display graphics that are going to come in mighty handy for mocking up my menu system !

Have a good Holiday season !

bill.