Skip to content

Commit c8e29da

Browse files
committed
Changed ESP32 TM1621 number overflow from "9999" to "12E3" (#21131)
1 parent 2cc785b commit c8e29da

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ All notable changes to this project will be documented in this file.
99
- Berry `tasmota.rtc("config_time")` (#21698)
1010
- Berry `math.min()` and `math.max()` (#21705)
1111
- Berry `FUNC_ANY_KEY` event calling `any_key()` (#21708)
12-
- Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes and once per second
12+
- Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes and once per second (#21711)
1313

1414
### Breaking Changed
1515

1616
### Changed
1717
- ESP32 support for energy margin checks, like ``MaxPower2`` per phase (#21695)
18+
- ESP32 TM1621 number overflow from "9999" to "12E3" (#21131)
1819

1920
### Fixed
2021

RELEASENOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
132132
- Berry `tasmota.rtc("config_time")` [#21698](https://github.com/arendst/Tasmota/issues/21698)
133133
- Berry `math.min()` and `math.max()` [#21705](https://github.com/arendst/Tasmota/issues/21705)
134134
- Berry `FUNC_ANY_KEY` event calling `any_key()` [#21708](https://github.com/arendst/Tasmota/issues/21708)
135+
- Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes and once per second [#21711](https://github.com/arendst/Tasmota/issues/21711)
135136
- HASPmota rounds to nearest int values passed as 'real' [#21599](https://github.com/arendst/Tasmota/issues/21599)
136137
- Matter support for Air Quality sensors [#21559](https://github.com/arendst/Tasmota/issues/21559)
137138
- Matter support for bridged Air Quality [#21597](https://github.com/arendst/Tasmota/issues/21597)
@@ -155,6 +156,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
155156
- ESP32 support for energy margin checks, like ``MaxPower2`` per phase [#21695](https://github.com/arendst/Tasmota/issues/21695)
156157
- ESP32 MI32 refactoring, bugfixes, generic device scanning [#21603](https://github.com/arendst/Tasmota/issues/21603)
157158
- ESP32 MI32 improve parser [#21648](https://github.com/arendst/Tasmota/issues/21648)
159+
- ESP32 TM1621 number overflow from "9999" to "12E3" [#21131](https://github.com/arendst/Tasmota/issues/21131)
158160
- Matter refactoring of bridged devices [#21575](https://github.com/arendst/Tasmota/issues/21575)
159161
- Matter filter suffix automatically added for sensors [#21589](https://github.com/arendst/Tasmota/issues/21589)
160162
- Matter support for Rain sensor [#21633](https://github.com/arendst/Tasmota/issues/21633)

tasmota/tasmota_xdrv_driver/xdrv_87_esp32_sonoff_tm1621.ino

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ enum Tm1621Units { TM1621_NONE, TM1621_TEMPERATURE, TM1621_HUMIDITY, TM1621_VOL
5656

5757
const uint8_t tm1621_commands[] = { TM1621_SYS_EN, TM1621_LCD_ON, TM1621_BIAS, TM1621_TIMER_DIS, TM1621_WDT_DIS, TM1621_TONE_OFF, TM1621_IRQ_DIS };
5858

59-
const char tm1621_kchar[] PROGMEM = { "0|1|2|3|4|5|6|7|8|9|-| " };
60-
// 0 1 2 3 4 5 6 7 8 9 - off
61-
const uint8_t tm1621_digit_row[2][12] = {{ 0x5F, 0x50, 0x3D, 0x79, 0x72, 0x6B, 0x6F, 0x51, 0x7F, 0x7B, 0x20, 0x00 },
62-
{ 0xF5, 0x05, 0xB6, 0x97, 0x47, 0xD3, 0xF3, 0x85, 0xF7, 0xD7, 0x02, 0x00 }};
59+
const char tm1621_kchar[] PROGMEM = { "0|1|2|3|4|5|6|7|8|9|-|E| " };
60+
// 0 1 2 3 4 5 6 7 8 9 - E off
61+
const uint8_t tm1621_digit_row[2][13] = {{ 0x5F, 0x50, 0x3D, 0x79, 0x72, 0x6B, 0x6F, 0x51, 0x7F, 0x7B, 0x20, 0x2F, 0x00 },
62+
{ 0xF5, 0x05, 0xB6, 0x97, 0x47, 0xD3, 0xF3, 0x85, 0xF7, 0xD7, 0x02, 0xF2, 0x00 }};
6363

6464
struct Tm1621 {
6565
uint8_t buffer[8];
@@ -230,23 +230,26 @@ void TM1621SendCommon(uint8_t common) {
230230

231231
void TM1621SendRows(void) {
232232
// Tm1621.row[x] = "text", "----", " " or a number with one decimal like "0.4", "237.5", "123456.7"
233-
// "123456.7" will be shown as "9999" being a four digit overflow
233+
// "123456.7" will be shown as "12E4" being a four digit overflow
234234

235235
// AddLog(LOG_LEVEL_DEBUG, PSTR("TM1: Row1 '%s', Row2 '%s'"), Tm1621.row[0], Tm1621.row[1]);
236236

237237
uint8_t buffer[8] = { 0 }; // TM1621 16-segment 4-bit common buffer
238238
char row[4];
239239
for (uint32_t j = 0; j < 2; j++) {
240-
// 0.4V => " 04", 0.0A => " ", 1234.5V => "1234"
240+
// 0.4V => " 04", 0.0A => " ", 1234.5V => "1234", 12345.6V => "12E3"
241241
uint32_t len = strlen(Tm1621.row[j]);
242242
char *dp = nullptr; // Expect number larger than "123"
243243
int row_idx = len -3; // "1234.5"
244244
if (len <= 5) { // "----", " ", "0.4", "237.5"
245245
dp = strchr(Tm1621.row[j], '.');
246246
row_idx = len -1;
247-
}
248-
else if (len > 6) { // "12345.6"
249-
snprintf_P(Tm1621.row[j], sizeof(Tm1621.row[j]), PSTR("9999"));
247+
} else { // "12345.6" = "12E3"
248+
if (len > 13) { // "123456789012.3" = "12E9"
249+
len = 13;
250+
}
251+
Tm1621.row[j][2] = 'E';
252+
Tm1621.row[j][3] = '0' + len -4;
250253
row_idx = 3;
251254
}
252255
row[3] = (row_idx >= 0) ? Tm1621.row[j][row_idx--] : ' ';

0 commit comments

Comments
 (0)