mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge pull request #3683 from tonhuisman/feature/p057-support-period-to-display
[P057] Add support for periods in display
This commit is contained in:
@@ -68,7 +68,7 @@ uint16_t CHT16K33::GetRow(uint8_t com)
|
||||
return 0;
|
||||
};
|
||||
|
||||
void CHT16K33::SetDigit(uint8_t com, uint8_t c)
|
||||
void CHT16K33::SetDigit(uint8_t com, uint8_t c, bool setDot)
|
||||
{
|
||||
uint16_t value = 0;
|
||||
|
||||
@@ -115,6 +115,9 @@ void CHT16K33::SetDigit(uint8_t com, uint8_t c)
|
||||
value = 0x40;
|
||||
break;
|
||||
}
|
||||
if (setDot) {
|
||||
value |= 0x80; // Set the dot-bit
|
||||
}
|
||||
|
||||
SetRow(com, value);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class CHT16K33 {
|
||||
void ClearRowBuffer(void);
|
||||
void SetRow(uint8_t com, uint16_t data);
|
||||
uint16_t GetRow(uint8_t com);
|
||||
void SetDigit(uint8_t com, uint8_t c);
|
||||
void SetDigit(uint8_t com, uint8_t c, bool setDot = false);
|
||||
|
||||
// LED output and control
|
||||
void SetBrightness(uint8_t b);
|
||||
|
||||
@@ -180,17 +180,21 @@ boolean Plugin_057(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
String text = parseStringToEnd(string, 2);
|
||||
|
||||
if (text.length() > 0) {
|
||||
if (!text.isEmpty()) {
|
||||
uint8_t seg = 0;
|
||||
uint8_t txt = 0; // Separate indexers for text and segments
|
||||
bool setDot;
|
||||
|
||||
P057_data->ledMatrix.ClearRowBuffer();
|
||||
|
||||
while (text[seg] && seg < 8)
|
||||
while (txt < text.length() && text[txt] && seg < 8)
|
||||
{
|
||||
// uint16_t value = 0;
|
||||
char c = text[seg];
|
||||
P057_data->ledMatrix.SetDigit(seg, c);
|
||||
setDot = (txt < text.length() - 1 && text[txt + 1] == '.');
|
||||
char c = text[txt];
|
||||
P057_data->ledMatrix.SetDigit(seg, c, setDot);
|
||||
seg++;
|
||||
txt++;
|
||||
if (setDot) { txt++; } // extra increment to skip past the dot
|
||||
}
|
||||
P057_data->ledMatrix.TransmitRowBuffer();
|
||||
success = true;
|
||||
|
||||
Reference in New Issue
Block a user