Skip to content

Commit

Permalink
Add command "Show esptool version" for ESP flasher
Browse files Browse the repository at this point in the history
  • Loading branch information
aivarannamaa committed Jun 2, 2023
1 parent fc37c35 commit df67a5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version history
==================
* Fix MicroPython config page regression introduced in 4.1.0b1 (#2724, #2763)
* Fix code completion shortcut displayed in macOS menu
* Add command "Show esptool version" for ESP flasher
* Close tab on middle click (#2767) by @mrexodia
* Make package manager support new micropython-lib index (#2777)
* Report macOS version instead of Darwin version in the About box
Expand Down
21 changes: 20 additions & 1 deletion thonny/plugins/micropython/esptool_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def prepare_work_get_options(self) -> Dict[str, Any]:
if port_was_used_in_thonny:
proxy.disconnect()

if self._work_mode in ["device_info", "image_info"]:
if self._work_mode in ["device_info", "image_info", "esptool_version"]:
self.show_log_frame()

return {
Expand Down Expand Up @@ -314,6 +314,13 @@ def perform_core_operation(

progress_text = "Querying device info"

elif self._work_mode == "esptool_version":
command = self._esptool_command + [
"version",
]

progress_text = "Querying esptool version"

elif self._work_mode == "image_info":
assert source_path
command = self._esptool_command + ["image_info", "--version", "2", source_path]
Expand Down Expand Up @@ -524,6 +531,11 @@ def populate_action_menu(self, action_menu: tk.Menu) -> None:
command=self._show_image_info,
state="normal" if self._can_query_image_info() else "disabled",
)
action_menu.add_command(
label="Show esptool version",
command=self._show_esptool_version,
state="normal" if self._can_show_esptool_version() else "disabled",
)

action_menu.add_separator()
if self._advanced_widgets[0].winfo_ismapped():
Expand All @@ -545,12 +557,19 @@ def _show_image_info(self) -> None:
self._work_mode = "image_info"
self.start_work_and_update_ui()

def _show_esptool_version(self) -> None:
self._work_mode = "esptool_version"
self.start_work_and_update_ui()

def _can_query_device_info(self) -> bool:
return self._state == "idle" and self._target_combo.get_selected_value() is not None

def _can_query_image_info(self) -> bool:
return self._state == "idle" and self._version_combo.get_selected_value() is not None

def _can_show_esptool_version(self) -> bool:
return self._state == "idle"

def _hide_advanced_options(self) -> None:
for widget in self._advanced_widgets:
widget.grid_remove()
Expand Down

0 comments on commit df67a5b

Please sign in to comment.