Mixing sub-menus and scrolling lines? #58
-
Hello I'm very confused with the syntax of this library. It seems there is a logic, but I can't figure it out... Is it possible to have such structure on a 2 lines LCD, for example: Main Menu:
Sub menu Equipment:
Sub menu Parameters:
Sub menu Go:
It is about a day I try and I can't make it work... Whether I use your example with system menu and I can only do 2 lines submenus, whether I use your example with scrolling menus but I can't do submenus. I really don't undestand how to mix them... Do you have a step by step tutorial (or a link to) ? All the best Fred |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
Hello @fred-76. To achieve this menu structure, you need to put every // lName - LiquidLine object
// sName - LiquidScreen object
// mName - LiquidMenu object
// fName - callback function
uint16_t var = 123;
LiquidLine lEquipment(0, 0, "Equipment");
LiquidLine lParameters(0, 0, "Parameters");
LiquidLine lGo(0, 0, "Go");
LiquidScreen sMain(lEquipment, lParameters, lGo);
LiquidMenu mMain(lcd, sMain);
LiquidLine lFocal(0, 0, "Focal length: ", var);
LiquidLine lAperture(0, 0, "Aperture: ", var);
LiquidLine lExposure(0, 0, "Exposure: ", var);
LiquidScreen sEquipment(lFocal, lAperture, lExposure);
LiquidMenu mEquipment(lcd, sEquipment);
LiquidLine lLcdBrightness(0, 0, "LCD brightness: ", var);
LiquidLine lLcdContrast(0, 0, "LCD contrast: ", var);
LiquidLine lDelay(0, 0, "Delay: ", var);
LiquidScreen sParameters(lLcdBrightness, lLcdContrast, lDelay);
LiquidMenu mParameters(lcd, sParameters);
LiquidLine lConfirm(0, 0, "Confirm");
LiquidLine lCancel(0, 0, "Cancel");
LiquidScreen sGo(lConfirm, lCancel);
LiquidMenu mGo(lcd, sGo);
LiquidSystem liquidSystem(mMain, mEquipment, mParameters, mGo);
// Used for attaching something to the lines, to make them focusable.
void fBlankFunction() {
return;
}
void fConfirm() {
return;
}
void fCancel() {
return;
}
void goto_mEquipment() {
liquidSystem.change_menu(mEquipment);
}
void goto_mParameters() {
liquidSystem.change_menu(mParameters);
}
void goto_mGo() {
liquidSystem.change_menu(mGo);
}
void goto_mMain() { // you can call this directly from a designated "back" button
liquidSystem.change_menu(mMain);
}
void setup() {
Serial.begin(250000);
lcd.begin(16, 2);
// Attaching a function to the lines is required for scrolling to work.
lEquipment.attach_function(1, goto_mEquipment);
lParameters.attach_function(1, goto_mParameters);
lGo.attach_function(1, goto_mGo);
lFocal.attach_function(1, fBlankFunction);
lAperture.attach_function(1, fBlankFunction);
lExposure.attach_function(1, fBlankFunction);
lLcdBrightness.attach_function(1, fBlankFunction);
lLcdContrast.attach_function(1, fBlankFunction);
lDelay.attach_function(1, fBlankFunction);
lConfirm.attach_function(1, fConfirm);
lCancel.attach_function(1, fCancel);
// Set the number of lines the display has.
/*
* Setting this is a must when you want to add more "lines" than
* the display actually has (the extra lines will be scrolled).
* This must be set after adding the "lines" to the "screen".
*/
sMain.set_displayLineCount(2);
sEquipment.set_displayLineCount(2);
sParameters.set_displayLineCount(2);
sGo.set_displayLineCount(2);
liquidSystem.update();
}
|
Beta Was this translation helpful? Give feedback.
-
I have a question, I have an LCD with 4 lines and I would like to scroll through the lines, also having submenus. I followed the steps but unfortunately I get this error code : Compilation error: no matching function for call to 'LiquidScreen::LiquidScreen(LiquidLine&, LiquidLine&, LiquidLine&, LiquidLine&, LiquidLine&)'.. I used 5 lines instead of 4 following the steps in this answer. How can I fix? |
Beta Was this translation helpful? Give feedback.
-
Hey GabboHD, I have the same issue. It works perfectly fine with 4 lines but I can't seem to figure out 5 lines. Can someone support? |
Beta Was this translation helpful? Give feedback.
-
You have to add line to menu after the attachment function
Il lun 27 mar 2023, 15:36 Schlappo22 ***@***.***> ha scritto:
… Hey GabboHD, I have the same issue. It works perfectly fine with 4 lines
but I can't seem to figure out 5 lines. Can someone support?
—
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6QPBBI52FOGAP6V7B4HIQLW6GJXBANCNFSM6AAAAAAV4H3TG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hello again, Anyway here is my code, I would really appreciate if someone could have a look as my knowledge is limited. The code is no where near done, but I am trying to resolve issues before I keep going. Thanks in advance!!! `
|
Beta Was this translation helpful? Give feedback.
-
Man, have you telegram? Add me @Gabbo_800A
We can talk on telegram
Anyway you haven't write liquidMenu.update for each menù. You can write
only Liquidsystem.update
Sorry for my English, but I'm italian
Il lun 27 mar 2023, 17:45 Schlappo22 ***@***.***> ha scritto:
… Hello again,
I have been trying to get the menu working with sub-menus and the ability
to scroll through like the initial post. I have been trying multiple things
and playing around with different add.line and add.screen functions etc.
Now I am a bit lost and don't know what else I could do to make it work.
The Code itself works but the menus are completely screwed now. I get that
if you don't have screens, you are not able to flick between them, that is
achieved by the focus instead. it seems to work properly on my main menu,
but does not work within the machine menu. In addition it seems the buttons
don't do what they should after some time, very weird behavior.
Anyway here is my code, I would really appreciate if someone could have a
look as my knowledge is limited. The code is no where near done, but I am
trying to resolve issues before I keep going. Thanks in advance!!!
`#include "Button.h"
#include <LiquidCrystal.h> // include the LiquidCrystal library
#include <LiquidMenu.h>
// initialize the library with the LCD pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// define the button pins
const bool pullup = true;
Button Down_Button(6, pullup);
Button Up_Button(7, pullup);
Button Select_Button(8, pullup);
Button Back_Button(9,pullup);
Button Spare_Button(10,pullup);
/*
- An enumerator can be used for the callback functions. It sets the
number
- for similar functions. Later when a function is attached it can be
passed
- with this enum rather than a magic number.
*/
enum FunctionTypes {
increase = 1,
decrease = 2,
};
//Speaker definition
int speakerPin = 13;
// Tone definition
int numTones = 10;
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
// mid C C# D D# E F F# G G# A
//Dispensing Formulas
// Water Variables Definition
int water_amount = 0;
int water_temperature = 0;
int water_speed = 0;
//Formula Variables Definition
int formula_amount = 0;
//Test Values
int formula_test_1 = 0;
int formula_test_2 = 0;
int value_test_1 = 0;
int value_test_2 = 0;
int value_test_3 = 0;
int value_test_4 = 0;
int value_test_5 = 0;
//Menu Setup
uint16_t var = 123;
//Main Menu
LiquidLine main_line_1(0, 0, "Water Set.");
LiquidLine main_line_2(0, 0, "Formula Set.");
LiquidLine main_line_3(0, 0, "Machine Set.");
LiquidScreen smain_1(main_line_1,main_line_2,main_line_3);
LiquidMenu mmain(lcd, smain_1, 1);
//Water Menu
LiquidLine water_line_1(0, 0, "Water Amount", water_amount);
LiquidLine water_line_2(0, 0, "Water Temperature", water_temperature);
LiquidLine water_line_3(0, 0, "Flow Speed", water_speed);
LiquidLine mmback_line(0, 0, "Back");
LiquidScreen swater_1(water_line_1, water_line_2, water_line_3,
mmback_line);
LiquidMenu mwater(lcd, swater_1);
//Formula Menu
LiquidLine formula_line_1(0, 0, "Formula Amount", formula_amount);
LiquidLine formula_line_2(0, 0, "Formula Test.1", formula_test_1);
LiquidLine formula_line_3(0, 0, "Formula Test.2", formula_test_2);
LiquidScreen sformula_1(formula_line_1, formula_line_2, formula_line_3,
mmback_line);
LiquidMenu mformula(lcd, sformula_1);
//Machine Menu
LiquidLine machine_line_1(0, 0, "Test 3.1.", value_test_1);
LiquidLine machine_line_2(0, 0, "Test 3.2.", value_test_2);
LiquidLine machine_line_3(0, 0, "Test 3.3.", value_test_3);
LiquidLine machine_line_4(0, 0, "Test 3.4.", value_test_4);
LiquidLine machine_line_5(0, 0, "Test 3.5.", value_test_5);
LiquidScreen smachine_1(machine_line_1, machine_line_2);
LiquidMenu mmachine(lcd, smachine_1);
//Overall Menu
LiquidSystem overall_menu(mmain, mwater, mformula, mmachine);
void buttonsCheck() {
if (Down_Button.check() == LOW) {
overall_menu.next_screen();
}
if (Up_Button.check() == LOW) {
overall_menu.previous_screen();
}
if (Select_Button.check() == LOW) {
overall_menu.call_function(increase);
}
if (Back_Button.check() == LOW) {
overall_menu.call_function(decrease);
}
if (Spare_Button.check() == LOW) {
overall_menu.switch_focus();
}
}
// Used for attaching something to the lines, to make them focusable.
void fBlankFunction() {
return;
}
void goto_mwater() {
overall_menu.change_menu(mwater);
}
void goto_mformula() {
overall_menu.change_menu(mformula);
}
void goto_mmachine() {
overall_menu.change_menu(mmachine);
}
//Callback function that will be attached to back_line to Main Menu
void mm_go_back(){
overall_menu.change_menu(mmain);
}
void setup() {
lcd.begin(16, 2);
// print something on the first row
lcd.setCursor(3, 0); // set the cursor position
lcd.print("Welcome to");
// print something on the second row
lcd.setCursor(2, 1); // set the cursor position
lcd.print("XXYYZZ");
delay(3000);
lcd.clear();
//Attaching a function to the lines is required for scrolling to work
//Main
main_line_1.attach_function(1, goto_mwater);
main_line_2.attach_function(1, goto_mformula);
main_line_3.attach_function(1, goto_mmachine);
mmback_line.attach_function(1, mm_go_back);
//Water
water_line_1.attach_function(1, fBlankFunction);
water_line_2.attach_function(1, fBlankFunction);
water_line_3.attach_function(1, fBlankFunction);
//Formula
formula_line_1.attach_function(1, fBlankFunction);
formula_line_2.attach_function(1, fBlankFunction);
formula_line_3.attach_function(1, fBlankFunction);
//Machine
machine_line_1.attach_function(1, fBlankFunction);
machine_line_2.attach_function(1, fBlankFunction);
machine_line_3.attach_function(1, fBlankFunction);
machine_line_4.attach_function(1, fBlankFunction);
machine_line_5.attach_function(1, fBlankFunction);
// Set the number of lines the display has
//Main
smain_1.set_displayLineCount(2);
//Water
swater_1.set_displayLineCount(2);
//Formula
sformula_1.set_displayLineCount(2);
//Machine
smachine_1.set_displayLineCount(2);
smachine_1.add_line(machine_line_3);
smachine_1.add_line(machine_line_4);
smachine_1.add_line(machine_line_5);
smachine_1.add_line(mmback_line);
mmain.add_screen(smain_1);
mwater.add_screen(swater_1);
mformula.add_screen(sformula_1);
mmachine.add_screen(smachine_1);
mmain.update();
mwater.update();
mformula.update();
mmachine.update();
overall_menu.update();
}
void loop() {
buttonsCheck();
}`
—
Reply to this email directly, view it on GitHub
<#58 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A6QPBBNZ5KS2247XEO45FTLW6GYYDANCNFSM6AAAAAAV4H3TG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I found the solution to the problem of not being able to scroll more than 4 line items. the |
Beta Was this translation helpful? Give feedback.
Hello @fred-76.
To achieve this menu structure, you need to put every
LiquidScreen
in its ownLiquidMenu
, since you're navigating the menu hierarchically (not scrolling through the screens). Here is an example: