# eric6.MicroPython.MicrobitDevices

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

### Global Attributes

None

### Classes

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

### Functions

None

## MicrobitDevice

Class implementing the device for BBC micro:bit boards.

### Derived from

MicroPythonDevice

### Class Attributes

None

### Class Methods

None

### Methods

MicrobitDevice | Constructor
__flashMicroPython | Private slot to flash the default MicroPython 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.
getFirmwareUrl | Public method to get the device firmware download URL.
getWorkspace | Public method to get the workspace directory.
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, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
parent (QObject)
  reference to the parent object

#### MicrobitDevice.__flashMicroPython

__flashMicroPython()

Private slot to flash the default MicroPython firmware to the device.

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

Returns:
  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.

Returns:
  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.

Returns:
  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.

Returns:
  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.

Returns:
  name of the device

Return Type:
  str

#### MicrobitDevice.forceInterrupt

forceInterrupt()

Public method to determine the need for an interrupt when opening the serial connection.

Returns:
  flag indicating an interrupt is needed

Return Type:
  bool

#### MicrobitDevice.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Returns:
  documentation URL of the device

Return Type:
  str

#### MicrobitDevice.getFirmwareUrl

getFirmwareUrl()

Public method to get the device firmware download URL.

Returns:
  firmware download URL of the device

Return Type:
  str

#### MicrobitDevice.getWorkspace

getWorkspace()

Public method to get the workspace directory.

Returns:
  workspace directory used for saving files

Return Type:
  str

#### MicrobitDevice.hasTimeCommands

hasTimeCommands()

Public method to check, if the device supports time commands.

The default returns True.

Returns:
  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