This is part of a bigger project, where I can change numbers, and I see it on the LCD. Some time ago I used this library with Leonardo, but I am quite sure I hadnt this problem (unfortunally, I lost that code).
I have setup this in LiquidMenu_config.h, neccesary for my bigger project:
/// Configures the number of available variables per line.
const uint8_t MAX_VARIABLES = 4; ///< @note Default: 5
/// Configures the number of available functions per line.
const uint8_t MAX_FUNCTIONS = 1; ///< @note Default: 8
/// Configures the number of available lines per screen.
const uint8_t MAX_LINES = 12; ///< @note Default: 12
/// Configures the number of available screens per menu.
const uint8_t MAX_SCREENS = 13; ///< @note Default: 14
/// Configures the number of available menus per menus system.
const uint8_t MAX_MENUS = 1; ///< @note Default: 8
The library does not appear to be handling the char* reference correctly.
If you use a char array instead of a char*, then copy the text into the char array, the menu will display properly. (You can use strcpy() and avoid the use of PROGMEM, I was trying to avoid storing three char arrays in ram)
#include <LiquidMenu.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
const char str1[] PROGMEM = "String1";
const char str2[] PROGMEM = "String2";
char dynamicText[8];
LiquidLine linea_1(1, 1, dynamicText);
LiquidScreen pantalla_1(linea_1);
LiquidMenu menu(lcd);
void setup() {
strcpy_P(dynamicText, str1); //initialize dynamic text
lcd.init();
lcd.backlight();
menu.add_screen(pantalla_1);
}
void loop() {
if (millis() < 5000ul){
strcpy_P(dynamicText, str1);
menu.softUpdate();
} else {
//strcpy_P(dynamicText, PSTR("testing")); //method of using text defined within strcpy()
strcpy_P(dynamicText, str2);
menu.softUpdate();
}
}
I'm not sure about what I'll say, but can you take the first code you gave, but you replace the dynamicText by *dynamicText in the line I quote. Then tell me if it works as expected
Does not work properly, only display 'S' constantly.
I think there must have been some modifications to the library that broke the char* for dynamic text, there are several references to using what the OP posted, stating that it should work, but in the latest version of the library it does not. Will take me a few minutes to test earlier version of the library (the config file has to be modified for each version to work with the I2C display).
< edit > char* works with version 1.3.0 and 1.5.1, but a char array does not.
Be careful, const char* does not work in 1.5.1, from what I can find that is used to indicate that the text is stored in PROGMEM, but there is a setting in the library that needs to be changed for that and I'm not going to go that far in testing.
I don't think the problem comes from the library but more from a confusion on the pointers!
You may want to look at what type of variable the function wants, and try to give it the good one
Thanks, david_2018 solution work properly. That explain because previous versions of my program did work, they worked with old libraries.
LiquidLine defines each line on each screen, and LiquidScreen defines each screen that will have a menu. A menu consists of several screens, and a screen consists of several lines.
In my case I use these functions in a line where I ask if I want to water or not, and therefore I need to show a dynamic text, depending on what I have programmed.
You can still install an older version of the library in the library manager. Seems odd that the author of the library would implement a change that breaks code written for previous versions.