Skip to content

Commit 628155c

Browse files
committedFeb 1, 2025
Add arrow buttons on thermography screen.
1 parent ad338b9 commit 628155c

8 files changed

+793
-677
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
# Mac special files
66
*/.DS_store
77
*/._*
8+
9+
widgets/*
10+

‎MLX90640.ino

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77
#include <Arduino.h>
88
#include "pin_assign.h"
99

10-
#define DEBUG true
10+
/*--------------------------------------------------------------------------------
11+
* Step 1: Configure serial output for debugging
12+
*--------------------------------------------------------------------------------*/
13+
#define DEBUG false
1114
#if DEBUG
1215
#define DBG_EXEC(x) x
1316
#else
1417
#define DBG_EXEC(x)
1518
#endif
1619

1720
/*--------------------------------------------------------------------------------
18-
* Step 1: Configure Operational settings
21+
* Step 2: Configure Operational settings
1922
*--------------------------------------------------------------------------------*/
2023
#define ENA_INTERPOLATION true // Enable interpolation
2124
#define ENA_MULTITASKING true // Enable multi-task by FreeRTOS
2225
#define ENA_OUTWARD_CAMERA false // Camera orientation (true: Outward, false: Selfie)
2326

2427
/*--------------------------------------------------------------------------------
25-
* Step 2: Select GFX Library
28+
* Step 3: Select GFX Library
2629
*--------------------------------------------------------------------------------*/
2730
#if 1
2831
/*--------------------------------------------------------------------------------
@@ -46,12 +49,12 @@
4649
#endif
4750

4851
/*--------------------------------------------------------------------------------
49-
* Step 3: Configure flash memory setting to save touch calibration data
52+
* Step 4: Configure flash memory setting to save touch calibration data
5053
*--------------------------------------------------------------------------------*/
51-
#define USE_PREFERENCES true
54+
#define USE_PREFERENCES false
5255

5356
/*--------------------------------------------------------------------------------
54-
* Step 4: Configure MLX90640 settings
57+
* Configure MLX90640 settings
5558
*--------------------------------------------------------------------------------*/
5659
#if ENA_INTERPOLATION
5760
#define INTERPOLATE_SCALE 8

‎images/CYD-CN1.jpg

90.6 KB
Loading

‎images/MLX90640-SCL.jpg

75.6 KB
Loading

‎touch.hpp

+39-21
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
*--------------------------------------------------------------------------------*/
88
typedef struct TouchConfig {
99
// Member variables
10-
uint16_t cal[8];
11-
int8_t offset[2];
10+
#if defined (LOVYANGFX_HPP_) || defined (_TFT_eSPIH_)
11+
uint16_t cal[8];
12+
#elif defined (_XPT2046_Touchscreen_h_)
13+
float cal[8];
14+
#else
15+
#error Unsupported touch screen library
16+
#endif
17+
int8_t offset[2];
1218

1319
// Comparison operator
1420
bool operator >= (TouchConfig &RHS) {
@@ -28,20 +34,30 @@ typedef struct TouchConfig {
2834
*--------------------------------------------------------------------------------*/
2935
TouchConfig_t tch_cnf = {
3036
#if defined (LOVYANGFX_HPP_)
37+
38+
// LovyanGFX
3139
.cal = { 0, 0, 0, 0, 0, 0, 0, 0 },
40+
3241
#elif defined (_TFT_eSPIH_)
42+
43+
// TFT_eSPI
3344
.cal = { 0, 0, 0, 0, 0, },
45+
3446
#else // defined (_XPT2046_Touchscreen_h_)
47+
48+
// XPT2046_Touchscreen
3549
.cal = { 0, },
50+
3651
#endif
52+
3753
.offset = { 0, },
3854
};
3955

4056
/*--------------------------------------------------------------------------------
4157
* Event definition
4258
*--------------------------------------------------------------------------------*/
43-
#define PERIOD_DEBOUNCE 25 // [msec]
44-
#define PERIOD_TOUCHED 50 // [msec]
59+
#define PERIOD_DEBOUNCE 25 // [msec]
60+
#define PERIOD_TOUCHED 50 // [msec]
4561
#define PERIOD_TAP2 200 // [msec]
4662
#define PERIOD_CLEAR_EVENT 100 // [msec]
4763

@@ -51,7 +67,7 @@ typedef enum {
5167
EVENT_FALLING = (0x02), // untouch --> touch
5268
EVENT_TOUCHED = (0x04), // touch --> touch
5369
EVENT_TAP2 = (0x08), // double tap
54-
EVENT_WATCH = (0x10), // execute a callback every watch cycle
70+
EVENT_EXPAND = (0x10), // not a touch event, but define for convenience
5571

5672
// alias
5773
EVENT_INIT = (EVENT_NONE),
@@ -63,6 +79,8 @@ typedef enum {
6379
EVENT_CHANGE = (EVENT_FALLING | EVENT_RISING),
6480
EVENT_SELECT = (EVENT_FALLING | EVENT_TAP2),
6581
EVENT_ALL = (EVENT_FALLING | EVENT_RISING | EVENT_TOUCHED),
82+
EVENT_WATCH = (EVENT_EXPAND), // watch events on a specific screen
83+
EVENT_SHOW = (EVENT_EXPAND), // show something on a specific screen
6684
} Event_t;
6785

6886
typedef struct Touch {
@@ -221,6 +239,10 @@ void touch_clear(void) {
221239
* Calibrating the touch panel
222240
*--------------------------------------------------------------------------------*/
223241
void touch_calibrate(TouchConfig_t *config) {
242+
if (!Serial) {
243+
Serial.begin(115200);
244+
}
245+
224246
#if defined (_XPT2046_Touchscreen_h_)
225247

226248
#elif defined (LOVYANGFX_HPP_)
@@ -233,14 +255,12 @@ void touch_calibrate(TouchConfig_t *config) {
233255
GFX_EXEC(setTextDatum(textdatum_t::top_left));
234256
GFX_EXEC(calibrateTouch(config->cal, TFT_WHITE, TFT_BLACK, std::max(lcd_width, lcd_height) >> 3));
235257

236-
DBG_EXEC({
237-
printf("\n// LovyanGFX\n");
238-
printf(".cal = { ");
239-
for (uint8_t i = 0; i < 8; ++i) {
240-
printf("%d\n", config->cal[i]);
241-
printf(i < 7 ? ", " : " },\n");
242-
}
243-
});
258+
printf("\n// LovyanGFX\n");
259+
printf(".cal = { ");
260+
for (uint8_t i = 0; i < 8; ++i) {
261+
printf("%d", config->cal[i]);
262+
printf(i < 7 ? ", " : " },\n");
263+
}
244264

245265
#elif defined (_TFT_eSPIH_)
246266

@@ -252,14 +272,12 @@ void touch_calibrate(TouchConfig_t *config) {
252272
GFX_EXEC(println("Touch corners in order"));
253273
GFX_EXEC(calibrateTouch(config->cal, TFT_MAGENTA, TFT_BLACK, 15));
254274

255-
DBG_EXEC({
256-
printf("\n// TFT_eSPI\n");
257-
printf(".cal = { ");
258-
for (uint8_t i = 0; i < 5; ++i) {
259-
printf("%d\n", config->cal[i]);
260-
printf(i < 4 ? ", " : "0, },\n");
261-
}
262-
});
275+
printf("\n// TFT_eSPI\n");
276+
printf(".cal = { ");
277+
for (uint8_t i = 0; i < 5; ++i) {
278+
printf("%d", config->cal[i]);
279+
printf(i < 4 ? ", " : "0, },\n");
280+
}
263281

264282
#endif
265283

‎widget.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static Widget_t const *focus = NULL;
5353
* Event message to command initialization
5454
*--------------------------------------------------------------------------------*/
5555
static constexpr Touch_t doInit = { EVENT_INIT, 0, 0 };
56+
static constexpr Touch_t showRange = { EVENT_SHOW, 0, 0 };
5657

5758
/*--------------------------------------------------------------------------------
5859
* Functions prototyping

‎widgets.h

+588-590
Large diffs are not rendered by default.

‎widgets.hpp

+153-60
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.