mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Firmware updater: Fix MMU flashing in GUI
This commit is contained in:
		
							parent
							
								
									09da7a84b5
								
							
						
					
					
						commit
						8208da0a7b
					
				
					 1 changed files with 20 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -107,7 +107,7 @@ struct FirmwareDialog::priv
 | 
			
		|||
 | 
			
		||||
	// GUI elements
 | 
			
		||||
	wxComboBox *port_picker;
 | 
			
		||||
	wxStaticText *port_autodetect;
 | 
			
		||||
	wxStaticText *txt_port_autodetect;
 | 
			
		||||
	wxFilePickerCtrl *hex_picker;
 | 
			
		||||
	wxStaticText *txt_status;
 | 
			
		||||
	wxGauge *progressbar;
 | 
			
		||||
| 
						 | 
				
			
			@ -134,6 +134,7 @@ struct FirmwareDialog::priv
 | 
			
		|||
	// Data
 | 
			
		||||
	std::vector<SerialPortInfo> ports;
 | 
			
		||||
	optional<SerialPortInfo> port;
 | 
			
		||||
	bool port_autodetect;
 | 
			
		||||
	HexFile hex_file;
 | 
			
		||||
 | 
			
		||||
	// This is a shared pointer holding the background AvrDude task
 | 
			
		||||
| 
						 | 
				
			
			@ -150,6 +151,7 @@ struct FirmwareDialog::priv
 | 
			
		|||
		btn_flash_label_flashing(_(L("Cancel"))),
 | 
			
		||||
		label_status_flashing(_(L("Flashing in progress. Please do not disconnect the printer!"))),
 | 
			
		||||
		timer_pulse(q),
 | 
			
		||||
		port_autodetect(false),
 | 
			
		||||
		progress_tasks_done(0),
 | 
			
		||||
		progress_tasks_bar(0),
 | 
			
		||||
		user_cancelled(false),
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +163,7 @@ struct FirmwareDialog::priv
 | 
			
		|||
	void set_txt_status(const wxString &label);
 | 
			
		||||
	void flashing_start(unsigned tasks);
 | 
			
		||||
	void flashing_done(AvrDudeComplete complete);
 | 
			
		||||
	void enable_port_picker(bool enable);
 | 
			
		||||
	void set_autodetect(bool autodetect);
 | 
			
		||||
	void update_flash_enabled();
 | 
			
		||||
	void load_hex_file(const wxString &path);
 | 
			
		||||
	void queue_event(AvrdudeEvent aevt, wxString message);
 | 
			
		||||
| 
						 | 
				
			
			@ -216,8 +218,10 @@ void FirmwareDialog::priv::find_serial_ports()
 | 
			
		|||
					idx = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			if (idx != -1)
 | 
			
		||||
			if (idx != -1) {
 | 
			
		||||
				port_picker->SetSelection(idx);
 | 
			
		||||
				update_flash_enabled();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -282,11 +286,13 @@ void FirmwareDialog::priv::flashing_done(AvrDudeComplete complete)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FirmwareDialog::priv::enable_port_picker(bool enable)
 | 
			
		||||
void FirmwareDialog::priv::set_autodetect(bool autodetect)
 | 
			
		||||
{
 | 
			
		||||
	port_picker->Show(enable);
 | 
			
		||||
	btn_rescan->Show(enable);
 | 
			
		||||
	port_autodetect->Show(! enable);
 | 
			
		||||
	port_autodetect = autodetect;
 | 
			
		||||
 | 
			
		||||
	port_picker->Show(!autodetect);
 | 
			
		||||
	btn_rescan->Show(!autodetect);
 | 
			
		||||
	txt_port_autodetect->Show(autodetect);
 | 
			
		||||
	q->Layout();
 | 
			
		||||
	fit_no_shrink();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -294,7 +300,7 @@ void FirmwareDialog::priv::enable_port_picker(bool enable)
 | 
			
		|||
void FirmwareDialog::priv::update_flash_enabled()
 | 
			
		||||
{
 | 
			
		||||
	const bool hex_exists = wxFileExists(hex_picker->GetPath());
 | 
			
		||||
	const bool port_valid = get_serial_port();
 | 
			
		||||
	const bool port_valid = port_autodetect || get_serial_port();
 | 
			
		||||
 | 
			
		||||
	btn_flash->Enable(hex_exists && port_valid);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -302,8 +308,8 @@ void FirmwareDialog::priv::update_flash_enabled()
 | 
			
		|||
void FirmwareDialog::priv::load_hex_file(const wxString &path)
 | 
			
		||||
{
 | 
			
		||||
	hex_file = HexFile(path.wx_str());
 | 
			
		||||
	const bool auto_lookup = hex_file.device == HexFile::DEV_MM_CONTROL || hex_file.device == HexFile::DEV_CW1;
 | 
			
		||||
	enable_port_picker(! auto_lookup);
 | 
			
		||||
	const bool autodetect = hex_file.device == HexFile::DEV_MM_CONTROL || hex_file.device == HexFile::DEV_CW1;
 | 
			
		||||
	set_autodetect(autodetect);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FirmwareDialog::priv::queue_event(AvrdudeEvent aevt, wxString message)
 | 
			
		||||
| 
						 | 
				
			
			@ -598,7 +604,7 @@ void FirmwareDialog::priv::perform_upload()
 | 
			
		|||
 | 
			
		||||
	load_hex_file(filename);  // Might already be loaded, but we want to make sure it's fresh
 | 
			
		||||
 | 
			
		||||
	if (! get_serial_port()) {
 | 
			
		||||
	if (!port_autodetect && !get_serial_port()) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -801,13 +807,13 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
 | 
			
		|||
 | 
			
		||||
	auto *label_port_picker = new wxStaticText(panel, wxID_ANY, _(L("Serial port:")));
 | 
			
		||||
	p->port_picker = new wxComboBox(panel, wxID_ANY);
 | 
			
		||||
	p->port_autodetect = new wxStaticText(panel, wxID_ANY, _(L("Autodetected")));
 | 
			
		||||
	p->txt_port_autodetect = new wxStaticText(panel, wxID_ANY, _(L("Autodetected")));
 | 
			
		||||
	p->btn_rescan = new wxButton(panel, wxID_ANY, _(L("Rescan")));
 | 
			
		||||
	auto *port_sizer = new wxBoxSizer(wxHORIZONTAL);
 | 
			
		||||
	port_sizer->Add(p->port_picker, 1, wxEXPAND | wxRIGHT, SPACING);
 | 
			
		||||
	port_sizer->Add(p->btn_rescan, 0);
 | 
			
		||||
	port_sizer->Add(p->port_autodetect, 1, wxEXPAND);
 | 
			
		||||
	p->enable_port_picker(true);
 | 
			
		||||
	port_sizer->Add(p->txt_port_autodetect, 1, wxEXPAND);
 | 
			
		||||
	p->set_autodetect(false);
 | 
			
		||||
 | 
			
		||||
	auto *label_progress = new wxStaticText(panel, wxID_ANY, _(L("Progress:")));
 | 
			
		||||
	p->progressbar = new wxGauge(panel, wxID_ANY, 1, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL | wxGA_SMOOTH);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue