ENH: change extruder icon colour when loading filament

Change-Id: Ifd1e9c868702352790de9ddf25f256d504875785
This commit is contained in:
tao.jin 2022-09-29 10:29:51 +08:00 committed by Lane.Wei
parent 633d14e711
commit d97db7e617
6 changed files with 56 additions and 0 deletions

View file

@ -358,6 +358,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
mc_print_sub_stage = 0;
mc_left_time = 0;
home_flag = -1;
hw_switch_state = 0;
printing_speed_lvl = PrintingSpeedLevel::SPEED_LEVEL_INVALID;
}
@ -1046,6 +1047,18 @@ bool MachineObject::is_axis_at_home(std::string axis)
}
}
bool MachineObject::is_filament_at_extruder()
{
if (hw_switch_state == 1)
return true;
else if (hw_switch_state == 0)
return false;
else {
//default
return true;
}
}
wxString MachineObject::get_curr_stage()
{
if (stage_list_info.empty()) {
@ -1820,6 +1833,9 @@ int MachineObject::parse_json(std::string payload)
if (jj.contains("home_flag")) {
home_flag = jj["home_flag"].get<int>();
}
if (jj.contains("hw_switch_state")) {
hw_switch_state = jj["hw_switch_state"].get<int>();
}
if (jj.contains("mc_remaining_time")) {
if (jj["mc_remaining_time"].is_string())

View file

@ -466,6 +466,7 @@ public:
int mc_left_time; /* left time in seconds */
int last_mc_print_stage;
int home_flag;
int hw_switch_state;
bool is_system_printing();
int print_error;
@ -476,6 +477,8 @@ public:
bool is_axis_at_home(std::string axis);
bool is_filament_at_extruder();
wxString get_curr_stage();
// return curr stage index of stage list
int get_curr_stage_idx();

View file

@ -177,6 +177,7 @@ void StatusBasePanel::init_bitmaps()
m_thumbnail_sdcard = ScalableBitmap(this, "monitor_sdcard_thumbnail", 120);
//m_bitmap_camera = create_scaled_bitmap("monitor_camera", nullptr, 18);
m_bitmap_extruder = *cache.load_png("monitor_extruder", FromDIP(28), FromDIP(70), false, false);
m_bitmap_extruder_load = *cache.load_png("monitor_extruder_load", FromDIP(28), FromDIP(70), false, false);
m_bitmap_sdcard_state_on = create_scaled_bitmap("sdcard_state_on", nullptr, 20);
m_bitmap_sdcard_state_off = create_scaled_bitmap("sdcard_state_off", nullptr, 20);
}
@ -1305,6 +1306,13 @@ void StatusPanel::update(MachineObject *obj)
update_temp_ctrl(obj);
update_misc_ctrl(obj);
if (obj && obj->is_filament_at_extruder()) {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder_load);
}
else {
m_bitmap_extruder_img->SetBitmap(m_bitmap_extruder);
}
// BBS hide tasklist info
// update_tasklist(obj);
update_ams(obj);

View file

@ -81,6 +81,7 @@ protected:
ScalableBitmap m_bitmap_use_time;
ScalableBitmap m_bitmap_use_weight;
wxBitmap m_bitmap_extruder;
wxBitmap m_bitmap_extruder_load;
CameraRecordingStatus m_state_recording{CameraRecordingStatus::RECORDING_NONE};
CameraTimelapseStatus m_state_timelapse{CameraTimelapseStatus::TIMELAPSE_NONE};