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 77594f1aba7db2948dd9b8627d74f37ff8dbf07a)
This commit is contained in:
hu.wang 2023-08-15 16:05:13 +08:00 committed by Lane.Wei
parent 3992c14ad6
commit b7b875a62a
6 changed files with 88 additions and 8 deletions

View file

@ -1347,6 +1347,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);
}
@ -1996,6 +2002,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;
@ -2368,6 +2383,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;
@ -2624,7 +2646,10 @@ bool MachineObject::is_function_supported(PrinterFunction func)
func_name = "FUNC_CAMERA_VIDEO";
break;
case FUNC_MEDIA_FILE:
func_name = "FUNC_MEDIA_FILE";
func_name = "FUNC_MEDIA_FILE";
break;
case FUNC_PROMPT_SOUND:
func_name = "FUNC_PROMPT_SOUND";
break;
case FUNC_REMOTE_TUNNEL:
parse_version_func();

View file

@ -107,6 +107,7 @@ enum PrinterFunction {
FUNC_CHAMBER_FAN,
FUNC_AUX_FAN,
FUNC_EXTRUSION_CALI,
FUNC_PROMPT_SOUND,
FUNC_VIRTUAL_TYAY,
FUNC_PRINT_ALL,
FUNC_FILAMENT_BACKUP,
@ -720,7 +721,9 @@ public:
int xcam_buildplate_marker_hold_count = 0;
bool xcam_support_recovery_step_loss { true };
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;
/*not support U2*/
@ -816,6 +819,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);
@ -849,6 +855,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(); }

View file

@ -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_function_supported(PrinterFunction::FUNC_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;

View file

@ -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;