# eric7.MicroPython.MicrobitDevices

Module implementing the device interface class for BBC micro:bit and Calliope mini boards.

### Global Attributes

None

### Classes

MicrobitDevice | Class implementing the device for BBC micro:bit and Calliope mini boards.

### Functions

None

## MicrobitDevice

Class implementing the device for BBC micro:bit and Calliope mini boards.

### Derived from

MicroPythonDevice

### Class Attributes

None

### Class Methods

None

### Methods

MicrobitDevice | Constructor
__flashMicroPython | Private slot to flash MicroPython or the DAPLink firmware to the device.
__resetDevice | Private slot to reset the connected device.
__saveMain | Private slot to copy the current script as 'main.py' onto the connected device.
__saveScriptToDevice | Private method to save the current script onto the connected device.
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.
runScript | Public method to run the given Python script.
setButtons | Public method to enable the supported action buttons.

### Static Methods

None

#### MicrobitDevice (Constructor)

MicrobitDevice(microPythonWidget, deviceType, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  type of the device
parent (QObject)
  reference to the parent 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.__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.__saveScriptToDevice

__saveScriptToDevice(scriptName="")

Private method to save the current script onto the connected device.

scriptName (str)
  name of the file on the device

#### 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.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.

Up