src/eric7/MicroPython/Devices/PyBoardDevices.py

branch
eric7
changeset 9765
6378da868bb0
parent 9763
52f982c08301
child 9770
2d7a244886d1
equal deleted inserted replaced
9764:57496966803c 9765:6378da868bb0
17 from eric7.EricWidgets import EricFileDialog, EricMessageBox 17 from eric7.EricWidgets import EricFileDialog, EricMessageBox
18 from eric7.EricWidgets.EricApplication import ericApp 18 from eric7.EricWidgets.EricApplication import ericApp
19 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog 19 from eric7.EricWidgets.EricProcessDialog import EricProcessDialog
20 from eric7.SystemUtilities import FileSystemUtilities 20 from eric7.SystemUtilities import FileSystemUtilities
21 21
22 from ..MicroPythonWidget import HAS_QTCHART
22 from . import FirmwareGithubUrls 23 from . import FirmwareGithubUrls
23 from .DeviceBase import BaseDevice 24 from .DeviceBase import BaseDevice
24 from ..MicroPythonWidget import HAS_QTCHART
25 25
26 26
27 class PyBoardDevice(BaseDevice): 27 class PyBoardDevice(BaseDevice):
28 """ 28 """
29 Class implementing the device for PyBoard boards. 29 Class implementing the device for PyBoard boards.
487 def __activateBootloader(self): 487 def __activateBootloader(self):
488 """ 488 """
489 Private slot to activate the bootloader and disconnect. 489 Private slot to activate the bootloader and disconnect.
490 """ 490 """
491 if self.microPython.isConnected(): 491 if self.microPython.isConnected():
492 self.microPython.commandsInterface().execute( 492 self.microPython.deviceInterface().execute(
493 [ 493 [
494 "import pyb", 494 "import pyb",
495 "pyb.bootloader()", 495 "pyb.bootloader()",
496 ] 496 ]
497 ) 497 )
498 # simulate pressing the disconnect button 498 # simulate pressing the disconnect button
499 self.microPython.on_connectButton_clicked() 499 self.microPython.on_connectButton_clicked()
500
501 ##################################################################
502 ## time related methods below
503 ##################################################################
504
505 def _getSetTimeCode(self):
506 """
507 Protected method to get the device code to set the time.
508
509 Note: This method must be implemented in the various device specific
510 subclasses.
511
512 @return code to be executed on the connected device to set the time
513 @rtype str
514 """
515 # rtc_time[0] - year 4 digit
516 # rtc_time[1] - month 1..12
517 # rtc_time[2] - day 1..31
518 # rtc_time[3] - weekday 1..7 1=Monday
519 # rtc_time[4] - hour 0..23
520 # rtc_time[5] - minute 0..59
521 # rtc_time[6] - second 0..59
522 # rtc_time[7] - yearday 1..366
523 # rtc_time[8] - isdst 0, 1, or -1
524
525 # The pyb.RTC.datetime() function takes the arguments in the
526 # order: (year, month, day, weekday, hour, minute, second,
527 # subseconds)
528 # http://docs.micropython.org/en/latest/library/pyb.RTC.html#pyb.RTC.datetime
529 return """
530 def set_time(rtc_time):
531 import pyb
532 rtc = pyb.RTC()
533 rtc.datetime(rtc_time[:7] + (0,))
534 """
500 535
501 536
502 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber): 537 def createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber):
503 """ 538 """
504 Function to instantiate a MicroPython device object. 539 Function to instantiate a MicroPython device object.

eric ide

mercurial