24 Ui_EspBackupRestoreFirmwareDialog): |
24 Ui_EspBackupRestoreFirmwareDialog): |
25 """ |
25 """ |
26 Class implementing a dialog to select the ESP chip type and the backup and |
26 Class implementing a dialog to select the ESP chip type and the backup and |
27 restore parameters. |
27 restore parameters. |
28 """ |
28 """ |
|
29 Chips = ( |
|
30 ("", ""), |
|
31 ("ESP32", "esp32"), |
|
32 ("ESP32-C3", "esp32c3"), |
|
33 ("ESP32-S2", "esp32s2"), |
|
34 ("ESP32-S3", "esp32s3"), |
|
35 ("ESP8266", "esp8266"), |
|
36 ) |
|
37 |
29 FlashModes = [ |
38 FlashModes = [ |
30 ("Quad I/O", "qio"), |
39 ("Quad I/O", "qio"), |
31 ("Quad Output", "qout"), |
40 ("Quad Output", "qout"), |
32 ("Dual I/O", "dio"), |
41 ("Dual I/O", "dio"), |
33 ("Dual Output", "dout"), |
42 ("Dual Output", "dout"), |
34 ] |
43 ] |
|
44 |
35 FlashSizes = { |
45 FlashSizes = { |
36 "ESP32": [ |
46 "esp32": [ |
37 (" 1 MB", "0x100000"), |
47 (" 1 MB", "0x100000"), |
38 (" 2 MB", "0x200000"), |
48 (" 2 MB", "0x200000"), |
39 (" 4 MB", "0x400000"), |
49 (" 4 MB", "0x400000"), |
40 (" 8 MB", "0x800000"), |
50 (" 8 MB", "0x800000"), |
41 ("16 MB", "0x1000000"), |
51 ("16 MB", "0x1000000"), |
42 ], |
52 ], |
43 "ESP8266": [ |
53 "esp32c3": [ |
|
54 (" 1 MB", "0x100000"), |
|
55 (" 2 MB", "0x200000"), |
|
56 (" 4 MB", "0x400000"), |
|
57 (" 8 MB", "0x800000"), |
|
58 ("16 MB", "0x1000000"), |
|
59 ], |
|
60 "esp32s2": [ |
|
61 (" 1 MB", "0x100000"), |
|
62 (" 2 MB", "0x200000"), |
|
63 (" 4 MB", "0x400000"), |
|
64 (" 8 MB", "0x800000"), |
|
65 ("16 MB", "0x1000000"), |
|
66 ], |
|
67 "esp32s3": [ |
|
68 (" 1 MB", "0x100000"), |
|
69 (" 2 MB", "0x200000"), |
|
70 (" 4 MB", "0x400000"), |
|
71 (" 8 MB", "0x800000"), |
|
72 ("16 MB", "0x1000000"), |
|
73 ], |
|
74 "esp8266": [ |
44 ("256 KB", "0x40000"), |
75 ("256 KB", "0x40000"), |
45 ("512 KB", "0x80000"), |
76 ("512 KB", "0x80000"), |
46 (" 1 MB", "0x100000"), |
77 (" 1 MB", "0x100000"), |
47 (" 2 MB", "0x200000"), |
78 (" 2 MB", "0x200000"), |
48 (" 4 MB", "0x400000"), |
79 (" 4 MB", "0x400000"), |
64 super().__init__(parent) |
95 super().__init__(parent) |
65 self.setupUi(self) |
96 self.setupUi(self) |
66 |
97 |
67 self.__isBackupMode = backupMode |
98 self.__isBackupMode = backupMode |
68 |
99 |
69 self.espComboBox.addItems(["", "ESP32", "ESP8266"]) |
100 for text, chip in self.Chips: |
|
101 self.espComboBox.addItem(text, chip) |
70 |
102 |
71 self.firmwarePicker.setFilters( |
103 self.firmwarePicker.setFilters( |
72 self.tr("Firmware Files (*.img);;All Files (*)")) |
104 self.tr("Firmware Files (*.img);;All Files (*)")) |
73 if self.__isBackupMode: |
105 if self.__isBackupMode: |
74 self.firmwarePicker.setMode( |
106 self.firmwarePicker.setMode( |
106 @param chip selected chip type |
138 @param chip selected chip type |
107 @type str |
139 @type str |
108 """ |
140 """ |
109 selectedSize = self.sizeComboBox.currentText() |
141 selectedSize = self.sizeComboBox.currentText() |
110 self.sizeComboBox.clear() |
142 self.sizeComboBox.clear() |
111 if chip and chip in self.FlashSizes: |
143 chipType = self.espComboBox.currentData() |
|
144 if chipType and chipType in self.FlashSizes: |
112 self.sizeComboBox.addItem("") |
145 self.sizeComboBox.addItem("") |
113 for text, data in self.FlashSizes[chip]: |
146 for text, data in self.FlashSizes[chipType]: |
114 self.sizeComboBox.addItem(text, data) |
147 self.sizeComboBox.addItem(text, data) |
115 |
148 |
116 self.sizeComboBox.setCurrentText(selectedSize) |
149 self.sizeComboBox.setCurrentText(selectedSize) |
117 |
150 |
118 self.__updateOkButton() |
151 self.__updateOkButton() |
134 @return tuple containing the selected chip type, the firmware size, |
167 @return tuple containing the selected chip type, the firmware size, |
135 the flash mode and the path of the firmware file |
168 the flash mode and the path of the firmware file |
136 @rtype tuple of (str, str, str, str) |
169 @rtype tuple of (str, str, str, str) |
137 """ |
170 """ |
138 return ( |
171 return ( |
139 self.espComboBox.currentText().lower(), |
172 self.espComboBox.currentData(), |
140 self.sizeComboBox.currentData(), |
173 self.sizeComboBox.currentData(), |
141 self.modeComboBox.currentData(), |
174 self.modeComboBox.currentData(), |
142 self.firmwarePicker.text(), |
175 self.firmwarePicker.text(), |
143 ) |
176 ) |