This example demonstrates how to create a custom character (glyph) and put it inside a LiquidLine object.
#include <LiquidCrystal.h>
const byte LCD_RS = 12;
const byte LCD_E = 11;
const byte LCD_D4 = 5;
const byte LCD_D5 = 4;
const byte LCD_D6 = 3;
const byte LCD_D7 = 2;
LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
namespace glyphs {
uint8_t thermometer[8] = {
0b00100,
0b01010,
0b01010,
0b01010,
0b10001,
0b11111,
0b01110,
0b00000
};
uint8_t celsiusSymbol[8] = {
0b00011,
0b00011,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
uint8_t fan1[8] = {
0b00000,
0b11001,
0b01011,
0b00100,
0b11010,
0b10011,
0b00000,
0b00000
};
uint8_t fan2[8] = {
0b00000,
0b10011,
0b11010,
0b00100,
0b01011,
0b11001,
0b00000,
0b00000
};
}
byte fan_glyphIndex = 0;
byte thermometer_glyphIndex = 2;
byte celsiusSymbol_glyphIndex = 3;
LiquidLine welcome_line2(0, 1,
"PROGMEM example");
LiquidLine line3(13, 1, celsiusSymbol_glyphIndex,
"C");
void setup() {
Serial.begin(250000);
lcd.createChar(fan_glyphIndex, glyphs::fan1);
lcd.createChar(fan_glyphIndex + 1, glyphs::fan2);
lcd.createChar(thermometer_glyphIndex, glyphs::thermometer);
lcd.createChar(celsiusSymbol_glyphIndex, glyphs::celsiusSymbol);
line1.set_asGlyph(1);
line2.set_asGlyph(1);
line3.set_asGlyph(1);
lcd.begin(16, 2);
}
void loop() {
static unsigned long lastMs_fanAnimation = 0;
static unsigned int period_fanAnimation = 500;
if (millis() - lastMs_fanAnimation > period_fanAnimation) {
lastMs_fanAnimation = millis();
static bool currentAnimation_fan = 0;
if (currentAnimation_fan == 0) {
currentAnimation_fan = 1;
fan_glyphIndex = 1;
} else {
currentAnimation_fan = 0;
fan_glyphIndex = 0;
}
menu.softUpdate();
}
static unsigned long lastMs_nextScreen = 0;
static unsigned int period_nextScreen = 4000;
if (millis() - lastMs_nextScreen > period_nextScreen) {
lastMs_nextScreen = millis();
menu.next_screen();
}
}