MicroPython mpy_network

Mon, 27 Feb 2023 16:24:53 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 27 Feb 2023 16:24:53 +0100
branch
mpy_network
changeset 9815
6cbe3948044c
parent 9814
1445ca4be40d
child 9816
4aeaf6df7283

MicroPython
- Added functionality to search for known boot volumes in the UF2 flash dialog.

docs/changelog.md file | annotate | diff | comparison | revisions
src/eric7/MicroPython/UF2FlashDialog.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/UF2FlashDialog.ui file | annotate | diff | comparison | revisions
--- a/docs/changelog.md	Mon Feb 27 16:22:19 2023 +0100
+++ b/docs/changelog.md	Mon Feb 27 16:24:53 2023 +0100
@@ -1,5 +1,10 @@
 # Change Log
 
+### Version 23.4
+- bug fixes
+- MicroPython
+    - Added functionality to search for known boot volumes in the UF2 flash dialog.
+
 ### Version 23.3
 - bug fixes
 - MicroPython
--- a/src/eric7/MicroPython/UF2FlashDialog.py	Mon Feb 27 16:22:19 2023 +0100
+++ b/src/eric7/MicroPython/UF2FlashDialog.py	Mon Feb 27 16:24:53 2023 +0100
@@ -13,7 +13,7 @@
 
 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt, QThread, pyqtSlot
 from PyQt6.QtSerialPort import QSerialPortInfo
-from PyQt6.QtWidgets import QDialog
+from PyQt6.QtWidgets import QDialog, QInputDialog
 
 from eric7.EricGui import EricPixmapCache
 from eric7.EricWidgets.EricApplication import ericApp
@@ -720,6 +720,9 @@
         self.bootPicker.setMode(EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE)
         self.bootPicker.setEnabled(False)
 
+        self.searchBootButton.setIcon(EricPixmapCache.getIcon("question"))
+        self.searchBootButton.setEnabled(False)
+
         self.__mandatoryStyleSheet = (
             "QLineEdit {border: 2px solid; border-color: #dd8888}"
             if ericApp().usesDarkPalette()
@@ -1002,7 +1005,7 @@
             QCoreApplication.processEvents(
                 QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents
             )
-            shutil.copy2(firmwarePath, volumePath)
+            shutil.copy(firmwarePath, volumePath)
             QThread.sleep(1)
             self.on_refreshButton_clicked()
 
@@ -1028,6 +1031,7 @@
         vidpid = self.devicesComboBox.itemData(index, self.DeviceVidPidRole)
         boardType = self.devicesComboBox.itemData(index, self.DeviceTypeRole)
 
+        self.searchBootButton.setEnabled(boardType == self.__manualType)
         self.bootPicker.setEnabled(boardType == self.__manualType)
         if boardType == self.__manualType:
             self.__showManualInstructions()
@@ -1071,3 +1075,34 @@
         @type str
         """
         self.__updateFlashButton()
+
+    @pyqtSlot()
+    def on_searchBootButton_clicked(self):
+        """
+        Private slot to look for all known boot paths and present a list to select from.
+        """
+        foundBootVolumes = set()
+        for boardType in SupportedUF2Boards:
+            for volumes in SupportedUF2Boards[boardType]["volumes"].values():
+                for volume in volumes:
+                    foundBootVolumes.update(
+                        FileSystemUtilities.findVolume(volume, findAll=True)
+                    )
+
+        if len(foundBootVolumes) == 0:
+            selectedVolume = ""
+        elif len(foundBootVolumes) == 1:
+            selectedVolume = list(foundBootVolumes)[0]
+        else:
+            result, ok = QInputDialog.getItem(
+                None,
+                QCoreApplication.translate("UF2FlashDialog", "Flash UF2 Device"),
+                QCoreApplication.translate(
+                    "UF2FlashDialog", "Select the Boot Volume of the device:"
+                ),
+                list(foundBootVolumes),
+                0, True,
+            )
+            selectedVolume = result if ok else ""
+
+        self.bootPicker.setText(selectedVolume)
--- a/src/eric7/MicroPython/UF2FlashDialog.ui	Mon Feb 27 16:22:19 2023 +0100
+++ b/src/eric7/MicroPython/UF2FlashDialog.ui	Mon Feb 27 16:24:53 2023 +0100
@@ -26,7 +26,7 @@
        </property>
       </widget>
      </item>
-     <item row="0" column="1">
+     <item row="0" column="1" colspan="2">
       <widget class="QComboBox" name="devicesComboBox">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -46,7 +46,7 @@
        </property>
       </widget>
      </item>
-     <item row="1" column="1">
+     <item row="1" column="1" colspan="2">
       <widget class="EricPathPicker" name="firmwarePicker" native="true">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -65,7 +65,7 @@
      <item row="2" column="0">
       <widget class="QLabel" name="label_2">
        <property name="text">
-        <string>'Boot' Path:</string>
+        <string>'Boot' Volume:</string>
        </property>
       </widget>
      </item>
@@ -85,6 +85,13 @@
        </property>
       </widget>
      </item>
+     <item row="2" column="2">
+      <widget class="QToolButton" name="searchBootButton">
+       <property name="toolTip">
+        <string>Press to check for all known boot volume names.</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
@@ -167,6 +174,7 @@
   <tabstop>devicesComboBox</tabstop>
   <tabstop>firmwarePicker</tabstop>
   <tabstop>bootPicker</tabstop>
+  <tabstop>searchBootButton</tabstop>
   <tabstop>flashButton</tabstop>
   <tabstop>infoEdit</tabstop>
   <tabstop>refreshButton</tabstop>

eric ide

mercurial