Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: I2CTextLCD.cpp
- Revision:
- 2:1c5dea5d8783
- Parent:
- 1:0eb3365ec819
- Child:
- 3:704f87be7993
--- a/I2CTextLCD.cpp Sun Dec 19 19:19:39 2010 +0000
+++ b/I2CTextLCD.cpp Thu Dec 23 12:42:37 2010 +0000
@@ -36,13 +36,14 @@
*
*/
-I2CTextLCD::I2CTextLCD(PinName sda, PinName scl, int i2cAddress , int columns, int rows) :
- _i2c(sda, scl) {
+I2CTextLCD::I2CTextLCD(PinName sda, PinName scl, int i2cAddress , int columns, int rows,
+ bool backlight) : _i2c(sda, scl) {
_i2cAddress = i2cAddress;
_columns = columns;
_rows = rows;
- _backlight=true;
+ _backlight=backlight;
+
// Should theoretically wait 15ms, but most things will be powered up pre-reset
// so i'll disable that for the minute. If implemented, could wait 15ms post reset
@@ -62,6 +63,8 @@
writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
cls();
+
+
}
int I2CTextLCD::_putc(int value) {
@@ -77,8 +80,12 @@
return 0;
}
-void I2CTextLCD::backlight(bool on) {
- _backlight=on;
+void I2CTextLCD::backlight(bool status) {
+ _backlight=status;
+ if (_backlight)
+ writeI2CByte(BACKLIGHT_ON | E_ON);
+ else
+ writeI2CByte(E_ON);
}
@@ -129,7 +136,7 @@
writeI2CByte(data | E_ON); // E=1
wait(0.000040f);
- writeI2CByte(data ); // E=0
+ writeI2CByte(data); // E=0
wait(0.000040f);
writeI2CByte(data | E_ON); // E=1
@@ -163,3 +170,6 @@
}
+
+
+