forked from Akcelerometry_drgania_WMT/PI_mikrokontroler
Wgranie zmian do repozytorium
This commit is contained in:
67
lib/LiquidCrystal_I2C/examples/Autoscroll/Autoscroll.ino
Normal file
67
lib/LiquidCrystal_I2C/examples/Autoscroll/Autoscroll.ino
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
NAME:
|
||||
Demonstration of Autoscroll function
|
||||
|
||||
DESCRIPTION:
|
||||
This sketch demonstrates the use of the autoscroll() and noAutoscroll()
|
||||
functions to make new text scroll or not.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 20.03.2016
|
||||
|
||||
CREDIT:
|
||||
The example taken and rewritten for I2C from official Arduino standard library
|
||||
(https://github.com/arduino/Arduino/tree/master/libraries/LiquidCrystal)
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry and library initialization
|
||||
const byte lcdAddr = 0x27; // Address of I2C backpack
|
||||
const byte lcdCols = 16; // Number of character in a row
|
||||
const byte lcdRows = 2; // Number of lines
|
||||
//const byte lcdAddr = 0x3F; // Address of I2C backpack
|
||||
//const byte lcdCols = 20; // Number of character in a row
|
||||
//const byte lcdRows = 4; // Number of lines
|
||||
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Demo parameters
|
||||
const byte lcdScrollRow = 0; // Number of a demo row counting from 0
|
||||
const unsigned int digitDelay = 500; // Miliseconds before displaying next digit
|
||||
|
||||
// Function for displaying demo digits
|
||||
void printDigits() {
|
||||
for (byte thisChar = 0; thisChar < 10; thisChar++) {
|
||||
lcd.print(thisChar);
|
||||
delay(digitDelay);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
lcd.setCursor(0, lcdScrollRow);
|
||||
printDigits();
|
||||
|
||||
// Set the cursor to the last column of the demo row and turn on autoscroll
|
||||
lcd.setCursor(lcdCols, lcdScrollRow);
|
||||
lcd.autoscroll();
|
||||
printDigits();
|
||||
lcd.noAutoscroll();
|
||||
lcd.clear();
|
||||
}
|
||||
|
||||
162
lib/LiquidCrystal_I2C/examples/CompleteTest/CompleteTest.ino
Normal file
162
lib/LiquidCrystal_I2C/examples/CompleteTest/CompleteTest.ino
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
NAME:
|
||||
Demo sketch for complete printing test of LCD
|
||||
|
||||
DESCRIPTION:
|
||||
The sketch demonstrates capabalities of the LCD by displaying several
|
||||
test.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDITS:
|
||||
Inspired by the example LCD_Test in the library LCDi2cW
|
||||
from "4-2-2009 dale@wentztech.com".
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.1.0
|
||||
Updated: 04.03.2015
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry for LCD 1602
|
||||
const byte lcdAddr = 0x27; // Typical address of I2C backpack for 1602
|
||||
const byte lcdCols = 16; // Number of characters in a row of display
|
||||
const byte lcdRows = 2; // Number of lines of display
|
||||
|
||||
// LCD address and geometry for LCD 2004
|
||||
//const byte lcdAddr = 0x3F; // Typical address of I2C backpack for 2004
|
||||
//const byte lcdCols = 20; // Number of characters in a row of display
|
||||
//const byte lcdRows = 4; // Number of lines of display
|
||||
|
||||
// Initialize library and setting LCD geometry
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Demo constants
|
||||
const int testDelay = 500; // Delay between tests in ms
|
||||
const int demoDelay = 3000; // Delay between demos in ms
|
||||
const byte demoNumMin = 1; // Range of demo tests
|
||||
const byte demoNumMax = 255;
|
||||
const byte charNumMin = 0; // Code of first displayed character
|
||||
const byte charNumMax = 255; // Code of last displayed character
|
||||
|
||||
// Demo variables
|
||||
byte col, row;
|
||||
unsigned int demoNum, charNum;
|
||||
char buffer[lcdCols + 1];
|
||||
|
||||
void setup() {
|
||||
// Initialize LCD
|
||||
lcd.init();
|
||||
lcd.backlight(); // Switch on the backlight LED, if any or wired
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
demoNum = max(demoNumMin, 1);
|
||||
while(demoNum >= demoNumMin && demoNum <= demoNumMax) {
|
||||
lcd.clear();
|
||||
lcd.cursor_off();
|
||||
lcd.blink_off();
|
||||
sprintf(buffer, "%u.", demoNum);
|
||||
lcd.print(buffer);
|
||||
|
||||
switch (demoNum) {
|
||||
case 1:
|
||||
lcd.print(F("Hello World!"));
|
||||
break;
|
||||
case 2:
|
||||
lcd.print(F("Dash Cursor"));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.cursor_on();
|
||||
break;
|
||||
case 3:
|
||||
lcd.print (F("Block Cursor"));
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.blink_on();
|
||||
break;
|
||||
case 4:
|
||||
lcd.print(F("No Cursor"));
|
||||
lcd.setCursor(0, 1);
|
||||
break;
|
||||
case 5:
|
||||
lcd.print(F("Characters"));
|
||||
lcd.cursor_on();
|
||||
charNum = charNumMin;
|
||||
while(charNum <= charNumMax) {
|
||||
row = 1;
|
||||
do {
|
||||
lcd.clear(row);
|
||||
col = 0;
|
||||
lcd.setCursor(col, row);
|
||||
do {
|
||||
lcd.write(char(charNum++));
|
||||
delay(testDelay);
|
||||
} while(++col < lcdCols && charNum <= charNumMax);
|
||||
} while(++row < lcdRows && charNum <= charNumMax);
|
||||
}
|
||||
lcd.cursor_off();
|
||||
break;
|
||||
case 6:
|
||||
for (byte row=0; row < lcdRows; row++) {
|
||||
lcd.print(F("Line "));
|
||||
lcd.print(row);
|
||||
delay(testDelay);
|
||||
lcd.setCursor(0, row + 1);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
lcd.print(F("Count to 255"));
|
||||
for (unsigned int i = 0; i < 256; i++) {
|
||||
lcd.clear(1);
|
||||
sprintf(buffer, "%03u 0x%02X %c", i, i, i);
|
||||
lcd.print(buffer);
|
||||
if (lcdCols >= 20) {
|
||||
lcd.print(" B");
|
||||
lcd.print(i, BIN);
|
||||
}
|
||||
delay(testDelay);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
lcd.print(F("Positions"));
|
||||
lcd.setCursor(0, 1);
|
||||
for (byte col = 0; col < lcdCols; col++) {
|
||||
lcd.write(col%10 + char('0'));
|
||||
delay(testDelay);
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
lcd.print(F("Clearing"));
|
||||
for (byte row = 1; row < lcdRows; row++) {
|
||||
// Fill row
|
||||
lcd.setCursor(0, row);
|
||||
for (byte col = 0; col < lcdCols; col++) {
|
||||
lcd.write(col%10 + char('0'));
|
||||
}
|
||||
delay(testDelay);
|
||||
// Clear row
|
||||
for (byte i = 0; i < lcdCols / 2; i++) {
|
||||
lcd.setCursor(lcdCols / 2 - i - 1, row);
|
||||
lcd.write(' ');
|
||||
lcd.setCursor(lcdCols / 2 + i, row);
|
||||
lcd.write(' ');
|
||||
delay(testDelay);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
demoNum = 0;
|
||||
continue;
|
||||
}
|
||||
delay(demoDelay);
|
||||
demoNum++;
|
||||
}
|
||||
}
|
||||
60
lib/LiquidCrystal_I2C/examples/CustomChars/CustomChars.ino
Normal file
60
lib/LiquidCrystal_I2C/examples/CustomChars/CustomChars.ino
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
|
||||
uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
|
||||
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
|
||||
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
|
||||
uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
|
||||
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
|
||||
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
|
||||
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.init(); // initialize the lcd
|
||||
lcd.backlight();
|
||||
|
||||
lcd.createChar(0, bell);
|
||||
lcd.createChar(1, note);
|
||||
lcd.createChar(2, clock);
|
||||
lcd.createChar(3, heart);
|
||||
lcd.createChar(4, duck);
|
||||
lcd.createChar(5, check);
|
||||
lcd.createChar(6, cross);
|
||||
lcd.createChar(7, retarrow);
|
||||
lcd.home();
|
||||
|
||||
lcd.print("Hello world...");
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print(" i ");
|
||||
lcd.write(3);
|
||||
lcd.print(" arduinos!");
|
||||
delay(5000);
|
||||
displayKeyCodes();
|
||||
|
||||
}
|
||||
|
||||
// display all keycodes
|
||||
void displayKeyCodes(void) {
|
||||
uint8_t i = 0;
|
||||
while (1) {
|
||||
lcd.clear();
|
||||
lcd.print("Codes 0x"); lcd.print(i, HEX);
|
||||
lcd.print("-0x"); lcd.print(i+16, HEX);
|
||||
lcd.setCursor(0, 1);
|
||||
for (int j=0; j<16; j++) {
|
||||
lcd.write(i+j);
|
||||
}
|
||||
i+=16;
|
||||
|
||||
delay(4000);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
}
|
||||
17
lib/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.ino
Normal file
17
lib/LiquidCrystal_I2C/examples/HelloWorld/HelloWorld.ino
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 20 chars and 4 line display
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.init(); // initialize the lcd
|
||||
|
||||
// Print a message to the LCD.
|
||||
lcd.backlight();
|
||||
lcd.print("Hello, world!");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
95
lib/LiquidCrystal_I2C/examples/Histogram/Histogram.ino
Normal file
95
lib/LiquidCrystal_I2C/examples/Histogram/Histogram.ino
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
NAME:
|
||||
Demo sketch for Histogram composed of Vertical Bar Graphs
|
||||
|
||||
DESCRIPTION:
|
||||
The sketch demonstrates usage of LiquidCrystal_I2C library version 2.x
|
||||
for programing histograms with help of vertical graphs.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* All graph values are displayed in number of vertical pixels.
|
||||
* The sketch demostrates a histogram
|
||||
- in second row with one row height
|
||||
- in full display are with
|
||||
with values changed randomly.
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 01.03.2015
|
||||
*/
|
||||
|
||||
/* Needed libraries
|
||||
Dispite the LCD library includes Wire library, the ArduinoIDE does not
|
||||
includes nested libraries, if they are not in the same folder.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry for LCD 1602
|
||||
const byte lcdAddr = 0x27; // Typical address of I2C backpack for 1602
|
||||
const byte lcdCols = 16; // Number of characters in a row of display
|
||||
const byte lcdRows = 2; // Number of lines of display
|
||||
|
||||
// LCD address and geometry for LCD 2004
|
||||
//const byte lcdAddr = 0x3F; // Typical address of I2C backpack for 2004
|
||||
//const byte lcdCols = 20; // Number of characters in a row of display
|
||||
//const byte lcdRows = 4; // Number of lines of display
|
||||
|
||||
// Initialize library and setting LCD geometry
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Demo constants
|
||||
const int graphDelay = 100; // Delay between histograms
|
||||
const int demoTime = 5000; // Showing time of a demo
|
||||
|
||||
// Demo variables
|
||||
byte graphPixelsCur, graphPixelsMax;
|
||||
unsigned long demoStart;
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize LCD
|
||||
lcd.init();
|
||||
lcd.backlight(); // Switch on the backlight LED, if any or wired
|
||||
|
||||
/* Initialize graph
|
||||
* Macro is defined in LiquidCrystal_I2C library.
|
||||
* Function uses all 8 custom character positions (0-7)
|
||||
and creates custom characters for displaying vertical bar.
|
||||
*/
|
||||
lcd.init_bargraph(LCDI2C_VERTICAL_BAR_GRAPH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Demo 1: One row histogram
|
||||
lcd.clear();
|
||||
lcd.print("Histogram");
|
||||
graphPixelsMax = LCD_CHARACTER_VERTICAL_DOTS;
|
||||
demoStart = millis();
|
||||
while(millis() - demoStart < demoTime) {
|
||||
for(byte graphCol = 0; graphCol < lcdCols; graphCol++) {
|
||||
graphPixelsCur = random(0, graphPixelsMax);
|
||||
lcd.draw_vertical_graph(1, graphCol, 1, graphPixelsCur);
|
||||
}
|
||||
delay(graphDelay);
|
||||
}
|
||||
// Demo 2: Full display histogram
|
||||
lcd.clear();
|
||||
graphPixelsMax = lcdRows * LCD_CHARACTER_VERTICAL_DOTS;
|
||||
demoStart = millis();
|
||||
while(millis() - demoStart < demoTime) {
|
||||
for(byte graphCol = 0; graphCol < lcdCols; graphCol++) {
|
||||
graphPixelsCur = random(0, graphPixelsMax);
|
||||
lcd.draw_vertical_graph(lcdRows - 1, graphCol, lcdRows, graphPixelsCur);
|
||||
}
|
||||
delay(graphDelay);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
NAME:
|
||||
Demo sketch for Horizontal Bar Graph
|
||||
|
||||
DESCRIPTION:
|
||||
The sketch demonstrates usage of LiquidCrystal_I2C library version 2.x
|
||||
for programing horizontal graphs, which mimics progress bar.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* All graph values are displayed in number of horizontal pixels.
|
||||
* The sketch demostrates
|
||||
- 1. Continues full row progress bar
|
||||
- 2. Continues half row central progress bar
|
||||
- 3. Random full row progress bar
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 01.03.2015
|
||||
*/
|
||||
|
||||
/* Needed libraries
|
||||
Dispite the LCD library includes Wire library, the ArduinoIDE does not
|
||||
includes nested libraries, if they are not in the same folder.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry for LCD 1602
|
||||
const byte lcdAddr = 0x27; // Typical address of I2C backpack for 1602
|
||||
const byte lcdCols = 16; // Number of characters in a row of display
|
||||
const byte lcdRows = 2; // Number of lines of display
|
||||
|
||||
// LCD address and geometry for LCD 2004
|
||||
//const byte lcdAddr = 0x3F; // Typical address of I2C backpack for 2004
|
||||
//const byte lcdCols = 20; // Number of characters in a row of display
|
||||
//const byte lcdRows = 4; // Number of lines of display
|
||||
|
||||
// Initialize library and setting LCD geometry
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Cursor coordinates and character row pattern for progress bar
|
||||
const byte graphRow = 1; // In this row the graph is displayed
|
||||
const byte labelRow = 0; // In this row the label is displayed
|
||||
const byte valueCol = lcdCols - 2; // In this column starts graph value
|
||||
const int graphDelay = 100; // Delay between graph values in ms
|
||||
const int demoDelay = 3000; // Delay between demos in ms
|
||||
|
||||
// Demo parameters
|
||||
const char graphType[] = " Bar";
|
||||
const char* graphLbls[] = {"Full", "Half", "Random"};
|
||||
const byte graphLens[] = {lcdCols, lcdCols / 2, lcdCols};
|
||||
const byte graphCols[] = {0, lcdCols / 4, 0};
|
||||
|
||||
// Demo variables
|
||||
byte graphPixelsCur, graphPixelsMax;
|
||||
|
||||
// Function for displaying graph label
|
||||
void printLabel(byte demo) {
|
||||
// Create label
|
||||
char labelText[valueCol];
|
||||
sprintf(labelText, "%1u.%s%s", demo + 1, graphLbls[demo], graphType);
|
||||
// Display label on clear display
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, labelRow);
|
||||
lcd.print(labelText);
|
||||
|
||||
}
|
||||
|
||||
// Function for displaying graph value
|
||||
void printValue(byte value) {
|
||||
lcd.clear(labelRow, valueCol); // Clear value space
|
||||
lcd.setCursor(valueCol, labelRow);
|
||||
lcd.print(value);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize LCD
|
||||
lcd.init();
|
||||
lcd.backlight(); // Switch on the backlight LED, if any or wired
|
||||
|
||||
/* Initialize graph
|
||||
* Macro is defined in LiquidCrystal_I2C library.
|
||||
* Function uses the first 5 custom character positions (0-4)
|
||||
and creates custom characters for displaying progress bar.
|
||||
*/
|
||||
lcd.init_bargraph(LCDI2C_HORIZONTAL_BAR_GRAPH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for(byte demoNum = 0; demoNum < sizeof(graphLens)/sizeof(graphLens[0]); demoNum++) {
|
||||
graphPixelsMax = graphLens[demoNum] * LCD_CHARACTER_HORIZONTAL_DOTS;
|
||||
printLabel(demoNum);
|
||||
switch (demoNum) {
|
||||
case 0:
|
||||
case 1:
|
||||
// Demo 1: Graph in full row with sequence values
|
||||
// Demo 2: Graph in half row with sequence values
|
||||
// Descending graph values
|
||||
for (byte i = graphPixelsMax; i > 0; i--) {
|
||||
graphPixelsCur = i - 1;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
// Ascending graph values
|
||||
for (byte i = 0; i < graphPixelsMax; i++) {
|
||||
graphPixelsCur = i;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Demo 3: Graph in full row with random values
|
||||
for (byte i = 0; i < graphPixelsMax; i++) {
|
||||
graphPixelsCur = random(0, graphPixelsMax);
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
break;
|
||||
}
|
||||
delay(demoDelay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
NAME:
|
||||
Demo sketch for Horizontal Line Graph
|
||||
|
||||
DESCRIPTION:
|
||||
The sketch demonstrates usage of LiquidCrystal_I2C library version 2.x
|
||||
for programing horizontal graphs, which mimics scale graphs.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* All graph values are displayed in number of horizontal pixels.
|
||||
* The sketch demostrates
|
||||
- 1. Continues full row scale graph
|
||||
- 2. Continues half row central scale graph
|
||||
- 3. Random full row scale graph
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 01.03.2015
|
||||
*/
|
||||
|
||||
/* Needed libraries
|
||||
Dispite the LCD library includes Wire library, the ArduinoIDE does not
|
||||
includes nested libraries, if they are not in the same folder.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry for LCD 1602
|
||||
const byte lcdAddr = 0x27; // Typical address of I2C backpack for 1602
|
||||
const byte lcdCols = 16; // Number of characters in a row of display
|
||||
const byte lcdRows = 2; // Number of lines of display
|
||||
|
||||
// LCD address and geometry for LCD 2004
|
||||
//const byte lcdAddr = 0x3F; // Typical address of I2C backpack for 2004
|
||||
//const byte lcdCols = 20; // Number of characters in a row of display
|
||||
//const byte lcdRows = 4; // Number of lines of display
|
||||
|
||||
// Initialize library and setting LCD geometry
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Cursor coordinates and character row pattern for progress bar
|
||||
const byte graphRow = 1; // In this row the graph is displayed
|
||||
const byte labelRow = 0; // In this row the label is displayed
|
||||
const byte valueCol = lcdCols - 2; // In this column starts graph value
|
||||
const int graphDelay = 200; // Delay between graph values in ms
|
||||
const int demoDelay = 3000; // Delay between demos in ms
|
||||
|
||||
// Demo parameters
|
||||
const char graphType[] = "Scale";
|
||||
const char* graphLbls[] = {"Full ", "Half ", "Random"};
|
||||
const byte graphLens[] = {lcdCols, lcdCols / 2, lcdCols};
|
||||
const byte graphCols[] = {0, lcdCols / 4, 0};
|
||||
|
||||
// Demo variables
|
||||
byte graphPixelsCur, graphPixelsMax;
|
||||
|
||||
// Function for displaying graph label
|
||||
void printLabel(byte demo) {
|
||||
// Create label
|
||||
char labelText[valueCol];
|
||||
sprintf(labelText, "%1u.%s%s", demo + 1, graphLbls[demo], graphType);
|
||||
// Display label on clear display
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, labelRow);
|
||||
lcd.print(labelText);
|
||||
|
||||
}
|
||||
|
||||
// Function for displaying graph value
|
||||
void printValue(byte value) {
|
||||
lcd.clear(labelRow, valueCol); // Clear value space
|
||||
lcd.setCursor(valueCol, labelRow);
|
||||
lcd.print(value);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize LCD
|
||||
lcd.init();
|
||||
lcd.backlight(); // Switch on the backlight LED, if any or wired
|
||||
|
||||
/* Initialize graph
|
||||
* Macro is defined in LiquidCrystal_I2C library.
|
||||
* Function uses the first 5 custom character positions (0-4)
|
||||
and creates custom characters for displaying progress bar.
|
||||
*/
|
||||
lcd.init_bargraph(LCDI2C_HORIZONTAL_LINE_GRAPH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for(byte demoNum = 0; demoNum < sizeof(graphLens)/sizeof(graphLens[0]); demoNum++) {
|
||||
graphPixelsMax = graphLens[demoNum] * LCD_CHARACTER_HORIZONTAL_DOTS;
|
||||
printLabel(demoNum);
|
||||
switch (demoNum) {
|
||||
case 0:
|
||||
case 1:
|
||||
// Demo 1: Graph in full row with sequence values
|
||||
// Demo 2: Graph in half row with sequence values
|
||||
// Descending graph values
|
||||
for (byte i = graphPixelsMax; i > 0; i--) {
|
||||
graphPixelsCur = i - 1;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
// Ascending graph values
|
||||
for (byte i = 0; i < graphPixelsMax; i++) {
|
||||
graphPixelsCur = i;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Demo 3: Graph in full row with random values
|
||||
for (byte i = 0; i < graphPixelsMax; i++) {
|
||||
graphPixelsCur = random(0, graphPixelsMax);
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_horizontal_graph(graphRow, graphCols[demoNum], graphLens[demoNum], graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
break;
|
||||
}
|
||||
delay(demoDelay);
|
||||
}
|
||||
}
|
||||
|
||||
24
lib/LiquidCrystal_I2C/examples/MultipleLcd/MultipleLcd.ino
Normal file
24
lib/LiquidCrystal_I2C/examples/MultipleLcd/MultipleLcd.ino
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd1(0x26,16,2); // set the LCD address of the first lcd to 0x26 for a 16 chars and 2 line display
|
||||
LiquidCrystal_I2C lcd2(0x27,16,2); // set the LCD address of the second lcd to 0x27 for a 16 chars and 2 line display
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd1.init(); // initialize the first lcd
|
||||
lcd2.init(); // initialize the second lcd
|
||||
|
||||
// Print a message on the first LCD.
|
||||
lcd1.backlight();
|
||||
lcd1.print("Hello, #1 world!");
|
||||
|
||||
// Print a message on the second LCD.
|
||||
lcd2.backlight();
|
||||
lcd2.print("Hello, #2 world!");
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
46
lib/LiquidCrystal_I2C/examples/README.md
Normal file
46
lib/LiquidCrystal_I2C/examples/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
<a id="library"></a>
|
||||
# LiquidCrystal_I2C
|
||||
It is the reimplementation of the standard Arduino LCD library, configured to work with parallel HD44780 compatible LCDs, and interfaced via a Chinese PCF8574 I2C serial extender.
|
||||
|
||||
<a id="examples"></a>
|
||||
## Examples
|
||||
##### Autoscroll
|
||||
Demonstrates autoscroll function.
|
||||
|
||||
##### CompleteTest
|
||||
Demo sketch for complete printing test of the LCD. The test suit consist of 9 tests each labeled in the first row.
|
||||
|
||||
##### CustomChars
|
||||
Creation of 8 custom characters in form of graphical symbols.
|
||||
|
||||
##### HelloWorld
|
||||
Standard initial example. Use it for checking basic functionality and address of the LCD.
|
||||
|
||||
##### Histogram
|
||||
Demo sketch for several histograms composed of vertical bar graphs. The values for graphs are generated randomly.
|
||||
1. The first demo histogram is displayed in one row only.
|
||||
1. The second demo histogram display across all rows of the LCD and uses its entire screen.
|
||||
|
||||
##### HorizontalBarGraph
|
||||
Demo sketch for horizontal bar graphs.
|
||||
1. The first demo histogram uses full row for continues increasing and decreasing values (breathing graph).
|
||||
1. The second demo histogram is a breathing graph using just one half of a row.
|
||||
1. The third demo histogram displays values generated randomly.
|
||||
|
||||
##### HorizontalLineGraph
|
||||
Demo sketch for horizontal line graphs. A value is represented just with a pipe on a row.
|
||||
1. The first demo histogram uses full row for continues increasing and decreasing values (running graph).
|
||||
1. The second demo histogram is a running graph using just one half of a row.
|
||||
1. The third demo histogram displays values generated randomly.
|
||||
|
||||
##### MultipleLcd
|
||||
Using multiple LCD on the same I2C bus but communicating on different addresses.
|
||||
|
||||
##### Scroll
|
||||
Demonstrates scrolling text to the left and right without changing text.
|
||||
|
||||
##### SerialDisplay
|
||||
Sketch receives characters from the serial port and displays them on the LCD one by one.
|
||||
|
||||
##### VerticalBarGraph
|
||||
Demo sketch for vertical bar graph. The graph uses all rows in the last column for continues increasing and decreasing values (breathing graph).
|
||||
71
lib/LiquidCrystal_I2C/examples/Scroll/Scroll.ino
Normal file
71
lib/LiquidCrystal_I2C/examples/Scroll/Scroll.ino
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
NAME:
|
||||
Demonstration scrolling text to the left and right without changing text.
|
||||
|
||||
DESCRIPTION:
|
||||
This sketch demonstrates the use of the scrollDisplayLeft() and
|
||||
scrollDisplayRight() functions to make new text scroll to the left and right.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 20.03.2016
|
||||
|
||||
CREDIT:
|
||||
The example taken and rewritten for I2C from official Arduino standard library
|
||||
(https://github.com/arduino/Arduino/tree/master/libraries/LiquidCrystal)
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry and library initialization
|
||||
const byte lcdAddr = 0x27; // Address of I2C backpack
|
||||
const byte lcdCols = 16; // Number of character in a row
|
||||
const byte lcdRows = 2; // Number of lines
|
||||
//const byte lcdAddr = 0x3F; // Address of I2C backpack
|
||||
//const byte lcdCols = 20; // Number of character in a row
|
||||
//const byte lcdRows = 4; // Number of lines
|
||||
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Demo parameters
|
||||
const char demoText[]= "Hello World!";
|
||||
const unsigned int scrollDelay = 500; // Miliseconds before scrolling next char
|
||||
const unsigned int demoDelay = 2000; // Miliseconds between demo loops
|
||||
byte textLen; // Number of visible characters in the text
|
||||
|
||||
void setup() {
|
||||
textLen = sizeof(demoText) - 1;
|
||||
lcd.init();
|
||||
lcd.backlight();
|
||||
lcd.print(demoText);
|
||||
delay(demoDelay);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Scroll entire text in a row to the left outside the screen
|
||||
for (byte positionCounter = 0; positionCounter < textLen; positionCounter++) {
|
||||
lcd.scrollDisplayLeft();
|
||||
delay(scrollDelay);
|
||||
}
|
||||
// Scroll hidden text through entire row to the right outside the screen
|
||||
for (byte positionCounter = 0; positionCounter < textLen + lcdCols; positionCounter++) {
|
||||
lcd.scrollDisplayRight();
|
||||
delay(scrollDelay);
|
||||
}
|
||||
// Scroll text to the right back to original position
|
||||
for (byte positionCounter = 0; positionCounter < lcdCols; positionCounter++) {
|
||||
lcd.scrollDisplayLeft();
|
||||
delay(scrollDelay);
|
||||
}
|
||||
delay(demoDelay);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
|
||||
* an attached LCD.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
|
||||
|
||||
void setup()
|
||||
{
|
||||
lcd.init(); // initialize the lcd
|
||||
lcd.backlight();
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// when characters arrive over the serial port...
|
||||
if (Serial.available()) {
|
||||
// wait a bit for the entire message to arrive
|
||||
delay(100);
|
||||
// clear the screen
|
||||
lcd.clear();
|
||||
// read all the available characters
|
||||
while (Serial.available() > 0) {
|
||||
// display each character to the LCD
|
||||
lcd.write(Serial.read());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
NAME:
|
||||
Demo sketch for Vertical Bar Graph
|
||||
|
||||
DESCRIPTION:
|
||||
The sketch demonstrates usage of LiquidCrystal_I2C library version 2.x
|
||||
for programing vertical graphs, which mimics histogram.
|
||||
* The sketch is intended preferrably for 16x2 LCD, but can be configured
|
||||
for 20x4 LCDs just by uncommenting and commenting related sections.
|
||||
* All graph values are displayed in number of vertical pixels.
|
||||
* The sketch demostrates vertical graphs from one row graph to full rows
|
||||
graph of the display.
|
||||
* The sketch is just for demonstration purposes, so that it is not
|
||||
optimized for memory usage.
|
||||
|
||||
LICENSE:
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the MIT License (MIT).
|
||||
|
||||
CREDENTIALS:
|
||||
Author: Libor Gabaj
|
||||
Version: 1.0.0
|
||||
Updated: 01.03.2015
|
||||
*/
|
||||
|
||||
/* Needed libraries
|
||||
Dispite the LCD library includes Wire library, the ArduinoIDE does not
|
||||
includes nested libraries, if they are not in the same folder.
|
||||
*/
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
|
||||
// LCD address and geometry for LCD 1602
|
||||
const byte lcdAddr = 0x27; // Typical address of I2C backpack for 1602
|
||||
const byte lcdCols = 16; // Number of characters in a row of display
|
||||
const byte lcdRows = 2; // Number of lines of display
|
||||
|
||||
// LCD address and geometry for LCD 2004
|
||||
//const byte lcdAddr = 0x3F; // Typical address of I2C backpack for 2004
|
||||
//const byte lcdCols = 20; // Number of characters in a row of display
|
||||
//const byte lcdRows = 4; // Number of lines of display
|
||||
|
||||
// Initialize library and setting LCD geometry
|
||||
LiquidCrystal_I2C lcd(lcdAddr, lcdCols, lcdRows);
|
||||
|
||||
// Cursor coordinates and character row pattern for progress bar
|
||||
const byte graphCol = lcdCols - 1; // In this column the graph is displayed
|
||||
const int graphDelay = 200; // Delay between graph values in ms
|
||||
const int demoDelay = 3000; // Delay between demos in ms
|
||||
|
||||
// Demo parameters
|
||||
const char graphType[] = " Col(s) Graph";
|
||||
|
||||
// Demo variables
|
||||
byte graphPixelsCur, graphPixelsMax;
|
||||
|
||||
// Function for displaying graph label
|
||||
void printLabel(byte rows) {
|
||||
const byte labelCol = 0;
|
||||
const byte labelRow = 0;
|
||||
// Create label
|
||||
char labelText[graphCol];
|
||||
sprintf(labelText, "%1u%s", rows, graphType);
|
||||
// Display label on clear display
|
||||
lcd.clear();
|
||||
lcd.setCursor(labelCol, labelRow);
|
||||
lcd.print(labelText);
|
||||
|
||||
}
|
||||
|
||||
// Function for displaying graph value
|
||||
void printValue(byte value) {
|
||||
const byte valueWidth = 2; // Max. digits in value
|
||||
const byte valueCol = graphCol - valueWidth - 1;
|
||||
const byte valueRow = 1;
|
||||
// Create value
|
||||
char valueFormat[4], valueText[valueWidth + 1];
|
||||
sprintf(valueFormat, "%%%1uu", valueWidth);
|
||||
sprintf(valueText, valueFormat, value);
|
||||
// Display label on clear display
|
||||
lcd.clear(valueRow, valueCol, valueWidth);
|
||||
lcd.setCursor(valueCol, valueRow);
|
||||
lcd.print(valueText);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// Initialize LCD
|
||||
lcd.init();
|
||||
lcd.backlight(); // Switch on the backlight LED, if any or wired
|
||||
|
||||
/* Initialize graph
|
||||
* Macro is defined in LiquidCrystal_I2C library.
|
||||
* Function uses all 8 custom character positions (0-7)
|
||||
and creates custom characters for displaying vertical bar.
|
||||
*/
|
||||
lcd.init_bargraph(LCDI2C_VERTICAL_BAR_GRAPH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for(byte graphHight = 1; graphHight <= lcdRows; graphHight++) {
|
||||
graphPixelsMax = graphHight * LCD_CHARACTER_VERTICAL_DOTS;
|
||||
printLabel(graphHight);
|
||||
for (byte i = graphPixelsMax; i > 0; i--) {
|
||||
graphPixelsCur = i - 1;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_vertical_graph(graphHight - 1, graphCol, graphHight, graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
// Ascending graph values
|
||||
for (byte i = 0; i < graphPixelsMax; i++) {
|
||||
graphPixelsCur = i;
|
||||
printValue(graphPixelsCur);
|
||||
lcd.draw_vertical_graph(graphHight - 1, graphCol, graphHight, graphPixelsCur);
|
||||
delay(graphDelay);
|
||||
}
|
||||
delay(demoDelay);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user