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: LCD.cpp
- Revision:
- 3:a65abeda9231
- Parent:
- 2:e3d3eaa27040
--- a/LCD.cpp Mon Mar 08 14:33:47 2021 +0000 +++ b/LCD.cpp Thu Mar 11 23:19:50 2021 +0000 @@ -3,7 +3,8 @@ #include <string> //Code for Newhaven NHD‐0216K3Z‐FL‐GBW LCD interfaced to FRDM-K64F via I2C -LCD::LCD() : i2c(PIN_SCL, PIN_SDA){ +LCD::LCD(I2C* i2cIn){ + i2c = i2cIn; LCD_init(); clearLCD(); wait_us(LCD_DELAY); //wait for stabilization @@ -12,25 +13,22 @@ void LCD::LCD_init(void) { //LCD Initiations--------------------------------------- - - i2c.frequency(LCD_FREQ); - char cmd[3]; cmd[0] = 0xFE; //For all cases cmd[1] = 0x52; cmd[2] = 40; //contrast 1 - 50 - i2c.write(addr, cmd, 3); + i2c->write(addr, cmd, 3); cmd[1] = 0x53; cmd[2] = 8; //Backlight 1-8 - i2c.write(addr, cmd, 3); + i2c->write(addr, cmd, 3); cmd[1] = 0x48; - i2c.write(addr, cmd, 2); //Underline cursor off + i2c->write(addr, cmd, 2); //Underline cursor off cmd[1] = 0x46; - i2c.write(addr, cmd, 2); //Cursor Home + i2c->write(addr, cmd, 2); //Cursor Home } //END LCD_init @@ -42,10 +40,10 @@ wait_us(100); cmd[1] = 0x51; - i2c.write(addr, cmd, 2); //clear current display + i2c->write(addr, cmd, 2); //clear current display cmd[1] = 0x46; - i2c.write(addr, cmd, 2); //Cursor Home + i2c->write(addr, cmd, 2); //Cursor Home } //END clearLCD @@ -66,12 +64,12 @@ for(i=0;i < topLine.length();i++) { //Display top line cmd[i]=topLine[i]; } - i2c.write(addr,cmd,16); + i2c->write(addr,cmd,16); cmd[0] = 0xFE; //Since it was overwritten above cmd[1] = 0x45; cmd[2] = 0x40; //LCD Cursor to next line - i2c.write(addr, cmd, 3); + i2c->write(addr, cmd, 3); wait_us(LCD_DELAY); //Delay between writing lines @@ -80,7 +78,7 @@ for(i=0;i < bottomLine.length();i++) { //Display bottom line cmd[i]=bottomLine[i]; } - i2c.write(addr,cmd,16); + i2c->write(addr,cmd,16); cmd[0] = 0xFE; //Since it was overwritten above } //END LCD_display