eric6/MicroPython/CircuitPythonFirmwareSelectionDialog.py

Wed, 27 Jan 2021 18:27:52 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 27 Jan 2021 18:27:52 +0100
branch
jsonfiles
changeset 8011
630a173cb137
parent 7923
91e843545d9a
child 8054
3d9db64dff2f
permissions
-rw-r--r--

Implemented the JSON based tasks files.

7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the firmware flashing data.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtCore import pyqtSlot
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui.E5PathPicker import E5PathPickerModes
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui import E5MessageBox
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_CircuitPythonFirmwareSelectionDialog import (
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Ui_CircuitPythonFirmwareSelectionDialog
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 )
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import UI.PixmapCache
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class CircuitPythonFirmwareSelectionDialog(
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 QDialog, Ui_CircuitPythonFirmwareSelectionDialog):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing a dialog to enter the firmware flashing data.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 def __init__(self, parent=None):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param parent reference to the parent widget
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type QWidget
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 super(CircuitPythonFirmwareSelectionDialog, self).__init__(parent)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setupUi(self)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.retestButton.setIcon(UI.PixmapCache.getIcon("rescan"))
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.firmwarePicker.setMode(E5PathPickerModes.OpenFileMode)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.firmwarePicker.setFilters(
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.tr("CircuitPython Firmware Files (*.uf2);;"
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 "All Files (*)"))
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.bootPicker.setMode(E5PathPickerModes.DirectoryShowFilesMode)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
7595
5db6bfeff23e MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
50 self.__manualMarker = "<manual>"
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 boards = (
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 ("", ""), # indicator for no selection
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
54 # Adafruit boards
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
55 ("--- Adafruit ---", ""),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
56 ("CLUE nRF52840 Express", "CLUEBOOT"),
7596
1b1f401e1d70 CircuitPython: added firmware boot device entries for "Adafruit CLUE" and "Circuit Playground Bluefruit".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7595
diff changeset
57 ("Circuit Playground Bluefruit", "CPLAYBTBOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 ("Circuit Playground Express", "CPLAYBOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
59 ("Feather Bluefruit Sense", "FTHR840BOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
60 ("Feather M0 Adalogger", "FEATHERBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
61 ("Feather M0 Basic", "FEATHERBOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 ("Feather M0 Express", "FEATHERBOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
63 ("Feather M0 RFM69", "FEATHERBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
64 ("Feather M0 RFM9x", "FEATHERBOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 ("Feather M4 Express", "FEATHERBOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
66 ("Feather nRF52840 Express", "FTHR840BOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 ("Gemma M0", "GEMMABOOT"),
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 ("Grand Central M4 Express", "GCM4BOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
69 ("Hallowing M4 Express", "HALLOM4BOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 ("ItsyBitsy M0 Express", "ITSYBOOT"),
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 ("ItsyBitsy M4 Express", "ITSYM4BOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
72 ("ItsyBitsy nRF52840 Express", " ITSY840BOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 ("Metro M0 Express", "METROBOOT"),
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 ("Metro M4 Express", "METROM4BOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
75 ("Metro M4 Express AirLift", "METROM4BOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 ("NeoTrelis M4 Express", "TRELM4BOOT"),
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
77 ("PyBadge", "BADGEBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
78 ("PyGamer", "PYGAMERBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
79 ("PyPortal", "PORTALBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
80 ("PyPortal Pynt", "PORTALBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
81 ("PyPortal Titano", "PORTALBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
82 ("PyRuler", "TRINKETBOOT"),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 ("Trinket M0", "TRINKETBOOT"),
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
7597
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
85 # SparkFun boards
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
86 ("--- SparkFun ---", ""),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
87 ("Qwiic Micro", "QwiicMicro"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
88 ("SAMD51 Thing Plus", "51THINGBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
89 ("RedBoard Turbo", "TURBOBOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
90 ("Pro nRF52840 Mini", "NRF52BOOT"),
9dac5ef0126d MicroPython: added more boards to the board selection to flash CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7596
diff changeset
91
7595
5db6bfeff23e MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
92 (self.tr("Manual Select"), self.__manualMarker),
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 )
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 for boardName, bootVolume in boards:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.boardComboBox.addItem(boardName, bootVolume)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 msh = self.minimumSizeHint()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.resize(max(self.width(), msh.width()), msh.height())
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 def __updateOkButton(self):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 Private method to update the state of the OK button and the retest
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 button.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 firmwareFile = self.firmwarePicker.text()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.retestButton.setEnabled(bool(firmwareFile) and
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 os.path.exists(firmwareFile))
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 if not bool(firmwareFile) or not os.path.exists(firmwareFile):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 enable = False
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 else:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 volumeName = self.boardComboBox.currentData()
7595
5db6bfeff23e MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
113 if volumeName and volumeName != self.__manualMarker:
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 # check if the user selected a board and the board is in
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 # bootloader mode
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 deviceDirectory = Utilities.findVolume(volumeName)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if deviceDirectory:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.bootPicker.setText(deviceDirectory)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 enable = True
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 else:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 enable = False
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 E5MessageBox.warning(
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self,
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.tr("Select Path to Device"),
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.tr("""<p>The device volume <b>{0}</b> could not"""
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """ be found. Is the device in 'bootloader'"""
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """ mode and mounted?</p> <p>Alternatively"""
7147
7f30b93eb51d Updated German and English translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7116
diff changeset
128 """ select the "Manual Select" entry and"""
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """ enter the path to the device below.</p>""")
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 .format(volumeName)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 )
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
7595
5db6bfeff23e MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
133 elif volumeName == self.__manualMarker:
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 # select the device path manually
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 deviceDirectory = self.bootPicker.text()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 enable = (bool(deviceDirectory) and
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 os.path.exists(deviceDirectory))
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 else:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 # illegal entry
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 enable = False
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 @pyqtSlot(str)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 def on_firmwarePicker_textChanged(self, firmware):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Private slot handling a change of the firmware path.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @param firmware path to the firmware
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @type str
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.__updateOkButton()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @pyqtSlot(int)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def on_boardComboBox_currentIndexChanged(self, index):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Private slot to handle the selection of a board type.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @param index index of the selected board type
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @type int
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
7595
5db6bfeff23e MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
163 if self.boardComboBox.itemData(index) == self.__manualMarker:
7116
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.bootPicker.clear()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.bootPicker.setEnabled(True)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 else:
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.bootPicker.setEnabled(False)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.__updateOkButton()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 @pyqtSlot()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 def on_retestButton_clicked(self):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 Private slot to research for the selected volume.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.__updateOkButton()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 @pyqtSlot(str)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 def on_bootPicker_textChanged(self, devicePath):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 Private slot handling a change of the device path.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 @param devicePath path to the device
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 @type str
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.__updateOkButton()
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 def getData(self):
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 Public method to obtain the entered data.
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 @return tuple containing the path to the CircuitPython firmware file
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 and the path to the device
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @rtype tuple of (str, str)
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
233b6e62ca2b CircuitPython: added code to flash a new CircuitPython firmware.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 return self.firmwarePicker.text(), self.bootPicker.text()

eric ide

mercurial