
Driver for a Text LCD using a PCF8574 over I2C
Dependencies: mbed
Fork of I2CTextLCD by
Diff: i2clcd/TextLCD.cpp
- Revision:
- 3:846b36e1f4d5
- Parent:
- 2:628a00fec43c
--- a/i2clcd/TextLCD.cpp Mon Jan 18 04:02:04 2016 +0000 +++ b/i2clcd/TextLCD.cpp Tue Jan 19 07:50:15 2016 +0000 @@ -52,8 +52,9 @@ #include "mbed.h" -TextLCD::TextLCD(PinName sda, PinName scl, int i2cAddress, LCDType type) : _i2c(sda, scl), _type(type) { - _i2cAddress = i2cAddress; +TextLCD::TextLCD(PinName sda, PinName scl, int i2cAddress, LCDType type) : _i2c(sda, scl), _i2cAddress(i2cAddress) , _type(type){ + // _i2cAddress = i2cAddress; + writeByte(E_ON,false); wait(0.015); // Wait 15ms to ensure powered up // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) @@ -114,7 +115,7 @@ void TextLCD::writeI2CByte(int data) { // equivalent to writeI2CByte - char * cmd = new char[1]; + char cmd[1]; cmd[0] = data; _i2c.write(_i2cAddress, cmd, 1); } @@ -128,9 +129,11 @@ data |= E_ON; // E on writeI2CByte(data); data ^= E_ON; // E off - wait_us(1); + //wait_us(1); + wait(0.000001f); // most instructions take 40us writeI2CByte(data); - wait_us(1000); + wait(0.001f); // most instructions take 40us + // wait_us(1000); } void TextLCD::writeByte(int data, bool rs) {