eric7.MicroPython.Devices.MicrobitDevices
Module implementing the device interface class for BBC micro:bit and
Calliope mini boards.
Global Attributes
Classes
| MicrobitDevice |
Class implementing the device for BBC micro:bit and Calliope mini boards. |
Functions
| createDevice |
Function to instantiate a MicroPython device object. |
MicrobitDevice
Class implementing the device for BBC micro:bit and Calliope mini boards.
Derived from
BaseDevice
Class Attributes
Class Methods
Methods
| MicrobitDevice |
Constructor |
| __createMicrobitMenu |
Private method to create the microbit submenu. |
| __firmwareVersionResponse |
Private method handling the response of the latest version request. |
| __flashMicroPython |
Private slot to flash MicroPython or the DAPLink firmware to the device. |
| __isCalliope |
Private method to check, if the device is a Calliope mini. |
| __isMicroBitV1 |
Private method to check, if the device is a BBC micro:bit v1. |
| __isMicroBitV2 |
Private method to check, if the device is a BBC micro:bit v2. |
| __resetDevice |
Private slot to reset the connected device. |
| __saveMain |
Private slot to copy the current script as 'main.py' onto the connected device. |
| __showFirmwareVersions |
Private slot to show the firmware version of the connected device and the available firmware version. |
| _getSetTimeCode |
Protected method to get the device code to set the time. |
| addDeviceMenuEntries |
Public method to add device specific entries to the given menu. |
| canRunScript |
Public method to determine, if a script can be executed. |
| canStartFileManager |
Public method to determine, if a File Manager can be started. |
| canStartPlotter |
Public method to determine, if a Plotter can be started. |
| canStartRepl |
Public method to determine, if a REPL can be started. |
| deviceName |
Public method to get the name of the device. |
| forceInterrupt |
Public method to determine the need for an interrupt when opening the serial connection. |
| getDocumentationUrl |
Public method to get the device documentation URL. |
| getDownloadMenuEntries |
Public method to retrieve the entries for the downloads menu. |
| hasFlashMenuEntry |
Public method to check, if the device has its own flash menu entry. |
| hasTimeCommands |
Public method to check, if the device supports time commands. |
| lls |
Public method to get a long directory listing of the connected device including meta data. |
| ls |
Public method to get a directory listing of the connected device. |
| pwd |
Public method to get the current directory of the connected device. |
| runScript |
Public method to run the given Python script. |
| setButtons |
Public method to enable the supported action buttons. |
Static Methods
MicrobitDevice (Constructor)
MicrobitDevice(microPythonWidget, deviceType, serialNumber, parent=None)
Constructor
- microPythonWidget (MicroPythonWidget)
-
reference to the main MicroPython widget
- deviceType (str)
-
type of the device
- serialNumber (str)
-
serial number of the board
- parent (QObject)
-
reference to the parent object
MicrobitDevice.__createMicrobitMenu
__createMicrobitMenu()
Private method to create the microbit submenu.
MicrobitDevice.__firmwareVersionResponse
__firmwareVersionResponse(reply)
Private method handling the response of the latest version request.
- reply (QNetworkReply)
-
reference to the reply object
MicrobitDevice.__flashMicroPython
__flashMicroPython(firmware=False)
Private slot to flash MicroPython or the DAPLink firmware to the
device.
- firmware (bool)
-
flag indicating to flash the DAPLink firmware
MicrobitDevice.__isCalliope
__isCalliope()
Private method to check, if the device is a Calliope mini.
- Return:
-
flag indicating a Calliope mini
- Return Type:
-
bool
MicrobitDevice.__isMicroBitV1
__isMicroBitV1()
Private method to check, if the device is a BBC micro:bit v1.
- Return:
-
falg indicating a BBC micro:bit v1
- Return Type:
-
bool
MicrobitDevice.__isMicroBitV2
__isMicroBitV2()
Private method to check, if the device is a BBC micro:bit v2.
- Return:
-
falg indicating a BBC micro:bit v2
- Return Type:
-
bool
MicrobitDevice.__resetDevice
__resetDevice()
Private slot to reset the connected device.
MicrobitDevice.__saveMain
__saveMain()
Private slot to copy the current script as 'main.py' onto the
connected device.
MicrobitDevice.__showFirmwareVersions
__showFirmwareVersions()
Private slot to show the firmware version of the connected device and the
available firmware version.
MicrobitDevice._getSetTimeCode
_getSetTimeCode()
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
- Return Type:
-
str
MicrobitDevice.addDeviceMenuEntries
addDeviceMenuEntries(menu)
Public method to add device specific entries to the given menu.
- menu (QMenu)
-
reference to the context menu
MicrobitDevice.canRunScript
canRunScript()
Public method to determine, if a script can be executed.
- Return:
-
tuple containing a flag indicating it is safe to start a
Plotter and a reason why it cannot.
- Return Type:
-
tuple of (bool, str)
MicrobitDevice.canStartFileManager
canStartFileManager()
Public method to determine, if a File Manager can be started.
- Return:
-
tuple containing a flag indicating it is safe to start a
File Manager and a reason why it cannot.
- Return Type:
-
tuple of (bool, str)
MicrobitDevice.canStartPlotter
canStartPlotter()
Public method to determine, if a Plotter can be started.
- Return:
-
tuple containing a flag indicating it is safe to start a
Plotter and a reason why it cannot.
- Return Type:
-
tuple of (bool, str)
MicrobitDevice.canStartRepl
canStartRepl()
Public method to determine, if a REPL can be started.
- Return:
-
tuple containing a flag indicating it is safe to start a REPL
and a reason why it cannot.
- Return Type:
-
tuple of (bool, str)
MicrobitDevice.deviceName
deviceName()
Public method to get the name of the device.
- Return:
-
name of the device
- Return Type:
-
str
MicrobitDevice.forceInterrupt
forceInterrupt()
Public method to determine the need for an interrupt when opening the
serial connection.
- Return:
-
flag indicating an interrupt is needed
- Return Type:
-
bool
MicrobitDevice.getDocumentationUrl
getDocumentationUrl()
Public method to get the device documentation URL.
- Return:
-
documentation URL of the device
- Return Type:
-
str
MicrobitDevice.getDownloadMenuEntries
getDownloadMenuEntries()
Public method to retrieve the entries for the downloads menu.
- Return:
-
list of tuples with menu text and URL to be opened for each
entry
- Return Type:
-
list of tuple of (str, str)
MicrobitDevice.hasFlashMenuEntry
hasFlashMenuEntry()
Public method to check, if the device has its own flash menu entry.
- Return:
-
flag indicating a specific flash menu entry
- Return Type:
-
bool
MicrobitDevice.hasTimeCommands
hasTimeCommands()
Public method to check, if the device supports time commands.
The default returns True.
- Return:
-
flag indicating support for time commands
- Return Type:
-
bool
MicrobitDevice.lls
lls(dirname="", fullstat=False, showHidden=False)
Public method to get a long directory listing of the connected device
including meta data.
- dirname (str)
-
name of the directory to be listed
- fullstat (bool)
-
flag indicating to return the full stat() tuple
- showHidden (bool)
-
flag indicating to show hidden files as well
- Return:
-
list containing the directory listing with tuple entries of
the name and and a tuple of mode, size and time (if fullstat is
false) or the complete stat() tuple. 'None' is returned in case the
directory doesn't exist.
- Return Type:
-
tuple of (str, tuple)
- Raises OSError:
-
raised to indicate an issue with the device
MicrobitDevice.ls
ls(dirname="")
Public method to get a directory listing of the connected device.
- dirname (str)
-
name of the directory to be listed
- Return:
-
tuple containg the directory listing
- Return Type:
-
tuple of str
- Raises OSError:
-
raised to indicate an issue with the device
MicrobitDevice.pwd
pwd()
Public method to get the current directory of the connected device.
- Return:
-
current directory
- Return Type:
-
str
MicrobitDevice.runScript
runScript(script)
Public method to run the given Python script.
- script (str)
-
script to be executed
MicrobitDevice.setButtons
setButtons()
Public method to enable the supported action buttons.
createDevice
createDevice(microPythonWidget, deviceType, vid, pid, boardName, serialNumber)
Function to instantiate a MicroPython device object.
- microPythonWidget (MicroPythonWidget)
-
reference to the main MicroPython widget
- deviceType (str)
-
device type assigned to this device interface
- vid (int)
-
vendor ID
- pid (int)
-
product ID
- boardName (str)
-
name of the board
- serialNumber (str)
-
serial number of the board
- Return:
-
reference to the instantiated device object
- Return Type:
-
MicrobitDevice