src/eric7/MicroPython/Devices/RP2040Devices.py

branch
eric7
changeset 9765
6378da868bb0
parent 9763
52f982c08301
child 9772
06ef28082c4d
equal deleted inserted replaced
9764:57496966803c 9765:6378da868bb0
14 14
15 from eric7 import Globals, Preferences 15 from eric7 import Globals, Preferences
16 from eric7.EricWidgets import EricMessageBox 16 from eric7.EricWidgets import EricMessageBox
17 from eric7.EricWidgets.EricApplication import ericApp 17 from eric7.EricWidgets.EricApplication import ericApp
18 18
19 from ..MicroPythonWidget import HAS_QTCHART
19 from . import FirmwareGithubUrls 20 from . import FirmwareGithubUrls
20 from .DeviceBase import BaseDevice 21 from .DeviceBase import BaseDevice
21 from ..MicroPythonWidget import HAS_QTCHART
22 22
23 23
24 class RP2040Device(BaseDevice): 24 class RP2040Device(BaseDevice):
25 """ 25 """
26 Class implementing the device for RP2040 based boards. 26 Class implementing the device for RP2040 based boards.
175 def __activateBootloader(self): 175 def __activateBootloader(self):
176 """ 176 """
177 Private method to switch the board into 'bootloader' mode. 177 Private method to switch the board into 'bootloader' mode.
178 """ 178 """
179 if self.microPython.isConnected(): 179 if self.microPython.isConnected():
180 self.microPython.commandsInterface().execute( 180 self.microPython.deviceInterface().execute(
181 [ 181 [
182 "import machine", 182 "import machine",
183 "machine.bootloader()", 183 "machine.bootloader()",
184 ] 184 ]
185 ) 185 )
294 self.tr("CircuitPython Libraries"), 294 self.tr("CircuitPython Libraries"),
295 Preferences.getMicroPython("CircuitPythonLibrariesUrl"), 295 Preferences.getMicroPython("CircuitPythonLibrariesUrl"),
296 ), 296 ),
297 ] 297 ]
298 298
299 ##################################################################
300 ## time related methods below
301 ##################################################################
302
303 def _getSetTimeCode(self):
304 """
305 Protected method to get the device code to set the time.
306
307 Note: This method must be implemented in the various device specific
308 subclasses.
309
310 @return code to be executed on the connected device to set the time
311 @rtype str
312 """
313 # rtc_time[0] - year 4 digit
314 # rtc_time[1] - month 1..12
315 # rtc_time[2] - day 1..31
316 # rtc_time[3] - weekday 1..7 1=Monday
317 # rtc_time[4] - hour 0..23
318 # rtc_time[5] - minute 0..59
319 # rtc_time[6] - second 0..59
320 # rtc_time[7] - yearday 1..366
321 # rtc_time[8] - isdst 0, 1, or -1
322
323 # The machine.rtc.datetime() function takes the arguments in the order:
324 # (year, month, day, weekday, hour, minute, second, subseconds)
325 # __IGNORE_WARNING_M891__
326 # https://docs.micropython.org/en/latest/library/machine.RTC.html#machine-rtc
327 return """
328 def set_time(rtc_time):
329 import machine
330 rtc = machine.RTC()
331 rtc.datetime(rtc_time[:7] + (0,))
332 """
333
299 334
300 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber): 335 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
301 """ 336 """
302 Function to instantiate a MicroPython device object. 337 Function to instantiate a MicroPython device object.
303 338

eric ide

mercurial