[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Dialog Box - having issues with Header text RSS feed
Forum Index » tcMenu Arduinio library
Author Message
WattsAmps


Joined: Nov 9, 2020
Messages: 9
Offline
Hi Dave

I am using the dialog box to prompt before saving settings to EEPROM.
I used this topic for guidance and example:
https://www.thecoderscorner.com/jforum/posts/list/45.page

I have it all working well with the exception of the header text where I am using the variable pgmHeaderText

Firstly my compiler throws an error saying it needs to be const char* headerPgm instead of a String.
If I change to const char* then if set to "TEST" I get odd text in the header like:
3'5&3
The buffer string works fine.

My code is:
void CALLBACK_FUNCTION exitAndSaveSettings(int id) {
    // TODO - your menu change code

  const char* pgmHeaderText = "TEST";
  bool remoteAllowed = true;
  BaseDialog* dlg = renderer.getDialog();
  dlg->setButtons(BTNTYPE_OK, BTNTYPE_CANCEL, 1);
  dlg->show(pgmHeaderText, remoteAllowed, onDialogFinished); // true = shows on remote sessions.
  dlg->copyIntoBuffer("Click OK to save");     
}

void onDialogFinished(ButtonType btnPressed, void* /*userdata*/) {        
    if(btnPressed == BTNTYPE_OK) {
      //  menuMgr.save(IntEeprom);
      renderer.takeOverDisplay(exitMenu);
    }
}


If I just enter text directly as per this:
dlg->show("TEST", remoteAllowed, onDialogFinished)
I still get the strange text.
Any idea what I am not understanding?
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
I'm not sure what board you're on, but if you are using ESP* or AVR, then the text for the header must reside in progmem at the moment. can you try adding PROGMEM to the text. For example:

const char pgmProceedText[] PROGMEM = "Proceed";


We can probably create another constructor that does not use progmem in the future..
WattsAmps


Joined: Nov 9, 2020
Messages: 9
Offline
Hi Dave thanks for prompt response.

You are right I am using a Mega2560.
And reading that post more carefully I now see your comment regarding PROGMEM at the end.

However if I do that I get no text just the title background - the buffer works fine.
So it is usable but lacking the header.

thanks

Marcus
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
That is rather strange as I've not seen that fail before if the text is stored in program memory, I'm wondering if there is some kind of issue here.

What size is your sketch when you upload it (flash size)? Is it over 64K? I'm wondering if there's something wrong with the near addressing. Easily fixed if it is that.

WattsAmps


Joined: Nov 9, 2020
Messages: 9
Offline
Hi Dave

Yes it is just under 90k = approx 35%

Marcus
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
The compiler for AVR on Arduino is supposed to move all progmem definitions into the lower 64K so I doubt it's that to be honest, many well-known libraries also assume progmem data to be in the lower 64K. So I assume the compiler does that automatically.

https://www.arduino.cc/reference/en/language/variables/utilities/progmem/

The common error is that the constant string referred to is not defined globally, make sure you define it outside of any function.

In fact in the gnu guide, they make it even clearer in the note about 30% of the way down the page, the progmem string manipulation functions only work on the lower 64K. So I assume the compiler arranges the constant data segments first in memory. It's the problem with having > 64K bus on an 8-bit device!
davetcc


Joined: Jan 19, 2019
Messages: 636
Offline
BTW, we'll make a version of the function that works with strings in RAM instead in the next patch.

https://github.com/davetcc/tcMenuLib/issues/79
WattsAmps


Joined: Nov 9, 2020
Messages: 9
Offline
Brilliant - moving it into global did the trick - many thanks again for your prompt replies - really appreciated
tikard


Joined: Jan 24, 2021
Messages: 2
Offline
I have the same issue on same hardware.

What was the fix to put it in global?
WattsAmps


Joined: Nov 9, 2020
Messages: 9
Offline
Just declare the variable towards the top of the sketch before set up.
So in my case I declared it after my library includes thus:
const char pgmProceedText [] PROGMEM = "SAVE SETTINGS";
around line 15
This seems to ensure the compiler includes it in the lower 64k
tikard


Joined: Jan 24, 2021
Messages: 2
Offline
Thanks. I tried everything too.
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.