LCD For I2C
Revision 1:a8cb70204513, committed 2016-12-03
- Comitter:
- sweilz
- Date:
- Sat Dec 03 10:50:46 2016 +0000
- Parent:
- 0:ef783944caa1
- Commit message:
- LCD FIBO
Changed in this revision
LCDTaonoi.cpp | Show annotated file Show diff for this revision Revisions of this file |
LCDTaonoi.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCDTaonoi.cpp Sat Dec 05 19:19:31 2015 +0000 +++ b/LCDTaonoi.cpp Sat Dec 03 10:50:46 2016 +0000 @@ -1,88 +1,14 @@ #include "LCDTaonoi.h" -/* -int main() -{ - // int ack; - //char cmd[2]; - - wait(0.015); - //cmd[0] = 0x0C; - //ack = lcd.write(addr,cmd,1); - //pc.printf("%d\n",ack); - //cmd[0] = 0x3C; - //ack = lcd.write(addr,cmd,1); - //pc.printf("%d\n",ack); - - - - //CLS - Command(0x01); - - - //Begin - Command(0x3); - wait(0.005); - Command(0x3); - wait_us(100); - Command(0x3); - Command(0x2); - //Command(0x2); - //Command(0x8); - Command(0x28); - //Command(0x0); - //Command(0xC); - Command(0x0C); - //Command(0x0); - //Command(0x6); - Command(0x06); - //Begin - char data[8] = "LIEWS"; - SendData("PRUEK"); - //Command(0x8); - //Command(0x0); - //Command(0x80); - //Command(0x0); - //Command(0x6); - //Command(0x5,1); - //Command(0x0,1); - //Command('P',1); - //Command('R',1); - //Command('U',1); - //Command('E',1); - //Command('K',1); - //Command(0xC0); - setCursor(0,3); - SendData(data); - //Command('L',1); - //Command('I',1); - //Command('E',1); - //Command('W',1); - //Command('S',1); - //Command(0x5,1); - //Command(0x2,1); - //Command(0x5,1); - //Command(0x5,1); - //Command(0x4,1); - //Command(0x5,1); - //Command(0x4,1); - //Command(0xB,1); - - - //CLS - //Command(0x0); - //Command(0x1); - -}*/ LCDTaonoi::LCDTaonoi(PinName _SDA, PinName _SCL , int _addr):lcd(_SDA,_SCL),addr(_addr) { - - wait(0.015); + wait_ms(55); + + Command(0x01);//CLS + wait_ms(15); - Command(0x01);//CLS - //Begin Command(0x3); wait(0.005); @@ -100,6 +26,12 @@ } +void LCDTaonoi::clear() +{ + Command(0x01); + wait_ms(5); + setCursor(0,0); +} void LCDTaonoi::Command (char value, int Mode ) { char _command[2]; @@ -164,14 +96,11 @@ } -void LCDTaonoi::SendData (char* Data) +void LCDTaonoi::print (string Data) { - for(int i = 0;; i++) { - if(Data[i]=='\0') - break; - - Command(Data[i],1); - + int8_t i=0; + while(Data[i]!='\0') + { + Command(Data[i++],1); } - } \ No newline at end of file
--- a/LCDTaonoi.h Sat Dec 05 19:19:31 2015 +0000 +++ b/LCDTaonoi.h Sat Dec 03 10:50:46 2016 +0000 @@ -1,24 +1,23 @@ #ifndef LCDTAONOI_H #define LCDTAONOI_H #include "mbed.h" +#include <string> class LCDTaonoi { public: LCDTaonoi(PinName _SDA, PinName _SCL , int _addr = 0x4E ); void Command (char value, int Mode = 0); - void SendData (char* Data); + void print (string Data); int address(int column, int row); void setCursor (int column, int row); + void clear(); //void Command (const char* value, int Mode ) // ~LCDTaonoi(); private: - //Serial pc(SERIAL_TX,SERIAL_RX); const int addr ; I2C lcd; }; - - #endif \ No newline at end of file