Arduino Menu 3.0

BennehBoy
Thu Mar 02, 2017 9:43 am
HI,

I was hoping to use an off the shelf menu system for one of my projects, this one seemed to offer some of the best features:

https://github.com/neu-rah/ArduinoMenu

It claimed to work on Teensy so I was hopeful that it would work with STM32

Anyway whilst compiling I get this error:

menuBase.cpp:50:76: error: in C++98 'defaultOptions' must be initialized by constructor, not by '{...}'

config defaultOptions={'>','-',false,false,Menu::defaultNavCodes,false,true};


BennehBoy
Thu Mar 02, 2017 10:38 am
I changed the build flags in boards.txt to this:

mapleMini.build.cpu_flags=-DMCU_STM32F103CB -DSERIAL_USB -std=gnu++11


BennehBoy
Thu Mar 02, 2017 10:41 am
Works == Compiles.

The Mini Crashes as soon as any of the input buttons are pressed.

Suspect this is because the menu code overloads a lot of functions.

Other code works fine with the uplifted c++ standard so it’s just this menu system, ah well. The joys of being on the fringe.


BennehBoy
Thu Mar 02, 2017 12:53 pm
OK so I found the cause of the crash, but I’m stumped regarding why.

Perhaps those with more experience may be able to assist?

When a button is pressed the menu fires this event

result action1(eventMask e,navNode& nav, prompt &item) {
Serial<<e<<" event on "<<item<<", proceed menu"<<endl;
Serial.flush();
return proceed;
}


stevestrong
Thu Mar 02, 2017 1:12 pm
Try to comment out the line with Serial.flush() as it will not work as expected.

BennehBoy
Thu Mar 02, 2017 1:22 pm
stevestrong wrote:Try to comment out the line with Serial.flush() as it will not work as expected.

victor_pv
Thu Mar 02, 2017 2:33 pm
BennehBoy wrote:stevestrong wrote:Try to comment out the line with Serial.flush() as it will not work as expected.

BennehBoy
Thu Mar 02, 2017 3:15 pm
Quite possibly.

I’ve reported it to the library maintainer, it’s a bit beyond me to debug.


zmemw16
Thu Mar 02, 2017 4:39 pm
what happens when just printing item? ‘Serial << item<<endl;’
and add a simple ‘Serial<<‘***************'<<endl;’ line to see if it dies there
srp

BennehBoy
Thu Mar 02, 2017 5:12 pm
zmemw16 wrote:what happens when just printing item? ‘Serial << item<<endl;’

victor_pv
Thu Mar 02, 2017 6:35 pm
BennehBoy wrote:zmemw16 wrote:what happens when just printing item? ‘Serial << item<<endl;’

BennehBoy
Thu Mar 02, 2017 7:06 pm
No it’s a pointer to a class instance, I think basically it’s self referential, the instance of the menu class that is selected passes a pointer to itself to the function, so that the code can say ‘menu item x’ was selected.

It’s not important really because I don’t think I’ll ever need to use that within my menu system.

And yes a debugger would be good – sure the hell beats moving a ‘Serial.println(“got here”);’ about in the code :D


BennehBoy
Thu Mar 02, 2017 9:11 pm
So it looks like idiot here must’ve done something daft, the code when refreshed from github runs fine on a nano, but still crashes the mini.

:(


RogerClark
Thu Mar 02, 2017 11:08 pm
Do you mean it crashes on some AVR boards ?

BennehBoy
Fri Mar 03, 2017 10:41 am
RogerClark wrote:Do you mean it crashes on some AVR boards ?

RogerClark
Fri Mar 03, 2017 11:20 am
These flags have been discussed on another thread

http://www.stm32duino.com/viewtopic.php?t=1241

It sounds like they are now the standard for the ARM Arduino build settings, so we should consider using them.

However I can only do limited testing e.g. with my projects, so the proof of the pudding would be just to update the repo and wait for people to complain if it caused side effects


BennehBoy
Fri Mar 03, 2017 1:02 pm
RogerClark wrote:These flags have been discussed on another thread

http://www.stm32duino.com/viewtopic.php?t=1241

It sounds like they are now the standard for the ARM Arduino build settings, so we should consider using them.

However I can only do limited testing e.g. with my projects, so the proof of the pudding would be just to update the repo and wait for people to complain if it caused side effects


victor_pv
Fri Mar 03, 2017 4:57 pm
RogerClark wrote:These flags have been discussed on another thread

http://www.stm32duino.com/viewtopic.php?t=1241

It sounds like they are now the standard for the ARM Arduino build settings, so we should consider using them.

However I can only do limited testing e.g. with my projects, so the proof of the pudding would be just to update the repo and wait for people to complain if it caused side effects


BennehBoy
Fri Mar 03, 2017 7:44 pm
My project uses H/W SPI & i2C, and a lot of libraries :D So has another base covered from the i2c perspective.

RogerClark
Fri Mar 03, 2017 8:23 pm
Victor

Ok.

I will do that.

I will post a replacement platform.txt


BennehBoy
Fri Mar 03, 2017 9:03 pm
Just be aware that on first compile cc1.exe will complain a lot.

RogerClark
Fri Mar 03, 2017 9:05 pm
BennehBoy wrote:Just be aware that on first compile cc1.exe will complain a lot.

BennehBoy
Fri Mar 03, 2017 9:12 pm
tbh I’m not entirely sure, when the IDE displays ‘Build options changed, rebuilding all’ and does a full compile it appears to pass the std=gnu++11 options into both the c++ and c compilers, the c one (cc1.exe I presume) then just displays a warning saying it was passed an option that is only relevant to c++. Fortunately it handles it well, just might show a lot of warnings that people are not used to.

cc1.exe: warning: command line option '-std=gnu++11' is valid for C++/ObjC++ but not for C [enabled by default]


BennehBoy
Fri Mar 03, 2017 9:16 pm
Incidentally, the menu system functions well other than for the issue with the demo (functionality that I won’t use).

There is an issue I’ve found when using multiple SSD1306 displays however, because a single framebuffer in ram is used for all the displays, and it gets cleared for each screen being drawn, this results in the menu blanking out each time ‘cleardisplay’ is called.

The reason this happens is the author has utilised lazy updates to minimise cpu cycles – ie if the menu has not changed, then it does not output to the buffer. I’m going to ask him if it’s possible to have a ‘redraw all’ or non lazy update added.

The workaround for the time being is to disable drawing to the other displays whilst in the menu – the menu is non blocking, so it was nice to still have the gauges on the other displays visible and updating…


RogerClark
Sat Mar 04, 2017 5:57 am
BennehBoy wrote:tbh I’m not entirely sure, when the IDE displays ‘Build options changed, rebuilding all’ and does a full compile it appears to pass the std=gnu++11 options into both the c++ and c compilers, the c one (cc1.exe I presume) then just displays a warning saying it was passed an option that is only relevant to c++. Fortunately it handles it well, just might show a lot of warnings that people are not used to.

cc1.exe: warning: command line option '-std=gnu++11' is valid for C++/ObjC++ but not for C [enabled by default]


BennehBoy
Sat Mar 04, 2017 8:54 am
Yeah, I probably added it in the wrong place.

I added it to the build flags for maple mini in boards.txt:

mapleMini.build.cpu_flags=-DMCU_STM32F103CB -DSERIAL_USB -std=gnu++11


zmemw16
Sat Mar 04, 2017 12:14 pm
no complaints if you put it in the compile.cpp.flags line and not the c.compile.flags line in platform.txt
Q also in the STM32F4 platform.txt or just add to all platform.txt files?
srp

RogerClark
Sat Mar 04, 2017 8:25 pm
zmemw16 wrote:no complaints if you put it in the compile.cpp.flags line and not the c.compile.flags line in platform.txt
Q also in the STM32F4 platform.txt or just add to all platform.txt files?
srp

Leave a Reply

Your email address will not be published. Required fields are marked *