Skip to content

Commit 5b98323

Browse files
committed
add torch
1 parent 2730123 commit 5b98323

6 files changed

Lines changed: 27 additions & 1 deletion

File tree

examples/companion_radio/ui-tiny/UITask.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,15 @@ void UITask::loop() {
643643
next_backlight_btn_check = millis() + 300;
644644
}
645645
#endif
646+
#if defined(HAS_TORCH)
647+
ev = back_btn.check();
648+
if (ev == BUTTON_EVENT_CLICK && c == 0) {
649+
c = checkDisplayOn(KEY_PREV);
650+
} else if (ev == BUTTON_EVENT_DOUBLE_CLICK) {
651+
board.toggleTorch();
652+
c = 0;
653+
}
654+
#endif
646655

647656
if (c != 0 && curr) {
648657
curr->handleInput(c);

variants/lilygo_techo_card/TechoCardBoard.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ void TechoCardBoard::onAfterTransmit() {
6767
Led_A.show();
6868
}
6969

70+
void TechoCardBoard::toggleTorch() {
71+
if (!_torchStatus) {
72+
Led_C.setPixelColor(0, 255, 255, 255);
73+
Led_C.show();
74+
_torchStatus = true;
75+
} else {
76+
Led_C.setPixelColor(0, 0, 0, 0);
77+
Led_C.show();
78+
_torchStatus = false;
79+
}
80+
}
81+
7082
void TechoCardBoard::turnOffLeds() {
7183
for (uint8_t i = 0; i < sizeof(Led) / sizeof(*Led); i++)
7284
{

variants/lilygo_techo_card/TechoCardBoard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
1616

1717
class TechoCardBoard : public NRF52BoardDCDC {
18+
bool _torchStatus = false;
1819
public:
1920
TechoCardBoard() : NRF52Board("TECHO_OTA") {}
2021
void begin();
@@ -29,6 +30,7 @@ class TechoCardBoard : public NRF52BoardDCDC {
2930

3031
void powerOff() override;
3132

33+
void toggleTorch();
3234
void turnOffLeds();
3335

3436
};

variants/lilygo_techo_card/platformio.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ build_flags = ${nrf52_base.build_flags}
1414
-D SX126X_CURRENT_LIMIT=140
1515
-D SX126X_RX_BOOSTED_GAIN=1
1616
-D HAS_NEOPIXEL=1
17+
-D HAS_TORCH=1
1718
; -D DISABLE_DIAGNOSTIC_OUTPUT
1819
-D ENV_INCLUDE_GPS=1
1920
-D DISPLAY_CLASS=U8g2Display
@@ -79,7 +80,7 @@ build_flags =
7980
-D UI_RECENT_LIST_SIZE=3
8081
-D UI_GPS_PAGE=1
8182
; -D MESH_PACKET_LOGGING=1
82-
; -D MESH_DEBUG=1
83+
-D MESH_DEBUG=1
8384
-D AUTO_SHUTDOWN_MILLIVOLTS=3300
8485
build_src_filter = ${LilyGo_T-Echo_Card.build_src_filter}
8586
+<helpers/nrf52/SerialBLEInterface.cpp>

variants/lilygo_techo_card/target.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ EnvironmentSensorManager sensors = EnvironmentSensorManager();
2323
#ifdef DISPLAY_CLASS
2424
DISPLAY_CLASS display;
2525
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
26+
MomentaryButton back_btn(PIN_BUTTON2, 1000, true);
2627
#endif
2728

2829
bool radio_init() {

variants/lilygo_techo_card/target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern EnvironmentSensorManager sensors;
2222
#ifdef DISPLAY_CLASS
2323
extern DISPLAY_CLASS display;
2424
extern MomentaryButton user_btn;
25+
extern MomentaryButton back_btn;
2526
#endif
2627

2728
bool radio_init();

0 commit comments

Comments
 (0)