Browse Source

Allow to disable the model warning beeping

Mostly useful for debugging
Yuri D'Elia 2 years ago
parent
commit
8620059067
4 changed files with 25 additions and 9 deletions
  1. 5 2
      Firmware/Marlin_main.cpp
  2. 3 2
      Firmware/temp_model.h
  3. 16 5
      Firmware/temperature.cpp
  4. 1 0
      Firmware/temperature.h

+ 5 - 2
Firmware/Marlin_main.cpp

@@ -7776,6 +7776,7 @@ Sigma_Exit:
     - `P` - power
     - `C` - capacitance
     - `S` - set 0=disable 1=enable (default)
+    - `B` - beep on warning threshold 0=disable 1=enable (default)
     - `E` - error threshold (define min/max values in variants)
     - `W` - warning threshold (define min/max values in variants)
     - `T` - ambient temperature correction
@@ -7785,25 +7786,27 @@ Sigma_Exit:
     {
         // parse all parameters
         float P = NAN, C = NAN, R = NAN, E = NAN, W = NAN, T = NAN, A = NAN;
-        int8_t I = -1, S = -1;
+        int8_t I = -1, S = -1, B = -1;
         if(code_seen('C')) C = code_value();
         if(code_seen('P')) P = code_value();
         if(code_seen('I')) I = code_value_short();
         if(code_seen('R')) R = code_value();
         if(code_seen('S')) S = code_value_short();
+        if(code_seen('B')) B = code_value_short();
         if(code_seen('E')) E = code_value();
         if(code_seen('W')) W = code_value();
         if(code_seen('T')) T = code_value();
         if(code_seen('A')) A = code_value();
 
         // report values if nothing has been requested
-        if(isnan(C) && isnan(P) && isnan(R) && isnan(E) && isnan(W) && isnan(T) && isnan(A) && I < 0 && S < 0) {
+        if(isnan(C) && isnan(P) && isnan(R) && isnan(E) && isnan(W) && isnan(T) && isnan(A) && I < 0 && S < 0 && B < 0) {
             temp_model_report_settings();
             break;
         }
 
         // update all set parameters
         if(S >= 0) temp_model_set_enabled(S);
+        if(B >= 0) temp_model_set_warn_beep(B);
         if(!isnan(C) || !isnan(P) || !isnan(T) || !isnan(W) || !isnan(E)) temp_model_set_params(C, P, T, W, E);
         if(I >= 0 && !isnan(R)) temp_model_set_resistance(I, R);
 

+ 3 - 2
Firmware/temp_model.h

@@ -69,8 +69,9 @@ struct model_data
     void step(uint8_t heater_pwm, uint8_t fan_pwm, float heater_temp, float ambient_temp);
 };
 
-static bool enabled;    // model check enabled
-static model_data data; // default heater data
+static bool enabled;          // model check enabled
+static bool warn_beep = true; // beep on warning threshold
+static model_data data;       // default heater data
 
 static bool calibrated(); // return calibration/model validity status
 static void check();      // check and trigger errors or warnings based on current state

+ 16 - 5
Firmware/temperature.cpp

@@ -2446,14 +2446,18 @@ void handle_warning()
 
     static bool beeper = false;
     if(warning_state.assert) {
-        // beep periodically
-        beeper = !beeper;
-        WRITE(BEEPER, beeper);
+        if(warn_beep) {
+            // beep periodically
+            beeper = !beeper;
+            WRITE(BEEPER, beeper);
+        }
     } else {
         // warning cleared, reset state
         warning_state.warning = false;
-        beeper = false;
-        WRITE(BEEPER, LOW);
+        if(warn_beep) {
+            beeper = false;
+            WRITE(BEEPER, LOW);
+        }
     }
 }
 
@@ -2520,9 +2524,15 @@ void temp_model_set_enabled(bool enabled)
         SERIAL_ECHOLNPGM("TM: invalid parameters, cannot enable");
 }
 
+void temp_model_set_warn_beep(bool enabled)
+{
+    temp_model::warn_beep = enabled;
+}
+
 void temp_model_set_params(float C, float P, float Ta_corr, float warn, float err)
 {
     TempMgrGuard temp_mgr_guard;
+
     if(!isnan(C) && C > 0) temp_model::data.C = C;
     if(!isnan(P) && P > 0) temp_model::data.P = P;
     if(!isnan(Ta_corr)) temp_model::data.Ta_corr = Ta_corr;
@@ -2570,6 +2580,7 @@ void temp_model_reset_settings()
     temp_model::data.Ta_corr = TEMP_MODEL_Ta_corr;
     temp_model::data.warn = TEMP_MODEL_W;
     temp_model::data.err = TEMP_MODEL_E;
+    temp_model::warn_beep = true;
     temp_model::enabled = false;
 }
 

+ 1 - 0
Firmware/temperature.h

@@ -231,6 +231,7 @@ void PID_autotune(float temp, int extruder, int ncycles);
 
 #ifdef TEMP_MODEL
 void temp_model_set_enabled(bool enabled);
+void temp_model_set_warn_beep(bool enabled);
 void temp_model_set_params(float C = NAN, float P = NAN, float Ta_corr = NAN, float warn = NAN, float err = NAN);
 void temp_model_set_resistance(uint8_t index, float R);