Corrected some code in the MicrobitDevices module related to CircuitPython. eric7

Mon, 24 Mar 2025 14:16:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 24 Mar 2025 14:16:32 +0100
branch
eric7
changeset 11189
289c7150ec4b
parent 11188
413f6ff459ab
child 11190
f5ffdf0164ab

Corrected some code in the MicrobitDevices module related to CircuitPython.

src/eric7/MicroPython/Devices/MicrobitDevices.py file | annotate | diff | comparison | revisions
diff -r 413f6ff459ab -r 289c7150ec4b src/eric7/MicroPython/Devices/MicrobitDevices.py
--- a/src/eric7/MicroPython/Devices/MicrobitDevices.py	Mon Mar 24 14:15:39 2025 +0100
+++ b/src/eric7/MicroPython/Devices/MicrobitDevices.py	Mon Mar 24 14:16:32 2025 +0100
@@ -76,9 +76,6 @@
         if self._deviceData:
             self._deviceData["local_mip"] = False
 
-        if self.hasCircuitPython():
-            self._submitMode = "paste"
-
     def setButtons(self):
         """
         Public method to enable the supported action buttons.
@@ -1023,9 +1020,12 @@
         @return list of command strings to be executed
         @rtype list of str
         """
-        # These are a subset of the generic ones.
-        return [  # needs to be splitted for boards with low memory
-            """def get_board_info():
+        if self.hasCircuitPython():
+            return super()._boardInformationCommands()
+        else:
+            # These are a subset of the generic ones.
+            return [  # needs to be splitted for boards with low memory
+                """def get_board_info():
     res = {}
 
     try:
@@ -1049,7 +1049,7 @@
 print(get_board_info())
 del get_board_info
 """,
-            """def get_board_info():
+                """def get_board_info():
     res = {}
 
     import sys
@@ -1084,7 +1084,7 @@
 print(get_board_info())
 del get_board_info
 """,
-            """def get_board_info():
+                """def get_board_info():
     res = {}
 
     try:
@@ -1098,8 +1098,8 @@
 print(get_board_info())
 del get_board_info
 """,
-            # micro:bit specific variants due to missing float support
-            """def get_board_info():
+                # micro:bit specific variants due to missing float support
+                """def get_board_info():
     res = {}
 
     import gc
@@ -1118,7 +1118,7 @@
 print(get_board_info())
 del get_board_info
 """,
-            """def get_board_info():
+                """def get_board_info():
     res = {}
 
     try:
@@ -1135,7 +1135,7 @@
 print(get_board_info())
 del get_board_info
 """,
-            """def get_board_info():
+                """def get_board_info():
     res = {}
 
     import machine as mc
@@ -1165,7 +1165,7 @@
 print(get_board_info())
 del get_board_info
 """,
-        ]
+            ]
 
     def getBoardInformation(self):
         """
@@ -1176,30 +1176,39 @@
         """
         res = super().getBoardInformation()
 
-        # post-process the results to determine the right float entries
+        if not self.hasCircuitPython():
+            # post-process the results to determine the right float entries
 
-        # 1. memory
-        res["mem_total_kb"] = res["mem_total"] / 1024.0
-        res["mem_used_kb"] = res["mem_used"] / 1024.0
-        res["mem_used_pc"] = res["mem_used"] / res["mem_total"] * 100.0
-        res["mem_free_kb"] = res["mem_free"] / 1024.0
-        res["mem_free_pc"] = res["mem_free"] / res["mem_total"] * 100.0
+            # 1. memory
+            res["mem_total_kb"] = res["mem_total"] / 1024.0
+            res["mem_used_kb"] = res["mem_used"] / 1024.0
+            res["mem_used_pc"] = res["mem_used"] / res["mem_total"] * 100.0
+            res["mem_free_kb"] = res["mem_free"] / 1024.0
+            res["mem_free_pc"] = res["mem_free"] / res["mem_total"] * 100.0
 
-        # 2. flash
-        if res["flash_info_available"]:
-            res["flash_total_kb"] = res["flash_total"] / 1024.0
-            res["flash_free_kb"] = res["flash_free"] / 1024.0
-            res["flash_used_kb"] = res["flash_total_kb"] - res["flash_free_kb"]
-            res["flash_free_pc"] = res["flash_free_kb"] / res["flash_total_kb"] * 100.0
-            res["flash_used_pc"] = res["flash_used_kb"] / res["flash_total_kb"] * 100.0
+            # 2. flash
+            if res["flash_info_available"]:
+                res["flash_total_kb"] = res["flash_total"] / 1024.0
+                res["flash_free_kb"] = res["flash_free"] / 1024.0
+                res["flash_used_kb"] = res["flash_total_kb"] - res["flash_free_kb"]
+                res["flash_free_pc"] = (
+                    res["flash_free_kb"] / res["flash_total_kb"] * 100.0
+                )
+                res["flash_used_pc"] = (
+                    res["flash_used_kb"] / res["flash_total_kb"] * 100.0
+                )
 
-        # 3. machine
-        res["mc_frequency_mhz"] = (
-            res["mc_frequency"] / 1000000.0 if res["mc_frequency"] is not None else None
-        )
-        with contextlib.suppress(KeyError):
-            if res["mc_temp_c"] is not None:
-                res["mc_temp_c"] = res["mc_temp_c"] / 100  # due to integer support only
+            # 3. machine
+            res["mc_frequency_mhz"] = (
+                res["mc_frequency"] / 1000000.0
+                if res["mc_frequency"] is not None
+                else None
+            )
+            with contextlib.suppress(KeyError):
+                if res["mc_temp_c"] is not None:
+                    res["mc_temp_c"] = (
+                        res["mc_temp_c"] / 100
+                    )  # due to integer support only
 
         return res
 

eric ide

mercurial