Merge pull request #3683 from tonhuisman/feature/p057-support-period-to-display

[P057] Add support for periods in display
This commit is contained in:
TD-er
2021-07-17 19:04:53 +02:00
committed by GitHub
3 changed files with 14 additions and 7 deletions
+4 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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);
+9 -5
View File
@@ -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;