Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Reddit menu example - May 8, 2019
- Displays a multi-level menu on a 20x4 LCD screen, with 5-button navigation.
- Board = Uno
- Other hardware: 20x4 I2C LCD
- 5 series-resistive buttons
- Button 1 should be left, button 2 down, button 3 up, button 4 right. 5 = select.
- buttons, resistors, pin levels:
- 1 220Ω 394
- 2 470Ω 329
- 3 1KΩ 264
- 4 2.2KΩ 194
- 5 4.7KΩ 114
- The default screen = no menu [press right button to enter menu]
- The normal screen #1 is numbered (1). You can have more than one default screen and set which one you want through the menu.
- (-the idea here is that you could contnuously monitor different sensors on different screens, since the screen isn't big enough to show all the sensors-)
- Main Menu >
- Air Quality [menu_first_level=1]
- > Settings (target values to set temp/humidty) [menu_second_level=]
- set temp [menu_third_level=] <--------------------------------------------------------- (this is assumed to be a temperature level in F, from 60 to 90) air_settings__temperature_target
- set humidity [menu_third_level=] <----------------------------------------------------- (this is assumed to be a humidity level in 5% increments, from 25 to 75) air_settings__humidity_target
- > AQ Monitor (temp, humidity, CO2 ppm) [menu_second_level=]
- temp [menu_third_level=] <------------------------------------------------------------- (this is assumed to be viewing a temperature reading) air_readings__temperature
- humidity [menu_third_level=] <--------------------------------------------------------- (this is assumed to be viewing a humidity setting) air_readings__humidity
- co2 ppm [menu_third_level=] <---------------------------------------------------------- (this is assumed to be viewing a CO2 reading) air_readings__co2
- Water Quality [menu_first_level=2]
- > Settings (target values to set pH, drain/fill interval) [menu_second_level=]
- set ph [menu_third_level=] <----------------------------------------------------------- (set pH fron zero to 14 in .5 increments) water_settings__ph_target
- set drain/fill interval [menu_third_level=] <------------------------------------------ (set time interval in 30 minute increments) water_settings__refill_interval
- > WQ Monitor (temp, pH, dissolved O2 ppm, conductivity, time since drain) [menu_second_level=]
- temp [menu_third_level=] <------------------------------------------------------------- (show water temperature) water_readings_temperature
- ph [menu_third_level=] <--------------------------------------------------------------- (show PH level) water_readings__ph_level
- dissoved 02 [menu_third_level=] <------------------------------------------------------ (show dissolved O2) water_readings__dissolved_02
- conductivity [menu_third_level=] <----------------------------------------------------- (show conductivity) water_readings__conductivity
- time since drain [menu_third_level=] <------------------------------------------------- (show time since previous drain/fill) water_readings__last_refill_time
- Power (value = 3) [menu_first_level=3]
- > Generator Monitor (volts, amps) [menu_second_level=]
- volts [menu_third_level=] <------------------------------------------------------------ (show volts reading) power_readings__generator_volts
- amps [menu_third_level=] <------------------------------------------------------------- (show amps reading ???? see notes below) power_readings__generator_amps
- > Load Monitor (volts, amps) [menu_second_level=]
- volts [menu_third_level=] <------------------------------------------------------------ (show volts ?????) power_readings__load_volts
- amps [menu_third_level=] <------------------------------------------------------------- (show amps ???) power_readings__load_amps
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- Just a note: you can't really measure the 'amps' of a generator without any load attached; you can only measure the amps flowing through {some electrical load} on the generator.
- And the volts that the generator puts out is going to be the same voltage drop across any single load.
- So it doesn't make much sense to show the volts and amps for both the generator and a single load.
- I put them in the menu anyway, but just so you know.
- Instead, just show the volts that the generator is producing, and the amps through the load.
- If you had more than one load on a generator, then you could show the current through all, or any one of the separate loads.
- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- Change default screen: this is a menu choice that I added to show how to change the default screen shown.
- > up/down changes the default screen through four different versions. Each of these could constantly show differnt things, if desired. -----> default_screen_to_use
- */
- #include "Wire.h" // For I2C
- #include "LiquidCrystal_I2C.h" // Library location --- https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c
- LiquidCrystal_I2C lcd(0x27, 20, 4); // 0x27 is -usually- the default I2C bus address of the backpack
- bool use_serial_messages = true; // general prototyping messages (allows disabling them for speed reasons)
- // The variables below is just for detecting button presses.
- int buttonInput_pin = A0; // The physical input pin for buttons.
- int buttonInput_pinValue = 0; // This is used for storing the actual pin value.
- int button_pressed_current_value = 0;
- int button_pressed_previous_value = 0;
- // Button 1 should be left, button 2 down, button 3 up, button 4 right. 5 = select.
- // The variables below is what is used in the menu function.
- int button_defined = 0; // This variable holds one of the values below:
- const int button_defined__no_button = 0;
- const int button_defined__left = 1;
- const int button_defined__down = 2;
- const int button_defined__up = 3;
- const int button_defined__right = 4;
- const int button_defined__select = 5;
- // The variables below are used to debounce button presses.
- // The buttons are going to be checked ten times a second.
- // Only one button press will be detected for each time the button is pressed. Holding the button down should not result in additional 'presses' being detected.
- bool buttons_enabled = true; // Used for debouncing buttons.
- int button_debounce_time = 100; // A time in milliseconds to debounce the buttons.
- unsigned long button_press_begin_time = 0;
- unsigned long button_press_current_time = 0;
- // This sketch shows a default screen, and then pressing the [right] button changes to the menu.
- int default_screen_to_use = 1; // This sketch has four different default screens provided. zero value is not used.
- int max_default_screen = 4; // This is to limit the default screen selection value.
- int menu_level = 0; // The left and right buttons change this value.
- // zero = show the default screen. 1 = navigate the menu. 2 = input values.
- int menu_end_state = 1; // The [up] and [down] buttons alter this value, if menu_level = 2.
- int menu_end_state__maximum_value = 17;
- /*
- The possible menu end points are shown below.
- Some of these are for setting target values and others are for viewing sensor values.
- 1 = air quality > settings > set temp
- 2 = air quality > settings > set humidity
- 3 = air monitor > temperature
- 4 = air monitor > humidity
- 5 = air monitor > co2 ppm
- 6 = water quality > settings > ph
- 7 = water quality > settings > drain/fill interval
- 8 = water monitor > temp
- 9 = water monitor > ph
- 10 = water monitor > dissolved 02
- 11 = water monitor > conductivity
- 12 = water monitor > last refill time
- 13 = power > generator volts
- 14 = power > generator current
- 15 = power > load volts
- 16 = power > load amps
- 17 = change default screen
- */
- // Variables for all of the end states above are declared below.
- // Some of these have initial values in them, just to provide something more interesting than having everything set to zeros.
- int air_quality__target_temperature = 75;
- float air_quality__target_humidity = 70;
- int air_quality__current_temperature = 80;
- float air_quality__current_humidity = 50;
- int air_monitor__current_co2_ppm = 220; // If co2 ppm goes over 32,000, we will all be dead anyway.
- float water_quality__target_ph = 8.0;
- int water_quality__refill_interval = 24; // assumed to be hours?
- int water_monitor__current_temperature = 70;
- float water_monitor__current_ph = 8.4;
- int water_monitor__dissolved_co2 = 700; // I am guessing what a typical figure for this might be?
- float water_monitor__conductivity = 25; // Also this
- int water_monitor__time_since_last_refill = 7; // assumed to be hours
- int power__generator_volts = 0;
- int power__generator_amps = 0;
- int power__load_volts = 0;
- int power__load_amps = 0;
- // related variables for the above variables,,,, are declared below
- // All of the target values need a minimum, maximum and change values defined.
- int air_quality__target_temperature_minimum_value = 0;
- int air_quality__target_temperature_maximum_value = 120;
- int air_quality__target_temperature_change_interval = 5;
- float air_quality__target_humidity_minimum_value = 20;
- float air_quality__target_humidity_maximum_value = 100;
- float air_quality__target_humidity_change_interval = 5;
- float water_quality__target_ph_minimum = 0;
- float water_quality__target_ph_maximum = 14;
- float water_quality__target_ph_change_interval = .2;
- int water_quality__refill_interval_minimum = 3;
- int water_quality__refill_interval_maximum_value = 96;
- int water_quality__refill_interval_change_interval = 3;
- bool update_menu_display = true; // If the display needs to be changed, this is set to true and refresh_menu() is called.
- void setup() {
- Serial.begin(9600);
- lcd.init();
- lcd.backlight();
- // buttonInput_pin is analogRead(), doesn't require declaration
- // I2C pins A4, A5 are fixed and don't require declaration
- lcd_clear_all_lines();
- show_menu();
- if (use_serial_messages == true) {
- Serial.println("Exiting setup()");
- }
- }
- void loop() {
- if (buttons_enabled == true) {
- check_buttons();
- start_button_timer();
- }
- else {
- check_button_timer();
- }
- } // end of main loop
- void check_buttons() {
- button_pressed_current_value = analogRead(buttonInput_pin);
- if (button_pressed_previous_value < 50 && button_pressed_current_value > 50) {
- // Your button values:
- if (button_pressed_current_value > 50 && button_pressed_current_value < 130) {
- button_pressed__select();
- }
- if (button_pressed_current_value > 180 && button_pressed_current_value < 220) {
- button_pressed__right();
- }
- if (button_pressed_current_value > 230 && button_pressed_current_value < 290) {
- button_pressed__up();
- }
- if (button_pressed_current_value > 300 && button_pressed_current_value < 360) {
- button_pressed__down();
- }
- if (button_pressed_current_value > 370 && button_pressed_current_value < 430) {
- // left button
- button_pressed__left();
- }
- /*
- // Below is the button values I had to use with the Robotdyne keypad running off USB voltage
- if (button_pressed_current_value > 635 && button_pressed_current_value < 655) {
- button_pressed__select(); // 645
- }
- if (button_pressed_current_value > 590 && button_pressed_current_value < 610) {
- button_pressed__right(); // 601
- }
- if (button_pressed_current_value > 813 && button_pressed_current_value < 833) {
- button_pressed__up(); // 823
- }
- if (button_pressed_current_value > 519 && button_pressed_current_value < 539) {
- button_pressed__down(); // 529
- }
- if (button_pressed_current_value > 685 && button_pressed_current_value < 705) {
- // left button
- button_pressed__left(); // 695
- }
- */
- }
- button_pressed_previous_value = button_pressed_current_value;
- }
- void operate_menu(int buttonPress) {
- // int menu_level = 0; // The left and right buttons change this value.
- // zero = show the default screen. 1 = navigate the menu. 2 = input values.
- // The left and right buttons always do the same thing, no matter where you are in the menu.
- if (buttonPress == button_defined__right) {
- if (menu_level < 2) {
- menu_level = menu_level + 1;
- update_menu_display = true;
- if (use_serial_messages == true) {
- Serial.print("+menu_level = ");
- Serial.println(menu_level);
- }
- }
- }
- if (buttonPress == button_defined__left) {
- if (menu_level > 0) {
- menu_level = menu_level - 1;
- update_menu_display = true;
- if (use_serial_messages == true) {
- Serial.print("-menu_level = ");
- Serial.println(menu_level);
- }
- }
- }
- if (menu_level == 0) {
- // Do nothing with the up and down button presses.
- // If menu_level is zero, then the program is on the default screen and the up and down buttons won't do anything.
- }
- // If menu_level = 1, the up and down buttons navigate over the menu choices.
- if (menu_level == 1) {
- if (buttonPress == button_defined__down) {
- if (menu_end_state < menu_end_state__maximum_value) {
- menu_end_state += 1;
- update_menu_display = true;
- }
- if (use_serial_messages == true) {
- Serial.print("menu_end_state = ");
- Serial.println(menu_end_state);
- }
- }
- if (buttonPress == button_defined__up) {
- if (menu_end_state > 1) {
- menu_end_state -= 1;
- update_menu_display = true;
- }
- if (use_serial_messages == true) {
- Serial.print("menu_end_state = ");
- Serial.println(menu_end_state);
- }
- }
- }
- // If menu_level = 2 then the up and down buttons change the values of the selected menu choice, if it is a setting.
- // Each menu choice for a setting has different values and limitations involved.
- if (menu_level == 2) {
- switch (menu_end_state) {
- case 1:
- // 1 = air quality > settings > set temp
- if (buttonPress == button_defined__down) {
- if (air_quality__target_temperature > air_quality__target_temperature_minimum_value) {
- air_quality__target_temperature -= air_quality__target_temperature_change_interval;
- update_menu_display = true;
- }
- }
- if (buttonPress == button_defined__up) {
- if (air_quality__target_temperature < air_quality__target_temperature_maximum_value) {
- air_quality__target_temperature += air_quality__target_temperature_change_interval;
- update_menu_display = true;
- }
- }
- break;
- case 2:
- // 2 = air quality > settings > set humidity
- if (buttonPress == button_defined__down) {
- if (air_quality__target_humidity > air_quality__target_humidity_minimum_value) {
- air_quality__target_humidity -= air_quality__target_humidity_change_interval;
- update_menu_display = true;
- }
- }
- if (buttonPress == button_defined__up) {
- if (air_quality__target_humidity < air_quality__target_humidity_maximum_value) {
- air_quality__target_humidity += air_quality__target_humidity_change_interval;
- update_menu_display = true;
- }
- }
- break;
- case 6:
- // 6 = water quality > settings > ph
- if (buttonPress == button_defined__down) {
- if (water_quality__target_ph > water_quality__target_ph_minimum) {
- water_quality__target_ph -= water_quality__target_ph_change_interval;
- update_menu_display = true;
- }
- }
- if (buttonPress == button_defined__up) {
- if (water_quality__target_ph < water_quality__target_ph_maximum) {
- water_quality__target_ph += water_quality__target_ph_change_interval;
- update_menu_display = true;
- }
- }
- break;
- case 7:
- // 7 = water quality > settings > drain/fill interval
- if (buttonPress == button_defined__down) {
- if (water_quality__refill_interval > water_quality__refill_interval_minimum) {
- water_quality__refill_interval -= water_quality__refill_interval_change_interval;
- update_menu_display = true;
- }
- }
- if (buttonPress == button_defined__up) {
- if (water_quality__refill_interval < water_quality__refill_interval_maximum_value) {
- water_quality__refill_interval += water_quality__refill_interval_change_interval;
- update_menu_display = true;
- }
- }
- break;
- case 17:
- // 17 = change default screen
- if (buttonPress == button_defined__down) {
- if (default_screen_to_use > 1) {
- default_screen_to_use -= 1;
- update_menu_display = true;
- }
- }
- if (buttonPress == button_defined__up) {
- if (default_screen_to_use < max_default_screen) {
- default_screen_to_use += 1;
- update_menu_display = true;
- }
- }
- break;
- }
- }
- }
- void refresh_menu() {
- if (update_menu_display == true) {
- show_menu();
- }
- }
- void show_menu() {
- // This re-prints the menu to the LCD display.
- lcd_clear_all_lines();
- // int menu_level = 0; // The left and right buttons change this value.
- // zero = show the default screen. 1 = navigate the menu. 2 = input values.
- if (menu_level == 0) {
- // This is the option to cause the default screen to be shown.
- lcd__display_default_screen();
- }
- else {
- switch (menu_end_state) {
- case 1:
- // 1 = air quality > settings > set temp
- menu_top_line__air_settings();
- menu_second_line__settings();
- menu_third_line__air_target_temperature();
- // Note: if you wanted to, you could just write each menu screen out here if you wanted.
- // That will take up some more program space, but it's only at 27% as it is.
- // I just tried to re-use commands as often as I could by putting re-usable ones into their functions.
- break;
- case 2:
- // 2 = air quality > settings > set humidity
- menu_top_line__air_settings();
- menu_second_line__settings();
- menu_third_line__air_target_humidity();
- break;
- case 3:
- // 3 = air monitor > temperature
- menu_top_line__air_monitor();
- menu_second_line__monitor();
- menu_third_line__air_monitor_temperature();
- break;
- case 4:
- // 4 = air monitor > humidity
- menu_top_line__air_monitor();
- menu_second_line__monitor();
- menu_third_line__air_monitor_humidity();
- break;
- case 5:
- // 5 = air monitor > co2 ppm
- menu_top_line__air_monitor();
- menu_second_line__monitor();
- menu_third_line__air_monitor_co2_ppm();
- break;
- case 6:
- // 6 = water quality > settings > ph
- menu_top_line__water_settings();
- menu_second_line__settings();
- menu_third_line__water_settings_ph();
- break;
- case 7:
- // 7 = water quality > settings > drain/fill interval
- menu_top_line__water_settings();
- menu_second_line__settings();
- menu_third_line__water_settings_refill_interval();
- break;
- case 8:
- // 8 = water monitor > temp
- menu_top_line__water_monitor();
- menu_second_line__monitor();
- menu_third_line__water_monitor_temperature();
- break;
- case 9:
- // 9 = water monitor > ph
- menu_top_line__water_monitor();
- menu_second_line__monitor();
- menu_third_line__water_monitor_ph();
- break;
- case 10:
- // 10 = water monitor > dissolved 02
- menu_top_line__water_monitor();
- menu_second_line__monitor();
- menu_third_line__water_monitor_co2();
- break;
- case 11:
- // 11 = water monitor > conductivity
- menu_top_line__water_monitor();
- menu_second_line__monitor();
- menu_third_line__water_monitor_conductivity();
- break;
- case 12:
- // 12 = water monitor > last refill time
- menu_top_line__water_monitor();
- menu_second_line__monitor();
- menu_third_line__water_monitor_time_since_last_refill();
- break;
- case 13:
- // 13 = power > generator volts
- menu_top_line__power_monitor();
- menu_second_line__monitor();
- menu_third_line__power_generator_volts();
- break;
- case 14:
- // 14 = power > generator current
- menu_top_line__power_monitor();
- menu_second_line__monitor();
- menu_third_line__power_generator_amps();
- break;
- case 15:
- // 15 = power > load volts
- menu_top_line__power_monitor();
- menu_second_line__monitor();
- menu_third_line__power_load_volts();
- break;
- case 16:
- // 16 = power > load amps
- menu_top_line__power_monitor();
- menu_second_line__monitor();
- menu_third_line__power_load_amps();
- break;
- case 17:
- // 17 = change default screen
- menu_top_line__default_screen();
- // This screen prints its own second line automagically.
- break;
- }
- }
- }
- void button_pressed__select() {
- button_defined = button_defined__select;
- operate_menu(button_defined);
- refresh_menu();
- if (use_serial_messages == true) {
- Serial.println("button = select");
- }
- }
- void button_pressed__right() {
- button_defined = button_defined__right;
- operate_menu(button_defined);
- refresh_menu();
- if (use_serial_messages == true) {
- Serial.println("button = right");
- }
- }
- void button_pressed__up() {
- button_defined = button_defined__up;
- operate_menu(button_defined);
- refresh_menu();
- if (use_serial_messages == true) {
- Serial.println("button = up");
- }
- }
- void button_pressed__down() {
- button_defined = button_defined__down;
- operate_menu(button_defined);
- refresh_menu();
- if (use_serial_messages == true) {
- Serial.println("button = down");
- }
- }
- void button_pressed__left() {
- button_defined = button_defined__left;
- operate_menu(button_defined);
- refresh_menu();
- if (use_serial_messages == true) {
- Serial.println("button = left");
- }
- }
- void button_pressed__no_button() {
- button_defined = button_defined__no_button;
- operate_menu(button_defined);
- refresh_menu();
- }
- void start_button_timer() {
- // This is for starting the button timer. This is done every time the button input is checked.
- buttons_enabled = false;
- button_press_begin_time = millis();
- }
- void check_button_timer() {
- // This function re-enables the button input if button_debounce_time has passed.
- button_press_current_time = millis();
- if (button_press_current_time >= button_press_begin_time) {
- if (button_press_current_time >= (button_press_begin_time + button_debounce_time)) {
- buttons_enabled = true;
- }
- }
- else {
- button_press_begin_time = millis();
- }
- }
- void lcd_clear_all_lines() {
- lcd_print_blank_line(1);
- lcd_print_blank_line(2);
- lcd_print_blank_line(3);
- lcd_print_blank_line(4);
- }
- void lcd_print_blank_line(int lineNumber) {
- // This function 'erases' a given line by printing 20 spaces in it.
- int sLine = lineNumber - 1;
- lcd.setCursor(0, sLine);
- lcd.print(" ");
- }
- // copy this onto the main file before posting...
- // The functions to print all the top lines for every menu option are below:
- void menu_top_line__air_settings() {
- lcd.setCursor(0, 0);
- lcd.print("Air quality:");
- }
- void menu_top_line__air_monitor() {
- lcd.setCursor(0, 0);
- lcd.print("Air monitor:");
- }
- void menu_top_line__water_settings() {
- lcd.setCursor(0, 0);
- lcd.print("Water quality:");
- }
- void menu_top_line__water_monitor() {
- lcd.setCursor(0, 0);
- lcd.print("Water monitor:");
- }
- void menu_top_line__power_monitor() {
- lcd.setCursor(0, 0);
- lcd.print("Power:");
- }
- void menu_top_line__default_screen() {
- lcd.setCursor(0, 0);
- lcd.print("Default screen:");
- lcd.setCursor(0, 1);
- lcd.print("current = ");
- lcd.setCursor(10, 1);
- lcd.print(default_screen_to_use);
- //lcd.setCursor(0, 2);
- //lcd.print("up/down to change");
- }
- // There is only two kinds of second lines used:
- void menu_second_line__settings() {
- lcd.setCursor(1, 1);
- lcd.print("Settings:");
- }
- void menu_second_line__monitor() {
- lcd.setCursor(1, 1);
- lcd.print("Monitor:");
- }
- // The functions to print every possible third-line message are below:
- void menu_third_line__air_target_temperature() {
- lcd.setCursor(2, 2);
- lcd.print("Temp = ");
- lcd.setCursor(9, 2);
- lcd.print(air_quality__target_temperature);
- if (menu_level == 1) {
- lcd.setCursor(0, 3);
- lcd.print("R=change value");
- }
- if (menu_level == 2) {
- lcd.setCursor(0, 3);
- lcd.print("U/D=value,left=exit");
- }
- }
- void menu_third_line__air_monitor_temperature() {
- lcd.setCursor(2, 2);
- lcd.print("Temp = ");
- lcd.setCursor(9, 2);
- get_sensor_data__air_current_temperature();
- lcd.print(air_quality__current_temperature);
- }
- void menu_third_line__air_target_humidity() {
- lcd.setCursor(2, 2);
- lcd.print("Humidity = ");
- lcd.setCursor(13, 2);
- lcd.print(air_quality__target_humidity);
- if (menu_level == 1) {
- lcd.setCursor(0, 3);
- lcd.print("R=change value");
- }
- if (menu_level == 2) {
- lcd.setCursor(0, 3);
- lcd.print("U/D=value,left=exit");
- }
- }
- void menu_third_line__air_monitor_humidity() {
- lcd.setCursor(2, 2);
- lcd.print("Humidity = ");
- lcd.setCursor(13, 2);
- get_sensor_data__air_current_humidity();
- lcd.print(air_quality__current_humidity);
- }
- void menu_third_line__air_monitor_co2_ppm() {
- lcd.setCursor(2, 2);
- lcd.print("CO2 ppm = ");
- lcd.setCursor(12, 2);
- get_sensor_data__air_current_co2_ppm();
- lcd.print(air_monitor__current_co2_ppm);
- }
- void menu_third_line__water_settings_ph() {
- lcd.setCursor(2, 2);
- lcd.print("pH = ");
- lcd.setCursor(7, 2);
- lcd.print(water_quality__target_ph);
- if (menu_level == 1) {
- lcd.setCursor(0, 3);
- lcd.print("R=change value");
- }
- if (menu_level == 2) {
- lcd.setCursor(0, 3);
- lcd.print("U/D=value,left=exit");
- }
- }
- void menu_third_line__water_settings_refill_interval() {
- lcd.setCursor(2, 2);
- lcd.print("Refill hrs = ");
- lcd.setCursor(15, 2);
- lcd.print(water_quality__refill_interval);
- if (menu_level == 1) {
- lcd.setCursor(0, 3);
- lcd.print("R=change value");
- }
- if (menu_level == 2) {
- lcd.setCursor(0, 3);
- lcd.print("U/D=value,left=exit");
- }
- }
- void menu_third_line__water_monitor_temperature() {
- lcd.setCursor(2, 2);
- lcd.print("Temp = ");
- lcd.setCursor(9, 2);
- get_sensor_data__water_current_temperature();
- lcd.print(water_monitor__current_temperature);
- }
- void menu_third_line__water_monitor_ph() {
- lcd.setCursor(2, 2);
- lcd.print("pH = ");
- lcd.setCursor(7, 2);
- get_sensor_data__water_current_ph();
- lcd.print(water_monitor__current_ph);
- }
- void menu_third_line__water_monitor_co2() {
- lcd.setCursor(2, 2);
- lcd.print("CO2 = ");
- lcd.setCursor(8, 2);
- get_sensor_data__water_dissolved_co2();
- lcd.print(water_monitor__dissolved_co2);
- }
- void menu_third_line__water_monitor_conductivity() {
- lcd.setCursor(2, 2);
- lcd.print("conduct = ");
- lcd.setCursor(12, 2);
- get_sensor_data__water_conductivity();
- lcd.print(water_monitor__conductivity);
- }
- void menu_third_line__water_monitor_time_since_last_refill() {
- lcd.setCursor(2, 2);
- lcd.print("last refill = ");
- lcd.setCursor(16, 2);
- get_sensor_data__water_time_since_last_refill();
- lcd.print(water_monitor__time_since_last_refill);
- }
- void menu_third_line__power_generator_volts() {
- lcd.setCursor(2, 2);
- lcd.print("gen volts = ");
- lcd.setCursor(14, 2);
- get_sensor_data__generator_volts();
- lcd.print(power__generator_volts);
- }
- void menu_third_line__power_generator_amps() {
- lcd.setCursor(2, 2);
- lcd.print("gen amps = ");
- lcd.setCursor(13, 2);
- get_sensor_data__generator_amps();
- lcd.print(power__generator_amps);
- }
- void menu_third_line__power_load_volts() {
- lcd.setCursor(2, 2);
- lcd.print("load volts = ");
- lcd.setCursor(14, 2);
- get_sensor_data__load_volts();
- lcd.print(power__load_volts);
- }
- void menu_third_line__power_load_amps() {
- lcd.setCursor(2, 2);
- lcd.print("load amps = ");
- lcd.setCursor(13, 2);
- get_sensor_data__load_amps();
- lcd.print(power__load_amps);
- }
- // There are currently no functions to print anything on the fourth line.
- void lcd__display_default_screen() {
- // This function shows the default screen, based on the value currently stored in default_screen_to_use.
- switch (default_screen_to_use) {
- case 1:
- lcd.setCursor(0, 0);
- lcd.print("default screen #1");
- lcd.setCursor(0, 1);
- lcd.print("press R for menu");
- // Since each of the default screens is printed separately, you can show different things on each of them.
- break;
- case 2:
- lcd.setCursor(0, 0);
- lcd.print("default screen #2");
- lcd.setCursor(0, 1);
- lcd.print("press R for menu");
- break;
- case 3:
- lcd.setCursor(0, 0);
- lcd.print("default screen #3");
- lcd.setCursor(0, 1);
- lcd.print("press R for menu");
- break;
- case 4:
- lcd.setCursor(0, 0);
- lcd.print("default screen #4");
- lcd.setCursor(0, 1);
- lcd.print("press R for menu");
- break;
- default:
- // error: incorrect value
- lcd.setCursor(0, 0);
- lcd.print("error!");
- lcd.setCursor(0, 1);
- lcd.print("default screen:");
- lcd.setCursor(0, 2);
- lcd.print("invalid code");
- break;
- }
- }
- void get_sensor_data__air_current_temperature() {
- // This function is for getting the current air temperature from whatever sensor you use.
- // store that value in air_quality__current_temperature
- }
- void get_sensor_data__air_current_humidity() {
- // This function is for getting the current air humidity from whatever sensor you use.
- // Store that value in air_quality__current_humidity
- }
- void get_sensor_data__air_current_co2_ppm() {
- // This function is for getting the current air co2 from whatever sensor you use.
- // Store that value in air_monitor__current_co2_ppm
- }
- void get_sensor_data__water_current_temperature() {
- // This function is for getting the current water temperature from whatever sensor you use.
- // Store that value in water_monitor__current_temperature
- }
- void get_sensor_data__water_current_ph() {
- // This function is for getting the current water ph from whatever sensor you use.
- // Store that value in water_monitor__current_ph
- }
- void get_sensor_data__water_dissolved_co2() {
- // This function is for getting the current water co2 from whatever sensor you use.
- // Store that value in water_monitor__dissolved_co2
- }
- void get_sensor_data__water_conductivity() {
- // This function is for getting the current water conductivity from whatever sensor you use.
- // Store that value in water_monitor__conductivity
- }
- void get_sensor_data__water_time_since_last_refill() {
- // This isn't really a sensor, unless you consider a RTC a sensor. But anyway.
- // This function is for getting the current water elapsed time since the last refill.
- // Store that value in water_monitor__time_since_last_refill
- }
- // The last four functions are below, even though all of them aren't really needed.
- void get_sensor_data__generator_volts() {
- // The variable for this is power__generator_volts
- }
- void get_sensor_data__generator_amps() {
- // The variable for this is power__generator_amps
- }
- void get_sensor_data__load_volts() {
- // The variable for this is power__load_volts
- }
- void get_sensor_data__load_amps() {
- // The variable for this is power__load_amps
- }
Add Comment
Please, Sign In to add comment