This has to be super simple but I can't figure it out. Trying to use LiquidMenu library with I2C LCD 20x4. Anyone know how to edit the LiquidMenu_config.h file to switch to I2C?
Here's the Config File
/**
@file
Configuration file for LiquidMenu library.
Contains global constants the configure the size of some of the arrays
used in the library, also configures the debugging messages.
*/
#pragma once
#include "LiquidMenu_const.h"
// Select a "LiquidCrystal" library:
// ---------------------------------
/*!
* @name Select a "LiquidCrystal" library
* @{
*/
/*!
* @name Arduino's parallel "LiquidCrystal" library
* @{
*/
//#ifndef LIQUIDMENU_LIBRARY
/// Wrapped library ID
// #define LIQUIDMENU_LIBRARY LiquidCrystal_LIBRARY
//#endif
//#ifndef DisplayClass
/// Name of wrapped library's class
// #define DisplayClass LiquidCrystal
//#endif
//!@}
/*!
* @name I2C library
* @see https://github.com/johnrickman/LiquidCrystal_I2C
* @{
*/
#ifndef LIQUIDMENU_LIBRARY
#define LIQUIDMENU_LIBRARY LiquidCrystal_I2C_LIBRARY
#endif
#ifndef DisplayClass
#define DisplayClass LiquidCrystal_I2C
#endif
!@}
/*!
* @name Some other library
* @{
*/
// #include <LIBRARY_HEADER.h>
// #ifndef DisplayClass
// #define DisplayClass LIBRARY_CONSTRUCTOR
// #endif
//!@}
//!@}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Configures the number of available variables per line.
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
/// Configures the number of available functions per line.
const uint8_t MAX_FUNCTIONS = 8; ///< @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 = 14; ///< @note Default: 14
/// Configures the number of available menus per menus system.
const uint8_t MAX_MENUS = 8; ///< @note Default: 8
/*!
* Enable/disable hiding the focus indicator.
*
* When enabled the focus indicator will disappear for one step after
* completing an iteration through the focusable lines. When disabled the focus
* indicator will go from the last focusable line directly to the first
* focusable line without disappearing (i.e. it will be always visible).
*/
#define LM_FOCUS_INDICATOR_GHOSTING true ///< @note Default: true
// Turns the debugging messages on or off.
#define LIQUIDMENU_DEBUG false ///< @note Default: false
Here's the Arduino file I'm trying to compile (example from LiquidMenu library) which is giving an error.
/*
* LiquidMenu library - I2C_menu.ino
* IMPORTANT: To configure the library for I2C connection define I2C
* as "true" in the "LiquidMenu_config.h" file.
*
* This is the "hello_menu" example configured for I2C connection.
*
* The difference in using an I2C display library instead of the
* official LiquidCrystal library is that void LiquidMenu::init()
* method needs to be called in setup() after the I2C display library
* is initialized. The other difference is that I2C needs to be defined
* as "true" in the "LiquidMenu_config.h" file.
*
* The circuit:
* https://raw.githubusercontent.com/VaSe7u/LiquidMenu/master/examples/I_I2C_menu/I2C_menu.png
* - PCF8574 module SCL to Arduino pin A5
* - PCF8574 module SDA to Arduino pin A4
* - PCF8574 module VCC to Arduino 5V
* - PCF8574 module GND to Arduino GND
*
* Created March 27, 2017
* by Vasil Kalchev
*
* https://github.com/VasilKalchev/LiquidMenu
*
*/
#include <Wire.h>
// The I2C LCD library
#include <LiquidCrystal_I2C.h>
// The menu wrapper library
#include <LiquidMenu.h>
// The I2C LCD object
LiquidCrystal_I2C lcd(0x27, 20, 4);
/*
* Variable 'analogReading' is later configured to
* be printed on the display. 'lastAnalogReading'
* is used to check if the variable has changed.
*/
const byte analogPin = A1;
unsigned short analogReading = 0;
unsigned short lastAnalogReading = 0;
/*
* Variables used for periodic execution of code. The first one is the period
* in milliseconds and the second one is the last time the code executed.
*/
unsigned int period_check = 1000;
unsigned long lastMs_check = 0;
unsigned int period_nextScreen = 5000;
unsigned long lastMs_nextScreen = 0;
/*
* LiquidLine objects represent a single line of text and/or variables
* on the display. The first two parameters are the column and row from
* which the line starts, the rest of the parameters are the text and/or
* variables that will be printed on the display. They can be up to four.
*/
// Here the line is set to column 1, row 0 and will print the passed
// string and the passed variable.
LiquidLine welcome_line1(1, 0, "LiquidMenu ", LIQUIDMENU_VERSION);
// Here the column is 3, the row is 1 and the string is "Hello Menu".
LiquidLine welcome_line2(1, 1, "Hello Menu I2C");
/*
* LiquidScreen objects represent a single screen. A screen is made of
* one or more LiquidLine objects. Up to four LiquidLine objects can
* be inserted from here, but more can be added later in setup() using
* welcome_screen.add_line(someLine_object);.
*/
// Here the LiquidLine objects are the two objects from above.
LiquidScreen welcome_screen(welcome_line1, welcome_line2);
// Here there is not only a text string but also a changing integer variable.
LiquidLine analogReading_line(0, 0, "Analog: ", analogReading);
LiquidScreen secondary_screen(analogReading_line);
/*
* The LiquidMenu object combines the LiquidScreen objects to form the
* menu. Here it is only instantiated and the screens are added later
* using menu.add_screen(someScreen_object);. This object is used to
* control the menu, for example: menu.next_screen(), menu.switch_focus()...
*/
LiquidMenu menu(lcd);
void setup() {
Serial.begin(250000);
pinMode(analogPin, INPUT);
// This is the I2C LCD object initialization.
lcd.init();
lcd.backlight();
// Menu initialization.
menu.init();
// This is the method used to add a screen object to the menu.
menu.add_screen(welcome_screen);
menu.add_screen(secondary_screen);
}
void loop() {
// Periodic reading of the analog pin.
if (millis() - lastMs_check > period_check) {
lastMs_check = millis();
analogReading = analogRead(analogPin);
/*
* Check if the analog value have changed
* and update the display if it has.
*/
if (analogReading != lastAnalogReading) {
lastAnalogReading = analogReading;
menu.update();
}
}
// Periodic switching to the next screen.
if (millis() - lastMs_nextScreen > period_nextScreen) {
lastMs_nextScreen = millis();
menu.next_screen();
}
}
In file included from /Users/gamaloacres/Documents/Arduino/libraries/LiquidMenu/src/LiquidMenu.h:47:0,
from /private/var/folders/0g/l_pzvy5s0xnc_tt974xf28s40000gn/T/.arduinoIDE-unsaved2024723-8543-pm7dwl.ce5w/sketch_aug23a/sketch_aug23a.ino:32:
/Users/gamaloacres/Documents/Arduino/libraries/LiquidMenu/src/LiquidMenu_config.h:46:1: error: stray '@' in program
@}
^
/Users/gamaloacres/Documents/Arduino/libraries/LiquidMenu/src/LiquidMenu_config.h:46:2: error: expected declaration before '}' token
@}
^