Skip to content

Commit 5e2eed2

Browse files
authored
Merge pull request #29 from Forairaaaaa/fix-bat-level-reading
Fix bat level reading
2 parents be4b8b7 + e824a76 commit 5e2eed2

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

main/apps/app_launcher/app_launcher.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ class Launcher : public mooncake::AppAbility {
3939
// 1 ~ 5
4040
uint8_t wifi_state = 5;
4141
// 1 ~ 4
42-
uint8_t bat_state = 1;
43-
std::string time = "12:34";
42+
uint8_t bat_state = 1;
43+
std::string bat_level = "100%";
44+
std::string time = "12:34";
4445
};
4546

4647
struct Data_t {

main/apps/app_launcher/view/system_bar/system_bar.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ void Launcher::render_system_bar()
4545

4646
// Bat
4747
if ((GetHAL().millis() - _data.bat_update_time_count) > 5000 || _data.bat_update_time_count == 0) {
48-
auto bat_level = GetHAL().getBatLevel();
48+
auto bat_level = GetHAL().getBatLevel();
49+
_data.system_state.bat_level = fmt::format("{}", bat_level);
4950
// mclog::tagInfo("system_bar", "get bat level: {}", bat_level);
51+
// printf("b:%d\n", bat_level);
5052

5153
if (bat_level >= 100) {
5254
_data.system_state.bat_state = 1;
@@ -94,7 +96,7 @@ void Launcher::render_system_bar()
9496
GetHAL().canvasSystemBar.pushImage(x, y, 16, 16, image_data_wifi5);
9597
}
9698

97-
// Bat
99+
// Bat icon
98100
x = GetHAL().canvasSystemBar.width() - 45;
99101
y = 5;
100102

@@ -108,6 +110,12 @@ void Launcher::render_system_bar()
108110
GetHAL().canvasSystemBar.pushImage(x, y, 32, 16, image_data_bat4);
109111
}
110112

113+
// Bat level
114+
GetHAL().canvasSystemBar.setFont(&fonts::Font0);
115+
GetHAL().canvasSystemBar.setTextColor((uint32_t)0x000000);
116+
GetHAL().canvasSystemBar.drawCenterString(_data.system_state.bat_level.c_str(), 176,
117+
GetHAL().canvasSystemBar.height() / 2 - 3);
118+
111119
// Push
112120
GetHAL().pushCanvasSystemBar();
113121
}

main/apps/utils/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#pragma once
77
#include <hal/hal.h>
88

9-
#define FW_VERSION "V0.1"
9+
#define FW_VERSION "V0.2"
1010

1111
#define ANIM_APP_OPEN() \
1212
for (int i = 10; i < 123; i += 8) { \

repos.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
{
33
"url": "https://github.com/m5stack/M5GFX.git",
44
"path": "components/M5GFX",
5-
"branch": "0.2.10"
5+
"branch": "0.2.15"
66
},
77
{
88
"url": "https://github.com/m5stack/M5Unified.git",
99
"path": "components/M5Unified",
10-
"branch": "0.2.8"
10+
"branch": "0.2.10"
1111
},
1212
{
1313
"url": "https://github.com/Forairaaaaa/mooncake.git",

0 commit comments

Comments
 (0)