Giter Club home page Giter Club logo

Comments (34)

christophepersoz avatar christophepersoz commented on May 8, 2024 2

Ok, I found the problem. The issue wasn't on your library side, it was due to the call of the function u8g.setFontPosTop(); inside the setup(). I have to admit that didn't find out immediately.
So you can definitively say that your lib is fully compatible with U8Glib on Teensy ;)

I will have a look later why this create so many problems, because there is a gfx.setFontPosBottom(); // U8Glib font positioning on menuOut() of menuU8G.h that should overcome that, but it seems it does not...

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024 1

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

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

thanks all for all testing and feedback, I do really appreciate it.

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Does MenuField.h include your changes with #define MEMMOD ?
I'm still getting some error related to ppm_read_ptr_near() with the latest v2.4.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

well there still was a pgm_read_byte_near on menu.cpp
I've removed that now

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

not good... broke something

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

its not possible to use a preprocessor define to turn progmem usage on/off @because, I have dependent code inside a .cpp file (and its gota be there), so i managed to make it automatic by checking #ifdef pgm_read_ptr_near, it will not be defined for teensy.
It compiles here but i have no teensy to upload it.
I've also noticed some general issues relating to navigation (not teensy related), will check that...

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

If you push it here in a zip file I can upload it onto my teensy and check it.
I do not understand why pgm_read_ptr_near() does not compile, because the function seems working on Teensy.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

its on current version

yea, that pgm_read_ptr_near somehow seems to not be defined on teensy 3.1/3.2 and i'm using that fact to distinguish between the cases

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Exact, it is not. Maybe be you could ask to Paul on PJRC forum, he usually answer to this kind of question. It is a bit too technical to my knowledge.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

i dont mind to use ram on teensy, theres plenty, i'm trying to support both modes, if I succeed then i might support dynamic menus.
does it run on teensy? (changes are already pushed)

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Indeed, that could be nice to support both. I tried yesterday to build the 2.4 on Teensy 3.2 and using MEMMOD tag, but it still some errors related to pgm_read_ptr_near(), here the log.

Arduino: 1.6.7 (Mac OS X), TD: 1.29, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimized (overclock), US English"

/Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware "/Applications/Arduino.app/Contents/Java/hardware" -tools "/Applications/Arduino.app/Contents/Java/tools-builder" -tools "/Applications/Arduino.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino.app/Contents/Java/libraries" -libraries "/Users/christophepersoz/Developer/_Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serial,speed=96opt,keys=en-us -ide-version=10607 -build-path "/var/folders/93/95zp52wn3dq81d0dgrtmj_b80000gn/T/build0da4f63f4b42a48bacd9931d3ed57970.tmp" -warnings=none -verbose "/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino"
/Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware "/Applications/Arduino.app/Contents/Java/hardware" -tools "/Applications/Arduino.app/Contents/Java/tools-builder" -tools "/Applications/Arduino.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino.app/Contents/Java/libraries" -libraries "/Users/christophepersoz/Developer/_Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serial,speed=96opt,keys=en-us -ide-version=10607 -build-path "/var/folders/93/95zp52wn3dq81d0dgrtmj_b80000gn/T/build0da4f63f4b42a48bacd9931d3ed57970.tmp" -warnings=none -verbose "/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino"

...

In file included from /Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:28:0:
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In member function 'virtual bool menuVariant<T>::needRedraw(menuOut&, bool)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:138:56: error: there are no arguments to 'pgm_read_ptr_near' that depend on a template parameter, so a declaration of 'pgm_read_ptr_near' must be available [-fpermissive]
    bool nr=((menuValue<T>*)pgm_read_ptr_near(&data[sel]))->value!=target;//||p.lastSel!=sel;
                                                        ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:138:56: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In member function 'void menuVariant<T>::sync()':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:146:52: error: there are no arguments to 'pgm_read_ptr_near' that depend on a template parameter, so a declaration of 'pgm_read_ptr_near' must be available [-fpermissive]
      if (((menuValue<T>*)pgm_read_ptr_near(&data[n]))->value==target)
                                                    ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In member function 'virtual void menuVariant<T>::printTo(menuOut&)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:152:42: error: there are no arguments to 'pgm_read_ptr_near' that depend on a template parameter, so a declaration of 'pgm_read_ptr_near' must be available [-fpermissive]
    ((prompt*)pgm_read_ptr_near(&data[sel]))->printTo(p);
                                          ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In member function 'virtual bool menuSelect<T>::needRedraw(menuOut&, bool)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:181:67: error: there are no arguments to 'pgm_read_ptr_near' that depend on a template parameter, so a declaration of 'pgm_read_ptr_near' must be available [-fpermissive]
    return ((menuValue<T>*)pgm_read_ptr_near(&menu::data[menu::sel]))->value!=menuVariant<T>::target;
                                                                   ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In member function 'virtual void menuSelect<T>::printTo(menuOut&)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:187:54: error: there are no arguments to 'pgm_read_ptr_near' that depend on a template parameter, so a declaration of 'pgm_read_ptr_near' must be available [-fpermissive]
    ((prompt*)pgm_read_ptr_near(&menu::data[menu::sel]))->printTo(p);
                                                      ^
In file included from /Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:29:0:
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h: In constructor 'menuU8G::menuU8G(U8GLIB&, unsigned char, unsigned char, unsigned char, unsigned char, uint8_t, uint8_t)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:31:13: warning: 'menuU8G::gfx' will be initialized after [-Wreorder]
     U8GLIB& gfx;
             ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:25:18: warning:   'unsigned char menuU8G::bgColor' [-Wreorder]
    unsigned char bgColor;
                  ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:32:5: warning:   when initialized here [-Wreorder]
     menuU8G(
     ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:27:18: warning: 'menuU8G::disabledColor' will be initialized after [-Wreorder]
    unsigned char disabledColor;
                  ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:24:18: warning:   'unsigned char menuU8G::hiliteColor' [-Wreorder]
    unsigned char hiliteColor;
                  ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:32:5: warning:   when initialized here [-Wreorder]
     menuU8G(
     ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:29:17: warning: 'menuU8G::disabledColorHi' will be initialized after [-Wreorder]
   unsigned char disabledColorHi;
                 ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:48:63: warning:   base 'menuOut' [-Wreorder]
     menuOut(gfx.getWidth()/resX,gfx.getHeight()/resY,resX,resY)
                                                               ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:32:5: warning:   when initialized here [-Wreorder]
     menuU8G(
     ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h: In member function 'virtual void menuU8G::printMenu(menu&, bool)':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuU8G.h:92:56: error: 'pgm_read_ptr_near' was not declared in this scope
      printPrompt(*(prompt*)pgm_read_ptr_near(&m.data[i]),i == m.sel,i+1,m.ox,(i-top)+m.oy,m.width);
                                                        ^
In file included from /Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:28:0:
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'menuField<T>::menuField(T&, const char*, const char*, T, T, T, T, bool (*)()) [with T = int]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:69:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:56:26: warning: 'menuField<int>::func' will be initialized after [-Wreorder]
   promptFeedback (*func)();
                          ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:55:8: warning:   'bool menuField<int>::tunning' [-Wreorder]
   bool tunning;
        ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:59:3: warning:   when initialized here [-Wreorder]
   menuField(T &value,const char * text,const char *units,T low,T high,T step,T tune=0,promptFeedback (*func)()=nothing)
   ^
In file included from /Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:28:0:
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'void menuVariant<T>::sync() [with T = bool]':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:260:64:   required from 'menuToggle<T>::menuToggle(const char*, unsigned int, menuValue<T>* const*, T&) [with T = bool]'
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:59:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:146:52: error: 'pgm_read_ptr_near' was not declared in this scope
      if (((menuValue<T>*)pgm_read_ptr_near(&data[n]))->value==target)
                                                    ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'void menuVariant<T>::sync() [with T = int]':
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:225:64:   required from 'menuChoice<T>::menuChoice(const char*, unsigned int, menuValue<T>* const*, T&) [with T = int]'
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:81:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:146:52: error: 'pgm_read_ptr_near' was not declared in this scope
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'void menuVariant<T>::printTo(menuOut&) [with T = int]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:152:42: error: 'pgm_read_ptr_near' was not declared in this scope
    ((prompt*)pgm_read_ptr_near(&data[sel]))->printTo(p);
                                          ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'bool menuVariant<T>::needRedraw(menuOut&, bool) [with T = int]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:138:56: error: 'pgm_read_ptr_near' was not declared in this scope
    bool nr=((menuValue<T>*)pgm_read_ptr_near(&data[sel]))->value!=target;//||p.lastSel!=sel;
                                                        ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'bool menuChoice<T>::activate(menuOut&, Stream&, bool) [with T = int]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:243:76: error: 'pgm_read_ptr_near' was not declared in this scope
     menuValue<T>* cp=(menuValue<T>*)pgm_read_ptr_near(&this->menu::data[op]);
                                                                            ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'void menuVariant<T>::printTo(menuOut&) [with T = bool]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:152:42: error: 'pgm_read_ptr_near' was not declared in this scope
    ((prompt*)pgm_read_ptr_near(&data[sel]))->printTo(p);
                                          ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'bool menuVariant<T>::needRedraw(menuOut&, bool) [with T = bool]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:138:56: error: 'pgm_read_ptr_near' was not declared in this scope
    bool nr=((menuValue<T>*)pgm_read_ptr_near(&data[sel]))->value!=target;//||p.lastSel!=sel;
                                                        ^
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h: In instantiation of 'bool menuToggle<T>::activate(menuOut&, Stream&, bool) [with T = bool]':
/Users/christophepersoz/Library/Mobile Documents/com~apple~CloudDocs/Developer/_Arduino/libraries/Menu/examples/U8Glib_ClickEncoder_Teensy_Demo.ino/U8Glib_ClickEncoder_Teensy_Demo.ino.ino:121:1:   required from here
/Users/christophepersoz/Developer/_Arduino/libraries/Menu/src/menuFields.h:267:82: error: 'pgm_read_ptr_near' was not declared in this scope
    menuValue<T>* cp=(menuValue<T>*)pgm_read_ptr_near(&this->menu::data[menu::sel]);
                                                                                  ^
Using library SPI at version 1.0 in folder: /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/libraries/SPI 
Using library U8g_teensy in folder: /Users/christophepersoz/Developer/_Arduino/libraries/U8g_teensy (legacy)
Using library U8glib in folder: /Users/christophepersoz/Developer/_Arduino/libraries/U8glib (legacy)
Using library Menu at version 2.4 in folder: /Users/christophepersoz/Developer/_Arduino/libraries/Menu 
Error compiling for "Teensy 3.2 / 3.1"

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

I've compiled that source here for teensy, with no errors

that menuFields.h:138 line is:

bool nr=((menuValue<T>*)pgmPtrNear(&data[sel]))->value!=target;//||p.lastSel!=sel;

on avrs it should translate to this (by detecting the presence of pgm_read_ptr_near macro)

bool nr=((menuValue<T>*)pgm_read_ptr_near(&data[sel]))->value!=target;

on teensy (macro pgm_read_ptr_near is not defined) it should translate to:

bool nr=((menuValue<T>*)(&data[sel]))->value!=target;

so it seems that our environment is a bit different somehow...

btw, do not define MEMMODE, it should be automatic

on macros.h:

#ifdef pgm_read_ptr_near
  //storing some values into avr flash memory (saving ram space)
  #define MEMMODE PROGMEM
  #define pgmPtrNear(addr) pgm_read_ptr_near(addr)
  #define pgmByteNear(addr) (pgm_read_byte_near(addr))
#else
  //use ram for non-avr devices
  #define MEMMODE
  #define pgmPtrNear(addr) (addr)
  #define pgmByteNear(addr) (*addr)
#endif

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

if errors persist when compiling simple examples like serial menu then please try replacing that conditional section #ifdef pgm_read_ptr_near .... with only the ram part by removing the avr defs like this:

/*#ifdef pgm_read_ptr_near
  //storing some values into avr flash memory (saving ram space)
  #define MEMMODE PROGMEM
  #define pgmPtrNear(addr) pgm_read_ptr_near(addr)
  #define pgmByteNear(addr) (pgm_read_byte_near(addr))
#else*/
  //use ram for non-avr devices
  #define MEMMODE
  #define pgmPtrNear(addr) (addr)
  #define pgmByteNear(addr) (*addr)
//#endif

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Sorry, I think it was a problem related to the version, I was downloading the 2.4 instead of the master branch where indeed I'm seeing the #ifdef you mentioned. So I'm going to make a build with that one ! Let's try and see what happen.

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

So, I can build it now, sorry for the lost of time. But, the menu does not work, at least it does not display anything. So I'm going to investigate a bit to see what's going on.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

serial_menu can be a good point

if it does not run ok => menu nav system
if it runs ok => display system

no time lost my friend, and I'm grateful for your patience. I had some errors, the kind of ones that compile ok (logic errors), like storing on ram and then trying to read from flash... it compiles but will print trash or reset the chip (unpredictable result).

and i hope i don't have much more of those ;D

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

How do you activate those lines ?

Serial<<"printing menu "<<m<<" top:"<<top<<endl;
Serial<<*menu::activeNode<<" <-> "<<*drawn<<endl;

I tried with Streaming.h library but it seems it does not understand the objects or pointers, Serial.print neither.

I can have some serial printing on the Monitor during the menuPoll, but nothing on display except String that are not in the menu and which are printed directly with DrawStr() from U8GLib.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

that << (stream operator) is with active on my debug utility streamFlow.h, its lighter that the standard c++ implementation and is handy for printing.

guess i can publish that... brb

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

That's why I tried with Streaming.h but it seems no so powerful...

BTW, I think that there is several issues. I included <menuPrint.h> to poll the menu described in U8Glib_menu.ino sketch to print it out directly on serial, and it does not print the right content, I only got 1> nothing more.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

yes i confirm that as a bug, by forcing ram build on arduino nano I had the same problem as you have on teensy...
means the back compatibility to ram mode is not ok yet... but now i know how to test it :D

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Yes, it seems so, streamFlow does not output a lot too :

printing menu Main menu top:0
Main menu <-> 

No more...
However, thanks for streamFlow.h ;)

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

there was a macro mess (about who gets the reference) that messed up ram mode for teensy
changes pushed to master

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

did I broke everything?

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Hi Rui,

Sorry, I'm abroad for work. I will have a look on the latest version when I will be back next week. I'll keep you in touch. Thanks !

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Hello Rui,

I'm back and I took few minutes to test the latest version of Menu on my Teensy board. First good news it does build, and "works" on Teensy, which is a quite good news, isn't it ;)

But, not everything is working well. I'm still using the file U8Glib_ClickEncoder_Teensy_demo.ino, which print out the menu on Serial and on display.

Here the bugs :

• On display, all the strings are not written (blank lines). Only one is visible: Exit
• On Serial and Display, the encoder is restricted to lines 1 and 2 of the menu, while it content 4 lines or more.
• But there is a strange behavior, if the line 2 is a FIELD, I can edit the value, validate it (seen on Serial), and then the limitation shift of one line. So after that I can only select lines 2 and 3, and so on. The range is still limited to 2 lines.
• Linked to that, the cycling navigation does not work

Any ideas of what's going wrong with the navigation ? It was working well before.
Here the Sketch file.

U8Glib_ClickEncoder_Teensy_Demo.zip

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Hi Rui,

Here a complete test of the v2.4 on Teensy. I made a video of that will show you the behavior of the v2.4 on Teensy. The video is based on the Sketch I sent you in my previous post.
Do you have an idea of what's going wrong - aside of the PROGMEM/Char* issue ?

Test ArduinoMenu 2.4 on Teensy.mp4.zip

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

not yet, sorry
been working on 3.0
but i will look at it...
it was not a good idea to make so much changes at once, this is getting though :D
PROGMEM was a big change it should have been a change for 3.0
learning...

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

noticed that you are calling poll in parallel for multiple devices... this will not work because menu structures hold variables like top that are device specific and also because printing an options will clear its needRedraw state and cause it not to be drawn on the other device

this is one of the issues i'm dealing with version 3.0, trying to achieve device independence

please comment out one of the .poll's

mainMenu.poll(gfx,allIn);
mainMenu.poll(menu_out,Serial);

also on input initialization (I'm using c++ metaprogramming)

Stream* inputs[]={&enc,&Serial};
chainStream<2> allIn(inputs);

the number 2 is the length of inputs list (be sure they match)

p.s. with these minor changes I've got it running on nano serial.. seem to work ok

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Thanks for the explanations and your quick answer. I tried to comments the gfx output and fix the chainStream value (2 in my case) and you were totally right, the serial output works well.
On the gfx side, the navigation is almost OK when I comments the Serial, but, the Exit seems unreachable and disappear on maxIndex-1. And of course, I can't see anything except blank lines due to the PROGMEM issue on Teensy.

Do you think is that possible to have previous PROGMEM working version ?

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

one way to check if its a PROGMEM problem is to use pure Serial as IO.

I have compiled here for nano (disabling progmem) and it seems to work, however on my device I had to set that contrast line to 128, u8g.setContrast(128); 0 or 255 would leave the screen black or white.
I'm also using the u8g.setFont(u8g_font_unifont); because the other was not installed available, so please check also if its not a font problem.
Also the wrap and exit function seem to work ok on serial input, didn't test with clickencoder...

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

Thanks for your feedback. What do you mean by use pure Serial ? I think that the Serial on Teensy is quite different than the one on Arduino (much much faster).

About U8Glib, the font I'm using is working well, otherwise I think that "Exit" won't shows up. I also know it works because I'm using the same font and parameters for my main program and other classes, which are working nicely. It seems it's much more behaviors linked to gfx displays rather than issues on Serial which is working perfectly now (I didn't know that I can't poll the menu on 2 different devices ;) )

I gong to have a closer look. Also the architecture of Teensy is quite different than the Arduino ones. I let you have a check on that : PROGMEM on Teensy 3.1

Also Paul Stoffregen mentioned that:
"On Teensy 3.0, all you have to do is use "const" in the variable declaration. Or at least that's all you're supposed to do. Everything that's "const" gets put into flash without consuming any RAM.

PROGMEM, pgm_read_byte() and the other AVR names are defined only so code designed for AVR can compile. But they do absolutely nothing on Teensy 3.0.

I'd recommend adding const to that huge array. If you're not planning to compile on Teensy 2.0 or other AVR boards, you might as well remove the PROGMEM stuff. Accessing the array normally is much nicer and more readable code that using pgm_read_byte()."

So on Teensy, by using "const" everything is automatic and you don't need to use anything else to save RAM, neither PROGMEM.

from arduinomenu.

neu-rah avatar neu-rah commented on May 8, 2024

the PROGMEM is important for small AVR's, they are short on RAM.

the point of using Serial for IO is to have a simple case, if it print on serial them PROGMEM stuff is ok.

its important to narrow down the problem cause.

for my compiles here, using just Serial or gfx+Serial they seem to work ok on nano (either using RAM or PROGMEM)

so, I'm a bit lost...

yeah const on C/C++ puts the data on the program segment, for AVR its flash, and for AVR's flash addressing is separate from RAM address, hence the need pf pgm macros

for using ram as you can see here https://github.com/neu-rah/ArduinoMenu/blob/master/src/macros.h#L9

all macros are just doing nothing

PROGMEM, pgm_read_byte() and the other AVR names are defined only so code designed for AVR can compile. But they do absolutely nothing on Teensy 3.0.

then even using progmem on teensy should work, because they already do nothing, but we got a compile error instead

from arduinomenu.

christophepersoz avatar christophepersoz commented on May 8, 2024

What I would like to say is that Teensy is an ARM architecture. Where AVRs have their RAM splitted in two different blocks and you need to use PROGMEM to move constant datas to PROGMEM instead of RAM. That's for AVR, and for sure it is important and save RAM on small boards. On ARM, it's completely different.

On the other side, as you said, if it prints on Serial, it should be printed on GFX... I'm gonna have a look on the print section in the coming days, I will keep you in touch.

from arduinomenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.