m5stack / uiflow-micropython

uiflow micropython project
https://uiflow2.m5stack.com
MIT License
53 stars 27 forks source link

Fix UART #19

Closed felmue closed 6 months ago

felmue commented 7 months ago

Note: not sure if that is the correct fix, but it works for me.

lbuque commented 6 months ago

@felmue What problems did you encounter?

felmue commented 6 months ago

Hello @lbuque

please see this thread. The issue is that UART / GPS init block is broken for M5Dial. (And is still broken in UIFlow2.0.4)

I created a ProjectZone example: _M5Dial_GPS_UnitUIFlow2.0.2 which shows the issue.

The error I am getting is: _OSError: (-261, 'ESP_ERR_NOTFOUND')

Thanks Felix

lbuque commented 6 months ago

@felmue I ran M5Dial_GPS_Unit_UIFlow2.0.2 using firmware 2.0.4 and it seemed to run normally. What did I miss?

felmue commented 6 months ago

Hello @lbuque

thank you for checking. Hmm, strange. And you are running UIFlow2.0.4 firmware on your M5Dial installed with M5Burner?

Thanks Felix

lbuque commented 6 months ago

@felmue The startup ui uses port a. When running main.py, it is not initialized, which will cause uart initialization to fail.

This is my solution:

diff --git a/m5stack/modules/startup/dial/framework.py b/m5stack/modules/startup/dial/framework.py
index d1327d5..8a07ea4 100644
--- a/m5stack/modules/startup/dial/framework.py
+++ b/m5stack/modules/startup/dial/framework.py
@@ -49,12 +49,12 @@ class Framework:
         app.start()

     async def run(self):
-        self.i2c0 = I2C(0, scl=Pin(15), sda=Pin(13), freq=100000)
+        # self.i2c0 = I2C(0, scl=Pin(15), sda=Pin(13), freq=100000)
         self._kb_status = False
-        if 0x5F in self.i2c0.scan():
-            self._kb = CardKBUnit(self.i2c0)
-            self._event = KeyEvent()
-            self._kb_status = True
+        # if 0x5F in self.i2c0.scan():
+        #     self._kb = CardKBUnit(self.i2c0)
+        #     self._event = KeyEvent()
+        #     self._kb_status = True
         rotary = Rotary()

         self._bar and self._bar.start()

I don't recommend using UART on PORTA.

lbuque commented 6 months ago

@felmue The startup ui uses port a. When running main.py, it is not initialized, which will cause uart initialization to fail.

This is my solution:

diff --git a/m5stack/modules/startup/dial/framework.py b/m5stack/modules/startup/dial/framework.py
index d1327d5..8a07ea4 100644
--- a/m5stack/modules/startup/dial/framework.py
+++ b/m5stack/modules/startup/dial/framework.py
@@ -49,12 +49,12 @@ class Framework:
         app.start()

     async def run(self):
-        self.i2c0 = I2C(0, scl=Pin(15), sda=Pin(13), freq=100000)
+        # self.i2c0 = I2C(0, scl=Pin(15), sda=Pin(13), freq=100000)
         self._kb_status = False
-        if 0x5F in self.i2c0.scan():
-            self._kb = CardKBUnit(self.i2c0)
-            self._event = KeyEvent()
-            self._kb_status = True
+        # if 0x5F in self.i2c0.scan():
+        #     self._kb = CardKBUnit(self.i2c0)
+        #     self._event = KeyEvent()
+        #     self._kb_status = True
         rotary = Rotary()

         self._bar and self._bar.start()

I don't recommend using UART on PORTA.

This method does not solve the problem 100%. It still has a high probability of abnormalities.

felmue commented 6 months ago

Hello @lbuque

thank you for looking into this.

BTW: I tried port B (instead of port A), but I get the same error as reported before.

Thanks Felix

lbuque commented 6 months ago

@felmue I updated Dial's firmware on M5Burner, please verify.

felmue commented 6 months ago

Hello @lbuque

I can confirm that M5Dial v2.0.4--hotfix firmware resolves the issue. I tested port A and B and both work fine now.

Thank you very much.

Thanks Felix