From d70b6c9d40c790aeef5f06c5d48600c389f2afa5 Mon Sep 17 00:00:00 2001 From: Steve Jernigan Date: Mon, 29 Jan 2024 16:18:11 -0500 Subject: [PATCH 1/2] keywords.txt --- src/ShiftRegister74HC595.h | 1 + src/ShiftRegister74HC595.hpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/ShiftRegister74HC595.h b/src/ShiftRegister74HC595.h index ac78fdf..9f8cfeb 100755 --- a/src/ShiftRegister74HC595.h +++ b/src/ShiftRegister74HC595.h @@ -16,6 +16,7 @@ class ShiftRegister74HC595 ShiftRegister74HC595(const uint8_t serialDataPin, const uint8_t clockPin, const uint8_t latchPin); void setAll(const uint8_t * digitalValues); + void setRegister(const uint8_t reg, const uint8_t digitalValues); #ifdef __AVR__ void setAll_P(const uint8_t * digitalValuesProgmem); // Experimental, PROGMEM data #endif diff --git a/src/ShiftRegister74HC595.hpp b/src/ShiftRegister74HC595.hpp index cb88886..2d40641 100644 --- a/src/ShiftRegister74HC595.hpp +++ b/src/ShiftRegister74HC595.hpp @@ -40,6 +40,17 @@ void ShiftRegister74HC595::setAll(const uint8_t * digitalValues) updateRegisters(); } +// Set all pins of a single shift registers at once. +// digitalVAlues is a uint8_t, reg is a uint8_t from 0 to Size -1 +template +void ShiftRegister74HC595::setRegister(const uint8_t reg, const uint8_t digitalValues) +{ + if (reg >=0 && reg < Size) { + memcpy( _digitalValues + reg, &digitalValues, 1); // dest, src, size + updateRegisters(); + } +} + // Experimental // The same as setAll, but the data is located in PROGMEM // For example with: From d311db4ef3b0331e31facb458203e2bdf8844cbe Mon Sep 17 00:00:00 2001 From: Steve Jernigan Date: Mon, 29 Jan 2024 16:21:18 -0500 Subject: [PATCH 2/2] Added ability to set a single register so you can build 7 segment displays on top of this library --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index 4711e16..23a09a0 100755 --- a/keywords.txt +++ b/keywords.txt @@ -1,6 +1,7 @@ ShiftRegister74HC595 KEYWORD1 setAll KEYWORD2 setAll_P KEYWORD2 +setRegister KEYWORD2 getAll KEYWORD2 set KEYWORD2 setNoUpdate KEYWORD2