ENH:Reduce the number of page faults on the device

Change-Id: I72e140de35d06308f8aa45f4254e049a83abc432
This commit is contained in:
tao wang 2024-08-12 14:21:48 +08:00 committed by Lane.Wei
parent 8c852bc925
commit 66403ba19f
5 changed files with 97 additions and 61 deletions

View File

@ -288,8 +288,8 @@ void MonitorPanel::on_update_all(wxMouseEvent &event)
{ {
if (update_flag) { if (update_flag) {
update_all(); update_all();
Layout(); //Layout();
Refresh(); //Refresh();
} }
} }
@ -297,8 +297,8 @@ void MonitorPanel::on_update_all(wxMouseEvent &event)
{ {
if (update_flag) { if (update_flag) {
update_all(); update_all();
Layout(); //Layout();
Refresh(); //Refresh();
} }
} }
@ -371,6 +371,7 @@ void MonitorPanel::update_all()
return; return;
} }
//BBS check mqtt connections if user is login //BBS check mqtt connections if user is login
if (wxGetApp().is_user_login()) { if (wxGetApp().is_user_login()) {
dev->check_pushing(); dev->check_pushing();
@ -420,7 +421,6 @@ void MonitorPanel::update_all()
show_status(MONITOR_NORMAL); show_status(MONITOR_NORMAL);
if (m_status_info_panel->IsShown()) { if (m_status_info_panel->IsShown()) {
m_status_info_panel->update(obj); m_status_info_panel->update(obj);
} }

View File

@ -2405,27 +2405,34 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
if (m_current_support_aux_fan != is_suppt_aux_fun) { if (m_current_support_aux_fan != is_suppt_aux_fun) {
if (is_suppt_aux_fun) { if (is_suppt_aux_fun) {
m_switch_printing_fan->Show(); if (!m_switch_printing_fan->IsShown()) {
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE); m_switch_printing_fan->Show();
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE); m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE); m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE); m_switch_cham_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
}
} }
else { else {
m_switch_printing_fan->Hide(); if (m_switch_printing_fan->IsShown()) {
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE); m_switch_printing_fan->Hide();
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE); m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE); m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE); m_switch_cham_fan->SetMinSize(MISC_BUTTON_2FAN_SIZE);
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_2FAN_SIZE);
}
} }
m_misc_ctrl_sizer->Layout(); m_misc_ctrl_sizer->Layout();
} }
if (!is_suppt_aux_fun && !is_suppt_cham_fun) { if (!is_suppt_aux_fun && !is_suppt_cham_fun) {
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE); if (!m_switch_nozzle_fan->IsShown()) {
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE); m_switch_nozzle_fan->Show();
m_misc_ctrl_sizer->Layout(); m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_1FAN_SIZE);
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_1FAN_SIZE);
m_misc_ctrl_sizer->Layout();
}
} }
@ -2491,21 +2498,27 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
void StatusPanel::update_extruder_status(MachineObject* obj) void StatusPanel::update_extruder_status(MachineObject* obj)
{ {
if (!obj) return; if (!obj) return;
if (obj->is_filament_at_extruder()) { wxBitmap tmp;
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { if (obj->is_filament_at_extruder()) {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_filled_load); if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
} tmp = m_bitmap_extruder_filled_load;
else { }
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_filled_unload); else {
} tmp = m_bitmap_extruder_filled_unload;
} }
else { }
if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) { else {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_load); if (obj->extruder_axis_status == MachineObject::ExtruderAxisStatus::LOAD) {
} else { tmp = m_bitmap_extruder_empty_load;
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_empty_unload); }
} else {
} tmp = m_bitmap_extruder_empty_unload;
}
}
if (tmp.GetBitmapData() != m_bitmap_extruder_now) {
m_bitmap_extruder_now = tmp.GetBitmapData();
m_bitmap_extruder_img->SetBitmap(tmp);
}
} }
void StatusPanel::update_ams(MachineObject *obj) void StatusPanel::update_ams(MachineObject *obj)
@ -3145,7 +3158,7 @@ void StatusPanel::update_subtask(MachineObject *obj)
reset_printing_values(); reset_printing_values();
} }
this->Layout(); m_project_task_panel->Layout();
} }
void StatusPanel::update_cloud_subtask(MachineObject *obj) void StatusPanel::update_cloud_subtask(MachineObject *obj)
@ -3231,7 +3244,6 @@ void StatusPanel::reset_printing_values()
m_start_loading_thumbnail = false; m_start_loading_thumbnail = false;
m_load_sdcard_thumbnail = false; m_load_sdcard_thumbnail = false;
skip_print_error = 0; skip_print_error = 0;
this->Layout();
} }
void StatusPanel::on_axis_ctrl_xy(wxCommandEvent &event) void StatusPanel::on_axis_ctrl_xy(wxCommandEvent &event)

View File

@ -273,6 +273,7 @@ protected:
wxBitmap m_bitmap_extruder_filled_load; wxBitmap m_bitmap_extruder_filled_load;
wxBitmap m_bitmap_extruder_empty_unload; wxBitmap m_bitmap_extruder_empty_unload;
wxBitmap m_bitmap_extruder_filled_unload; wxBitmap m_bitmap_extruder_filled_unload;
wxBitmapRefData* m_bitmap_extruder_now;
CameraRecordingStatus m_state_recording{CameraRecordingStatus::RECORDING_NONE}; CameraRecordingStatus m_state_recording{CameraRecordingStatus::RECORDING_NONE};
CameraTimelapseStatus m_state_timelapse{CameraTimelapseStatus::TIMELAPSE_NONE}; CameraTimelapseStatus m_state_timelapse{CameraTimelapseStatus::TIMELAPSE_NONE};

View File

@ -52,10 +52,11 @@ void ImageSwitchButton::SetLabels(wxString const &lbl_on, wxString const &lbl_of
labels[0] = lbl_on; labels[0] = lbl_on;
labels[1] = lbl_off; labels[1] = lbl_off;
auto fina_txt = GetValue() ? labels[0] : labels[1]; auto fina_txt = GetValue() ? labels[0] : labels[1];
if (GetToolTipText() != fina_txt) if (GetToolTipText() != fina_txt) {
SetToolTip(fina_txt); SetToolTip(fina_txt);
messureSize(); messureSize();
Refresh(); Refresh();
}
} }
void ImageSwitchButton::SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off) void ImageSwitchButton::SetImages(ScalableBitmap &img_on, ScalableBitmap &img_off)
@ -76,9 +77,11 @@ void ImageSwitchButton::SetTextColor(StateColor const &color)
void ImageSwitchButton::SetValue(bool value) void ImageSwitchButton::SetValue(bool value)
{ {
m_on_off = value; if (m_on_off != value) {
messureSize(); m_on_off = value;
Refresh(); messureSize();
Refresh();
}
} }
void ImageSwitchButton::SetPadding(int padding) void ImageSwitchButton::SetPadding(int padding)
@ -236,16 +239,20 @@ void FanSwitchButton::SetTextColor(StateColor const& color)
void FanSwitchButton::SetValue(bool value) void FanSwitchButton::SetValue(bool value)
{ {
m_on_off = value; if (m_on_off != value) {
messureSize(); m_on_off = value;
Refresh(); messureSize();
Refresh();
}
} }
void FanSwitchButton::SetPadding(int padding) void FanSwitchButton::SetPadding(int padding)
{ {
m_padding = padding; if (m_padding != padding) {
messureSize(); m_padding = padding;
Refresh(); messureSize();
Refresh();
}
} }
void FanSwitchButton::messureSize() void FanSwitchButton::messureSize()
@ -325,8 +332,10 @@ void FanSwitchButton::Rescale()
void FanSwitchButton::setFanValue(int val) void FanSwitchButton::setFanValue(int val)
{ {
m_speed = val; if (m_speed != val) {
Refresh(); m_speed = val;
Refresh();
}
} }
void FanSwitchButton::mouseDown(wxMouseEvent& event) void FanSwitchButton::mouseDown(wxMouseEvent& event)

View File

@ -162,26 +162,36 @@ wxString TempInput::erasePending(wxString &str)
void TempInput::SetTagTemp(int temp) void TempInput::SetTagTemp(int temp)
{ {
text_ctrl->SetValue(wxString::Format("%d", temp)); auto tp = wxString::Format("%d", temp);
messureSize(); if ((text_ctrl->GetValue() != wxString("_")) && (text_ctrl->GetValue() != tp) ) {
Refresh(); text_ctrl->SetValue(tp);
messureSize();
Refresh();
}
} }
void TempInput::SetTagTemp(wxString temp) void TempInput::SetTagTemp(wxString temp)
{ {
text_ctrl->SetValue(temp); if (text_ctrl->GetValue() != temp) {
messureSize(); text_ctrl->SetValue(temp);
Refresh(); messureSize();
Refresh();
}
} }
void TempInput::SetCurrTemp(int temp) void TempInput::SetCurrTemp(int temp)
{ {
SetLabel(wxString::Format("%d", temp)); auto tp = wxString::Format("%d", temp);
if (GetLabel() != tp) {
SetLabel(tp);
}
} }
void TempInput::SetCurrTemp(wxString temp) void TempInput::SetCurrTemp(wxString temp)
{ {
SetLabel(temp); if (GetLabel() != temp) {
SetLabel(temp);
}
} }
void TempInput::Warning(bool warn, WarningType type) void TempInput::Warning(bool warn, WarningType type)
@ -245,14 +255,18 @@ void TempInput::Warning(bool warn, WarningType type)
void TempInput::SetIconActive() void TempInput::SetIconActive()
{ {
actice = true; if (!actice) {
Refresh(); actice = true;
Refresh();
}
} }
void TempInput::SetIconNormal() void TempInput::SetIconNormal()
{ {
actice = false; if (actice) {
Refresh(); actice = false;
Refresh();
}
} }
void TempInput::SetMaxTemp(int temp) { max_temp = temp; } void TempInput::SetMaxTemp(int temp) { max_temp = temp; }