Go Down

Topic: New Arduino library: MenuSystem (Read 26983 times) previous topic - next topic

Dorzo_

Hi fellow duinists,

I am doing a project which includes a tft display, and at startup it is supposed to have some menu items where the user can select some startup options.
I have successfully made a sketch that will display some menu-items, a sub-menu (level 2 items) and am able to navigate it with some buttons.

After many failed attempts i have even been able to show and modify a NumericMenuItem. (select first time allows editing the number, then selecting again lets me go back to navigate the menu.

What i have not been able to do, but i think it must be possible, is to display that number as an integer, rather than as it is implemented in the library, a float.
As far as i understand, I should be able to define a ' format_value_fn '  that formats the float value into any String in a specific way.
But here i run into a problem. I get :

error: invalid conversion from 'String (*)(float)' to 'NumericMenuItem::FormatValueFnPtr {aka const String (*)(float)}' [-fpermissive]

It seems that the function i created is correct in that it returns a String from the input of a float, but the IDE complains that my function is not a member function of the NumericMenuItem class??

Does anyone have an example of using this format_value_fn, either adding it while defining the NumericMenuItem, or somewhere in the sketch by using the 'set_number_formatter' member function of the class?


Thanks for just reading :-)

Go Up