Skip to content

Commit 7fe0457

Browse files
committed
update firmware v1.1
1 parent 0be95ba commit 7fe0457

27 files changed

Lines changed: 387 additions & 198 deletions

File tree

dependencies.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ dependencies:
251251
type: service
252252
version: 0.0.11
253253
espressif/esp-sr:
254-
component_hash: aa58d6a13a49600314a50a27240ccbd17e407f608216a3086d4868e0da2e8053
254+
component_hash: 809d0041cdddd98a278f0d5afef7bb60a451290577b98cf718dfffc91bdcbd9b
255255
dependencies:
256256
- name: espressif/cjson
257257
registry_url: https://components.espressif.com
@@ -260,7 +260,7 @@ dependencies:
260260
- name: espressif/dl_fft
261261
registry_url: https://components.espressif.com
262262
require: private
263-
version: '>=0.2.0'
263+
version: '>=0.6.0'
264264
- name: espressif/esp-dsp
265265
registry_url: https://components.espressif.com
266266
require: private
@@ -271,7 +271,7 @@ dependencies:
271271
source:
272272
registry_url: https://components.espressif.com
273273
type: service
274-
version: 2.4.6
274+
version: 2.4.7
275275
espressif/esp-zboss-lib:
276276
component_hash: 321883d142421f65009972408287441794250057668a11abbdfd8bec77c3309a
277277
dependencies:
@@ -529,15 +529,15 @@ dependencies:
529529
type: idf
530530
version: 5.5.1
531531
joltwallet/littlefs:
532-
component_hash: fab83a8a57de01b05441557d78e9d10c755413a1836af4b2762b539add0c14b1
532+
component_hash: 3af20a3d75c49db9dc2286fd50862c34055c9f578419ad1f2bf7ed3ed01391fe
533533
dependencies:
534534
- name: idf
535535
require: private
536536
version: '>=5.0'
537537
source:
538538
registry_url: https://components.espressif.com
539539
type: service
540-
version: 1.22.2
540+
version: 1.22.3
541541
m5stack/m5ioe1:
542542
component_hash: 1e16ad396711cd21b588ba3290aa20f9605f950702e15b8e44e38a56ead0a38c
543543
dependencies:
@@ -571,6 +571,6 @@ direct_dependencies:
571571
- idf
572572
- m5stack/m5ioe1
573573
- m5stack/m5pm1
574-
manifest_hash: 5bc4ef0a9a6a2eaf0de9b066d098c32c011fcfae184db5d8bc4d1045ad50a707
574+
manifest_hash: 580d9d9a16f6786291242118794d0081e0f9d0a1b6f6f53966c6a7399dd8c770
575575
target: esp32s3
576576
version: 2.0.0

main/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(APP_SRCS
33
"./hal/hal_board.cpp"
44
"./hal/hal_buzzer.cpp"
55
"./hal/hal_display.cpp"
6+
"./hal/hal_imu.cpp"
67
"./hal/hal_lora.cpp"
78
"./hal/hal_mic.cpp"
89
"./hal/hal_tf_card.cpp"

main/apps/app_battery/app_battery.cpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ static constexpr int BATTERY_X = 86;
2626
static constexpr int BATTERY_Y = 13;
2727
static constexpr int BATTERY_W = 129 - 86;
2828
static constexpr int BATTERY_H = 30 - 13;
29+
static constexpr int BATTERY_OUTLINE_MARGIN = 4;
30+
static constexpr int BATTERY_BLOCK_RADIUS = 3;
31+
static constexpr int BATTERY_OUTLINE_RADIUS = BATTERY_BLOCK_RADIUS + BATTERY_OUTLINE_MARGIN;
32+
static constexpr int BATTERY_OUTLINE_WIDTH = 2;
33+
static constexpr int BATTERY_OUTLINE_X = BATTERY_X - BATTERY_OUTLINE_MARGIN;
34+
static constexpr int BATTERY_OUTLINE_Y = BATTERY_Y - BATTERY_OUTLINE_MARGIN;
35+
static constexpr int BATTERY_OUTLINE_W = BATTERY_W + BATTERY_OUTLINE_MARGIN * 2;
36+
static constexpr int BATTERY_OUTLINE_H = BATTERY_H + BATTERY_OUTLINE_MARGIN * 2;
2937
static constexpr int BATTERY_TOUCH_MARGIN_X = 8;
3038
static constexpr int BATTERY_TOUCH_MARGIN_Y = 8;
3139

@@ -183,21 +191,20 @@ static void drawCenteredBatteryText(const char* text, int x_offset = 0)
183191

184192
static void fillLeftRoundRect(int x, int y, int w, int h, int radius)
185193
{
186-
GetHAL().display.fillRoundRect(x, y, w, h, radius, TFT_BLACK);
194+
GetHAL().display.fillSmoothRoundRect(x, y, w, h, radius, TFT_BLACK);
187195
GetHAL().display.fillRect(x + radius, y, w - radius, h, TFT_BLACK);
188196
}
189197

190198
static void fillRightRoundRect(int x, int y, int w, int h, int radius)
191199
{
192-
GetHAL().display.fillRoundRect(x, y, w, h, radius, TFT_BLACK);
200+
GetHAL().display.fillSmoothRoundRect(x, y, w, h, radius, TFT_BLACK);
193201
GetHAL().display.fillRect(x, y, w - radius, h, TFT_BLACK);
194202
}
195203

196204
static void drawBatteryBlocks(int percent)
197205
{
198-
static constexpr int BLOCK_COUNT = 5;
199-
static constexpr int BLOCK_GAP = 1;
200-
static constexpr int ROUND_RADIUS = 2;
206+
static constexpr int BLOCK_COUNT = 5;
207+
static constexpr int BLOCK_GAP = 1;
201208

202209
const int filled_blocks = percent <= 0 ? 0 : std::clamp((percent * BLOCK_COUNT + 99) / 100, 1, BLOCK_COUNT);
203210
const int first_filled_index = BLOCK_COUNT - filled_blocks;
@@ -211,9 +218,9 @@ static void drawBatteryBlocks(int percent)
211218

212219
if (i >= first_filled_index) {
213220
if (i == 0) {
214-
fillLeftRoundRect(x, BATTERY_Y, block_w, BATTERY_H, ROUND_RADIUS);
221+
fillLeftRoundRect(x, BATTERY_Y, block_w, BATTERY_H, BATTERY_BLOCK_RADIUS);
215222
} else if (i == BLOCK_COUNT - 1) {
216-
fillRightRoundRect(x, BATTERY_Y, block_w, BATTERY_H, ROUND_RADIUS);
223+
fillRightRoundRect(x, BATTERY_Y, block_w, BATTERY_H, BATTERY_BLOCK_RADIUS);
217224
} else {
218225
GetHAL().display.fillRect(x, BATTERY_Y, block_w, BATTERY_H, TFT_BLACK);
219226
}
@@ -224,6 +231,16 @@ static void drawBatteryBlocks(int percent)
224231
}
225232
}
226233

234+
static void drawBatteryOutline()
235+
{
236+
GetHAL().display.fillSmoothRoundRect(BATTERY_OUTLINE_X, BATTERY_OUTLINE_Y, BATTERY_OUTLINE_W, BATTERY_OUTLINE_H,
237+
BATTERY_OUTLINE_RADIUS, TFT_BLACK);
238+
GetHAL().display.fillSmoothRoundRect(
239+
BATTERY_OUTLINE_X + BATTERY_OUTLINE_WIDTH, BATTERY_OUTLINE_Y + BATTERY_OUTLINE_WIDTH,
240+
BATTERY_OUTLINE_W - BATTERY_OUTLINE_WIDTH * 2, BATTERY_OUTLINE_H - BATTERY_OUTLINE_WIDTH * 2,
241+
BATTERY_OUTLINE_RADIUS - BATTERY_OUTLINE_WIDTH, TFT_WHITE);
242+
}
243+
227244
void AppBattery::onCreate()
228245
{
229246
setAppInfo().name = "AppBattery";
@@ -258,7 +275,7 @@ void AppBattery::onRunning()
258275
return;
259276
}
260277

261-
if (!_has_drawn || GetHAL().isRefreshRequested() || now_ms - _last_update_ms >= APP_BATTERY_REFRESH_MS) {
278+
if (!_has_drawn || GetHAL().isFullRedrawRequested() || now_ms - _last_update_ms >= APP_BATTERY_REFRESH_MS) {
262279
drawBattery(true);
263280
}
264281
}
@@ -294,7 +311,8 @@ void AppBattery::drawBattery(bool sample_voltage)
294311
const int percent = getBatteryPercent(static_cast<std::int16_t>(battery_mv));
295312

296313
GetHAL().display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
297-
GetHAL().display.fillRect(BATTERY_X, BATTERY_Y, BATTERY_W, BATTERY_H, TFT_WHITE);
314+
GetHAL().display.fillRect(BATTERY_OUTLINE_X, BATTERY_OUTLINE_Y, BATTERY_OUTLINE_W, BATTERY_OUTLINE_H, TFT_WHITE);
315+
drawBatteryOutline();
298316
GetHAL().display.setTextColor(TFT_BLACK, TFT_WHITE);
299317
if (_display_mode == BATTERY_MODE_PERCENT) {
300318
char percent_text[8] = {};
@@ -311,9 +329,8 @@ void AppBattery::drawBattery(bool sample_voltage)
311329
} else {
312330
drawBatteryBlocks(percent);
313331
}
314-
315332
if (!GetHAL().isRefreshRequested()) {
316-
GetHAL().flushDisplay(BATTERY_X, BATTERY_Y, BATTERY_W, BATTERY_H);
333+
GetHAL().flushDisplay(BATTERY_OUTLINE_X, BATTERY_OUTLINE_Y, BATTERY_OUTLINE_W, BATTERY_OUTLINE_H);
317334
GetHAL().display.waitDisplay();
318335
}
319336

main/apps/app_brightness/app_brightness.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void AppBrightness::onRunning()
196196
GetHAL().requestRefresh();
197197
}
198198

199-
if (changed || !_has_drawn || GetHAL().isRefreshRequested()) {
199+
if (changed || !_has_drawn || GetHAL().isFullRedrawRequested()) {
200200
drawBrightness();
201201
}
202202
}

main/apps/app_buzzer/app_buzzer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,29 @@ void AppBuzzer::onRunning()
9797
_pending_mute = true;
9898
_mute_apply_ms = now_ms + BUZZER_MUTE_SOUND_MS;
9999
}
100-
GetHAL().requestRefresh();
101-
drawBuzzer();
100+
drawBuzzer(true);
102101
return;
103102
}
104103

105-
if (!_has_drawn || GetHAL().isRefreshRequested()) {
104+
if (!_has_drawn || GetHAL().isFullRedrawRequested()) {
106105
drawBuzzer();
107106
}
108107
}
109108

110-
void AppBuzzer::drawBuzzer()
109+
void AppBuzzer::drawBuzzer(bool force_refresh)
111110
{
112111
const bool muted = GetHAL().isBuzzerMuted() || _pending_mute;
113112
const std::uint8_t* start = muted ? img_MUTE_ON_start : img_MUTE_OFF_start;
114113
const std::uint8_t* end = muted ? img_MUTE_ON_end : img_MUTE_OFF_end;
115114

116-
GetHAL().display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
115+
GetHAL().display.setEpdMode(m5gfx::epd_mode_t::epd_fast);
117116
GetHAL().display.drawPng(start, end - start, BUZZER_X, BUZZER_Y);
118117

119-
if (!GetHAL().isRefreshRequested()) {
118+
if (force_refresh || !GetHAL().isRefreshRequested()) {
120119
GetHAL().flushDisplay(BUZZER_X, BUZZER_Y, BUZZER_W, BUZZER_H);
121120
GetHAL().display.waitDisplay();
122121
}
122+
GetHAL().display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
123123

124124
_has_drawn = true;
125125
}

main/apps/app_buzzer/app_buzzer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ class AppBuzzer : public mooncake::AppAbility {
2020
bool _has_drawn = false;
2121
bool _pending_mute = false;
2222

23-
void drawBuzzer();
23+
void drawBuzzer(bool force_refresh = false);
2424
};

main/apps/app_clock/app_clock.cpp

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -501,36 +501,6 @@ void AppClock::scheduleNextAutoNtp(std::uint32_t delay_ms)
501501
_next_auto_ntp_ms = GetHAL().millis() + delay_ms;
502502
}
503503

504-
void AppClock::captureNtpBackground()
505-
{
506-
auto& display = GetHAL().display;
507-
const int screen_w = display.width();
508-
const int screen_h = display.height();
509-
if (screen_w <= 0 || screen_h <= 0) {
510-
_ntp_background_valid = false;
511-
return;
512-
}
513-
514-
const std::size_t buffer_size = static_cast<std::size_t>(screen_w) * static_cast<std::size_t>(screen_h);
515-
_ntp_background.resize(buffer_size);
516-
display.readRect(0, 0, screen_w, screen_h, _ntp_background.data());
517-
_ntp_background_w = static_cast<std::int16_t>(screen_w);
518-
_ntp_background_h = static_cast<std::int16_t>(screen_h);
519-
_ntp_background_valid = true;
520-
}
521-
522-
void AppClock::restoreNtpBackground()
523-
{
524-
if (!_ntp_background_valid || _ntp_background.empty()) {
525-
GetHAL().drawBackground(m5gfx::epd_mode_t::epd_fastest, false);
526-
return;
527-
}
528-
529-
auto& display = GetHAL().display;
530-
display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
531-
display.pushImage(0, 0, _ntp_background_w, _ntp_background_h, _ntp_background.data());
532-
}
533-
534504
/* -------------------------------------------------------------------------- */
535505
/* Lifecycle */
536506
/* -------------------------------------------------------------------------- */
@@ -594,7 +564,7 @@ void AppClock::onRunning()
594564
const auto timezone_date_time = convertRtcToTimezone(date_time, TIMEZONES[_timezone_index]);
595565
minute_changed = makeDisplayMinuteKey(timezone_date_time) != _last_display_minute_key;
596566
}
597-
if (!_has_drawn || GetHAL().isRefreshRequested() || minute_changed ||
567+
if (!_has_drawn || GetHAL().isFullRedrawRequested() || minute_changed ||
598568
now_ms - _last_update_ms >= CLOCK_REFRESH_MS) {
599569
drawTime();
600570
}
@@ -606,7 +576,7 @@ void AppClock::onRunning()
606576

607577
void AppClock::openNtpDialog()
608578
{
609-
captureNtpBackground();
579+
GetHAL().captureDisplaySnapshot();
610580
_ntp_dialog_open = true;
611581
_ntp_scan_running = false;
612582
_ntp_success_close_ms = 0;
@@ -619,7 +589,7 @@ void AppClock::openNtpDialog()
619589
WiFi.scanDelete();
620590
GetHAL().setUiModalActive(true);
621591
GetHAL().playBuzzerPattern(NTP_DIALOG_OPEN_TONES, 2);
622-
drawNtpDialog();
592+
drawNtpDialog(true);
623593
}
624594

625595
void AppClock::closeNtpDialog()
@@ -635,13 +605,15 @@ void AppClock::closeNtpDialog()
635605
_ntp_touching = false;
636606
_ntp_list_touching = false;
637607
_ntp_list_dragged = false;
638-
restoreNtpBackground();
639-
_has_drawn = false;
640-
_ntp_background_valid = false;
641-
GetHAL().releaseModalNextFrame();
608+
if (!GetHAL().restoreDisplaySnapshot()) {
609+
GetHAL().drawBackground(m5gfx::epd_mode_t::epd_fast, false);
610+
}
611+
GetHAL().clearDisplaySnapshot();
612+
_has_drawn = false;
613+
GetHAL().releaseModalNextFrame(m5gfx::epd_mode_t::epd_fast);
642614
}
643615

644-
void AppClock::drawNtpDialog()
616+
void AppClock::drawNtpDialog(bool full_refresh)
645617
{
646618
auto& display = GetHAL().display;
647619
display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
@@ -671,7 +643,7 @@ void AppClock::drawNtpDialog()
671643
display.drawString("AUTO TIME SYNC", NTP_FIELD_X, NTP_AUTO_Y + NTP_AUTO_H / 2);
672644
drawNtpToggle(_ntp_auto_enabled, NTP_AUTO_TOGGLE_X, NTP_AUTO_Y, NTP_AUTO_TOGGLE_W, NTP_AUTO_H);
673645

674-
drawNtpButton(_ntp_scan_running ? "SCANNING..." : "SCAN NETWORKS", NTP_SCAN_X, NTP_BUTTON_ROW_Y, NTP_ACTION_W,
646+
drawNtpButton(_ntp_scan_running ? "SCANNING..." : "SCAN Wi-Fi", NTP_SCAN_X, NTP_BUTTON_ROW_Y, NTP_ACTION_W,
675647
NTP_ACTION_H, _ntp_scan_running);
676648
drawNtpButton(_ntp_connecting || _ntp_syncing ? "SYNCING TIME" : "SYNC TIME", NTP_SYNC_X, NTP_BUTTON_ROW_Y,
677649
NTP_ACTION_W, NTP_ACTION_H, _ntp_connecting || _ntp_syncing);
@@ -718,8 +690,10 @@ void AppClock::drawNtpDialog()
718690
}
719691
}
720692

693+
display.setEpdMode(full_refresh ? m5gfx::epd_mode_t::epd_fast : m5gfx::epd_mode_t::epd_fastest);
721694
GetHAL().flushDisplay(NTP_DIALOG_X, NTP_DIALOG_Y, NTP_DIALOG_W, NTP_DIALOG_H);
722695
display.waitDisplay();
696+
display.setEpdMode(m5gfx::epd_mode_t::epd_fastest);
723697
}
724698

725699
void AppClock::drawNtpInputFields()
@@ -757,10 +731,12 @@ void AppClock::handleNtpDialog()
757731
if (_keyboard.isOpen()) {
758732
auto closeKeyboardAndRedraw = [&]() {
759733
commitNtpKeyboard();
760-
restoreNtpBackground();
734+
if (!GetHAL().restoreDisplaySnapshot()) {
735+
GetHAL().drawBackground(m5gfx::epd_mode_t::epd_fast, false);
736+
}
761737
GetHAL().requestRefresh();
762738
drawTime();
763-
drawNtpDialog();
739+
drawNtpDialog(true);
764740
};
765741
auto switchKeyboardField = [&](std::uint8_t field) {
766742
if (_ntp_edit_field == field) {
@@ -845,10 +821,10 @@ void AppClock::handleNtpDialog()
845821
}
846822
_ntp_touching = false;
847823

848-
const int dx = point.x - _ntp_touch_start_x;
849-
const int dy = point.y - _ntp_touch_start_y;
850-
const bool started_in_list = _ntp_touch_start_x >= NTP_LIST_X && _ntp_touch_start_x <= NTP_LIST_X + NTP_LIST_W &&
851-
_ntp_touch_start_y >= NTP_LIST_Y && _ntp_touch_start_y < NTP_LIST_Y + list_h;
824+
const int dx = point.x - _ntp_touch_start_x;
825+
const int dy = point.y - _ntp_touch_start_y;
826+
const bool started_in_list = _ntp_touch_start_x >= NTP_LIST_X && _ntp_touch_start_x <= NTP_LIST_X + NTP_LIST_W &&
827+
_ntp_touch_start_y >= NTP_LIST_Y && _ntp_touch_start_y < NTP_LIST_Y + list_h;
852828
const bool is_vertical_swipe = started_in_list && std::abs(dy) >= NTP_LIST_ROW_H && std::abs(dy) > std::abs(dx);
853829
if (max_scroll > 0 && is_vertical_swipe) {
854830
const int old_scroll = _ntp_list_scroll;

main/apps/app_clock/app_clock.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class AppClock : public mooncake::AppAbility {
2525

2626
ScreenKeyboard _keyboard;
2727
std::vector<WifiChoice> _ntp_networks;
28-
std::vector<std::uint8_t> _ntp_background;
2928
std::string _ntp_ssid;
3029
std::string _ntp_password;
3130
std::string _ntp_status;
@@ -41,8 +40,6 @@ class AppClock : public mooncake::AppAbility {
4140
std::int16_t _ntp_last_touch_y = 0;
4241
std::int16_t _ntp_touch_start_x = 0;
4342
std::int16_t _ntp_touch_start_y = 0;
44-
std::int16_t _ntp_background_w = 0;
45-
std::int16_t _ntp_background_h = 0;
4643
std::uint8_t _ntp_edit_field = 0;
4744
std::uint8_t _timezone_index = 0;
4845
bool _ntp_dialog_open = false;
@@ -54,14 +51,13 @@ class AppClock : public mooncake::AppAbility {
5451
bool _ntp_touching = false;
5552
bool _ntp_list_touching = false;
5653
bool _ntp_list_dragged = false;
57-
bool _ntp_background_valid = false;
5854
bool _has_drawn = false;
5955

6056
void drawTime();
6157
void switchTimezone();
6258
void openNtpDialog();
6359
void closeNtpDialog();
64-
void drawNtpDialog();
60+
void drawNtpDialog(bool full_refresh = false);
6561
void drawNtpInputFields();
6662
void handleNtpDialog();
6763
void startNtpScan();
@@ -73,6 +69,4 @@ class AppClock : public mooncake::AppAbility {
7369
void loadNtpSettings();
7470
void saveNtpSettings();
7571
void scheduleNextAutoNtp(std::uint32_t delay_ms);
76-
void captureNtpBackground();
77-
void restoreNtpBackground();
7872
};

0 commit comments

Comments
 (0)