Updating LiquidCrystal API and examples.
This commit is contained in:
parent
f504460fc4
commit
58b4e52f7f
|
@ -219,25 +219,25 @@ void LiquidCrystal::scrollDisplayRight(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for text that flows Left to Right
|
// This is for text that flows Left to Right
|
||||||
void LiquidCrystal::shiftLeft(void) {
|
void LiquidCrystal::leftToRight(void) {
|
||||||
_displaymode |= LCD_ENTRYLEFT;
|
_displaymode |= LCD_ENTRYLEFT;
|
||||||
command(LCD_ENTRYMODESET | _displaymode);
|
command(LCD_ENTRYMODESET | _displaymode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for text that flows Right to Left
|
// This is for text that flows Right to Left
|
||||||
void LiquidCrystal::shiftRight(void) {
|
void LiquidCrystal::rightToLeft(void) {
|
||||||
_displaymode &= ~LCD_ENTRYLEFT;
|
_displaymode &= ~LCD_ENTRYLEFT;
|
||||||
command(LCD_ENTRYMODESET | _displaymode);
|
command(LCD_ENTRYMODESET | _displaymode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will 'right justify' text from the cursor
|
// This will 'right justify' text from the cursor
|
||||||
void LiquidCrystal::shiftIncrement(void) {
|
void LiquidCrystal::autoscroll(void) {
|
||||||
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
|
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
|
||||||
command(LCD_ENTRYMODESET | _displaymode);
|
command(LCD_ENTRYMODESET | _displaymode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will 'left justify' text from the cursor
|
// This will 'left justify' text from the cursor
|
||||||
void LiquidCrystal::shiftDecrement(void) {
|
void LiquidCrystal::noAutoscroll(void) {
|
||||||
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
|
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
|
||||||
command(LCD_ENTRYMODESET | _displaymode);
|
command(LCD_ENTRYMODESET | _displaymode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,10 @@ public:
|
||||||
void cursor();
|
void cursor();
|
||||||
void scrollDisplayLeft();
|
void scrollDisplayLeft();
|
||||||
void scrollDisplayRight();
|
void scrollDisplayRight();
|
||||||
void printLeft();
|
void leftToRight();
|
||||||
void printRight();
|
void rightToLeft();
|
||||||
void shiftLeft();
|
void autoscroll();
|
||||||
void shiftRight();
|
void noAutoscroll();
|
||||||
void shiftIncrement();
|
|
||||||
void shiftDecrement();
|
|
||||||
|
|
||||||
void createChar(uint8_t, uint8_t[]);
|
void createChar(uint8_t, uint8_t[]);
|
||||||
void setCursor(uint8_t, uint8_t);
|
void setCursor(uint8_t, uint8_t);
|
||||||
|
|
|
@ -45,12 +45,12 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Turn off the display:
|
// Turn off the blinking cursor:
|
||||||
lcd.noBlink();
|
lcd.noBlink();
|
||||||
delay(500);
|
delay(3000);
|
||||||
// Turn on the display:
|
// Turn on the blinking cursor:
|
||||||
lcd.blink();
|
lcd.blink();
|
||||||
delay(500);
|
delay(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,10 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Turn off the display:
|
// Turn off the cursor:
|
||||||
lcd.noCursor();
|
lcd.noCursor();
|
||||||
delay(500);
|
delay(500);
|
||||||
// Turn on the display:
|
// Turn on the cursor:
|
||||||
lcd.cursor();
|
lcd.cursor();
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
/*
|
/*
|
||||||
LiquidCrystal Library - Increment/Decrement
|
LiquidCrystal Library - Autoscroll
|
||||||
|
|
||||||
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
|
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
|
||||||
library works with all LCD displays that are compatible with the
|
library works with all LCD displays that are compatible with the
|
||||||
Hitachi HD44780 driver. There are many of them out there, and you
|
Hitachi HD44780 driver. There are many of them out there, and you
|
||||||
can usually tell them by the 16-pin interface.
|
can usually tell them by the 16-pin interface.
|
||||||
|
|
||||||
This sketch demonstrates the use of the shiftIncrement()
|
This sketch demonstrates the use of the autoscroll()
|
||||||
and shifDecrement() functions.
|
and noAutoscroll() functions.
|
||||||
|
|
||||||
The circuit:
|
The circuit:
|
||||||
* LCD RS pin to digital pin 12
|
* LCD RS pin to digital pin 12
|
||||||
|
@ -37,29 +37,30 @@
|
||||||
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// set up the LCD's number of rows and columns:
|
// set up the LCD's number of columns and rows:
|
||||||
lcd.begin(2, 16);
|
lcd.begin(2, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// set the cursor to (0,0):
|
// set the cursor to (0,0):
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
// set the display to left justify:
|
|
||||||
lcd.shiftDecrement();
|
|
||||||
// print from 0 to 9:
|
// print from 0 to 9:
|
||||||
for (int thisChar = 0; thisChar < 10; thisChar++) {
|
for (int thisChar = 0; thisChar < 10; thisChar++) {
|
||||||
lcd.print(thisChar);
|
lcd.print(thisChar);
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
// set the cursor to (16,0):
|
|
||||||
|
// set the cursor to (16,1):
|
||||||
lcd.setCursor(16,1);
|
lcd.setCursor(16,1);
|
||||||
// set the display to left justify:
|
// set the display to automatically scroll:
|
||||||
lcd.shiftIncrement();
|
lcd.autoscroll();
|
||||||
// print from 0 to 9:
|
// print from 0 to 9:
|
||||||
for (int thisChar = 0; thisChar < 10; thisChar++) {
|
for (int thisChar = 0; thisChar < 10; thisChar++) {
|
||||||
lcd.print(thisChar);
|
lcd.print(thisChar);
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
|
// turn off automatic scrolling
|
||||||
|
lcd.noAutoscroll();
|
||||||
|
|
||||||
// clear screen for the next loop:
|
// clear screen for the next loop:
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
LiquidCrystal Library - Shift
|
LiquidCrystal Library - TextDirection
|
||||||
|
|
||||||
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
|
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
|
||||||
library works with all LCD displays that are compatible with the
|
library works with all LCD displays that are compatible with the
|
||||||
Hitachi HD44780 driver. There are many of them out there, and you
|
Hitachi HD44780 driver. There are many of them out there, and you
|
||||||
can usually tell them by the 16-pin interface.
|
can usually tell them by the 16-pin interface.
|
||||||
|
|
||||||
This sketch demonstrates how to use shiftLeft() and shiftRight()
|
This sketch demonstrates how to use leftToRight() and rightToLeft()
|
||||||
to move the cursor.
|
to move the cursor.
|
||||||
|
|
||||||
The circuit:
|
The circuit:
|
||||||
|
@ -51,12 +51,12 @@ void loop() {
|
||||||
// reverse directions at 'm':
|
// reverse directions at 'm':
|
||||||
if (thisChar == 'm') {
|
if (thisChar == 'm') {
|
||||||
// go right for the next letter
|
// go right for the next letter
|
||||||
lcd.shiftRight();
|
lcd.rightToLeft();
|
||||||
}
|
}
|
||||||
// reverse again at 's':
|
// reverse again at 's':
|
||||||
if (thisChar == 's') {
|
if (thisChar == 's') {
|
||||||
// go left for the next letter
|
// go left for the next letter
|
||||||
lcd.shiftLeft();
|
lcd.leftToRight();
|
||||||
}
|
}
|
||||||
// reset at 'z':
|
// reset at 'z':
|
||||||
if (thisChar > 'z') {
|
if (thisChar > 'z') {
|
||||||
|
|
|
@ -12,10 +12,15 @@ LiquidCrystal KEYWORD1
|
||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
begin KEYWORD2
|
||||||
clear KEYWORD2
|
clear KEYWORD2
|
||||||
home KEYWORD2
|
home KEYWORD2
|
||||||
print KEYWORD2
|
print KEYWORD2
|
||||||
setCursor KEYWORD2
|
setCursor KEYWORD2
|
||||||
|
cursor KEYWORD2
|
||||||
|
noCursor KEYWORD2
|
||||||
|
blink KEYWORD2
|
||||||
|
noBlink KEYWORD2
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Constants (LITERAL1)
|
# Constants (LITERAL1)
|
||||||
|
|
Loading…
Reference in New Issue