Sat, 26 Apr 2025 12:34:32 +0200
MicroPython
- Added a configuration option to disable the support for the no longer produced Pimoroni Pico Wireless Pack.
<!DOCTYPE html> <html><head> <title>eric7.MicroPython.Devices.Nrf52Devices</title> <meta charset="UTF-8"> <link rel="stylesheet" href="styles.css"> </head> <body> <a NAME="top" ID="top"></a> <h1>eric7.MicroPython.Devices.Nrf52Devices</h1> <p> Module implementing the device interface class for NRF52 boards with UF2 support. </p> <h3>Global Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#Nrf52Device">Nrf52Device</a></td> <td>Class implementing the device for NRF52 boards with UF2 support.</td> </tr> </table> <h3>Functions</h3> <table> <tr> <td><a href="#createDevice">createDevice</a></td> <td>Function to instantiate a MicroPython device object.</td> </tr> </table> <hr /> <hr /> <a NAME="Nrf52Device" ID="Nrf52Device"></a> <h2>Nrf52Device</h2> <p> Class implementing the device for NRF52 boards with UF2 support. </p> <h3>Derived from</h3> BaseDevice <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#Nrf52Device.__init__">Nrf52Device</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#Nrf52Device.__activateBootloader">__activateBootloader</a></td> <td>Private slot to switch the board into 'bootloader' mode.</td> </tr> <tr> <td><a href="#Nrf52Device.__createNrfMenu">__createNrfMenu</a></td> <td>Private method to create the NRF52 submenu.</td> </tr> <tr> <td><a href="#Nrf52Device.__firmwareVersionResponse">__firmwareVersionResponse</a></td> <td>Private slot handling the response of the latest version request.</td> </tr> <tr> <td><a href="#Nrf52Device.__flashPython">__flashPython</a></td> <td>Private slot to flash a MicroPython firmware to the device.</td> </tr> <tr> <td><a href="#Nrf52Device.__resetDevice">__resetDevice</a></td> <td>Private slot to reset the connected device.</td> </tr> <tr> <td><a href="#Nrf52Device.__showFirmwareVersions">__showFirmwareVersions</a></td> <td>Private slot to show the firmware version of the connected device and the available firmware version.</td> </tr> <tr> <td><a href="#Nrf52Device.activateBluetoothInterface">activateBluetoothInterface</a></td> <td>Public method to activate the Bluetooth interface.</td> </tr> <tr> <td><a href="#Nrf52Device.addDeviceMenuEntries">addDeviceMenuEntries</a></td> <td>Public method to add device specific entries to the given menu.</td> </tr> <tr> <td><a href="#Nrf52Device.canRunScript">canRunScript</a></td> <td>Public method to determine, if a script can be executed.</td> </tr> <tr> <td><a href="#Nrf52Device.canStartFileManager">canStartFileManager</a></td> <td>Public method to determine, if a File Manager can be started.</td> </tr> <tr> <td><a href="#Nrf52Device.canStartPlotter">canStartPlotter</a></td> <td>Public method to determine, if a Plotter can be started.</td> </tr> <tr> <td><a href="#Nrf52Device.canStartRepl">canStartRepl</a></td> <td>Public method to determine, if a REPL can be started.</td> </tr> <tr> <td><a href="#Nrf52Device.deactivateBluetoothInterface">deactivateBluetoothInterface</a></td> <td>Public method to deactivate the Bluetooth interface.</td> </tr> <tr> <td><a href="#Nrf52Device.deviceName">deviceName</a></td> <td>Public method to get the name of the device.</td> </tr> <tr> <td><a href="#Nrf52Device.forceInterrupt">forceInterrupt</a></td> <td>Public method to determine the need for an interrupt when opening the serial connection.</td> </tr> <tr> <td><a href="#Nrf52Device.getBluetoothStatus">getBluetoothStatus</a></td> <td>Public method to get Bluetooth status data of the connected board.</td> </tr> <tr> <td><a href="#Nrf52Device.getDeviceScan">getDeviceScan</a></td> <td>Public method to perform a Bluetooth device scan.</td> </tr> <tr> <td><a href="#Nrf52Device.getDocumentationUrl">getDocumentationUrl</a></td> <td>Public method to get the device documentation URL.</td> </tr> <tr> <td><a href="#Nrf52Device.getDownloadMenuEntries">getDownloadMenuEntries</a></td> <td>Public method to retrieve the entries for the downloads menu.</td> </tr> <tr> <td><a href="#Nrf52Device.hasBluetooth">hasBluetooth</a></td> <td>Public method to check the availability of Bluetooth.</td> </tr> <tr> <td><a href="#Nrf52Device.hasFlashMenuEntry">hasFlashMenuEntry</a></td> <td>Public method to check, if the device has its own flash menu entry.</td> </tr> <tr> <td><a href="#Nrf52Device.runScript">runScript</a></td> <td>Public method to run the given Python script.</td> </tr> <tr> <td><a href="#Nrf52Device.setButtons">setButtons</a></td> <td>Public method to enable the supported action buttons.</td> </tr> <tr> <td><a href="#Nrf52Device.supportsDeviceScan">supportsDeviceScan</a></td> <td>Public method to indicate, that the Bluetooth implementation supports scanning for devices.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Nrf52Device.__init__" ID="Nrf52Device.__init__"></a> <h4>Nrf52Device (Constructor)</h4> <b>Nrf52Device</b>(<i>microPythonWidget, deviceType, parent=None</i>) <p> Constructor </p> <dl> <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt> <dd> reference to the main MicroPython widget </dd> <dt><i>deviceType</i> (str)</dt> <dd> device type assigned to this device interface </dd> <dt><i>parent</i> (QObject)</dt> <dd> reference to the parent object </dd> </dl> <a NAME="Nrf52Device.__activateBootloader" ID="Nrf52Device.__activateBootloader"></a> <h4>Nrf52Device.__activateBootloader</h4> <b>__activateBootloader</b>(<i></i>) <p> Private slot to switch the board into 'bootloader' mode. </p> <a NAME="Nrf52Device.__createNrfMenu" ID="Nrf52Device.__createNrfMenu"></a> <h4>Nrf52Device.__createNrfMenu</h4> <b>__createNrfMenu</b>(<i></i>) <p> Private method to create the NRF52 submenu. </p> <a NAME="Nrf52Device.__firmwareVersionResponse" ID="Nrf52Device.__firmwareVersionResponse"></a> <h4>Nrf52Device.__firmwareVersionResponse</h4> <b>__firmwareVersionResponse</b>(<i>reply</i>) <p> Private slot handling the response of the latest version request. </p> <dl> <dt><i>reply</i> (QNetworkReply)</dt> <dd> reference to the reply object </dd> </dl> <a NAME="Nrf52Device.__flashPython" ID="Nrf52Device.__flashPython"></a> <h4>Nrf52Device.__flashPython</h4> <b>__flashPython</b>(<i></i>) <p> Private slot to flash a MicroPython firmware to the device. </p> <a NAME="Nrf52Device.__resetDevice" ID="Nrf52Device.__resetDevice"></a> <h4>Nrf52Device.__resetDevice</h4> <b>__resetDevice</b>(<i></i>) <p> Private slot to reset the connected device. </p> <a NAME="Nrf52Device.__showFirmwareVersions" ID="Nrf52Device.__showFirmwareVersions"></a> <h4>Nrf52Device.__showFirmwareVersions</h4> <b>__showFirmwareVersions</b>(<i></i>) <p> Private slot to show the firmware version of the connected device and the available firmware version. </p> <a NAME="Nrf52Device.activateBluetoothInterface" ID="Nrf52Device.activateBluetoothInterface"></a> <h4>Nrf52Device.activateBluetoothInterface</h4> <b>activateBluetoothInterface</b>(<i></i>) <p> Public method to activate the Bluetooth interface. </p> <dl> <dt>Return:</dt> <dd> flag indicating the new state of the Bluetooth interface </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <dl> <dt>Raises <b>OSError</b>:</dt> <dd> raised to indicate an issue with the device </dd> </dl> <a NAME="Nrf52Device.addDeviceMenuEntries" ID="Nrf52Device.addDeviceMenuEntries"></a> <h4>Nrf52Device.addDeviceMenuEntries</h4> <b>addDeviceMenuEntries</b>(<i>menu</i>) <p> Public method to add device specific entries to the given menu. </p> <dl> <dt><i>menu</i> (QMenu)</dt> <dd> reference to the context menu </dd> </dl> <a NAME="Nrf52Device.canRunScript" ID="Nrf52Device.canRunScript"></a> <h4>Nrf52Device.canRunScript</h4> <b>canRunScript</b>(<i></i>) <p> Public method to determine, if a script can be executed. </p> <dl> <dt>Return:</dt> <dd> tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot. </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (bool, str) </dd> </dl> <a NAME="Nrf52Device.canStartFileManager" ID="Nrf52Device.canStartFileManager"></a> <h4>Nrf52Device.canStartFileManager</h4> <b>canStartFileManager</b>(<i></i>) <p> Public method to determine, if a File Manager can be started. </p> <dl> <dt>Return:</dt> <dd> tuple containing a flag indicating it is safe to start a File Manager and a reason why it cannot. </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (bool, str) </dd> </dl> <a NAME="Nrf52Device.canStartPlotter" ID="Nrf52Device.canStartPlotter"></a> <h4>Nrf52Device.canStartPlotter</h4> <b>canStartPlotter</b>(<i></i>) <p> Public method to determine, if a Plotter can be started. </p> <dl> <dt>Return:</dt> <dd> tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot. </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (bool, str) </dd> </dl> <a NAME="Nrf52Device.canStartRepl" ID="Nrf52Device.canStartRepl"></a> <h4>Nrf52Device.canStartRepl</h4> <b>canStartRepl</b>(<i></i>) <p> Public method to determine, if a REPL can be started. </p> <dl> <dt>Return:</dt> <dd> tuple containing a flag indicating it is safe to start a REPL and a reason why it cannot. </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (bool, str) </dd> </dl> <a NAME="Nrf52Device.deactivateBluetoothInterface" ID="Nrf52Device.deactivateBluetoothInterface"></a> <h4>Nrf52Device.deactivateBluetoothInterface</h4> <b>deactivateBluetoothInterface</b>(<i></i>) <p> Public method to deactivate the Bluetooth interface. </p> <dl> <dt>Return:</dt> <dd> flag indicating the new state of the Bluetooth interface </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <dl> <dt>Raises <b>OSError</b>:</dt> <dd> raised to indicate an issue with the device </dd> </dl> <a NAME="Nrf52Device.deviceName" ID="Nrf52Device.deviceName"></a> <h4>Nrf52Device.deviceName</h4> <b>deviceName</b>(<i></i>) <p> Public method to get the name of the device. </p> <dl> <dt>Return:</dt> <dd> name of the device </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Nrf52Device.forceInterrupt" ID="Nrf52Device.forceInterrupt"></a> <h4>Nrf52Device.forceInterrupt</h4> <b>forceInterrupt</b>(<i></i>) <p> Public method to determine the need for an interrupt when opening the serial connection. </p> <dl> <dt>Return:</dt> <dd> flag indicating an interrupt is needed </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <a NAME="Nrf52Device.getBluetoothStatus" ID="Nrf52Device.getBluetoothStatus"></a> <h4>Nrf52Device.getBluetoothStatus</h4> <b>getBluetoothStatus</b>(<i></i>) <p> Public method to get Bluetooth status data of the connected board. </p> <dl> <dt>Return:</dt> <dd> list of tuples containing the translated status data label and the associated value </dd> </dl> <dl> <dt>Return Type:</dt> <dd> list of tuples of (str, str) </dd> </dl> <dl> <dt>Raises <b>OSError</b>:</dt> <dd> raised to indicate an issue with the device </dd> </dl> <a NAME="Nrf52Device.getDeviceScan" ID="Nrf52Device.getDeviceScan"></a> <h4>Nrf52Device.getDeviceScan</h4> <b>getDeviceScan</b>(<i>timeout=10</i>) <p> Public method to perform a Bluetooth device scan. </p> <dl> <dt><i>timeout</i> (int (optional))</dt> <dd> duration of the device scan in seconds (defaults to 10) </dd> </dl> <dl> <dt>Return:</dt> <dd> tuple containing a dictionary with the scan results and an error string </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (dict, str) </dd> </dl> <a NAME="Nrf52Device.getDocumentationUrl" ID="Nrf52Device.getDocumentationUrl"></a> <h4>Nrf52Device.getDocumentationUrl</h4> <b>getDocumentationUrl</b>(<i></i>) <p> Public method to get the device documentation URL. </p> <dl> <dt>Return:</dt> <dd> documentation URL of the device </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Nrf52Device.getDownloadMenuEntries" ID="Nrf52Device.getDownloadMenuEntries"></a> <h4>Nrf52Device.getDownloadMenuEntries</h4> <b>getDownloadMenuEntries</b>(<i></i>) <p> Public method to retrieve the entries for the downloads menu. </p> <dl> <dt>Return:</dt> <dd> list of tuples with menu text and URL to be opened for each entry </dd> </dl> <dl> <dt>Return Type:</dt> <dd> list of tuple of (str, str) </dd> </dl> <a NAME="Nrf52Device.hasBluetooth" ID="Nrf52Device.hasBluetooth"></a> <h4>Nrf52Device.hasBluetooth</h4> <b>hasBluetooth</b>(<i></i>) <p> Public method to check the availability of Bluetooth. </p> <dl> <dt>Return:</dt> <dd> flag indicating the availability of Bluetooth </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <dl> <dt>Raises <b>OSError</b>:</dt> <dd> raised to indicate an issue with the device </dd> </dl> <a NAME="Nrf52Device.hasFlashMenuEntry" ID="Nrf52Device.hasFlashMenuEntry"></a> <h4>Nrf52Device.hasFlashMenuEntry</h4> <b>hasFlashMenuEntry</b>(<i></i>) <p> Public method to check, if the device has its own flash menu entry. </p> <dl> <dt>Return:</dt> <dd> flag indicating a specific flash menu entry </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <a NAME="Nrf52Device.runScript" ID="Nrf52Device.runScript"></a> <h4>Nrf52Device.runScript</h4> <b>runScript</b>(<i>script</i>) <p> Public method to run the given Python script. </p> <dl> <dt><i>script</i> (str)</dt> <dd> script to be executed </dd> </dl> <a NAME="Nrf52Device.setButtons" ID="Nrf52Device.setButtons"></a> <h4>Nrf52Device.setButtons</h4> <b>setButtons</b>(<i></i>) <p> Public method to enable the supported action buttons. </p> <a NAME="Nrf52Device.supportsDeviceScan" ID="Nrf52Device.supportsDeviceScan"></a> <h4>Nrf52Device.supportsDeviceScan</h4> <b>supportsDeviceScan</b>(<i></i>) <p> Public method to indicate, that the Bluetooth implementation supports scanning for devices. </p> <dl> <dt>Return:</dt> <dd> flag indicating that the scanning function is supported </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="createDevice" ID="createDevice"></a> <h2>createDevice</h2> <b>createDevice</b>(<i>microPythonWidget, deviceType, _vid, _pid, _boardName, _serialNumber</i>) <p> Function to instantiate a MicroPython device object. </p> <dl> <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt> <dd> reference to the main MicroPython widget </dd> <dt><i>deviceType</i> (str)</dt> <dd> device type assigned to this device interface </dd> <dt><i>_vid</i> (int)</dt> <dd> vendor ID (unused) </dd> <dt><i>_pid</i> (int)</dt> <dd> product ID (unused) </dd> <dt><i>_boardName</i> (str)</dt> <dd> name of the board (unused) </dd> <dt><i>_serialNumber</i> (str)</dt> <dd> serial number of the board (unused) </dd> </dl> <dl> <dt>Return:</dt> <dd> reference to the instantiated device object </dd> </dl> <dl> <dt>Return Type:</dt> <dd> RP2Device </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>