Skip to content

Commit 16f34ba

Browse files
authored
Merge pull request #12 from hasenradball/develop
provide new wire interface
2 parents 32cfb67 + 5b50705 commit 16f34ba

File tree

11 files changed

+73
-65
lines changed

11 files changed

+73
-65
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ only a current source to VCC is active.
5151
A detailed description of the PCF8574 you will find in the [pcf8574.pdf](./docs/pcf8574.pdf).
5252

5353
## Library Usage
54+
Possibly make a weather station.
55+
56+
![Weather](./docs/LCD_Temp_Hum.JPG)
5457

5558
# License
5659
This library is licensed under MIT Licence.

docs/LCD_Temp_Hum.JPG

378 KB
Loading

examples/Custom_Chars/Custom_Chars.ino

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <LCD-I2C.h>
11+
#include <Wire.h>
1112

1213
// Default address of most PCF8574 modules, change according
1314

@@ -62,20 +63,20 @@ uint8_t snow[8] =
6263
};
6364

6465
void setup() {
65-
lcd.begin();
66-
lcd.display();
67-
lcd.backlight();
66+
Wire.begin();
67+
lcd.begin(&Wire);
68+
lcd.display();
69+
lcd.backlight();
6870

69-
lcd.createChar(0, happy);
70-
lcd.createChar(1, wow);
71-
lcd.createChar(2, anchor);
72-
lcd.createChar(3, snow);
71+
lcd.createChar(0, happy);
72+
lcd.createChar(1, wow);
73+
lcd.createChar(2, anchor);
74+
lcd.createChar(3, snow);
7375

74-
75-
lcd.write(0);
76-
lcd.write(1);
77-
lcd.write(2);
78-
lcd.write(3);
76+
lcd.write(0);
77+
lcd.write(1);
78+
lcd.write(2);
79+
lcd.write(3);
7980
}
8081

8182
void loop() {

examples/Functions/Functions.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <LCD-I2C.h>
11+
#include <Wire.h>
1112

1213
// Default address of most PCF8574 modules, change according
1314

@@ -22,9 +23,10 @@ LCD_I2C lcd(0x27, 16, 2);
2223
*/
2324

2425
void setup() {
25-
lcd.begin();
26-
lcd.display();
27-
lcd.backlight();
26+
Wire.begin();
27+
lcd.begin(&Wire);
28+
lcd.display();
29+
lcd.backlight();
2830
}
2931

3032
void loop()

examples/Hello_World/Hello_World.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*/
99

1010
#include <LCD-I2C.h>
11-
11+
#include <Wire.h>
1212

1313
LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according
1414

1515
void setup() {
1616
// If you are using more I2C devices using the Wire library use lcd.begin(false)
1717
// this stop the library(LCD-I2C) from calling Wire.begin()
18-
lcd.begin();
18+
Wire.begin();
19+
lcd.begin(&Wire);
1920
lcd.display();
2021
lcd.backlight();
2122
}

examples/write_character_codes/write_character_codes.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
*/
99

1010
#include <LCD-I2C.h>
11-
11+
#include <Wire.h>
1212

1313
LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according
1414

1515
void setup() {
1616
// If you are using more I2C devices using the Wire library use lcd.begin(false)
1717
// this stop the library(LCD-I2C) from calling Wire.begin()
18-
lcd.begin();
18+
Wire.begin();
19+
lcd.begin(&Wire);
1920
lcd.display();
2021
lcd.backlight();
2122
}

keywords.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ setCursor KEYWORD2
4141
HD44780_CLEAR_DISPLAY LITERAL1
4242
HD44780_CURSOR_HOME LITERAL1
4343
HD44780_ENTRY_MODE_SET LITERAL1
44-
HD44780_ACCOMPANIES_DISPLAY_SHIFT LITERAL1
45-
HD44780_ENTRY_SHIFTINCREMENT LITERAL1
46-
HD44780_ENTRY_SHIFTDECREMENT LITERAL1
47-
HD44780_DISPLAY_CONTROL LITERAL1
48-
HD44780_BLINK_ON LITERAL1
49-
HD44780_CURSOR_ON LITERAL1
50-
HD44780_DISPLAY_ON LITERAL1
51-
HD44780_CURSOR_OR_DISPLAY_SHIFT LITERAL1
52-
HD44780_SHIFT_RIGHT LITERAL1
53-
HD44780_DISPLAY_SHIFT LITERAL1
54-
HD44780_CURSOR_MOVE LITERAL1
55-
HD44780_FUNCTION_SET LITERAL1
56-
HD44780_5x10_DOTS LITERAL1
57-
HD44780_5x8_DOTS LITERAL1
58-
HD44780_2_LINE LITERAL1
59-
HD44780_1_LINE LITERAL1
60-
HD44780_8_BIT_MODE LITERAL1
61-
HD44780_4_BIT_MODE LITERAL1
62-
HD44780_SET_CGRAM_ADDR LITERAL1
63-
HD44780_SET_DDRRAM_ADDR LITERAL1
44+
HD44780_ACCOMPANIES_DISPLAY_SHIFT LITERAL1
45+
HD44780_ENTRY_SHIFTINCREMENT LITERAL1
46+
HD44780_ENTRY_SHIFTDECREMENT LITERAL1
47+
HD44780_DISPLAY_CONTROL LITERAL1
48+
HD44780_BLINK_ON LITERAL1
49+
HD44780_CURSOR_ON LITERAL1
50+
HD44780_DISPLAY_ON LITERAL1
51+
HD44780_CURSOR_OR_DISPLAY_SHIFT LITERAL1
52+
HD44780_SHIFT_RIGHT LITERAL1
53+
HD44780_DISPLAY_SHIFT LITERAL1
54+
HD44780_CURSOR_MOVE LITERAL1
55+
HD44780_FUNCTION_SET LITERAL1
56+
HD44780_5x10_DOTS LITERAL1
57+
HD44780_5x8_DOTS LITERAL1
58+
HD44780_2_LINE LITERAL1
59+
HD44780_1_LINE LITERAL1
60+
HD44780_8_BIT_MODE LITERAL1
61+
HD44780_4_BIT_MODE LITERAL1
62+
HD44780_SET_CGRAM_ADDR LITERAL1
63+
HD44780_SET_DDRRAM_ADDR LITERAL1

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "LCD-I2C",
3-
"version": "0.3.0",
3+
"version": "1.0.0",
44
"repository":
55
{
66
"type": "git",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=LCD-I2C
2-
version=0.3.0
2+
version=1.0.0
33
author=Frank Häfele <mail@frankhaefele.de>
44
maintainer=Frank Häfele <mail@frankhaefele.de>
55
sentence=C++ Library for Liquid Crystal Displays (LCD) with the Hitachi HD44780 display driver.

src/LCD-I2C.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
#include "LCD-I2C.h"
2-
#include "Wire.h"
2+
#include <LCD_Constants.h>
33

44
/**
55
* @brief function begin
66
*
77
* @param beginWire if true start I²C wire
88
*/
9-
void LCD_I2C::begin(bool beginWire) {
10-
if (beginWire)
11-
Wire.begin();
12-
13-
// Clear i2c adapter
14-
I2C_Write(0b00000000);
15-
// Wait more than 40 ms after powerOn
16-
delay(50);
17-
InitializeLCD();
9+
void LCD_I2C::begin(TwoWire *wire) {
10+
_wire = wire;
11+
12+
// Clear i2c adapter
13+
I2C_Write(0b00000000);
14+
// Wait more than 40 ms after powerOn
15+
delay(50);
16+
InitializeLCD();
1817
}
1918

2019
/**
@@ -370,9 +369,9 @@ void LCD_I2C::writeCharCode(uint8_t code) {
370369
* @param output data to write
371370
*/
372371
void LCD_I2C::I2C_Write(uint8_t output) {
373-
Wire.beginTransmission(_address);
374-
Wire.write(output);
375-
Wire.endTransmission();
372+
_wire->beginTransmission(_address);
373+
_wire->write(output);
374+
_wire->endTransmission();
376375
}
377376

378377
/**

0 commit comments

Comments
 (0)