70 lines
1.6 KiB
Plaintext
70 lines
1.6 KiB
Plaintext
1,6c1
|
|
< //www.DFRobot.com
|
|
< //last updated on 26/11/2010
|
|
< //Tim Starling Fix the reset bug (Thanks Tim)
|
|
< //wiki doc http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)
|
|
< //Support Forum: http://www.dfrobot.com/forum/
|
|
<
|
|
---
|
|
> // LiquidCrystal_I2C V2.0
|
|
10d4
|
|
< #include "WProgram.h"
|
|
12c6
|
|
<
|
|
---
|
|
> #include "Arduino.h"
|
|
67c61
|
|
< delay(50);
|
|
---
|
|
> delayMicroseconds(50000);
|
|
77,90c71,84
|
|
< // we start in 8bit mode, try to set 4 bit mode
|
|
< write4bits(0x03 << 4);
|
|
< delayMicroseconds(4500); // wait min 4.1ms
|
|
<
|
|
< // second try
|
|
< write4bits(0x03 << 4);
|
|
< delayMicroseconds(4500); // wait min 4.1ms
|
|
<
|
|
< // third go!
|
|
< write4bits(0x03 << 4);
|
|
< delayMicroseconds(150);
|
|
<
|
|
< // finally, set to 4-bit interface
|
|
< write4bits(0x02 << 4);
|
|
---
|
|
> // we start in 8bit mode, try to set 4 bit mode
|
|
> write4bits(0x03);
|
|
> delayMicroseconds(4500); // wait min 4.1ms
|
|
>
|
|
> // second try
|
|
> write4bits(0x03);
|
|
> delayMicroseconds(4500); // wait min 4.1ms
|
|
>
|
|
> // third go!
|
|
> write4bits(0x03);
|
|
> delayMicroseconds(150);
|
|
>
|
|
> // finally, set to 4-bit interface
|
|
> write4bits(0x02);
|
|
225c219
|
|
< inline void LiquidCrystal_I2C::write(uint8_t value) {
|
|
---
|
|
> inline size_t LiquidCrystal_I2C::write(uint8_t value) {
|
|
226a221
|
|
> return 0;
|
|
235,238c230,233
|
|
< uint8_t highnib=value&0xf0;
|
|
< uint8_t lownib=(value<<4)&0xf0;
|
|
< write4bits((highnib)|mode);
|
|
< write4bits((lownib)|mode);
|
|
---
|
|
> uint8_t highnib=value>>4;
|
|
> uint8_t lownib=value & 0x0F;
|
|
> write4bits((highnib)|mode);
|
|
> write4bits((lownib)|mode);
|
|
248c243
|
|
< Wire.send((int)(_data) | _backlightval);
|
|
---
|
|
> Wire.write((int)(_data) | _backlightval);
|