Skip to content

Commit f1813ed

Browse files
committed
Corrected an issue where the display color of high temperature areas becomes saturated and becomes low temperature color.
1 parent 0d9076d commit f1813ed

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lib_deps = bblanchon/ArduinoJson
2727
build_type = release
2828
build_flags = -DCORE_DEBUG_LEVEL=0 -O3
2929
extra_scripts = post:generate_user_custom.py
30-
custom_firmware_version = 0.0.10
30+
custom_firmware_version = 0.0.11
3131
custom_firmware_name = TLite-FW
3232
custom_firmware_suffix = .bin
3333
custom_firmware_dir = r:\

src/common_header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
static constexpr const uint8_t firmware_ver_major = 0;
77
static constexpr const uint8_t firmware_ver_minor = 0;
8-
static constexpr const uint8_t firmware_ver_patch = 10;
8+
static constexpr const uint8_t firmware_ver_patch = 11;
99

1010
static constexpr uint8_t frame_width = 32;
1111
static constexpr uint8_t frame_height = 24;

src/main.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,14 +2234,15 @@ class image_ui_t : public ui_base_t {
22342234
int32_t v0;
22352235
int32_t v1 = ((param->frame->pixel_raw[(fy - 1) * frame_width] -
22362236
param->range_temp_lower)
2237-
<< 16) /
2238-
boxHeight;
2237+
<< 8) /
2238+
param->temp_diff;
2239+
v1 = (v1 < 0) ? 0 : (v1 > 255) ? 255 : v1;
22392240
int32_t v2;
22402241
int32_t v3 = ((param->frame->pixel_raw[(fy)*frame_width] -
22412242
param->range_temp_lower)
2242-
<< 16) /
2243-
boxHeight;
2244-
2243+
<< 8) /
2244+
param->temp_diff;
2245+
v3 = (v3 < 0) ? 0 : (v3 > 255) ? 255 : v3;
22452246
int32_t x1 = 0;
22462247
for (int32_t fx = 1; fx < frame_width; ++fx) {
22472248
int32_t x0 = x1;
@@ -2250,15 +2251,17 @@ class image_ui_t : public ui_base_t {
22502251
v0 = v1;
22512252
v1 = ((param->frame->pixel_raw[fx + (fy - 1) * frame_width] -
22522253
param->range_temp_lower)
2253-
<< 16) /
2254-
boxHeight;
2254+
<< 8) /
2255+
param->temp_diff;
2256+
v1 = (v1 < 0) ? 0 : (v1 > 255) ? 255 : v1;
22552257
v2 = v3;
22562258
v3 = ((param->frame->pixel_raw[fx + (fy)*frame_width] -
22572259
param->range_temp_lower)
2258-
<< 16) /
2259-
boxHeight;
2260+
<< 8) /
2261+
param->temp_diff;
2262+
v3 = (v3 < 0) ? 0 : (v3 > 255) ? 255 : v3;
22602263
if (boxWidth == 0) continue;
2261-
int32_t divider = boxWidth * param->temp_diff;
2264+
uint32_t mul = (1 << 16) / (boxWidth * boxHeight);
22622265

22632266
int32_t ypos = y0 - canvas_y;
22642267
int32_t by = 0;
@@ -2268,18 +2271,15 @@ class image_ui_t : public ui_base_t {
22682271
}
22692272
for (; by < boxHeight && ypos < canvas->height();
22702273
++by, ++ypos) {
2271-
int32_t v02 = (v0 * (boxHeight - by) + v2 * by) / divider;
2272-
int32_t v13 = (v1 * (boxHeight - by) + v3 * by) / divider;
2274+
uint32_t v02 = (v0 * (boxHeight - by) + v2 * by) * mul;
2275+
uint32_t v13 = (v1 * (boxHeight - by) + v3 * by) * mul;
22732276
auto img_buf =
22742277
&((m5gfx::swap565_t*)
22752278
canvas->getBuffer())[_client_rect.x + x0 +
22762279
ypos * canvas->width()];
22772280
for (int32_t bx = 0; bx < boxWidth; ++bx) {
2278-
int32_t v = (v02 * (boxWidth - bx) + v13 * bx) >> 8;
2279-
img_buf[bx] = m5gfx::getSwap16(
2280-
(param->color_map[(v < 0) ? 0
2281-
: (v > 255) ? 255
2282-
: v]));
2281+
uint32_t v = (v02 * (boxWidth - bx) + v13 * bx) >> 16;
2282+
img_buf[bx] = m5gfx::getSwap16(param->color_map[v]);
22832283
}
22842284
}
22852285
}

0 commit comments

Comments
 (0)