From 28376584a327fb8e66e8118110649bcf5a878050 Mon Sep 17 00:00:00 2001 From: "hu.wang" Date: Tue, 15 Aug 2023 16:05:13 +0800 Subject: [PATCH] NEW:[STUDIO-4012] support prompt sound support modifying whether to turn on prompt sound from the print option pop-up window Change-Id: I3206bfcefc9292dd2a7acb7294addc901ad21d4d (cherry picked from commit ecc13666689d7f644ed3db36088b32b239728779) --- resources/config.json | 14 ++++++---- src/slic3r/GUI/DeviceManager.cpp | 22 ++++++++++++++++ src/slic3r/GUI/DeviceManager.hpp | 6 +++++ src/slic3r/GUI/PrintOptionsDialog.cpp | 37 ++++++++++++++++++++++++--- src/slic3r/GUI/PrintOptionsDialog.hpp | 3 +++ 5 files changed, 74 insertions(+), 8 deletions(-) diff --git a/resources/config.json b/resources/config.json index 53a7abeeb..f5330647b 100644 --- a/resources/config.json +++ b/resources/config.json @@ -14,9 +14,10 @@ "FUNC_VIRTUAL_CAMERA": false, "FUNC_PRINT_WITHOUT_SD": false, "FUNC_ALTER_RESOLUTION": false, - "FUNC_PRINT_ALL": false, - "FUNC_EXTRUSION_CALI": true + "FUNC_EXTRUSION_CALI": true, + "FUNC_VIRTUAL_TYAY": true, + "FUNC_PROMPT_SOUND": false }, "camera_resolution": [ "720p" ], "bed_temperature_limit": 100, @@ -42,7 +43,8 @@ "FUNC_ALTER_RESOLUTION": false, "FUNC_PRINT_ALL": false, "FUNC_VIRTUAL_TYAY": true, - "FUNC_EXTRUSION_CALI": true + "FUNC_EXTRUSION_CALI": true, + "FUNC_PROMPT_SOUND": false }, "camera_resolution": [ "720p" ], "bed_temperature_limit": 100, @@ -58,7 +60,8 @@ "FUNC_VIRTUAL_TYAY": true, "FUNC_EXTRUSION_CALI": false, "FUNC_LOCAL_TUNNEL": false, - "FUNC_CHAMBER_TEMP": false + "FUNC_CHAMBER_TEMP": false, + "FUNC_PROMPT_SOUND": false }, "model_id": "BL-P002", "compatible_machine": [ "BL-P001", "C11", "C12"], @@ -72,7 +75,8 @@ "FUNC_CHAMBER_TEMP": false, "FUNC_VIRTUAL_TYAY": true, "FUNC_EXTRUSION_CALI": false, - "FUNC_LOCAL_TUNNEL": false + "FUNC_LOCAL_TUNNEL": false, + "FUNC_PROMPT_SOUND": false }, "model_id": "BL-P001", "compatible_machine": [ "BL-P002", "C11", "C12"], diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index d420bce2f..aabe720fb 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1350,6 +1350,12 @@ void MachineObject::parse_status(int flag) ams_auto_switch_filament_flag = ((flag >> 10) & 0x1) != 0; } + if (xcam_prompt_sound_hold_count > 0) + xcam_prompt_sound_hold_count--; + else { + xcam_allow_prompt_sound = ((flag >> 17) & 0x1) != 0; + } + sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11); } @@ -1920,6 +1926,15 @@ int MachineObject::command_set_printing_option(bool auto_recovery) return this->publish_json(j.dump()); } +int MachineObject::command_set_prompt_sound(bool prompt_sound){ + json j; + j["print"]["command"] = "print_option"; + j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++); + j["print"]["sound_enable"] = prompt_sound; + + return this->publish_json(j.dump()); +} + int MachineObject::command_ams_switch_filament(bool switch_filament) { json j; @@ -2279,6 +2294,13 @@ int MachineObject::command_xcam_control_auto_recovery_step_loss(bool on_off) return command_set_printing_option(on_off); } +int MachineObject::command_xcam_control_allow_prompt_sound(bool on_off) +{ + xcam_allow_prompt_sound = on_off; + xcam_prompt_sound_hold_count = HOLD_COUNT_MAX; + return command_set_prompt_sound(on_off); +} + void MachineObject::set_bind_status(std::string status) { bind_user_name = status; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index bbea0756c..8700bbd47 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -683,7 +683,9 @@ public: bool xcam_buildplate_marker_detector{ false }; int xcam_buildplate_marker_hold_count = 0; bool xcam_auto_recovery_step_loss{ false }; + bool xcam_allow_prompt_sound{ false }; int xcam_auto_recovery_hold_count = 0; + int xcam_prompt_sound_hold_count = 0; int ams_print_option_count = 0; //supported features @@ -804,6 +806,9 @@ public: // set printing speed int command_set_printing_speed(PrintingSpeedLevel lvl); + //set pormpt sound + int command_set_prompt_sound(bool prompt_sound); + // set print option int command_set_printing_option(bool auto_recovery); @@ -837,6 +842,7 @@ public: int command_xcam_control_first_layer_inspector(bool on_off, bool print_halt); int command_xcam_control_buildplate_marker_detector(bool on_off); int command_xcam_control_auto_recovery_step_loss(bool on_off); + int command_xcam_control_allow_prompt_sound(bool on_off); /* common apis */ inline bool is_local() { return !dev_ip.empty(); } diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index 221673b5b..d0792f75c 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -55,6 +55,12 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent) } evt.Skip(); }); + m_cb_sup_sound->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& evt) { + if (obj) { + obj->command_xcam_control_allow_prompt_sound(m_cb_sup_sound->GetValue()); + } + evt.Skip(); + }); wxGetApp().UpdateDlgDarkUI(this); } @@ -131,14 +137,23 @@ void PrintOptionsDialog::update_options(MachineObject* obj_) m_cb_auto_recovery->Hide(); line4->Hide(); } + if (obj_->is_support_prompt_sound) { + text_sup_sound->Show(); + m_cb_sup_sound->Show(); + line5->Show(); + } + else { + text_sup_sound->Hide(); + m_cb_sup_sound->Hide(); + line5->Hide(); + } this->Freeze(); - auto test1 = obj_->xcam_first_layer_inspector; - auto test2 = obj_->xcam_buildplate_marker_detector; - auto test3 = obj_->xcam_auto_recovery_step_loss; + m_cb_first_layer->SetValue(obj_->xcam_first_layer_inspector); m_cb_plate_mark->SetValue(obj_->xcam_buildplate_marker_detector); m_cb_auto_recovery->SetValue(obj_->xcam_auto_recovery_step_loss); + m_cb_sup_sound->SetValue(obj_->xcam_allow_prompt_sound); m_cb_ai_monitoring->SetValue(obj_->xcam_ai_monitoring); for (auto i = AiMonitorSensitivityLevel::LOW; i < LEVELS_NUM; i = (AiMonitorSensitivityLevel) (i + 1)) { @@ -256,6 +271,22 @@ wxBoxSizer* PrintOptionsDialog::create_settings_group(wxWindow* parent) sizer->Add(line4, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20)); sizer->Add(0,0,0,wxTOP, FromDIP(20)); + //Allow prompt sound + line_sizer = new wxBoxSizer(wxHORIZONTAL); + m_cb_sup_sound = new CheckBox(parent); + text_sup_sound = new wxStaticText(parent, wxID_ANY, _L("Allow Prompt Sound")); + text_sup_sound->SetFont(Label::Body_14); + line_sizer->Add(FromDIP(5), 0, 0, 0); + line_sizer->Add(m_cb_sup_sound, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5)); + line_sizer->Add(text_sup_sound, 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); + + line5 = new StaticLine(parent, false); + line5->SetLineColour(STATIC_BOX_LINE_COL); + sizer->Add(line5, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(20)); + ai_monitoring_level_list->Connect( wxEVT_COMBOBOX, wxCommandEventHandler(PrintOptionsDialog::set_ai_monitor_sensitivity), NULL, this ); return sizer; diff --git a/src/slic3r/GUI/PrintOptionsDialog.hpp b/src/slic3r/GUI/PrintOptionsDialog.hpp index e9221ef7f..e348d64fa 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.hpp +++ b/src/slic3r/GUI/PrintOptionsDialog.hpp @@ -26,6 +26,7 @@ protected: CheckBox* m_cb_ai_monitoring; CheckBox* m_cb_plate_mark; CheckBox* m_cb_auto_recovery; + CheckBox* m_cb_sup_sound; wxStaticText* text_first_layer; wxStaticText* text_ai_monitoring; wxStaticText* text_ai_monitoring_caption; @@ -33,10 +34,12 @@ protected: wxStaticText* text_plate_mark; wxStaticText* text_plate_mark_caption; wxStaticText* text_auto_recovery; + wxStaticText* text_sup_sound; StaticLine* line1; StaticLine* line2; StaticLine* line3; StaticLine* line4; + StaticLine* line5; wxBoxSizer* create_settings_group(wxWindow* parent); bool print_halt = false;