arduino-libraries / liquidcrystal Goto Github PK
View Code? Open in Web Editor NEWLiquid Crystal Library for Arduino
Home Page: http://arduino.cc/
Liquid Crystal Library for Arduino
Home Page: http://arduino.cc/
Hi,
I'm calling a function to print a dynamic string in LCD and i have been using delay which is stopping my program from other process, I also used millis but didn't help
what can i do here?
delayMicroseconds(50000);
is blocking on esp8266, prevents some wifi routines and can trigger watchdog also, and probably not needed for most instances anyway.
Print.h dependency is not included with some boards (for example mbed based boards). Easy fix is to replace Print.h with Arduino.h
In LiquidCrystal.cpp at line 107, there is delayMicroseconds(50000); startup delay of 50ms.
Because maximum value that function delayMicroseconds() can handle is 16383, instead of 50mS you got only around 2mS delay.
Make this delay in form of:
for(unsigned char i=0;i<5;i++)
delayMicroseconds(10000);
Best regards from Republic of Serbia.
From @manfredjonsson on May 28, 2012 15:31
This Version of the Liquid Crystal Library can be inherited from other classes.
A possible usage is outlined in http://github.com/manfredjonsson/LiquidCrystalAddons
Because of the many changes, each commit contains one step of the improvements.
Commit 1: Fixes
Commit 2: Minimal set of changes for inheritance
Commit 3: Make it smaller
Copied from original issue: arduino/Arduino/pull/87
From @cmaglie on November 15, 2012 18:47
This is Issue 726 moved from a Google Code project.
Added by 2011-11-22T16:22:34.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Enhancement, Priority-Medium
What change would like to see?
Currently scrollDisplayLeft
and scrollDisplayRight
do not accept parameters. I would to to proved an integer to indicate a scroll amount other than the default of '1'.
Why?
To simplify project code and make the function more versatile.
Seldom is it needed to shift the display only one positions. Therefore, it is necessary to put the function in a loop. This complicates the codes.
If I need to scroll my display 16 positions (a common display width) I currently need to write something like:
for (uint8_t i=16; i--;) scrollDisplayLeft();
This is the most compact and efficient code I have been able to come up with.
A more efficient method would be:
scrollDisplayLeft(16);
The compiler could better optimize the code since there is only one loop in one location rather than several loops in different locations.
Would this cause any incompatibilities with previous versions?
No.
This is my tested proposed code based on arduino-1.0-rc2:
LiquidCrystal.h
void scrollDisplayLeft(uint8_t iCnt=1);
void scrollDisplayRight(uint8_t iCnt=1);
LiquidCrystal.c
void LiquidCrystal::scrollDisplayLeft(uint8_t iCnt) {
while (iCnt-- != 0)
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void LiquidCrystal::scrollDisplayRight(uint8_t iCnt) {
while (iCnt-- != 0)
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}
Copied from original issue: arduino/Arduino#726
From @cmaglie on November 15, 2012 18:48
This is Issue 748 moved from a Google Code project.
Added by 2011-12-13T16:12:43.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Enhancement, Priority-Medium
What change would like to see?
I noticed that the Liquid Crystal library is performing amazing delays of thousands microseconds instead of reading the busy flag. Why don't we use the busy flag, which was especially buit for this usage?
Why?
A lot of time is lost because of active waits.
Would this cause any incompatibilities with previous versions? If so, how
can these be mitigated?
Not any incompatibility with previous versions.
Copied from original issue: arduino/Arduino#748
ESP32-s2 is crashing on LCD initialization. Code is 'Hello World' from examples.
Debug Logs is as follow.
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x10 (RTCWDT_RTC_RST),boot:0xb (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6100,len:0x8
load:0x3ffe6108,len:0x620
load:0x4004c000,len:0xa38
load:0x40050000,len:0x2848
entry 0x4004c190
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}
Hello, I use this library for the LCD 0802A screen, but there was a problem, if there are more than 8 characters, then the text does not go to the second line.
https://www.arduino.cc/en/Reference/LiquidCrystalCreateChar
Change:
Create a custom character (gylph) for use on the LCD.
to:
Create a custom character (glyph) for use on the LCD.
Originally reported at http://forum.arduino.cc/index.php?topic=554489
See this issue
hello,
i interfaced lcd 16x2 by 4 bit mode with esp32 and GPIO connect as rs-io17,en-io16,d4-io18,d5-io19,d6-io1,d7-io23
LiquidCrystal lcd(17, 16, 18, 19, 1, 23);
and try for print hello world but it prints "l" instead of"h" and also problem in other characters
please give me replay as soon as possible!!
Current implementation is confusing. Entry mode set command uses 2 bits - lowest one is for disabling (0
) or enabling (1
) display shift, and shift direction is specified by second bit (0
shifts right, 1
shifts left). Second bit itself is used to increment (1
) or decrement (0
) the DDRAM address (cursor position) when new character is put to DDRAM.
Suggesting the following naming:
// flags for display entry mode
#define LCD_ENTRYSHIFTDISABLE 0x00
#define LCD_ENTRYSHIFTENABLE 0x01
#define LCD_ENTRYDECREMENTADDRESS 0x00
#define LCD_ENTRYINCREMENTADDRESS 0x02
#define LCD_ENTRYRIGHTTOLEFT LCD_ENTRYDECREMENTADDRESS
#define LCD_ENTRYLEFTTORIGHT LCD_ENTRYINCREMENTADDRESS
From @Chisalita on July 24, 2013 13:12
Added functions to read data from LCD, to delete last character, to
delete a character at specified position, get current position, get
character from a position and get more characters at once, making it
faster.
Copied from original issue: arduino/Arduino/pull/1517
Moved from arduino/Arduino#9887 by @Camo2000
I have found an issue with the LCD display Output, it works fine until you add the word "Mode" as a string. The display then corrupts and I can not see why unless there is a method to control the LED display with text. However if you use any string with the word in it, it still corrupts:-
All fail.
String MyTitles[ARRAYSIZE]={"Mode", "Effect", "Pallete", "Sin8", "Sin16", "Speed", "LED Spacing"};
this fails if Mode is in the list
Hope some of you can replicate this.
The comments at
have a broken link to https://www.arduino.cc/en/Tutorial/LibraryExamples/HelloWorld
See discussion at https://forum.arduino.cc/t/lcd-example-in-arduino/1086684 which suggests using the tutorial at https://docs.arduino.cc/learn/electronics/lcd-displays#hello-world-example instead. (The code there also has the same broken link)
From @inversesandwich on May 26, 2013 13:32
Fixed incompatibility with newer Arduino software and updated documentation. Centered custom character animation for a 16x2 display and updated link for character generator as previous link is dead.
Copied from original issue: arduino/Arduino/pull/1436
I'm new to github and arduino, but using LiquidCrystal_I2C lcd(0x27, 16, 2); causes an error on NodeMCU boards (and maybe others) but not on Mega 2560. The workaround is to replace it with LiquidCrystal_I2C lcd(0x27); and add lcd.begin(16,2); in setup. Maybe this is obvious, but it confused me a lot, and the error message was very unhelpful. ("Invalid Converson from ‘int’ to ‘t_backlighPol" [-fpermissive]")
init()
function for some reason calls begin(16, 1)
without any good reason for doing so. init()
is normally called from LiquidCrystal
constructor and begin()
needs to be called from user program before any other code. Current code actually performs double LCD initialization which appears to be harmless but unneeded/time consuming.
LiquidCrystal/src/LiquidCrystal.cpp
Lines 70 to 76 in db84824
Code won't compile as this Library is missing a ".h" file, called "seesaw.h"!!!, would be nice if someone could point where this file is located if in any other library, thanks
Moved from arduino/Arduino#2191 by @anthony-ngu
The LiquidCrystal Library should handle '\r' and '\n' characters properly.
When a println is used, it sends both the \r and \n characters and the LiquidCrystal library prints those characters out. Instead it should set the cursor to a row below.
It seems it misses a carriage return in the comment:
// with the arduino pin number it is connected toconst int rs=12, en=11, d4=5, d5=4, d6=3, d7=2;
should be:
// with the arduino pin number it is connected to
const int rs=12, en=11, d4=5, d5=4, d6=3, d7=2;
Impacted sketch:
Hey everyone,
https://www.arduino.cc/en/Reference/LiquidCrystalCreateChar
The example code for the Arduino Reference contains this byte:
byte smiley[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000 };
When creating this character, the code only used 7 bytes, not 8. With beginners in mind, I would recommend adding the unneeded 8th byte "0b00000" to give a clear template. Without all these bytes a beginner may not understand how to create a full character if the instructions were not completely read.
Im begin a project for my school where I need create a personal library like LiquidCrystal, the work is awesome and legible but I dont can found where is defined lcd.print.Please help me.
The example is "Hello World" I see the lcd.print but in LiquidCrystal.h and .cpp i dont found nothing except:
" virtual size_t write(uint8_t);
using Print::write; "
"inline size_t LiquidCrystal::write(uint8_t value) {
send(value, HIGH);
return 1; // assume sucess "
"void LiquidCrystal::write4bits(uint8_t value) {
for (int i = 0; i < 4; i++) {
digitalWrite(_data_pins[i], (value >> i) & 0x01);"
This is Issue 196 moved from a Google Code project.
Added by 2010-02-01T16:37:19.000Z by damellis.
Please review that bug for more context and additional comments, but update this bug.
Original labels: Type-Enhancement, Priority-Medium, Component-Core
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264823411
"40x4 LCDs
I added support for an LCD of 4 LInes and 40 characters. I think that if 24x4, 32x4 LCDs exist,
they would also work with the software as I have modified it although I have not had the
opportunity to test that. The 40x4 LCD (and any HD44780 based LCD with between 81 and 160
characters) will have 2 enable lines. To use an LCD with 4 lines and 40 columns you would
declare your LiquidCrystal object as:
LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0); at this time I don’t support
8 data lines nor do I support eliminating the RW line in this option.Then in the setup function
you would call:
lcd.begin(40,4);
Linewrap
When you declare the dimensions of the LCD in your begin call, the LiquidCrystal library
remembers how long the lines are. Now when it reaches the end of line 1, text wraps onto line 2
(not line 3 as previously).
16x4 LCDs
The begin statement also correctly positions text at the beginning of the line on 16x4 (and 40x4)
LCDs, which were not correctly handled before.
setCursor
In the past setCursor selected a location in the HD44780’s RAM not actually a screen location. If
you use any of the commands that shift the display left or right with the previous routines, then
setCursor and print, text appears in an unexpected location on the screen. With the new
software, if you call either scrollDisplayLeft() or scrollDisplayRight(), the LiquidCrystal package
keeps track of the relationship between RAM and the LCD so that setCursor coordinates are
pegged to a specific spot on the screen, rather than a spot in RAM. The sotware does not handle
autoScroll, however. Call home() after autoScroll to restore the expected relationship between
setCursor and the LCD screen.
Testing the LCD Busy Flag
Previous versions of LiquidCrystal always used timed delays on the Arduino side of the interface
to give the LCD module enough time to complete its operation. This version still does that if you
tie the RW pin to ground and do not tell LiquidCrystal what that pin number is. If you do specify
RW now, however, the software will poll the busy flag on the LCD module. Arduino operations
may thus overlap LCD operations and potentially things may go a little faster.
Crazy 8 Addressing
16x1 LCDs often have an unusual address layout; these modules often have two 8 character
halves and work best with this software if you declare them as lcd.begin(8,2); if you do that, then
you can print(“abcdefghilklmno”); and have all the characters appear as you would like across the
screen. If you use any of the scrolling commands, the bizarre addressing of these modules will
manifest itself. For details follow the LCD Addressing link at web.alfredstate.edu/weimandn
Disadvantages
The two real disadvantages I can see to the changes I have made are:
The code is longer than before. Much of the increase is in checkLcdBusyFlag() and this could be
fairly easily replaced with delayMicroseconds(100);
There are going to be some incompatibilities between code that assumed that line 1 wrapped
onto line 3, etc."
Hello!
I think it would be useful to have PROGMEM ready createChar variant - creating custom characters is usually done only once, so wasting RAM for bitmap could be avoided by loading it directly from program memory. I wonder if something like this would be sufficient?
void createCharProgMem(uint8_t location, const uint8_t charmap[]) {
location &= 0x7; // we only have 8 locations 0-7
command(LCD_SETCGRAMADDR | (location << 3));
for (uint8_t i = 0; i < 8; i++) {
write(pgm_read_byte_near(charmap + i));
}
}
void createChar(uint8_t location, const __FlashStringHelper *buf) {
location &= 0x7; // we only have 8 locations 0-7
command(LCD_SETCGRAMADDR | (location << 3));
for (uint8_t i = 0; i < 8; i++) {
write(pgm_read_byte_near((const uint8_t *)buf + i));
}
}
Moved from arduino/Arduino#4809 by @tablatronix
createChar
does not work after calling setCursor
at least for me, was driving me nuts until I made sure to always do it before moving the cursor.
// would not print my character
lcd.setCursor(numCols-1, 0);
lcd.createChar(1,custombyte);
lcd.write((char)1);
Can't compile with Arduino Nano Every
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Nano Every, ATMEGA328"
In file included from /Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src/LiquidCrystal.cpp:1:0:
/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src/LiquidCrystal.h:45:36: error: expected class-name before '{' token
class LiquidCrystal : public Print {
^
/Applications/Arduino.app/Contents/Java/libraries/LiquidCrystal/src/LiquidCrystal.h:86:9: error: 'Print' has not been declared
using Print::write;
^~~~~
exit status 1
Error compiling for board Arduino Nano Every.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.