Skip to content

Commit

Permalink
Select custom "LiquidCrystal" library.
Browse files Browse the repository at this point in the history
  • Loading branch information
VasilKalchev committed Apr 6, 2019
1 parent 8bdfd97 commit 914570d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 26 deletions.
2 changes: 1 addition & 1 deletion examples/I_I2C_menu/I_I2C_menu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void setup() {
lcd.init();
lcd.backlight();

// This methid needs to be called when using an I2C display library.
// Menu initialization.
menu.init();

// This is the method used to add a screen object to the menu.
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LiquidMenu
version=1.4.1
version=1.5.0
author=Vasil Kalchev <vase7u@gmail.com>
maintainer=Vasil Kalchev <vase7u@gmail.com>
sentence=Menu creation Arduino library for LCDs, extends LiquidCrystal.
Expand Down
20 changes: 15 additions & 5 deletions src/LiquidMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ const uint8_t DIVISION_LINE_LENGTH = 40; ///< Sets the length of the division li
LiquidMenu::LiquidMenu(DisplayClass &liquidCrystal, uint8_t startingScreen)
: _p_liquidCrystal(&liquidCrystal), _screenCount(0),
_currentScreen(startingScreen - 1) {
#ifndef I2C
_p_liquidCrystal->createChar(15, glyph::rightFocus);
_p_liquidCrystal->createChar(14, glyph::leftFocus);
_p_liquidCrystal->createChar(13, glyph::customFocus);
#endif
}

LiquidMenu::LiquidMenu(DisplayClass &liquidCrystal, LiquidScreen &liquidScreen,
Expand Down Expand Up @@ -229,6 +224,21 @@ void LiquidMenu::update() const {
}

void LiquidMenu::softUpdate() const {
/* TEMPORARY FIX!
* Calls methods on the `DisplayClass` object only after it is
* initialized. This makes it compatible with different
* "LiquidCrystal" libraries and doesn't break the current API.
* Will be removed for version 2.0.0 when `LiquidMenu::init()` will
* become mandatory.
*/
static bool firstRun = true;
if (firstRun) {
firstRun = false;
_p_liquidCrystal->createChar(15, glyph::rightFocus);
_p_liquidCrystal->createChar(14, glyph::leftFocus);
_p_liquidCrystal->createChar(13, glyph::customFocus);
}

DEBUGLN(F("Updating the LCD"));
for (uint8_t b = 0; b < DIVISION_LINE_LENGTH; b++) {
DEBUG(F("-"));
Expand Down
26 changes: 10 additions & 16 deletions src/LiquidMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Include file for LiquidMenu library.
@author Vasil Kalchev
@date 2016
@version 1.4.0
@version 1.5.0
@copyright The MIT License
@todo: Change/Remove variables/screens/menus maybe
Expand All @@ -49,26 +49,20 @@ Include file for LiquidMenu library.
#include "LiquidMenu_config.h"
#include "LiquidMenu_debug.h"

#if I2C
# if LCD_RUS
# include <LCD_1602_RUS.h>
# define DisplayClass LCD_1602_RUS
# pragma message ("LiquidMenu: Configured for I2C/LCD_1602_RUS. Edit 'LiquidMenu_config.h' file to change it.")
# else
# include <LiquidCrystal_I2C.h>
# define DisplayClass LiquidCrystal_I2C
# pragma message ("LiquidMenu: Configured for I2C. Edit 'LiquidMenu_config.h' file to change it.")
# endif

#if LIQUIDMENU_LIBRARY == LiquidCrystal_LIBRARY
# pragma message ("LiquidMenu: Selected 'LiquidCrystal' (parallel) library. Edit 'LiquidMenu_config.h' file to change it.")
#elif LIQUIDMENU_LIBRARY == LiquidCrystal_I2C_LIBRARY
# pragma message ("LiquidMenu: Selected 'LiquidCrystal_I2C' (I2C) library. Edit 'LiquidMenu_config.h' file to change it.")
#else
# include <LiquidCrystal.h>
# define DisplayClass LiquidCrystal
# pragma message ("LiquidMenu: Configured for Parallel. Edit 'LiquidMenu_config.h' file to change it.")
# pragma message ("LiquidMenu: Selected custom library. Edit 'LiquidMenu_config.h' file to change it.")
#endif

#if LIQUIDMENU_DEBUG
# warning "LiquidMenu: Debugging messages are enabled."
#endif


typedef bool (*boolFnPtr)();
typedef int8_t (*int8tFnPtr)();
typedef uint8_t (*uint8tFnPtr)();
Expand All @@ -82,7 +76,7 @@ typedef char (*charFnPtr)();
typedef char * (*charPtrFnPtr)();
typedef const char * (*constcharPtrFnPtr)();

const char LIQUIDMENU_VERSION[] = "1.4"; ///< The version of the library.
const char LIQUIDMENU_VERSION[] = "1.5"; ///< The version of the library.

/// Data type enum.
/**
Expand All @@ -92,7 +86,7 @@ enum class DataType : uint8_t {
NOT_USED = 0,
BOOL = 1, BOOLEAN = 1,
INT8_T = 8,
UINT8_T = 9, BYTE = 9,
UINT8_T = 9,
INT16_T = 16,
UINT16_T = 17,
INT32_T = 32,
Expand Down
27 changes: 24 additions & 3 deletions src/LiquidMenu_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,30 @@ used in the library, also configures the debugging messages.

#pragma once

/// Switches the communication method to I2C
#define I2C false ///< @note Default: false
#define LCD_RUS false ///< @note Default: false
/// These defines are used for determining the compiler messages:
#define LiquidCrystal_LIBRARY (1)
#define LiquidCrystal_I2C_LIBRARY (2)


/// Select a "LiquidCrystal" library:
/// ---------------------------------

/// Arduino's parallel "LiquidCrystal" library:
#define LIQUIDMENU_LIBRARY LiquidCrystal_LIBRARY
#include <LiquidCrystal.h>
#define DisplayClass LiquidCrystal

/// I2C library (https://github.com/johnrickman/LiquidCrystal_I2C):
// #define LIQUIDMENU_LIBRARY LiquidCrystal_I2C_LIBRARY
// #include <LiquidCrystal_I2C.h>
// #define DisplayClass LiquidCrystal_I2C

/// Some other library:
// #include <LIBRARY_HEADER.h>
// #define DisplayClass LIBRARY_CONSTRUCTOR

/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


/// Configures the number of available variables per line.
const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5
Expand Down

0 comments on commit 914570d

Please sign in to comment.