0.2.2 I2C_LCD

This commit is contained in:
Rob Tillaart 2024-08-26 17:51:51 +02:00
parent 72e9d0d510
commit 023af681a4
13 changed files with 421 additions and 21 deletions

View File

@ -6,12 +6,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.2] - 2024-08-26
- fix #11, add dice example
- add single pixel example
- update spectrum_column example
- fix special chars, LCD_SQROOT + LCD_SIGMA + LCD_SUM
- add custom chars +- and euro
- fix version in .cpp
## [0.2.1] - 2024-01-08
- add ESP8266 performance figures.
- update readme.md
- clean up examples
## [0.2.0] - 2024-01-02
- Fix #6, clean up code
- rewrote the bitsInOrder optimization

View File

@ -1,7 +1,7 @@
//
// FILE: I2C_LCD.cpp
// AUTHOR: Rob.Tillaart
// VERSION: 0.2.0
// VERSION: 0.2.2
// DATE: 2023-12-16
// PURPOSE: Arduino library for I2C_LCD
// URL: https://github.com/RobTillaart/I2C_LCD

View File

@ -2,13 +2,13 @@
//
// FILE: I2C_LCD.h
// AUTHOR: Rob.Tillaart
// VERSION: 0.2.1
// VERSION: 0.2.2
// DATE: 2023-12-16
// PURPOSE: Arduino library for I2C_LCD
// URL: https://github.com/RobTillaart/I2C_LCD
#define I2C_LCD_LIB_VERSION (F("0.2.1"))
#define I2C_LCD_LIB_VERSION (F("0.2.2"))
#include "Arduino.h"

View File

@ -212,6 +212,28 @@ uint8_t heart[] = {
B00000
};
uint8_t euro[] = {
B00000,
B00111,
B01000,
B11111,
B01000,
B11111,
B01000,
B00111
};
uint8_t plusminus[] = {
B00000,
B00100,
B00100,
B11111,
B00100,
B00100,
B11111,
B00000
};
// -- END OF FILE --

View File

@ -15,13 +15,14 @@ const char LCD_ALPHA = 0xE0;
const char LCD_BETA = 0xE2;
const char LCD_EPSILON = 0xE3;
const char LCD_MU = 0xE4;
const char LCD_RHO = 0xE5;
const char LCD_SQROOT = 0xE7;
const char LCD_SIGMA = 0xE5;
const char LCD_RHO = 0xE6;
const char LCD_SQROOT = 0xE8;
const char LCD_THETA = 0xF2;
const char LCD_INFINITY = 0xF3;
const char LCD_OHM = 0xF4;
const char LCD_SIGMA = 0xF6;
const char LCD_SUM = 0xF6;
const char LCD_PI = 0xF7;
const char LCD_XAVG = 0xF8;

View File

@ -0,0 +1,124 @@
// FILE: I2C_LCD_custom_chars.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo I2C_LCD library
// URL: https://github.com/RobTillaart/I2C_LCD
#include "I2C_LCD.h"
#include "I2C_LCD_custom_chars.h"
I2C_LCD lcd(39);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println(__FILE__);
Serial.print("I2C_LCD_LIB_VERSION: ");
Serial.println(I2C_LCD_LIB_VERSION);
Serial.println();
Wire.begin();
Wire.setClock(100000);
lcd.begin(20, 4);
Serial.print("Connected: ");
Serial.println(lcd.isConnected());
lcd.display();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" custom characters");
}
void loop()
{
lcd.createChar(0, paragraph);
lcd.setCursor(0, 2);
lcd.special(0);
lcd.createChar(1, copyRight);
lcd.setCursor(1, 2);
lcd.special(1);
lcd.createChar(2, lessThan);
lcd.setCursor(2, 2);
lcd.special(2);
lcd.createChar(3, moreThan);
lcd.setCursor(3, 2);
lcd.special(3);
lcd.createChar(4, notEqual);
lcd.setCursor(4, 2);
lcd.special(4);
delay(2000);
lcd.createChar(0, doubleUP);
lcd.setCursor(0, 2);
lcd.special(0);
lcd.createChar(1, doubleDOWN);
lcd.setCursor(1, 2);
lcd.special(1);
lcd.createChar(2, openUP);
lcd.setCursor(2, 2);
lcd.special(2);
lcd.createChar(3, openDown);
lcd.setCursor(3, 2);
lcd.special(3);
delay(2000);
lcd.createChar(0, bracketRight);
lcd.setCursor(0, 2);
lcd.special(0);
lcd.createChar(1, bracketLeft);
lcd.setCursor(1, 2);
lcd.special(1);
lcd.createChar(2, singleLine);
lcd.setCursor(2, 2);
lcd.special(2);
lcd.createChar(3, doubleLine);
lcd.setCursor(3, 2);
lcd.special(3);
delay(2000);
lcd.createChar(0, OnOff);
lcd.setCursor(0, 2);
lcd.special(0);
lcd.createChar(1, smiley);
lcd.setCursor(1, 2);
lcd.special(1);
lcd.createChar(2, heart);
lcd.setCursor(2, 2);
lcd.special(2);
lcd.createChar(3, euro);
lcd.setCursor(3, 2);
lcd.special(3);
lcd.createChar(4, plusminus);
lcd.setCursor(4, 2);
lcd.special(4);
delay(2000);
}
// -- END OF FILE --

View File

@ -0,0 +1,78 @@
// FILE: I2C_LCD_custom_chars_dice.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo I2C_LCD library
// URL: https://github.com/RobTillaart/I2C_LCD
#include "I2C_LCD.h"
uint8_t dice_chars[6][8]
{
{ 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }, // 1
{ 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 }, // 2
{ 0x00, 0x10, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00 }, // 3
{ 0x00, 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00 }, // 4
{ 0x00, 0x11, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00 }, // 5
{ 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x00 } // 6
};
I2C_LCD lcd(39);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println(__FILE__);
Serial.print("I2C_LCD_LIB_VERSION: ");
Serial.println(I2C_LCD_LIB_VERSION);
Serial.println();
Wire.begin();
Wire.setClock(100000);
lcd.begin(20, 4);
Serial.print("Connected: ");
Serial.println(lcd.isConnected());
lcd.display();
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Dice characters");
for (int i = 0; i < 6; i++)
{
lcd.createChar(i, dice_chars[i]);
delay(5);
}
lcd.setCursor(4, 1);
for (int i = 0; i < 6; i++)
{
lcd.special(i);
lcd.print(" ");
}
lcd.setCursor(0, 3);
lcd.print("done...");
}
void loop()
{
for (int p = 0; p < 19; p++)
{
lcd.setCursor(p, 2);
lcd.special(random(6));
delay(250);
lcd.setCursor(p, 2);
lcd.print(' ');
}
lcd.setCursor(19, 2);
lcd.special(random(6));
delay(2000);
}
// -- END OF FILE --

View File

@ -0,0 +1,88 @@
// FILE: I2C_LCD_custom_chars_pixel.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo I2C_LCD library - Single pixel walk with ASDF keys
// continuous creation of custom chars.
// URL: https://github.com/RobTillaart/I2C_LCD
#include "I2C_LCD.h"
uint8_t pixel_char[8]
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
int x = 0, y = 0;
I2C_LCD lcd(39);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.println(__FILE__);
Serial.print("I2C_LCD_LIB_VERSION: ");
Serial.println(I2C_LCD_LIB_VERSION);
Serial.println();
Wire.begin();
Wire.setClock(100000);
lcd.begin(20, 4);
Serial.print("Connected: ");
Serial.println(lcd.isConnected());
lcd.display();
lcd.clear();
}
void loop()
{
if (Serial.available())
{
int c = Serial.read();
if (c == 'a') x = (x + 99) % 100;
if (c == 's') x = (x + 1) % 100;
if (c == 'd') y = (y + 1) % 32;
if (c == 'f') y = (y + 31) % 32;
setXY(x, y);
}
// x = random(100);
// y = random(32);
// setXY(x, y);
// delay(1000);
}
void setXY(int x, int y)
{
static int a = 0;
static int b = 0;
static int c = 0;
static int d = 0;
// clear, not optimized.
for (int i = 0; i < 8; i++) pixel_char[i] = 0;
lcd.setCursor(a, b);
lcd.print(' ');
// calculate new coordinates of char
a = x / 5;
b = y / 8;
// calculate pixel within char
c = x - a * 5;
d = y - b * 8;
pixel_char[d] = 1 << (4 - c);
// store
lcd.createChar(0, pixel_char);
// and display.
lcd.setCursor(a, b);
lcd.special(0);
}
// -- END OF FILE --

View File

@ -20,16 +20,43 @@
I2C_LCD lcd(39);
// note the full filled block => lcd.special(255);
uint8_t colblock[7][8] =
// WIDE columns (5 pixel wire)
//uint8_t colblock[8][8] =
//{
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F },
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F },
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F },
// { 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F },
// { 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F },
// { 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F },
// { 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F },
// { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F }
//};
// SMALL columns (3 pixel wire)
//uint8_t colblock[8][8] =
//{
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E },
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E },
// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x0E },
// { 0x00, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x0E, 0x0E },
// { 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E },
// { 0x00, 0x00, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E },
// { 0x00, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E },
// { 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E }
//};
// LINE columns (1 pixel wire)
uint8_t colblock[8][8] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F },
{ 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F },
{ 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F },
{ 0x00, 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F },
{ 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F }
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04 },
{ 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04 },
{ 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04 },
{ 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 },
{ 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 },
{ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04 }
};
@ -73,7 +100,7 @@ void loop()
{
spectrumColumn(i, random(32));
}
delay(1000);
delay(500); // adjust the speed
}
@ -87,7 +114,7 @@ void spectrumColumn(uint8_t col, int value)
{
lcd.setCursor(col, 3 - row);
if (value <= 0) lcd.print(' ');
else if (value >= 8) lcd.special(255);
else if (value >= 8) lcd.special(7);
else lcd.special(value - 1);
value -= 8;
}

View File

@ -0,0 +1,49 @@
IDE: 1.8.19
Board: ESP32 240 MHz
I2C_LCD\examples\I2C_LCD_performance\I2C_LCD_performance.ino
I2C_LCD_LIB_VERSION: 0.2.1
performance
speed: 100000
print time (us): 4265
clear time (us): 2000
performance
speed: 200000
print time (us): 2420
clear time (us): 2000
performance
speed: 300000
print time (us): 1807
clear time (us): 2000
performance
speed: 400000
print time (us): 1497
clear time (us): 2000
performance
speed: 500000
print time (us): 1322
clear time (us): 2000
performance
speed: 600000
print time (us): 1184
clear time (us): 2000
performance
speed: 700000
print time (us): 1108
clear time (us): 2000
performance
speed: 800000
print time (us): 1037
clear time (us): 2000

View File

@ -37,16 +37,20 @@ void setup()
lcd.print(LCD_BETA);
lcd.print(LCD_EPSILON);
lcd.print(LCD_MU);
lcd.print(LCD_SIGMA);
lcd.print(LCD_RHO);
lcd.print(LCD_SQROOT);
lcd.print(LCD_THETA);
lcd.print(LCD_INFINITY);
lcd.print(LCD_OHM);
lcd.print(LCD_SIGMA);
lcd.print(LCD_SUM);
lcd.print(LCD_PI);
lcd.print(LCD_XAVG);
lcd.print(LCD_DEGREE);
lcd.print(LCD_DIVIDE);
lcd.setCursor(0, 3);
lcd.print("done...");
}

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/I2C_LCD.git"
},
"version": "0.2.1",
"version": "0.2.2",
"license": "MIT",
"frameworks": "*",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=I2C_LCD
version=0.2.1
version=0.2.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C_LCD.