Skip to content

Commit 41df7ef

Browse files
authored
Merge branch 'develop' into pioarduino
2 parents e49dab1 + fcb9ec0 commit 41df7ef

5 files changed

Lines changed: 154 additions & 149 deletions

File tree

variants/esp32s3/m5stack_cardputer_adv/variant.cpp renamed to src/platform/extra_variants/m5stack_cardputer_adv/variant.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
#include "AudioBoard.h"
21
#include "configuration.h"
32

3+
#ifdef M5STACK_CARDPUTER_ADV
4+
5+
#include "AudioBoard.h"
6+
47
DriverPins PinsAudioBoardES8311;
58
AudioBoard board(AudioDriverES8311, PinsAudioBoardES8311);
69

@@ -38,3 +41,5 @@ void lateInitVariant()
3841
es8311_write_reg(0x32, 0xBF); // DAC volume (0dB)
3942
es8311_write_reg(0x37, 0x08); // EQ bypass
4043
}
44+
45+
#endif
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#include "configuration.h"
2+
3+
#ifdef T5_S3_EPAPER_PRO
4+
5+
#include "Observer.h"
6+
#include "TouchDrvGT911.hpp"
7+
#include "Wire.h"
8+
#include "input/InputBroker.h"
9+
#include "input/TouchScreenImpl1.h"
10+
#include "sleep.h"
11+
12+
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
13+
#include "graphics/niche/InkHUD/InkHUD.h"
14+
#include "graphics/niche/InkHUD/SystemApplet.h"
15+
16+
// Bridges touch events from TouchScreenImpl1 directly into InkHUD,
17+
// bypassing the InputBroker (which is excluded in InkHUD builds).
18+
// Routing mirrors the mini-epaper-s3 two-way rocker pattern:
19+
// - Nav left/right: prevApplet/nextApplet when idle, navUp/Down when a system applet has focus (e.g. menu)
20+
// - Nav up/down: navUp/navDown always (menu scroll)
21+
// - Tap: shortpress (cycle applets / confirm in menu)
22+
// - Long press: longpress (open menu / back)
23+
class TouchInkHUDBridge : public Observer<const InputEvent *>
24+
{
25+
int onNotify(const InputEvent *e) override
26+
{
27+
auto *inkhud = NicheGraphics::InkHUD::InkHUD::getInstance();
28+
29+
// Keep alignment in sync with the current rotation so that visual-frame gestures
30+
// always pass through nav functions without remapping: (rotation + alignment) % 4 == 0.
31+
inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4;
32+
33+
// Check whether a system applet (e.g. menu) is currently handling input
34+
bool systemHandlingInput = false;
35+
for (NicheGraphics::InkHUD::SystemApplet *sa : inkhud->systemApplets) {
36+
if (sa->handleInput) {
37+
systemHandlingInput = true;
38+
break;
39+
}
40+
}
41+
42+
switch (e->inputEvent) {
43+
case INPUT_BROKER_USER_PRESS:
44+
inkhud->shortpress();
45+
break;
46+
case INPUT_BROKER_SELECT:
47+
inkhud->longpress();
48+
break;
49+
case INPUT_BROKER_LEFT:
50+
if (systemHandlingInput)
51+
inkhud->navUp();
52+
else
53+
inkhud->prevApplet();
54+
break;
55+
case INPUT_BROKER_RIGHT:
56+
if (systemHandlingInput)
57+
inkhud->navDown();
58+
else
59+
inkhud->nextApplet();
60+
break;
61+
case INPUT_BROKER_UP:
62+
inkhud->navUp();
63+
break;
64+
case INPUT_BROKER_DOWN:
65+
inkhud->navDown();
66+
break;
67+
default:
68+
break;
69+
}
70+
return 0;
71+
}
72+
};
73+
74+
static TouchInkHUDBridge touchBridge;
75+
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
76+
77+
TouchDrvGT911 touch;
78+
79+
// Commands the GT911 into standby before the Wire bus is torn down.
80+
// notifyDeepSleep fires before Wire.end() in doDeepSleep(), so I2C is still available here.
81+
struct TouchDeepSleepObserver {
82+
int onDeepSleep(void *)
83+
{
84+
touch.sleep();
85+
return 0;
86+
}
87+
CallbackObserver<TouchDeepSleepObserver, void *> observer{this, &TouchDeepSleepObserver::onDeepSleep};
88+
} static touchDeepSleepObserver;
89+
90+
bool readTouch(int16_t *x, int16_t *y)
91+
{
92+
if (!digitalRead(GT911_PIN_INT)) {
93+
int16_t raw_x;
94+
int16_t raw_y;
95+
if (touch.getPoint(&raw_x, &raw_y)) {
96+
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
97+
// Transform raw GT911 axes to visual-frame coordinates for the current display rotation.
98+
// rotation=3 is the physical identity (device's default orientation).
99+
switch (NicheGraphics::InkHUD::InkHUD::getInstance()->persistence->settings.rotation) {
100+
default:
101+
case 3:
102+
*x = raw_x;
103+
*y = raw_y;
104+
break; // identity
105+
case 2:
106+
*x = (EPD_WIDTH - 1) - raw_y;
107+
*y = raw_x;
108+
break; // 90° CW tilt
109+
case 1:
110+
*x = (EPD_HEIGHT - 1) - raw_x;
111+
*y = (EPD_WIDTH - 1) - raw_y;
112+
break; // 180° flip
113+
case 0:
114+
*x = raw_y;
115+
*y = (EPD_HEIGHT - 1) - raw_x;
116+
break; // 90° CCW tilt
117+
}
118+
#else
119+
*x = raw_x;
120+
*y = raw_y;
121+
#endif
122+
LOG_DEBUG("touched(%d/%d)", *x, *y);
123+
return true;
124+
}
125+
}
126+
return false;
127+
}
128+
129+
// T5-S3-ePaper Pro specific (late-) init
130+
void lateInitVariant(void)
131+
{
132+
touch.setPins(GT911_PIN_RST, GT911_PIN_INT);
133+
if (touch.begin(Wire, GT911_SLAVE_ADDRESS_H, GT911_PIN_SDA, GT911_PIN_SCL)) {
134+
touchDeepSleepObserver.observer.observe(&notifyDeepSleep);
135+
touchScreenImpl1 = new TouchScreenImpl1(EPD_WIDTH, EPD_HEIGHT, readTouch);
136+
touchScreenImpl1->init();
137+
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
138+
touchBridge.observe(touchScreenImpl1);
139+
#endif
140+
} else {
141+
LOG_ERROR("Failed to find touch controller!");
142+
}
143+
}
144+
#endif

variants/esp32s3/m5stack_cardputer_adv/platformio.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ build_flags =
1010
-D M5STACK_CARDPUTER_ADV
1111
-D ARDUINO_USB_CDC_ON_BOOT=1
1212
-I variants/esp32s3/m5stack_cardputer_adv
13-
build_src_filter =
14-
${esp32s3_base.build_src_filter}
15-
+<../variants/esp32s3/m5stack_cardputer_adv>
1613
lib_deps =
1714
${esp32s3_base.lib_deps}
1815
# renovate: datasource=git-refs depName=meshtastic-st7789 packageName=https://github.com/meshtastic/st7789 gitBranch=main

variants/esp32s3/t5s3_epaper/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ board_build.partition = default_16MB.csv
55
board_check = true
66
upload_protocol = esptool
77
build_flags = -fno-strict-aliasing
8-
${esp32_base.build_flags}
8+
${esp32s3_base.build_flags}
99
-I variants/esp32s3/t5s3_epaper
1010
-D T5_S3_EPAPER_PRO
1111
-D USE_EINK
Lines changed: 3 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,6 @@
1-
#include "configuration.h"
2-
3-
#ifdef T5_S3_EPAPER_PRO
4-
5-
#include "Observer.h"
6-
#include "TouchDrvGT911.hpp"
7-
#include "Wire.h"
8-
#include "input/InputBroker.h"
9-
#include "input/TouchScreenImpl1.h"
10-
#include "sleep.h"
11-
12-
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
13-
#include "graphics/niche/InkHUD/InkHUD.h"
14-
#include "graphics/niche/InkHUD/SystemApplet.h"
15-
16-
// Bridges touch events from TouchScreenImpl1 directly into InkHUD,
17-
// bypassing the InputBroker (which is excluded in InkHUD builds).
18-
// Routing mirrors the mini-epaper-s3 two-way rocker pattern:
19-
// - Nav left/right: prevApplet/nextApplet when idle, navUp/Down when a system applet has focus (e.g. menu)
20-
// - Nav up/down: navUp/navDown always (menu scroll)
21-
// - Tap: shortpress (cycle applets / confirm in menu)
22-
// - Long press: longpress (open menu / back)
23-
class TouchInkHUDBridge : public Observer<const InputEvent *>
24-
{
25-
int onNotify(const InputEvent *e) override
26-
{
27-
auto *inkhud = NicheGraphics::InkHUD::InkHUD::getInstance();
28-
29-
// Keep alignment in sync with the current rotation so that visual-frame gestures
30-
// always pass through nav functions without remapping: (rotation + alignment) % 4 == 0.
31-
inkhud->persistence->settings.joystick.alignment = (4 - inkhud->persistence->settings.rotation) % 4;
32-
33-
// Check whether a system applet (e.g. menu) is currently handling input
34-
bool systemHandlingInput = false;
35-
for (NicheGraphics::InkHUD::SystemApplet *sa : inkhud->systemApplets) {
36-
if (sa->handleInput) {
37-
systemHandlingInput = true;
38-
break;
39-
}
40-
}
41-
42-
switch (e->inputEvent) {
43-
case INPUT_BROKER_USER_PRESS:
44-
inkhud->shortpress();
45-
break;
46-
case INPUT_BROKER_SELECT:
47-
inkhud->longpress();
48-
break;
49-
case INPUT_BROKER_LEFT:
50-
if (systemHandlingInput)
51-
inkhud->navUp();
52-
else
53-
inkhud->prevApplet();
54-
break;
55-
case INPUT_BROKER_RIGHT:
56-
if (systemHandlingInput)
57-
inkhud->navDown();
58-
else
59-
inkhud->nextApplet();
60-
break;
61-
case INPUT_BROKER_UP:
62-
inkhud->navUp();
63-
break;
64-
case INPUT_BROKER_DOWN:
65-
inkhud->navDown();
66-
break;
67-
default:
68-
break;
69-
}
70-
return 0;
71-
}
72-
};
73-
74-
static TouchInkHUDBridge touchBridge;
75-
#endif // MESHTASTIC_INCLUDE_NICHE_GRAPHICS
76-
77-
TouchDrvGT911 touch;
78-
79-
// Commands the GT911 into standby before the Wire bus is torn down.
80-
// notifyDeepSleep fires before Wire.end() in doDeepSleep(), so I2C is still available here.
81-
struct TouchDeepSleepObserver {
82-
int onDeepSleep(void *)
83-
{
84-
touch.sleep();
85-
return 0;
86-
}
87-
CallbackObserver<TouchDeepSleepObserver, void *> observer{this, &TouchDeepSleepObserver::onDeepSleep};
88-
} static touchDeepSleepObserver;
89-
90-
bool readTouch(int16_t *x, int16_t *y)
91-
{
92-
if (!digitalRead(GT911_PIN_INT)) {
93-
int16_t raw_x;
94-
int16_t raw_y;
95-
if (touch.getPoint(&raw_x, &raw_y)) {
96-
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
97-
// Transform raw GT911 axes to visual-frame coordinates for the current display rotation.
98-
// rotation=3 is the physical identity (device's default orientation).
99-
switch (NicheGraphics::InkHUD::InkHUD::getInstance()->persistence->settings.rotation) {
100-
default:
101-
case 3:
102-
*x = raw_x;
103-
*y = raw_y;
104-
break; // identity
105-
case 2:
106-
*x = (EPD_WIDTH - 1) - raw_y;
107-
*y = raw_x;
108-
break; // 90° CW tilt
109-
case 1:
110-
*x = (EPD_HEIGHT - 1) - raw_x;
111-
*y = (EPD_WIDTH - 1) - raw_y;
112-
break; // 180° flip
113-
case 0:
114-
*x = raw_y;
115-
*y = (EPD_HEIGHT - 1) - raw_x;
116-
break; // 90° CCW tilt
117-
}
118-
#else
119-
*x = raw_x;
120-
*y = raw_y;
121-
#endif
122-
LOG_DEBUG("touched(%d/%d)", *x, *y);
123-
return true;
124-
}
125-
}
126-
return false;
127-
}
1+
#include "variant.h"
2+
#include "Arduino.h"
3+
#include "pins_arduino.h"
1284

1295
void earlyInitVariant()
1306
{
@@ -161,20 +37,3 @@ void variant_shutdown()
16137
// Ensure frontlight is off during deep sleep
16238
digitalWrite(BOARD_BL_EN, LOW);
16339
}
164-
165-
// T5-S3-ePaper Pro specific (late-) init
166-
void lateInitVariant(void)
167-
{
168-
touch.setPins(GT911_PIN_RST, GT911_PIN_INT);
169-
if (touch.begin(Wire, GT911_SLAVE_ADDRESS_H, GT911_PIN_SDA, GT911_PIN_SCL)) {
170-
touchDeepSleepObserver.observer.observe(&notifyDeepSleep);
171-
touchScreenImpl1 = new TouchScreenImpl1(EPD_WIDTH, EPD_HEIGHT, readTouch);
172-
touchScreenImpl1->init();
173-
#ifdef MESHTASTIC_INCLUDE_NICHE_GRAPHICS
174-
touchBridge.observe(touchScreenImpl1);
175-
#endif
176-
} else {
177-
LOG_ERROR("Failed to find touch controller!");
178-
}
179-
}
180-
#endif

0 commit comments

Comments
 (0)