chipKIT® Development Platform

Inspired by Arduino™

My first menu class...

Created Wed, 04 Sep 2013 08:37:12 +0000 by unexpectedly


unexpectedly

Wed, 04 Sep 2013 08:37:12 +0000

I've been all over the internet and between state machines and this class which I haven't been able to port, I'm starting on a menu class. It is more-or-less tied to my hardware but I'm trying to make it generic-ish as I go. Many thanks to that end to the dang compiler for making it hard to cheat.

I have epic respect to the folks who made the OMMenuMgr class, but something isn't translating correctly for me and it's not bringing text labels back correctly. Maybe if it were to be debugged on target? (actually, I'm going to offer to send the guy a working uC32 and 1.8" TFT with a few C Notes to see if he can port it for us)

So, all of you ( majenko ) who read this with a particular 1.8" TFT graphics shield I am almost as zealous about as a baptist minister from The South, maybe you can help lend ideas? :D

Specifically, I am somewhat wondering how to handle sub menus and registering callbacks for those. If it were coded in php, I'd run a associative array of function pointers, which I can declare dynamically. Wow, php has made me so lame in C/C++...

I'm attaching the code in case anyone cares ( majenko ), but the mfm.h and .cpp are pretty simple. ( mfm = my first menu, which literally it is ) Apologies in advance for the I2C sparkfun real time clock it is expecting if you try to actually run it. That's all up before setup() and in guiFooter().

:mrgreen: Chris


majenko

Wed, 04 Sep 2013 09:04:03 +0000

Are you stalking me? :twisted:

When my TFT arrives from the states (another 6 weeks yet probably - I also have a 2.2" TFT coming for another project...) I'll have a tinker with your lib.

Normally I wouldn't "register" anything at run-time, but it would all be defined beforehand in static arrays of structs, where the struct contains the menu title (and other attributes), as well as the function pointer for the function to run. A sub-menu is then just a function that displays a menu.


unexpectedly

Wed, 04 Sep 2013 18:13:27 +0000

I've seen so many pre-runtime struct defs that they make my eyes glaze over. While coding on a chipKIT isn't like for a Windows app, here's a spot that for developer friendliness, some SRAM waste is worth it.

My paid-for embedded job had a sort-of menu framework setup, but that box ran vxWorks and took 3 to 4 minutes to boot. But we sold them to TV networks who never restart them anyway. (Except until 5 minutes before the Monday Night Football demo for ABC)

BTW, those LIBs are amazing! Can't wait to try them out! :D Since we're about the only two people currently busy here, I am kinda stalking you.