src/eric7/MicroPython/Devices/PyBoardDevices.py

branch
eric7
changeset 9765
6378da868bb0
parent 9763
52f982c08301
child 9770
2d7a244886d1
--- a/src/eric7/MicroPython/Devices/PyBoardDevices.py	Tue Feb 14 11:09:49 2023 +0100
+++ b/src/eric7/MicroPython/Devices/PyBoardDevices.py	Tue Feb 14 18:10:30 2023 +0100
@@ -19,9 +19,9 @@
 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog
 from eric7.SystemUtilities import FileSystemUtilities
 
+from ..MicroPythonWidget import HAS_QTCHART
 from . import FirmwareGithubUrls
 from .DeviceBase import BaseDevice
-from ..MicroPythonWidget import HAS_QTCHART
 
 
 class PyBoardDevice(BaseDevice):
@@ -489,7 +489,7 @@
         Private slot to activate the bootloader and disconnect.
         """
         if self.microPython.isConnected():
-            self.microPython.commandsInterface().execute(
+            self.microPython.deviceInterface().execute(
                 [
                     "import pyb",
                     "pyb.bootloader()",
@@ -498,6 +498,41 @@
             # simulate pressing the disconnect button
             self.microPython.on_connectButton_clicked()
 
+    ##################################################################
+    ## 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 pyb.RTC.datetime() function takes the arguments in the
+        # order: (year, month, day, weekday, hour, minute, second,
+        # subseconds)
+        # http://docs.micropython.org/en/latest/library/pyb.RTC.html#pyb.RTC.datetime
+        return """
+def set_time(rtc_time):
+    import pyb
+    rtc = pyb.RTC()
+    rtc.datetime(rtc_time[:7] + (0,))
+"""
+
 
 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
     """

eric ide

mercurial