From bd825d3ec9e093b0197a9f53f2967b9d2898e376 Mon Sep 17 00:00:00 2001 From: miclol Date: Fri, 12 Jan 2024 21:27:59 -0800 Subject: [PATCH 1/2] Added setSegmentsDigit Function --- SevSeg.cpp | 10 ++++++++++ SevSeg.h | 1 + 2 files changed, 11 insertions(+) diff --git a/SevSeg.cpp b/SevSeg.cpp index 46d5921..4dcd60b 100644 --- a/SevSeg.cpp +++ b/SevSeg.cpp @@ -433,6 +433,16 @@ void SevSeg::setSegments(const uint8_t segs[]) { } } +// setSegmentsDigit +/******************************************************************************/ +// Like setSegments above, but only manipulates the segments for one digit +// digitNum is 0-indexed. +void SevSeg::setSegmentsDigit(const uint8_t digitNum, const uint8_t segs) { + if (digitNum < numDigits) { + digitCodes[digitNum] = segs; + } +} + // getSegments /******************************************************************************/ // Gets the 'digitCodes' of currently displayed segments. diff --git a/SevSeg.h b/SevSeg.h index fcc0451..7ef224d 100644 --- a/SevSeg.h +++ b/SevSeg.h @@ -49,6 +49,7 @@ class SevSeg void setSegments(const uint8_t segs[]); void getSegments(uint8_t segs[]); + void setSegmentsDigit(const uint8_t digitNum, const uint8_t segs); void setChars(const char str[]); void blank(void); From f364aac2ea70711bde84027d73eb72d5dd3bdf54 Mon Sep 17 00:00:00 2001 From: miclol Date: Fri, 12 Jan 2024 21:58:07 -0800 Subject: [PATCH 2/2] Changed README.md and keywords.txt --- README.md | 11 +++++++++++ keywords.txt | 1 + 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index e27fb36..4c64a63 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,17 @@ To blank the display, call: sevseg.blank(); ``` +### Custom display setting +```c++ +// Set the segments for every digit on the display +uint8_t segs[4] = {0, 0x5B, 0x6D, 0x63}; +sevseg.setSegments(segs); +``` +```c++ +// Set the segments for a single digit. Set digit 3 to 0x63. +sevseg.setSegmentsDigit(3, 0x63); +``` +You can manipulate individual segments if needed. Each byte represents the display of a single digit, with each bit representing a single segment. The bits represent segments in the order .GFEDCBA. See SevSeg.cpp for more examples of these 'digitCodes'. ### Setting the brightness diff --git a/keywords.txt b/keywords.txt index fe678ae..776ff5b 100644 --- a/keywords.txt +++ b/keywords.txt @@ -6,6 +6,7 @@ refreshDisplay KEYWORD2 setBrightness KEYWORD2 getSegments KEYWORD2 setSegments KEYWORD2 +setSegmentsDigit KEYWORD2 setChars KEYWORD2 blank KEYWORD2 COMMON_CATHODE LITERAL1