Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mathertel/LiquidCrystal_PCF8574
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.2.0
Choose a base ref
...
head repository: mathertel/LiquidCrystal_PCF8574
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 17, 2018

  1. Use correct field separator in keywords.txt

    The Arduino IDE requires the use of a single true tab separator between the keyword name and identifier. When spaces are used rather than a true tab the keyword is not highlighted.
    
    Reference:
    https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywords
    per1234 authored Jul 17, 2018
    Copy the full SHA
    144ce4d View commit details

Commits on Dec 10, 2019

  1. Copy the full SHA
    671199c View commit details

Commits on Dec 11, 2019

  1. Fix unused parameter 'cols' warning [-Wunused-parameter] in begin(int…

    … cols, int lines)
    
    Signed-off-by: Eddy Petrișor <eddy.petrisor@gmail.com>
    eddyp committed Dec 11, 2019
    Copy the full SHA
    a7b4550 View commit details

Commits on Jul 3, 2020

  1. Merge pull request #7 from per1234/keywords-separator

    Use correct field separator in keywords.txt
    mathertel authored Jul 3, 2020
    Copy the full SHA
    285241d View commit details
  2. Merge pull request #10 from uCautomation/fix-unused-cols-parameter-wa…

    …rning
    
    Fix unused parameter 'cols' warning [-Wunused-parameter] in begin(int cols, int lines)
    mathertel authored Jul 3, 2020
    Copy the full SHA
    51a3a08 View commit details
  3. Merge pull request #9 from Gasman2014/CreateChar

    Change CreateChar (int, int[]) to (int, byte[])
    mathertel authored Jul 3, 2020
    Copy the full SHA
    b3b83e7 View commit details

Commits on Oct 24, 2020

  1. Copy the full SHA
    4bade02 View commit details

Commits on Oct 27, 2020

  1. Copy the full SHA
    224b7e7 View commit details
  2. Copy the full SHA
    d77cb78 View commit details

Commits on Oct 30, 2020

  1. Merge pull request #15 from markub3327/patch-1

    row_offsets calculated by columns parameter
    mathertel authored Oct 30, 2020
    Copy the full SHA
    9af188e View commit details
  2. Copy the full SHA
    1be19f2 View commit details

Commits on Dec 16, 2020

  1. User provided i2cport

    added user provided i2c port.
    changed int to uint8_t
    provided example program for custom i2c port
    uutzinger committed Dec 16, 2020
    Copy the full SHA
    db08789 View commit details

Commits on Jan 17, 2021

  1. Update to version 1.3.0

    mathertel committed Jan 17, 2021
    Copy the full SHA
    06e21ce View commit details

Commits on May 23, 2022

  1. Copy the full SHA
    53aa4e9 View commit details
  2. Copy the full SHA
    1846b27 View commit details
  3. Merge pull request #23 from markisch:fix-category

    Category of this library is "Display"
    mathertel authored May 23, 2022
    Copy the full SHA
    333d017 View commit details
  4. Merge pull request #21 from markisch:feature-command

    Add LCD API command() function
    mathertel authored May 23, 2022
    Copy the full SHA
    a024179 View commit details

Commits on May 24, 2022

  1. Add a PROGMEM variant createChar_P()

    Allow data for custom characters to be stored in PROGMEM on the AVR platform.
    Like the NewLiquidCrystal library, we also offer a variant of createChar()
    which _assumes_ PROGMEM if the data type is const.
    markisch committed May 24, 2022
    Copy the full SHA
    6d42a6d View commit details
  2. Allow arbitrary pin assignments

    Add new constructors and class variables to allow changing the pin layout.
    markisch committed May 24, 2022
    Copy the full SHA
    11971eb View commit details

Commits on May 25, 2022

  1. Merge pull request #22 from markisch:feature-createCharPgm

    Add a PROGMEM variant createCharPgm()
    mathertel authored May 25, 2022
    Copy the full SHA
    0ea7dfb View commit details
  2. Merge pull request #24 from markisch:feature-pin-assignment

    Allow arbitrary pin assignments
    mathertel authored May 25, 2022
    Copy the full SHA
    47c73a4 View commit details
  3. Use unsigned 8bit integers instead of signed int

    All function parameters need to be positive and 8bit only. So using uint8_t
    instead of signed 16bit integers not only makes the code and memory size
    smaller on 9bit platforms, but also is in line with the original
    LiquidCrystal library.
    markisch committed May 25, 2022
    Copy the full SHA
    528ec5f View commit details

Commits on May 28, 2022

  1. Merge pull request #25 from markisch/fix-int-size

    Use unsigned 8bit instead of signed 16bit integers
    mathertel authored May 28, 2022
    Copy the full SHA
    7d4cfb1 View commit details
  2. version 2.0.0 preparations

    mathertel committed May 28, 2022
    Copy the full SHA
    9fa4297 View commit details
  3. Copy the full SHA
    4cc9363 View commit details

Commits on May 30, 2022

  1. Speed up transfers

    An I2C transmission has a significant overhead of ~10+1 I2C clock cycles.
    Reducing the number of beginTransmission()/endTransmission() pairs
    from twice every nibble to once per _send() hence speeds up transmission
    times significantly.
    
    The specified I2C clock rate speed of the PCF8574 chip is 100KHz.
    Transmitting a single byte over I2C takes 9 clock ticks or 90us.
    Even if the I2C bus is operated beyond the chip's spec in fast mode
    at 400 kHz, any additional delays during transmission shorter than this
    are unnecessary.
    
    Commands are only executed after the second nibble is transmitted.
    The 37us delay after the first nibble is hence unnecessary.
    
    We now omit any additional delays and perform a transmission only once
    per _send() command. This reduces the time from 4x(11+9) = 80 cycles to
    4x9 + 11 = 47 cycles. Taking the delays into account, this changes the
    time per command from 800us + 4*38us = 952us to 470us at the default
    100kHz bus speed.
    markisch committed May 30, 2022
    Copy the full SHA
    c6c6531 View commit details

Commits on Jun 5, 2022

  1. avoid compiler warnings

    mathertel committed Jun 5, 2022
    3
    Copy the full SHA
    a61ebb2 View commit details
  2. Merge pull request #26 from markisch:feature-faster

    Speed up transfers
    mathertel authored Jun 5, 2022
    Copy the full SHA
    6e3b436 View commit details

Commits on Jun 6, 2022

  1. Copy the full SHA
    9a788c1 View commit details
  2. Copy the full SHA
    5ded6c6 View commit details

Commits on Jun 12, 2022

  1. Copy the full SHA
    da95307 View commit details
  2. Copy the full SHA
    300497e View commit details
  3. version 2.0.0 preparations

    mathertel committed Jun 12, 2022
    Copy the full SHA
    d4594d0 View commit details
  4. version 2.0.0 preparations

    mathertel committed Jun 12, 2022
    Copy the full SHA
    d628d76 View commit details

Commits on Jul 2, 2022

  1. Copy the full SHA
    5567e1d View commit details
  2. Merged with version 2.0.0

    uutzinger committed Jul 2, 2022
    Copy the full SHA
    1371920 View commit details

Commits on Aug 13, 2022

  1. Copy the full SHA
    4016ab0 View commit details

Commits on Aug 21, 2022

  1. Merge pull request #27 from uutzinger/master

    Enable using non-default i2c port.
    New example.
    mathertel authored Aug 21, 2022
    Copy the full SHA
    426468c View commit details
  2. docu

    mathertel committed Aug 21, 2022
    Copy the full SHA
    33f8726 View commit details
  3. version=2.1.0

    mathertel committed Aug 21, 2022
    Copy the full SHA
    a114a69 View commit details

Commits on Apr 2, 2023

  1. Copy the full SHA
    dfce60c View commit details
  2. version=2.1.1

    robaol committed Apr 2, 2023
    Copy the full SHA
    1d92a4c View commit details
  3. version=2.2.0

    robaol committed Apr 2, 2023
    Copy the full SHA
    1c6bc56 View commit details
  4. Copy the full SHA
    3d62fa8 View commit details

Commits on Apr 3, 2023

  1. Merge pull request #30 from robaol/master

    Provide default i2c address
    Thanks for the contribution.
    I will add some documentation too.
    mathertel authored Apr 3, 2023
    Copy the full SHA
    0745864 View commit details
  2. Copy the full SHA
    4cb67f4 View commit details
  3. docu fixed

    mathertel committed Apr 3, 2023
    Copy the full SHA
    1916b21 View commit details
98 changes: 98 additions & 0 deletions .github/workflows/arduino-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This is a basic workflow to help you get started with Actions for Arduino library projects

name: Arduino Library Checks

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [master]
pull_request:
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:

# This defines a job for checking the Arduino library format specifications
# see <https://github.com/marketplace/actions/arduino-arduino-lint-action>

lint:
name: check library format
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v2

# Arduino - lint
- name: Arduino-lint
uses: arduino/arduino-lint-action@v1
with:
library-manager: update
verbose: false

# These jobs are used to compile the examples fot the specific processor/board.
# see <https://github.com/marketplace/actions/compile-arduino-sketches>

compile-uno:
name: compile uno examples
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v2

# Compile Examples for UNO
- name: Compile examples for UNO
uses: arduino/compile-sketches@v1
with:
verbose: true
fqbn: arduino:avr:uno
sketch-paths: |
- 'examples/LiquidCrystal_PCF8574_Test'
compile-esp8266:
name: compile esp8266 examples
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v2

# Compile Examples for ESP8266
- name: Compile examples for ESP8266
uses: arduino/compile-sketches@v1
with:
verbose: true
platforms: |
# Install ESP8266 platform via Boards Manager
- name: esp8266:esp8266
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
version: 3.0.0
fqbn: esp8266:esp8266:nodemcuv2
sketch-paths: |
- 'examples/LiquidCrystal_PCF8574_Test'
compile-esp32:
name: compile ESP32 examples
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v2

# Compile Examples for ESP32
- name: Compile examples for ESP32
uses: arduino/compile-sketches@v1
with:
verbose: true
# Install ESP32 platform via Boards Manager
platforms: |
- name: "esp32:esp32"
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
version: 2.0.3
fqbn: esp32:esp32:esp32
sketch-paths: |
- 'examples/LiquidCrystal_PCF8574_Test'
31 changes: 23 additions & 8 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
Software License Agreement (BSD License)
BSD 3-Clause License

Copyright (c) 2005-2016 by Matthias Hertel, http://www.mathertel.de/
Copyright (c) 2005-2020, Matthias Hertel, http://www.mathertel.de/

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

•Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
•Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
•Neither the name of the copyright owners nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

See http://www.mathertel.de/License.aspx
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
# Arduino Library for LiquidCrystal displays with I2C PCF8574 adapter

[![Arduino Library Checks](https://github.com/mathertel/LiquidCrystal_PCF8574/actions/workflows/arduino-checks.yml/badge.svg)](https://github.com/mathertel/LiquidCrystal_PCF8574/actions/workflows/arduino-checks.yml)

[![arduino-library-badge](https://www.ardu-badge.com/badge/LiquidCrystal_PCF8574.svg?)](https://www.ardu-badge.com/LiquidCrystal_PCF8574)

A library for driving LiquidCrystal displays (LCD) by using the I2C bus and an PCF8574 I2C adapter.

There are modules that can be soldered or stacked to the display that offers a I2C interface for communication instead of the 8+ digital lines that are used to send data to the display.
There are modules that can be soldered or stacked to the display that offers an I2C interface for communication instead of the 8+ digital lines that are used to send data to the display.

Most of these modules used the internal wiring that is supported by this library. If you use a module with a different wiring you can adjust this in the code (see comments).
Most of these modules use the wiring that is supported by this library's default configuration.
If you use a module with a different wiring, you can use one of the class constructors which allow you to specify the pin assignments.

See the web site for more details and pictures: <https://www.mathertel.de/Arduino/LiquidCrystal_PCF8574.aspx>

## Changes Version 2.2.0 (2023-04-03)

The default i2c address 0x27 is set as default parameter.

You can use an explicit i2c address with

``` cpp
LiquidCrystal_PCF8574 lcd(0x22); // set the LCD address to 0x22
```
or you can rely on the default i2c address = 0x27 with
``` cpp
LiquidCrystal_PCF8574 lcd(); // use the default LCD address == 0x27
```

See datasheet of PCF8574 (and PCF8574A) for further info on usable i2c addresses.

Thanks for contribution from @robaol

## Changes Version 2.1.0 (2022-08-21)

Enables using a non-default i2c / TwoWire port for boards that support multiple ports.

Added example `LCD_Burnin.ino` showing how to transfer a 20 char and 4 lines buffer to a device all at once.

Thanks for additions from @uutzinger

## Changes Version 2.0.0 (2022-05-26)

* The interface was modified to use 8-bit datatypes as supported by the underling hardware.
* A createChar version with PROGMEM character data for AVR processors was added.
* A constructor with pin assignments was added to allow easy adoption to other wirings than the default.

Thanks for additions from @markisch.
51 changes: 51 additions & 0 deletions examples/LCD_Burnin/LCD_Burnin.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// LCD with i2c backpack test
// This example shows how to transfer an in-memory buffer to the LCD at once.
// A TwoWire instance is given as a parameter to lcd.begin to show how to pass a non default wire interface.
// Urs Utzinger, 2020

#include <Arduino.h>
#include <Wire.h>
#include "LiquidCrystal_PCF8574.h"

TwoWire Wire_1 = TwoWire();

LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27
char lcdDisplay[4][20]; // 4 lines of 20 character buffer

void setup()
{
Wire_1.begin(D1, D2); // custom i2c port on ESP
Wire_1.setClock(100000); // standard 100kHz speed
Wire_1.setClockStretchLimit(200000); // some devices might need clock stretching
lcd.begin(20,4, Wire_1);
lcd.setBacklight(255);
}

void loop()
{
char lcdbuf[21];
const char someLine[] = "0123456789ABCDEF1234"; // 20 chars

// fill the screen buffer
strncpy(&lcdDisplay[0][0], someLine , 20);
strncpy(&lcdDisplay[1][0], someLine , 20);
strncpy(&lcdDisplay[2][0], someLine , 20);
strncpy(&lcdDisplay[3][0], someLine , 20);
// prepare screen
lcd.home();
lcd.clear();
lcd.setCursor(0, 0);
// copy the buffer to the screen
// 1st line continues at 3d line
// 2nd line continues at 4th line
strncpy(lcdbuf, &lcdDisplay[0][0], 20); lcdbuf[20] = '\0'; // create a termineted text line
lcd.print(lcdbuf); // print the line to screen
strncpy(lcdbuf, &lcdDisplay[2][0], 20); lcdbuf[20] = '\0';
lcd.print(lcdbuf);
strncpy(lcdbuf, &lcdDisplay[1][0], 20); lcdbuf[20] = '\0';
lcd.print(lcdbuf);
strncpy(lcdbuf, &lcdDisplay[3][0], 20); lcdbuf[20] = '\0';
lcd.print(lcdbuf);

delay(50); // keep short to test if screen corrupts with frequent writes
}
43 changes: 30 additions & 13 deletions examples/LiquidCrystal_PCF8574_Test/LiquidCrystal_PCF8574_Test.ino
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#include <LiquidCrystal_PCF8574.h>
// This example shows various featues of the library for LCD with 16 chars and 2 lines.

#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>

LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_PCF8574 lcd(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display

int show = -1;

void setup()
{
// 2 custom characters

byte dotOff[] = { 0b00000, 0b01110, 0b10001, 0b10001,
0b10001, 0b01110, 0b00000, 0b00000 };
byte dotOn[] = { 0b00000, 0b01110, 0b11111, 0b11111,
0b11111, 0b01110, 0b00000, 0b00000 };

void setup() {
int error;

Serial.begin(115200);
@@ -16,7 +25,7 @@ void setup()
while (!Serial)
;

Serial.println("Dose: check for LCD");
Serial.println("Probing for PCF8574 on address 0x27...");

// See http://playground.arduino.cc/Main/I2cScanner how to test for a I2C device.
Wire.begin();
@@ -28,17 +37,19 @@ void setup()
if (error == 0) {
Serial.println(": LCD found.");
show = 0;
lcd.begin(16, 2); // initialize the lcd
lcd.begin(16, 2); // initialize the lcd

lcd.createChar(1, dotOff);
lcd.createChar(2, dotOn);

} else {
Serial.println(": LCD not found.");
} // if
} // if

} // setup()
} // setup()


void loop()
{
void loop() {
if (show == 0) {
lcd.setBacklight(255);
lcd.home();
@@ -96,10 +107,16 @@ void loop()
lcd.clear();
lcd.print("write-");

} else if (show > 12) {
} else if (show == 13) {
lcd.clear();
lcd.print("custom 1:<\01>");
lcd.setCursor(0, 1);
lcd.print("custom 2:<\02>");

} else {
lcd.print(show - 13);
} // if
} // if

delay(1400);
show = (show + 1) % 16;
} // loop()
} // loop()
4 changes: 3 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Datatypes (KEYWORD1)
#######################################

LiquidCrystal_PCF8574 KEYWORD1
LiquidCrystal_PCF8574 KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
@@ -29,8 +29,10 @@ autoscroll KEYWORD2
noAutoscroll KEYWORD2
setBacklight KEYWORD2
createChar KEYWORD2
createChar_P KEYWORD2
setCursor KEYWORD2
write KEYWORD2
command KEYWORD2

#######################################
# Instances (KEYWORD2)
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=LiquidCrystal_PCF8574
version=1.2.0
version=2.2.0
author=Matthias Hertel
maintainer=Matthias Hertel <www.mathertel.de>
sentence=A library for driving LiquidCrystal displays (LCD) by using the I2C bus and an PCF8574 I2C adapter.
paragraph=This library uses the original Wire library for communication.
category=Communication
category=Display
url=https://www.mathertel.de/Arduino/LiquidCrystal_PCF8574.aspx
architectures=*
Loading