# eric7.MicroPython.Devices.TeensyDevices

Module implementing the device interface class for Teensy boards with MicroPython.

### Global Attributes

None

### Classes

TeensyDevice | Class implementing the device for Teensy boards with MicroPython.

### Functions

createDevice | Function to instantiate a MicroPython device object.
showTeensyFlashInstructions | Slot to show a message box with instruction to flash the Teensy.
startTeensyLoader | Slot to start the 'Teensy Loader' application.

## TeensyDevice

Class implementing the device for Teensy boards with MicroPython.

### Derived from

BaseDevice

### Class Attributes

None

### Class Methods

None

### Methods

TeensyDevice | Constructor
__createTeensyMenu | Private method to create the microbit submenu.
__firmwareVersionResponse | Private slot handling the response of the latest version request.
__resetDevice | Private slot to reset 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.
getFirmwareUrl | Public method to get the device firmware download URL.
runScript | Public method to run the given Python script.
setButtons | Public method to enable the supported action buttons.

### Static Methods

None

#### TeensyDevice (Constructor)

TeensyDevice(microPythonWidget, deviceType, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
parent (QObject)
  reference to the parent object

#### TeensyDevice.__createTeensyMenu

__createTeensyMenu()

Private method to create the microbit submenu.

#### TeensyDevice.__firmwareVersionResponse

__firmwareVersionResponse(reply)

Private slot handling the response of the latest version request.

reply (QNetworkReply)
  reference to the reply object

#### TeensyDevice.__resetDevice

__resetDevice()

Private slot to reset the connected device.

#### TeensyDevice.__showFirmwareVersions

__showFirmwareVersions()

Private slot to show the firmware version of the connected device and the available firmware version.

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

#### TeensyDevice.addDeviceMenuEntries

addDeviceMenuEntries(menu)

Public method to add device specific entries to the given menu.

menu (QMenu)
  reference to the context menu

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

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

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

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

#### TeensyDevice.deviceName

deviceName()

Public method to get the name of the device.

Return:
  name of the device

Return Type:
  str

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

#### TeensyDevice.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Return:
  documentation URL of the device

Return Type:
  str

#### TeensyDevice.getFirmwareUrl

getFirmwareUrl()

Public method to get the device firmware download URL.

Return:
  firmware download URL of the device

Return Type:
  str

#### TeensyDevice.runScript

runScript(script)

Public method to run the given Python script.

script (str)
  script to be executed

#### TeensyDevice.setButtons

setButtons()

Public method to enable the supported action buttons.

Up

## 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 (unused)
_pid (int)
  product ID (unused)
_boardName (str)
  name of the board (unused)
_serialNumber (str)
  serial number of the board (unused)

Return:
  reference to the instantiated device object

Return Type:
  PyBoardDevice

Up

## showTeensyFlashInstructions

showTeensyFlashInstructions()

Slot to show a message box with instruction to flash the Teensy.

Up

## startTeensyLoader

startTeensyLoader()

Slot to start the 'Teensy Loader' application.

Note: The application must be accessible via the application search path.

Up