ENH: add nozzle blob detection and air printing detection

jira: new

Change-Id: Ie4a19a7ad7d0b10a021c516cbc3a84b4ae734302
This commit is contained in:
liz.li 2024-04-01 10:30:27 +08:00 committed by Lane.Wei
parent cd9305e3e0
commit c5d9b3a3a7
7 changed files with 152 additions and 0 deletions

View File

@ -193,6 +193,37 @@ void AMSSetting::create()
m_sizer_switch_filament_tip->Add(m_sizer_switch_filament_inline, 1, wxALIGN_CENTER, 0);
// checkbox area 5
wxBoxSizer* m_sizer_air_print = new wxBoxSizer(wxHORIZONTAL);
m_checkbox_air_print = new ::CheckBox(m_panel_body);
m_checkbox_air_print->Bind(wxEVT_TOGGLEBUTTON, &AMSSetting::on_air_print_detect, this);
m_sizer_air_print->Add(m_checkbox_air_print, 0, wxTOP, 1);
m_sizer_air_print->Add(0, 0, 0, wxLEFT, 12);
m_title_air_print = new wxStaticText(m_panel_body, wxID_ANY, _L("Air Printing Detection"), wxDefaultPosition, wxDefaultSize, 0);
m_title_air_print->SetFont(::Label::Head_13);
m_title_air_print->SetForegroundColour(AMS_SETTING_GREY800);
m_title_air_print->Wrap(AMS_SETTING_BODY_WIDTH);
m_sizer_air_print->Add(m_title_air_print, 1, wxEXPAND, 0);
wxBoxSizer* m_sizer_air_print_tip = new wxBoxSizer(wxHORIZONTAL);
m_sizer_air_print_tip->Add(0, 0, 0, wxLEFT, 10);
// tip line
auto m_sizer_air_print_inline = new wxBoxSizer(wxVERTICAL);
m_tip_air_print_line = new Label(m_panel_body,
_L("Detects clogging and filament grinding, halting printing immediately to conserve time and filament.")
);
m_tip_air_print_line->SetFont(::Label::Body_13);
m_tip_air_print_line->SetForegroundColour(AMS_SETTING_GREY700);
m_tip_air_print_line->SetSize(wxSize(AMS_SETTING_BODY_WIDTH, -1));
m_tip_air_print_line->Wrap(AMS_SETTING_BODY_WIDTH);
m_sizer_air_print_inline->Add(m_tip_air_print_line, 0, wxEXPAND, 0);
m_sizer_air_print_tip->Add(m_sizer_air_print_inline, 1, wxALIGN_CENTER, 0);
// panel img
wxPanel* m_panel_img = new wxPanel(m_panel_body, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_panel_img->SetBackgroundColour(AMS_SETTING_GREY200);
@ -221,6 +252,11 @@ void AMSSetting::create()
m_sizerl_body->Add(m_sizer_switch_filament_tip, 0, wxLEFT, 18);
m_sizerl_body->Add(0, 0, 0, wxTOP, 6);
m_sizerl_body->Add(0, 0, 0, wxTOP, FromDIP(5));
m_sizerl_body->Add(m_sizer_air_print, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_air_print_tip, 0, wxLEFT, 18);
m_sizerl_body->Add(0, 0, 0, wxTOP, 6);
m_sizerl_body->Add(0, 0, 0, wxTOP, FromDIP(5));
m_sizerl_body->Add(m_panel_img, 1, wxEXPAND | wxALL, FromDIP(5));
m_panel_body->SetSizer(m_sizerl_body);
@ -339,6 +375,22 @@ void AMSSetting::update_switch_filament(bool selected)
m_checkbox_switch_filament->SetValue(selected);
}
void AMSSetting::update_air_printing_detection(bool selected)
{
if (obj->is_support_air_print_detection) {
m_checkbox_air_print->Show();
m_title_air_print->Show();
m_tip_air_print_line->Show();
}
else {
m_checkbox_air_print->Hide();
m_title_air_print->Hide();
m_tip_air_print_line->Hide();
}
Layout();
m_checkbox_air_print->SetValue(selected);
}
void AMSSetting::on_select_ok(wxMouseEvent &event)
{
@ -418,6 +470,13 @@ void AMSSetting::on_switch_filament(wxCommandEvent& event)
event.Skip();
}
void AMSSetting::on_air_print_detect(wxCommandEvent& event)
{
bool air_print_detect = m_checkbox_air_print->GetValue();
obj->command_ams_air_print_detect(air_print_detect);
event.Skip();
}
wxString AMSSetting::append_title(wxString text)
{
wxString lab;

View File

@ -33,11 +33,13 @@ public:
void update_starting_read_mode(bool selected);
void update_remain_mode(bool selected);
void update_switch_filament(bool selected);
void update_air_printing_detection(bool selected);
void on_select_ok(wxMouseEvent& event);
void on_insert_material_read(wxCommandEvent &event);
void on_starting_read(wxCommandEvent &event);
void on_remain(wxCommandEvent& event);
void on_switch_filament(wxCommandEvent& event);
void on_air_print_detect(wxCommandEvent& event);
wxString append_title(wxString text);
wxStaticText *append_text(wxString text);
MachineObject *obj{nullptr};
@ -70,6 +72,10 @@ protected:
wxStaticText* m_title_switch_filament;
Label* m_tip_switch_filament_line1;
CheckBox* m_checkbox_air_print;
wxStaticText* m_title_air_print;
Label* m_tip_air_print_line;
wxStaticText *m_tip_ams_img;
Button * m_button_auto_demarcate;

View File

@ -1392,6 +1392,12 @@ void MachineObject::parse_status(int flag)
if(!is_support_motor_noise_cali){
is_support_motor_noise_cali = ((flag >> 21) & 0x1) != 0;
}
is_support_nozzle_blob_detection = ((flag >> 25) & 0x1) != 0;
nozzle_blob_detection_enabled = ((flag >> 24) & 0x1) != 0;
is_support_air_print_detection = ((flag >> 29) & 0x1) != 0;
ams_air_print_status = ((flag >> 28) & 0x1) != 0;
if (!is_support_p1s_plus) {
auto supported_plus = ((flag >> 27) & 0x1) != 0;
@ -2024,6 +2030,16 @@ int MachineObject::command_set_printing_option(bool auto_recovery)
return this->publish_json(j.dump());
}
int MachineObject::command_nozzle_blob_detect(bool nozzle_blob_detect)
{
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["nozzle_blob_detect"] = nozzle_blob_detect;
nozzle_blob_detection_enabled = nozzle_blob_detect;
return this->publish_json(j.dump());
}
int MachineObject::command_set_prompt_sound(bool prompt_sound){
json j;
j["print"]["command"] = "print_option";
@ -2056,6 +2072,19 @@ int MachineObject::command_ams_switch_filament(bool switch_filament)
return this->publish_json(j.dump());
}
int MachineObject::command_ams_air_print_detect(bool air_print_detect)
{
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["air_print_detect"] = air_print_detect;
ams_air_print_status = air_print_detect;
BOOST_LOG_TRIVIAL(trace) << "command_ams_air_print_detect:" << air_print_detect;
return this->publish_json(j.dump());
}
int MachineObject::command_axis_control(std::string axis, double unit, double input_val, int speed)
{

View File

@ -491,6 +491,7 @@ public:
bool ams_power_on_flag { false };
bool ams_calibrate_remain_flag { false };
bool ams_auto_switch_filament_flag { false };
bool ams_air_print_status { false };
bool ams_support_use_ams { false };
bool ams_support_virtual_tray { true };
int ams_humidity;
@ -618,6 +619,7 @@ public:
int curr_layer = 0;
int total_layers = 0;
bool is_support_layer_num { false };
bool nozzle_blob_detection_enabled{ false };
int cali_version = -1;
float cali_selected_nozzle_dia { 0.0 };
@ -757,6 +759,8 @@ public:
bool is_support_wait_sending_finish{false};
bool is_support_user_preset{false};
bool is_support_p1s_plus{false};
bool is_support_nozzle_blob_detection{false};
bool is_support_air_print_detection{false};
int nozzle_max_temperature = -1;
int bed_temperature_limit = -1;
@ -847,6 +851,7 @@ public:
int command_ams_user_settings(int ams_id, bool start_read_opt, bool tray_read_opt, bool remain_flag = false);
int command_ams_user_settings(int ams_id, AmsOptionType op, bool value);
int command_ams_switch_filament(bool switch_filament);
int command_ams_air_print_detect(bool air_print_detect);
int command_ams_calibrate(int ams_id);
int command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max);
int command_ams_select_tray(std::string tray_id);
@ -871,6 +876,8 @@ public:
// set print option
int command_set_printing_option(bool auto_recovery);
int command_nozzle_blob_detect(bool nozzle_blob_detect);
// axis string is X, Y, Z, E
int command_axis_control(std::string axis, double unit = 1.0f, double input_val = 1.0f, int speed = 3000);

View File

@ -67,6 +67,12 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
}
evt.Skip();
});
m_cb_nozzle_blob->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& evt) {
if (obj) {
obj->command_nozzle_blob_detect(m_cb_nozzle_blob->GetValue());
}
evt.Skip();
});
wxGetApp().UpdateDlgDarkUI(this);
}
@ -163,6 +169,18 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
m_cb_filament_tangle->Hide();
line6->Hide();
}
if (obj_->is_support_nozzle_blob_detection) {
text_nozzle_blob->Show();
m_cb_nozzle_blob->Show();
text_nozzle_blob_caption->Show();
line7->Show();
}
else {
text_nozzle_blob->Hide();
m_cb_nozzle_blob->Hide();
text_nozzle_blob_caption->Hide();
line7->Hide();
}
this->Freeze();
@ -171,6 +189,7 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
m_cb_auto_recovery->SetValue(obj_->xcam_auto_recovery_step_loss);
m_cb_sup_sound->SetValue(obj_->xcam_allow_prompt_sound);
m_cb_filament_tangle->SetValue(obj_->xcam_filament_tangle_detect);
m_cb_nozzle_blob->SetValue(obj_->nozzle_blob_detection_enabled);
m_cb_ai_monitoring->SetValue(obj_->xcam_ai_monitoring);
for (auto i = AiMonitorSensitivityLevel::LOW; i < LEVELS_NUM; i = (AiMonitorSensitivityLevel) (i + 1)) {
@ -325,6 +344,33 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent)
line6 = new StaticLine(parent, false);
line6->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line6, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
sizer->Add(0, 0, 0, wxTOP, FromDIP(20));
//nozzle blob detect
line_sizer = new wxBoxSizer(wxHORIZONTAL);
m_cb_nozzle_blob = new CheckBox(parent);
text_nozzle_blob = new wxStaticText(parent, wxID_ANY, _L("Nozzle Clumping Detection"));
text_nozzle_blob->SetFont(Label::Body_14);
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer->Add(m_cb_nozzle_blob, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
line_sizer->Add(text_nozzle_blob, 1, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
sizer->Add(0, 0, 0, wxTOP, FromDIP(15));
sizer->Add(line_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(18));
line_sizer->Add(FromDIP(5), 0, 0, 0);
line_sizer = new wxBoxSizer(wxHORIZONTAL);
wxString nozzle_blob_caption_text = _L("Check if the nozzle is clumping by filament or other foreign objects.");
text_nozzle_blob_caption = new Label(parent, nozzle_blob_caption_text);
text_nozzle_blob_caption->SetFont(Label::Body_14);
text_nozzle_blob_caption->Wrap(-1);
text_nozzle_blob_caption->SetForegroundColour(STATIC_TEXT_CAPTION_COL);
line_sizer->Add(FromDIP(30), 0, 0, 0);
line_sizer->Add(text_nozzle_blob_caption, 1, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(0));
sizer->Add(line_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(18));
line7 = new StaticLine(parent, false);
line7->SetLineColour(STATIC_BOX_LINE_COL);
sizer->Add(line7, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20));
ai_monitoring_level_list->Connect( wxEVT_COMBOBOX, wxCommandEventHandler(PrintOptionsDialog::set_ai_monitor_sensitivity), NULL, this );

View File

@ -49,6 +49,7 @@ protected:
CheckBox* m_cb_auto_recovery;
CheckBox* m_cb_sup_sound;
CheckBox* m_cb_filament_tangle;
CheckBox* m_cb_nozzle_blob;
wxStaticText* text_first_layer;
wxStaticText* text_ai_monitoring;
wxStaticText* text_ai_monitoring_caption;
@ -58,12 +59,15 @@ protected:
wxStaticText* text_auto_recovery;
wxStaticText* text_sup_sound;
wxStaticText* text_filament_tangle;
wxStaticText* text_nozzle_blob;
wxStaticText* text_nozzle_blob_caption;
StaticLine* line1;
StaticLine* line2;
StaticLine* line3;
StaticLine* line4;
StaticLine* line5;
StaticLine* line6;
StaticLine* line7;
wxBoxSizer* create_settings_group(wxWindow* parent);
bool print_halt = false;

View File

@ -2454,6 +2454,7 @@ void StatusPanel::update_ams(MachineObject *obj)
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
m_ams_setting_dlg->update_remain_mode(obj->ams_calibrate_remain_flag);
m_ams_setting_dlg->update_switch_filament(obj->ams_auto_switch_filament_flag);
m_ams_setting_dlg->update_air_printing_detection(obj->ams_air_print_status);
}
}
if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; }