Best way to display whether sensor is active on LiquidMenu line?

/*
 * LiquidMenu library - system_menu.ino
 *
 * This example demonstrates the how to build a menu system.
 *
 * Menu system is a collection of menus. To build a menu system
 * you need to put the menus into an object of class LiquidSystem.
 * The methods used on LiquidMenu should now be called directly
 * on the LiquidSystem object. To switch between menus use the
 * bool LiquidSystem::change_menu(LiquidMenu &p_liquidMenu) method.
 * This method can be wrapped inside a callback function and called
 * on through the menu. This example also uses EEPROM to save the
 * state of the LED and reading period.
 *
 *
 * The circuit:
 * https://github.com/VasilKalchev/LiquidMenu/blob/master/examples/H_system_menu/system_menu.png
 * - LCD RS pin to Arduino pin 12
 * - LCD E pin to Arduino pin 11
 * - LCD D4 pin to Arduino pin 5
 * - LCD D5 pin to Arduino pin 4
 * - LCD D6 pin to Arduino pin 3
 * - LCD D7 pin to Arduino pin 2
 * - LCD R/W pin to ground
 * - LCD VSS pin to ground
 * - LCD VDD pin to 5V
 * - 10k ohm potentiometer: ends to 5V and ground, wiper to LCD V0
 * - 150 ohm resistor from 5V to LCD Anode
 * - LCD Cathode to ground
 * - ----
 * - Button (left) to Arduino pin A0 and ground
 * - Button (right) to Arduino pin 7 and ground
 * - Button (up) to Arduino pin 8 and ground
 * - Button (down) to Arduino pin 9 and ground
 * - Button (enter) to Arduino pin 10 and ground
 * - A PWM controlled device (LED...) to Arduino pin 6
 * - some analog input to Arduino pin A4 (unconnected also works)
 * - some analog input to Arduino pin A5 (unconnected also works)
 *
 * Created July 24, 2016
 * by Vasil Kalchev
 *
 * https://github.com/VasilKalchev/LiquidMenu
 *
 */
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};


// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidScreen welcome_screen(welcome_line1, welcome_line2);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
 * LiquidSystem object combines the LiquidMenu objects to form
 * a menu system. It provides the same functions as LiquidMenu
 * with the addition of add_menu() and change_menu().
 */
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
	if (right.check() == LOW) {
		menu_system.next_screen();
	}
	if (left.check() == LOW) {
		menu_system.previous_screen();
	}
	if (up.check() == LOW) {
		menu_system.call_function(increase);
	}
	if (down.check() == LOW) {
		menu_system.call_function(decrease);
	}
	if (enter.check() == LOW) {
		menu_system.switch_focus();
	}
}

// Callback function that will be attached to back_line.
void go_back() {
	// This function takes reference to the wanted menu.
	menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
	menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
	menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
	if (pin6_level < 225) {
		pin6_level += 25;
	}
	else {
		pin6_level = 250;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void decrease_pin6() {
	if (pin6_level > 25) {
		pin6_level -= 25;
	}
	else {
		pin6_level = 0;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void save_input() {
	EEPROM.put(11, sample_period);
	input_saved = (char*)" *";
}

void save_output() {
	EEPROM.put(9, pin6_level);
	output_saved = (char*)" *";
}

void increase_samplePeriod() {
	if (sample_period < 10) {
		sample_period++;
		input_saved = (char*)"  ";
	}
}

void decrease_samplePeriod() {
	if (sample_period > 0) {
		sample_period--;
		input_saved = (char*)"  ";
	}
}

void setup() {
	Serial.begin(250000);

	pinMode(pin6, OUTPUT);

	// Reads the values recorded in the EEPROM
	EEPROM.get(9, pin6_level);
	EEPROM.get(11, sample_period);
	analogWrite(pin6, pin6_level);

	lcd.init();
	lcd.backlight();

	back_line.set_focusPosition(Position::LEFT);

	back_line.attach_function(1, go_back);
	back_line.attach_function(2, go_back);

	outputs_line.attach_function(1, goto_outputs_menu);
	outputs_line.attach_function(2, goto_outputs_menu);
	inputs_line.attach_function(1, goto_inputs_menu);
	inputs_line.attach_function(2, goto_inputs_menu);

	pin6_line.attach_function(increase, increase_pin6);
	pin6_line.attach_function(decrease, decrease_pin6);

	oSave_line.attach_function(1, save_output);
	oSave_line.attach_function(2, save_output);
	iSave_line.attach_function(1, save_input);
	iSave_line.attach_function(2, save_input);
	iSample_line.attach_function(increase, increase_samplePeriod);
	iSample_line.attach_function(decrease, decrease_samplePeriod);

	input_saved = (char*)" *";
	output_saved = (char*)" *";

	menu_system.update();
}

void loop() {
	buttonsCheck();

	static unsigned long lastMillis_sample = 0;
	if (millis() - lastMillis_sample > (sample_period * 1000)) {
		lastMillis_sample = millis();
		menu_system.update();
	}

}

I included code from what I am currently working with since my question can apply to it, my question is what would be the best way to display ON, or OFF next to the Outputs line in the liquidline variable? Assign a String array[“ON”,“OFF”] and write a conditional statement if digitalWrite(pinofsensor) == HIGH, x = 0 else x = 1. Add the array with x to LiquidLine outputs_line(0, 0, “/Outputs”+array[ x]);

Would that work?

I’d like to have a menu for relay control on 8 channels and would like the menu to display ON next to the menu name if any of the relay’s are on, and inside the menu have the ability to go up and down through the 8 channels turning off and on through a function call by button press.

lcd.print(digitalRead(pinofsensor) ? "ON" : "OFF");

Adjust the logic to suit your system

UKHeliBob:

lcd.print(digitalRead(pinofsensor) ? "ON" : "OFF");

Adjust the logic to suit your system

Could you post a example of it used in the sketch I provided to learn from please?

LiquidLine outputs_line(0, 0, "/Outputs"? "ON":"OFF");
I don't understand what the ? means, or how it'd know to post on or off but wouldnt this just print both?
I was thinking of a string array["ON","OFF"] and having a conditional statement evaluate whether the array should point to on or off. Just not sure if itd work yet, which is why im asking here first due to experience and should get a better answer then I can come up with.

lcd.print(digitalRead(pinofsensor) ? "ON" : "OFF");

This is simply a shorter way of writing

if (digitalRead(pinofsensor) == true)
  {
     lcd.print("ON");
  }
else
  {
     lcd.print("OFF")
  }

The ? is equivalent to if (true) and the : is the equivalent to the else

By all means create an array containing the required text and use the value of digitalRead(pinofsensor) as the index to it to print the appropriate text. However, make sure that you use an array of strings (or pointers to them) rather than Strings which are wasteful of memory.

I cannot tell where in your code you want to conditionally print "ON" or "OFF"

Liquidline outputs_line is where I would like to see the example applied so can see it in use to learn and use it in other areas of my project.

That’s very cool that a if/else condition can be shortened, the “?” threw me off and didn’t understand that.

I am guessing but try this

LiquidLine outputs_line(0, 0, "/Outputs");  //I assume that this prints the text at 0,0
LiquidLine outputs_line(8, 0, digitalRead(pinofsensor) ? "ON" : "OFF");  //? print at 8, 0 ?

or

LiquidLine outputs_line(0, 0, digitalRead(pinofsensor) ? "/Outputs ON" : "/Outputs OFF");

What is the significance of the / in front of the text ?

I don't have all those libraries installed. But, I imagine it would be something like this:

In Global Definitions:

const uint8_t onOffLength = 4;
const char onOffLiterals[][onOffLength] = {"On", "Off"};
char onOffBuffer[onOffLength];

LiquidLine outputs_line(0, 0, "/Outputs ", onOffBuffer);

In your code, do:

strcpy(onOffBuffer, onOffLiterals[x]);

before the call to 'update()'.

You may also be able to do something like this:

In Global Definitions:

const uint8_t onOffLength = 4;
const char onOffLiterals[][onOffLength] = {"On", "Off"};
const char *literalPtr;

LiquidLine outputs_line(0, 0, "/Outputs", literalPtr);

In your code, do:

literalPtr = onOffLiterals[x];

before the call to 'update()'.

As I said, I don't have those libraries (or the hardware). So, you'll have to experiment.

EDIT:
After looking at the library source code again, I'm thinking this way may not work.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

char onOFF[] = {'ON', 'OFF'};
int x;

// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidScreen welcome_screen(welcome_line1, welcome_line2);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ", onOFF[x]);
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
 * LiquidSystem object combines the LiquidMenu objects to form
 * a menu system. It provides the same functions as LiquidMenu
 * with the addition of add_menu() and change_menu().
 */
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);

void offON() {
	int x = 1;
}

// Checks all the buttons.
void buttonsCheck() {
	if (right.check() == LOW) {
		menu_system.next_screen();
	}
	if (left.check() == LOW) {
		menu_system.previous_screen();
	}
	if (up.check() == LOW) {
		menu_system.call_function(increase);
	}
	if (down.check() == LOW) {
		menu_system.call_function(decrease);
	}
	if (enter.check() == LOW) {
		menu_system.switch_focus();
	}
}

// Callback function that will be attached to back_line.
void go_back() {
	// This function takes reference to the wanted menu.
	menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
	menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
	menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
	if (pin6_level < 225) {
		pin6_level += 25;
	}
	else {
		pin6_level = 250;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void decrease_pin6() {
	if (pin6_level > 25) {
		pin6_level -= 25;
	}
	else {
		pin6_level = 0;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void save_input() {
	EEPROM.put(11, sample_period);
	input_saved = (char*)" *";
}

void save_output() {
	EEPROM.put(9, pin6_level);
	output_saved = (char*)" *";
}

void increase_samplePeriod() {
	if (sample_period < 10) {
		sample_period++;
		input_saved = (char*)"  ";
	}
}

void decrease_samplePeriod() {
	if (sample_period > 0) {
		sample_period--;
		input_saved = (char*)"  ";
	}
}

void setup() {
	Serial.begin(250000);

	pinMode(pin6, OUTPUT);

	// Reads the values recorded in the EEPROM
	EEPROM.get(9, pin6_level);
	EEPROM.get(11, sample_period);
	analogWrite(pin6, pin6_level);

	lcd.init();
	lcd.backlight();

	back_line.set_focusPosition(Position::LEFT);

	back_line.attach_function(1, go_back);
	back_line.attach_function(2, go_back);

	outputs_line.attach_function(1, goto_outputs_menu);
	outputs_line.attach_function(2, goto_outputs_menu);
	inputs_line.attach_function(1, goto_inputs_menu);
	inputs_line.attach_function(2, goto_inputs_menu);

	pin6_line.attach_function(increase, increase_pin6);
	pin6_line.attach_function(decrease, decrease_pin6);

	oSave_line.attach_function(1, save_output);
	oSave_line.attach_function(2, save_output);
	iSave_line.attach_function(1, save_input);
	iSave_line.attach_function(2, save_input);
	iSample_line.attach_function(increase, increase_samplePeriod);
	iSample_line.attach_function(decrease, decrease_samplePeriod);

	input_saved = (char*)" *";
	output_saved = (char*)" *";

	menu_system.update();
}

void loop() {
	buttonsCheck();
	static unsigned long lastMillis_sample = 0;
	if (millis() - lastMillis_sample > (sample_period * 1000)) {
		lastMillis_sample = millis();
		menu_system.update();
	}

}

Here’s what I tried but the O in ON doesn’t display.
Going to try editting/adding a liquidline that displays this next to the OUTPUT line.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

String onOFF[] = {"ON", "OFF"};
int x;


// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidScreen welcome_screen(welcome_line1, welcome_line2);

// These lines direct to other menus.
LiquidLine outputs_line(0, 0, "/Outputs ", onOFF[x]);
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
 * LiquidSystem object combines the LiquidMenu objects to form
 * a menu system. It provides the same functions as LiquidMenu
 * with the addition of add_menu() and change_menu().
 */
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);

void offON() {
	int x = 1;
}

// Checks all the buttons.
void buttonsCheck() {
	if (right.check() == LOW) {
		menu_system.next_screen();
	}
	if (left.check() == LOW) {
		menu_system.previous_screen();
	}
	if (up.check() == LOW) {
		menu_system.call_function(increase);
	}
	if (down.check() == LOW) {
		menu_system.call_function(decrease);
	}
	if (enter.check() == LOW) {
		menu_system.switch_focus();
	}
}

// Callback function that will be attached to back_line.
void go_back() {
	// This function takes reference to the wanted menu.
	menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
	menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
	menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
	if (pin6_level < 225) {
		pin6_level += 25;
	}
	else {
		pin6_level = 250;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void decrease_pin6() {
	if (pin6_level > 25) {
		pin6_level -= 25;
	}
	else {
		pin6_level = 0;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void save_input() {
	EEPROM.put(11, sample_period);
	input_saved = (char*)" *";
}

void save_output() {
	EEPROM.put(9, pin6_level);
	output_saved = (char*)" *";
}

void increase_samplePeriod() {
	if (sample_period < 10) {
		sample_period++;
		input_saved = (char*)"  ";
	}
}

void decrease_samplePeriod() {
	if (sample_period > 0) {
		sample_period--;
		input_saved = (char*)"  ";
	}
}

void setup() {
	Serial.begin(250000);

	pinMode(pin6, OUTPUT);

	// Reads the values recorded in the EEPROM
	EEPROM.get(9, pin6_level);
	EEPROM.get(11, sample_period);
	analogWrite(pin6, pin6_level);

	lcd.init();
	lcd.backlight();

	back_line.set_focusPosition(Position::LEFT);

	back_line.attach_function(1, go_back);
	back_line.attach_function(2, go_back);

	outputs_line.attach_function(1, goto_outputs_menu);
	outputs_line.attach_function(2, goto_outputs_menu);
	inputs_line.attach_function(1, goto_inputs_menu);
	inputs_line.attach_function(2, goto_inputs_menu);

	pin6_line.attach_function(increase, increase_pin6);
	pin6_line.attach_function(decrease, decrease_pin6);

	oSave_line.attach_function(1, save_output);
	oSave_line.attach_function(2, save_output);
	iSave_line.attach_function(1, save_input);
	iSave_line.attach_function(2, save_input);
	iSample_line.attach_function(increase, increase_samplePeriod);
	iSample_line.attach_function(decrease, decrease_samplePeriod);

	input_saved = (char*)" *";
	output_saved = (char*)" *";

	menu_system.update();
}

void loop() {
	buttonsCheck();
	static unsigned long lastMillis_sample = 0;
	if (millis() - lastMillis_sample > (sample_period * 1000)) {
		lastMillis_sample = millis();
		menu_system.update();
	}

}

String turns the characters into numbers so it says 93 next to /Outouts.
Was thinking also having 2 variables each defined to off or on and having a void decide which.

String turns the characters into numbers

I have no idea what this means, nor do I understand why you are using Strings (uppercase S)

and having a void decide which.

When you say "a void" I assume that you mean a function.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;

enum FunctionTypes {
 increase = 1,
 decrease = 2,
};

char onOFF[2][4] = {'ON', 'OFF'};
int x;


// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidScreen welcome_screen(welcome_line1, welcome_line2);

// These lines direct to other menus.
LiquidLine offON(13,0, onOFF[1][4]);
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line, offON);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
 * LiquidSystem object combines the LiquidMenu objects to form
 * a menu system. It provides the same functions as LiquidMenu
 * with the addition of add_menu() and change_menu().
 */
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
 if (right.check() == LOW) {
 menu_system.next_screen();
 }
 if (left.check() == LOW) {
 menu_system.previous_screen();
 }
 if (up.check() == LOW) {
 menu_system.call_function(increase);
 }
 if (down.check() == LOW) {
 menu_system.call_function(decrease);
 }
 if (enter.check() == LOW) {
 menu_system.switch_focus();
 }
}

// Callback function that will be attached to back_line.
void go_back() {
 // This function takes reference to the wanted menu.
 menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
 menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
 menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
 if (pin6_level < 225) {
 pin6_level += 25;
 }
 else {
 pin6_level = 250;
 }
 analogWrite(pin6, pin6_level);
 output_saved = (char*)"  ";
}

void decrease_pin6() {
 if (pin6_level > 25) {
 pin6_level -= 25;
 }
 else {
 pin6_level = 0;
 }
 analogWrite(pin6, pin6_level);
 output_saved = (char*)"  ";
}

void save_input() {
 EEPROM.put(11, sample_period);
 input_saved = (char*)" *";
}

void save_output() {
 EEPROM.put(9, pin6_level);
 output_saved = (char*)" *";
}

void increase_samplePeriod() {
 if (sample_period < 10) {
 sample_period++;
 input_saved = (char*)"  ";
 }
}

void decrease_samplePeriod() {
 if (sample_period > 0) {
 sample_period--;
 input_saved = (char*)"  ";
 }
}

void setup() {
 Serial.begin(250000);

 pinMode(pin6, OUTPUT);

 // Reads the values recorded in the EEPROM
 EEPROM.get(9, pin6_level);
 EEPROM.get(11, sample_period);
 analogWrite(pin6, pin6_level);

 lcd.init();
 lcd.backlight();

 back_line.set_focusPosition(Position::LEFT);

 back_line.attach_function(1, go_back);
 back_line.attach_function(2, go_back);

 outputs_line.attach_function(1, goto_outputs_menu);
 outputs_line.attach_function(2, goto_outputs_menu);
 inputs_line.attach_function(1, goto_inputs_menu);
 inputs_line.attach_function(2, goto_inputs_menu);

 pin6_line.attach_function(increase, increase_pin6);
 pin6_line.attach_function(decrease, decrease_pin6);

 oSave_line.attach_function(1, save_output);
 oSave_line.attach_function(2, save_output);
 iSave_line.attach_function(1, save_input);
 iSave_line.attach_function(2, save_input);
 iSample_line.attach_function(increase, increase_samplePeriod);
 iSample_line.attach_function(decrease, decrease_samplePeriod);

 input_saved = (char*)" *";
 output_saved = (char*)" *";

 menu_system.update();
}

void loop() {
 buttonsCheck();
 static unsigned long lastMillis_sample = 0;
 if (millis() - lastMillis_sample > (sample_period * 1000)) {
 lastMillis_sample = millis();
 menu_system.update();
 }

}

LiquidLine offON(13,0, onOFF[1][4]);

For some reason multi dimensional arrays dont display as wished.
I believe could write a function for onOFF pointing to on or off?

Yes by void I meant function.

char onOFF[2][4] = {'ON', 'OFF'};

chars are single characters

I somewhat had that realization that char is single characters after seeing the display on the first attempt.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidMenu.h>
#include <EEPROM.h>
#include "Button.h"
LiquidCrystal_I2C lcd(0x27, 20, 4);

// Button objects instantiation
const bool pullup = true;
Button left(8, pullup);
Button right(9, pullup);
Button up(10, pullup);
Button down(11, pullup);
Button enter(12, pullup);

// Pin definitions and variables for their state.
const byte pin6 = 6;
byte pin6_level = 0;

const byte pinA4 = A4;
byte pinA4_value = 0;

const byte pinA5 = A5;
byte pinA5_value = 0;

// The analog reading sample period in seconds.
// It is later overwritten by it's EEPROM value.
unsigned short sample_period = 2;

// Text used for indication for the save lines.
char* input_saved;
char* output_saved;
char* onOFF;

enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

//char onOFF[] = {'ON', 'OFF'};
int x;


// A LiquidLine object can be used more that once.
LiquidLine back_line(11, 1, "/BACK");


LiquidLine welcome_line1(1, 0, "LiquidSenu ", LIQUIDMENU_VERSION);
LiquidLine welcome_line2(1, 1, "System example");
LiquidScreen welcome_screen(welcome_line1, welcome_line2);

// These lines direct to other menus.
LiquidLine offON(11,0, onOFF);
LiquidLine outputs_line(0, 0, "/Outputs ");
LiquidLine inputs_line(0, 1, "/Inputs");
LiquidScreen io_screen(outputs_line, inputs_line, offON);

// This is the first menu.
LiquidMenu main_menu(lcd, welcome_screen, io_screen, 1);


LiquidLine pin6_line(0, 0, "Pin 6: ", pin6_level);
LiquidScreen pin6_screen(pin6_line);

LiquidLine oSave_line(0, 0, "Save", output_saved);
LiquidScreen oSecondary_screen(oSave_line, back_line);

// This is the second menu.
LiquidMenu outputs_menu(lcd, pin6_screen, oSecondary_screen);


LiquidLine pinA4_line(0, 0, "Pin A4: ", pinA4_value);
LiquidLine pinA5_line(0, 1, "Pin A5: ", pinA5_value);
LiquidScreen pinsA4_A5_screen(pinA4_line, pinA5_line);

LiquidLine iSample_line(0, 0, "Sample: ", sample_period, "s");
LiquidLine iSave_line(0, 1, "Save", input_saved);
LiquidScreen iSecondary_screen(iSample_line, iSave_line, back_line);

// And this is the final third menu.
LiquidMenu inputs_menu(lcd, pinsA4_A5_screen, iSecondary_screen);

/*
 * LiquidSystem object combines the LiquidMenu objects to form
 * a menu system. It provides the same functions as LiquidMenu
 * with the addition of add_menu() and change_menu().
 */
LiquidSystem menu_system(main_menu, outputs_menu, inputs_menu);


// Checks all the buttons.
void buttonsCheck() {
	if (right.check() == LOW) {
		menu_system.next_screen();
	}
	if (left.check() == LOW) {
		menu_system.previous_screen();
	}
	if (up.check() == LOW) {
		menu_system.call_function(increase);
	}
	if (down.check() == LOW) {
		menu_system.call_function(decrease);
	}
	if (enter.check() == LOW) {
		menu_system.switch_focus();
	}
}

// Callback function that will be attached to back_line.
void go_back() {
	// This function takes reference to the wanted menu.
	menu_system.change_menu(main_menu);
}

void goto_outputs_menu() {
	menu_system.change_menu(outputs_menu);
}

void goto_inputs_menu() {
	menu_system.change_menu(inputs_menu);
}

void increase_pin6() {
	if (pin6_level < 225) {
		pin6_level += 25;
	}
	else {
		pin6_level = 250;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void decrease_pin6() {
	if (pin6_level > 25) {
		pin6_level -= 25;
	}
	else {
		pin6_level = 0;
	}
	analogWrite(pin6, pin6_level);
	output_saved = (char*)"  ";
}

void save_input() {
	EEPROM.put(11, sample_period);
	input_saved = (char*)" *";
}

void save_output() {
	EEPROM.put(9, pin6_level);
	output_saved = (char*)" *";
}

void increase_samplePeriod() {
	if (sample_period < 10) {
		sample_period++;
		input_saved = (char*)"  ";
	}
}

void decrease_samplePeriod() {
	if (sample_period > 0) {
		sample_period--;
		input_saved = (char*)"  ";
	}
}

void setup() {
	Serial.begin(250000);

	pinMode(pin6, OUTPUT);

	// Reads the values recorded in the EEPROM
	EEPROM.get(9, pin6_level);
	EEPROM.get(11, sample_period);
	analogWrite(pin6, pin6_level);

	lcd.init();
	lcd.backlight();

	back_line.set_focusPosition(Position::LEFT);

	back_line.attach_function(1, go_back);
	back_line.attach_function(2, go_back);

	outputs_line.attach_function(1, goto_outputs_menu);
	outputs_line.attach_function(2, goto_outputs_menu);
	inputs_line.attach_function(1, goto_inputs_menu);
	inputs_line.attach_function(2, goto_inputs_menu);

	pin6_line.attach_function(increase, increase_pin6);
	pin6_line.attach_function(decrease, decrease_pin6);

	oSave_line.attach_function(1, save_output);
	oSave_line.attach_function(2, save_output);
	iSave_line.attach_function(1, save_input);
	iSave_line.attach_function(2, save_input);
	iSample_line.attach_function(increase, increase_samplePeriod);
	iSample_line.attach_function(decrease, decrease_samplePeriod);

	input_saved = (char*)" *";
	output_saved = (char*)" *";
	onOFF = (char *)"ON";

	menu_system.update();
}

void loop() {
	buttonsCheck();
	static unsigned long lastMillis_sample = 0;
	if (millis() - lastMillis_sample > (sample_period * 1000)) {
		lastMillis_sample = millis();
		menu_system.update();
	}

}

That does print “ON” 3 spaces from /Outputs
Liquidline offOn was set to 9,0… in order to only have one space between words printed.
I am assuming I can write a function that takes ‘char* onOFF’ as a argument, in the function have a
loop of how many outputs im checking to a int and something like…
for(int x; x<8;x++){
if(digitalRead(x) == HIGH){
onOFF = (char*)“ON”;}
else{
onOFF = (char*)“OFF”;}}

x can be tied to a array of pins to check. This concept should work right?

Does anyone have a idea how to display time on a created 3rd line for the welcome menu?
rtc ds1307
I keep on trying different things but always wants me to define a type for the variable but don't know of the datetime type.