This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to implement LCD menu structure

Hello all,

I have to implement a MENU screen including a few sub menu's on a 230x240 pixel LCD display. Selecting sub-menu's is done through digital inputs(buttons). I can poll these inputs or generate an interrupt to detect an active input.

I can write everything on the display I want to. So I can build the individial menu screens.

My problem is how do I implement a software structure to write the mainmenu and sub-menu's to the screen.

Does someone have an idea or an example?

Thanks,

Jan

  • well, without going any furtyher, I have done it extensively using the "switch" statement.

    Erik

  • Is it OK to use function pointers in your system?

  • I am bussy maken software that is using a lot of switch statements as well.

    Does it work reliable?

    Regards,

    Jan

    P.s. I find the software look very messy. Thats why I am looking for better/other options.

  • I am bussy maken software that is using a lot of switch statements as well.

    Does it work reliable?


    can't answer that, I did not write the code :).

    If the question is: "does the switch stement work as stated in ANSI C?" I have never seen any notion in this forum or in my work that it does not.

    One caveat: it does take time.

    I think that at one time I saw it converted to a jump table (in Keil?) and would absolutotally love to know how to make it so that happens in Keil. I can appreciate that you have to "help" the compiler by not using willy-nilly values for the cases. I have tried offset by 2 for the cases with no improvement.

    Erik

  • sorry, re above:

    I missed the "ARM" the above apply to the '51.

    Anyhow, I doubt Keil could stay in business if the switch statement did not "work reliably"

    Erik

  • "I find the software look very messy."

    This is largely a matter of style - and that is under your control!

    If your style looks messy, try to refine it, or change it.

  • "If your style looks messy, try to refine it, or change it."

    Control can sometimes be embodied in data.

    ------------------------------------------------------------

    Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won't usually need your flowcharts; they'll be obvious.

    Frederick P. Brooks, Jr., The Mythical Man Month

  • "Control can sometimes be embodied in data."

    Very true.

    One way to do it is tables of function pointers. I know this is problematic on C51, but I guess it should be OK on an ARM?

    If you don't like or can't use function pointers, you can simply use an ID in a switch to do direct calls; eg,

    switch( menu_option )
    {
       case OPTION_1:
          sub_menu_1();
          break;
    
       case OPTION_2:
          sub_menu_2();
          break;
    
       case OPTION_3:
          action_3();
          break;
    
       case OPTION_4:
          action_4();
          break;
    
       default:
          show_help();
          break;
    }