Skip to content

Martin4017/LCDShiftView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LCDShiftView

Lightweight Arduino library to control HD44780-compatible LCDs through a 74HC595 shift register.

Overview

LCDShiftView reduces wiring to 3 Arduino pins (data, clock, latch) while keeping common LiquidCrystal-style controls.

It also includes helper APIs to make screen updates easier without extra code in user sketches.

Features

  • Works with standard HD44780 LCDs (16x2, 20x4, etc.)
  • 3-wire control through one 74HC595
  • Flexible mapping for LCD pins (RS, E, D4..D7)
  • Backlight control
  • Custom characters
  • Fast internal write path and reduced overhead for small boards
  • Extra helper methods: printAt, writeAt, clearRow, clearArea, printPadded, printCentered, printfAt, setRowOffsets
  • Runtime tuning: setBacklightBit, setTimings, and begin(..., backlightOn)

Wiring

Typical mapping:

LCD Pin Connect to 74HC595
RS Q0
E Q1
D4 Q2
D5 Q3
D6 Q4
D7 Q5
BL (optional) Q7

74HC595 to Arduino:

74HC595 Pin Arduino
DS Data pin
SHCP Clock pin
STCP Latch pin

Basic Example

#include <LCDShiftView.h>

const uint8_t dataPin  = 10;
const uint8_t clockPin = 11;
const uint8_t latchPin = 12;

LCDShiftView lcd(dataPin, clockPin, latchPin);

void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello");
}

void loop() {
}

Helper Methods (New)

printAt(col, row, text)

Print text directly at a specific location.

lcd.printAt(0, 0, "Temp:");

writeAt(col, row, value)

Write one byte/character at a location.

lcd.writeAt(15, 1, '*');

clearRow(row, fill = ' ')

Fill one row with a character (default is space).

lcd.clearRow(1);          // clear row 1
lcd.clearRow(0, '-');     // fill row with '-'

clearArea(col, row, width, height = 1, fill = ' ')

Fill a rectangular area.

lcd.clearArea(5, 0, 6);          // clear 6 chars in row 0
lcd.clearArea(0, 0, 16, 2, '.'); // fill full 16x2 with dots

printPadded(col, row, text, width, fill = ' ')

Print text in fixed width and fill remaining space.

lcd.printPadded(6, 0, "27.3C", 10);  // overwrites old longer values cleanly
lcd.printPadded(0, 1, F("READY"), 16, ' ');

printCentered(row, text)

Center text in a row.

lcd.printCentered(0, "READY");
lcd.printCentered(1, F("WAIT"));

printfAt(col, row, format, ...)

Print formatted values at a fixed location.

lcd.printfAt(0, 1, "V=%d I=%d", volts, amps);

setRowOffsets(r0, r1, r2, r3)

Set custom DDRAM row offsets for non-standard displays.

lcd.setRowOffsets(0x00, 0x40, 0x14, 0x54);

setBacklightBit(bit)

Use a different 74HC595 output bit for backlight control.

lcd.setBacklightBit(7); // default

setTimings(execUs, clearHomeUs)

Tune instruction delays for specific LCD modules.

lcd.setTimings(37, 1520);

Core API

  • begin(cols, rows, charsize = 0x00)
  • begin(cols, rows, charsize, backlightOn)
  • clear(), home()
  • clearRow(...), clearArea(...)
  • setCursor(col, row), printAt(...), writeAt(...), printfAt(...)
  • print(...), println(...), write(...)
  • display(), noDisplay()
  • cursor(), noCursor()
  • blink(), noBlink()
  • scrollDisplayLeft(), scrollDisplayRight()
  • leftToRight(), rightToLeft()
  • autoscroll(), noAutoscroll()
  • createChar(location, charmap)
  • backlight(state)
  • setBacklightBit(bit)
  • setPins(rs, e, d4, d5, d6, d7)
  • setRowOffsets(r0, r1, r2, r3)
  • setTimings(execUs, clearHomeUs)
  • getRowOffset(row) (deprecated)

Notes

  • For very small MCUs, prefer const char* / F("...") for constant text.
  • Repeatedly printing dynamic values is easier with printPadded to avoid leftover characters.
  • If your LCD has unusual row layout, use setRowOffsets.
  • printfAt uses a configurable buffer size via LCDSHIFTVIEW_PRINTF_BUFFER (default 64).

New Examples

  • examples/HelpersQuick/HelpersQuick.ino: printAt, writeAt, printCentered
  • examples/RowHelpers/RowHelpers.ino: clearRow, printPadded
  • examples/CustomRowOffsets/CustomRowOffsets.ino: setRowOffsets, getRowOffset
  • examples/AdvancedInit/AdvancedInit.ino: begin(..., backlightOn), setBacklightBit, setTimings
  • examples/ClearArea/ClearArea.ino: clearArea
  • examples/PrintfAt/PrintfAt.ino: printfAt
  • examples/FlashHelpers/FlashHelpers.ino: helper methods with F("...")

License

See LICENSE.

About

LCDShiftView.h let you use LCD via Shift Register (74HC595)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages