src/eric7/MicroPython/Devices/RP2040Devices.py

branch
eric7
changeset 9765
6378da868bb0
parent 9763
52f982c08301
child 9772
06ef28082c4d
--- a/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Feb 14 11:09:49 2023 +0100
+++ b/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Feb 14 18:10:30 2023 +0100
@@ -16,9 +16,9 @@
 from eric7.EricWidgets import EricMessageBox
 from eric7.EricWidgets.EricApplication import ericApp
 
+from ..MicroPythonWidget import HAS_QTCHART
 from . import FirmwareGithubUrls
 from .DeviceBase import BaseDevice
-from ..MicroPythonWidget import HAS_QTCHART
 
 
 class RP2040Device(BaseDevice):
@@ -177,7 +177,7 @@
         Private method to switch the board into 'bootloader' mode.
         """
         if self.microPython.isConnected():
-            self.microPython.commandsInterface().execute(
+            self.microPython.deviceInterface().execute(
                 [
                     "import machine",
                     "machine.bootloader()",
@@ -296,6 +296,41 @@
             ),
         ]
 
+    ##################################################################
+    ## time related methods below
+    ##################################################################
+
+    def _getSetTimeCode(self):
+        """
+        Protected method to get the device code to set the time.
+
+        Note: This method must be implemented in the various device specific
+        subclasses.
+
+        @return code to be executed on the connected device to set the time
+        @rtype str
+        """
+        # rtc_time[0] - year    4 digit
+        # rtc_time[1] - month   1..12
+        # rtc_time[2] - day     1..31
+        # rtc_time[3] - weekday 1..7 1=Monday
+        # rtc_time[4] - hour    0..23
+        # rtc_time[5] - minute  0..59
+        # rtc_time[6] - second  0..59
+        # rtc_time[7] - yearday 1..366
+        # rtc_time[8] - isdst   0, 1, or -1
+
+        # The machine.rtc.datetime() function takes the arguments in the order:
+        # (year, month, day, weekday, hour, minute, second, subseconds)
+        # __IGNORE_WARNING_M891__
+        # https://docs.micropython.org/en/latest/library/machine.RTC.html#machine-rtc
+        return """
+def set_time(rtc_time):
+    import machine
+    rtc = machine.RTC()
+    rtc.datetime(rtc_time[:7] + (0,))
+"""
+
 
 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
     """

eric ide

mercurial