Skip to content

Commit 9e0b491

Browse files
committed
patches: Implementing deepSleep/setChargeCurrent for Tab5.
Signed-off-by: lbuque <1102390310@qq.com>
1 parent 00cca57 commit 9e0b491

5 files changed

Lines changed: 88 additions & 7 deletions

File tree

m5stack/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ M5UNIFIED_PATCH_SERIES = \
336336
2008-Only-use-old-rmt-driver.patch \
337337
2009-fix-SoftI2C.patch \
338338
2010-Support-Nesso-N1.patch \
339-
2011-Add-DualKey.patch
339+
2011-Add-DualKey.patch \
340+
2012-Implementing-deepSleep-for-Tab5.patch \
341+
2013-Implement-setChargeCurrent-for-Tab5.patch
340342

341343
ADF_PATCH_SERIES = \
342344
3002-Modify-i2s_stream_idf5.patch

m5stack/modules/startup/tab5/hal_tab5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_battery_level(self) -> int:
100100
return M5.Power.getBatteryLevel()
101101

102102
def get_output_current(self) -> float:
103-
return M5.Power.getBatteryCurrent()
103+
return M5.Power.getBatteryCurrent() / 1000.0
104104

105105
def is_charging(self) -> bool:
106106
return M5.Power.isCharging()

m5stack/modules/startup/tab5/launcher/components/status_bar.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ def __init__(self, parent: lv.obj):
107107
self._update_img()
108108
self._update_labels()
109109

110-
# TODO: Update task
111-
self._img.set_style_image_recolor_opa(123, lv.PART.MAIN)
112-
113-
# self._task = asyncio.create_task(self.update_task())
110+
self._task = asyncio.create_task(self.update_task())
114111

115112
async def update_task(self):
116113
while True:
@@ -128,7 +125,7 @@ def _update_img(self):
128125

129126
def _update_labels(self):
130127
self._label_bat_level.set_text(str(get_hal().get_battery_level()) + "%")
131-
self._label_output_current.set_text(str(round(get_hal().get_output_current(), 2)) + "A")
128+
self._label_output_current.set_text(str(round(get_hal().get_output_current(), 1)) + "A")
132129

133130

134131
class ItemCharge:
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Index: M5Unified/src/utility/Power_Class.cpp
2+
===================================================================
3+
--- M5Unified.orig/src/utility/Power_Class.cpp
4+
+++ M5Unified/src/utility/Power_Class.cpp
5+
@@ -8,6 +8,7 @@
6+
7+
#include <esp_log.h>
8+
#include <esp_sleep.h>
9+
+#include "driver/rtc_io.h"
10+
#include <sdkconfig.h>
11+
12+
#include <soc/soc_caps.h>
13+
@@ -989,7 +990,7 @@ namespace m5
14+
(void)touch_wakeup;
15+
#else
16+
ESP_LOGD("Power","deepSleep");
17+
-#if defined (CONFIG_IDF_TARGET_ESP32C3) || defined (CONFIG_IDF_TARGET_ESP32C6) || defined (CONFIG_IDF_TARGET_ESP32P4)
18+
+#if defined (CONFIG_IDF_TARGET_ESP32C3) || defined (CONFIG_IDF_TARGET_ESP32C6) // || defined (CONFIG_IDF_TARGET_ESP32P4)
19+
20+
#else
21+
22+
@@ -1003,7 +1004,14 @@ namespace m5
23+
uint_fast8_t wpin = _wakeupPin;
24+
if (touch_wakeup && wpin < GPIO_NUM_MAX)
25+
{
26+
+#if SOC_PM_SUPPORT_EXT0_WAKEUP
27+
esp_sleep_enable_ext0_wakeup((gpio_num_t)wpin, false);
28+
+#elif SOC_PM_SUPPORT_EXT1_WAKEUP && SOC_RTCIO_PIN_COUNT > 0
29+
+ const uint64_t ext_wakeup_pin_1_mask = 1ULL << _wakeupPin;
30+
+ ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup_io(ext_wakeup_pin_1_mask, ESP_EXT1_WAKEUP_ANY_LOW));
31+
+ ESP_ERROR_CHECK(rtc_gpio_pullup_dis((gpio_num_t)_wakeupPin));
32+
+ ESP_ERROR_CHECK(rtc_gpio_pulldown_en((gpio_num_t)_wakeupPin));
33+
+#endif
34+
while (m5gfx::gpio_in(wpin) == false)
35+
{
36+
// Issue #91, ( M5Paper wakes too soon from deep sleep when touch wakeup is enabled - with solution )
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Index: M5Unified/src/utility/Power_Class.cpp
2+
===================================================================
3+
--- M5Unified.orig/src/utility/Power_Class.cpp
4+
+++ M5Unified/src/utility/Power_Class.cpp
5+
@@ -1415,6 +1415,41 @@ namespace m5
6+
#endif
7+
8+
default:
9+
+#if defined (CONFIG_IDF_TARGET_ESP32P4)
10+
+ switch (M5.getBoard()) {
11+
+ case board_t::board_M5Tab5: {
12+
+ switch (max_mA) {
13+
+ case 0:
14+
+ // charge disable
15+
+ M5.getIOExpander(1).digitalWrite(7, false); // CHG_EN = HIGH
16+
+ // qc disable
17+
+ M5.getIOExpander(1).digitalWrite(5, true); // CHG_EN = LOW
18+
+ break;
19+
+
20+
+ case 500:
21+
+ // charge enable
22+
+ M5.getIOExpander(1).digitalWrite(7, true); // CHG_EN = HIGH
23+
+ // qc disable
24+
+ M5.getIOExpander(1).digitalWrite(5, true); // CHG_EN = LOW
25+
+ break;
26+
+
27+
+ case 1000:
28+
+ // charge enable
29+
+ M5.getIOExpander(1).digitalWrite(7, true); // CHG_EN = HIGH
30+
+ // qc enable
31+
+ M5.getIOExpander(1).digitalWrite(5, false); // CHG_EN = LOW
32+
+ break;
33+
+
34+
+ default:
35+
+ break;
36+
+ }
37+
+ }
38+
+ break;
39+
+
40+
+ default:
41+
+ return;
42+
+ }
43+
+#endif
44+
return;
45+
}
46+
}

0 commit comments

Comments
 (0)