4
4
5
5
// Section : constructor
6
6
7
- HD44780LCD :: HD44780LCD(uint8_t NumRow, uint8_t NumCol, uint8_t I2Caddress)
7
+ HD44780LCD :: HD44780LCD(uint8_t NumRow, uint8_t NumCol, uint8_t I2Caddress,TwoWire *twi )
8
8
{
9
9
_NumRowsLCD = NumRow;
10
10
_NumColsLCD = NumCol;
11
11
_LCDSlaveAddresI2C = I2Caddress;
12
+ wire = twi;
12
13
}
13
14
15
+
14
16
// Section : Functions
15
17
16
18
// Func Desc: Send data byte to LCD via I2C
@@ -27,9 +29,9 @@ void HD44780LCD::PCF8574_LCDSendData(unsigned char data) {
27
29
dataI2C[2 ] = dataLower | (LCD_DATA_BYTE_ON & _LCDBackLight); // enable=1 and rs =1 1101 YYYY-X-en-X-rs
28
30
dataI2C[3 ] = dataLower | (LCD_DATA_BYTE_OFF & _LCDBackLight); // enable=0 and rs =1 1001 YYYY-X-en-X-rs
29
31
30
- Wire. beginTransmission (_LCDSlaveAddresI2C);
31
- Wire. write (dataI2C, 4 ) ;
32
- TransmissionCode = Wire. endTransmission ();
32
+ wire-> beginTransmission (_LCDSlaveAddresI2C);
33
+ wire-> write (dataI2C, 4 ) ;
34
+ TransmissionCode = wire-> endTransmission ();
33
35
if (TransmissionCode!= 0 )
34
36
{
35
37
#ifdef LCD_SERIAL_DEBUG
@@ -58,9 +60,9 @@ void HD44780LCD::PCF8574_LCDSendCmd(unsigned char cmd) {
58
60
cmdI2C[2 ] = cmdLower | (LCD_CMD_BYTE_ON & _LCDBackLight); // YYYY-1100 YYYY-led-en-rw-rs ,enable=1 and rs =0
59
61
cmdI2C[3 ] = cmdLower | (LCD_CMD_BYTE_OFF & _LCDBackLight); // YYYY-1000 YYYY-led-en-rw-rs ,enable=0 and rs =0
60
62
61
- Wire. beginTransmission (_LCDSlaveAddresI2C);
62
- Wire. write (cmdI2C, 4 ) ;
63
- TransmissionCode = Wire. endTransmission ();
63
+ wire-> beginTransmission (_LCDSlaveAddresI2C);
64
+ wire-> write (cmdI2C, 4 ) ;
65
+ TransmissionCode = wire-> endTransmission ();
64
66
if (TransmissionCode!= 0 )
65
67
{
66
68
#ifdef LCD_SERIAL_DEBUG
@@ -283,10 +285,11 @@ void HD44780LCD::PCF8574_LCDBackLightSet(bool OnOff)
283
285
bool HD44780LCD::PCF8574_LCD_I2C_ON ()
284
286
{
285
287
uint8_t TransmissionCode = 0 ;
286
- Wire.begin ();
287
- Wire.setClock (100000UL );
288
- Wire.beginTransmission (_LCDSlaveAddresI2C);
289
- TransmissionCode = Wire.endTransmission ();
288
+
289
+ wire->begin ();
290
+ // Wire.setClock(100000UL); // V 1.2.0
291
+ wire->beginTransmission (_LCDSlaveAddresI2C);
292
+ TransmissionCode = wire->endTransmission ();
290
293
if (TransmissionCode!= 0 )
291
294
{
292
295
#ifdef LCD_SERIAL_DEBUG
0 commit comments