@@ -3316,129 +3316,6 @@ void GCodes::HandleReply(GCodeBuffer& gb, OutputBuffer *reply)
33163316 }
33173317}
33183318
3319- // Configure heater protection (M143). Returns true if an error occurred
3320- GCodeResult GCodes::SetHeaterProtection (GCodeBuffer& gb, const StringRef& reply)
3321- {
3322- const int index = (gb.Seen (' P' ))
3323- ? gb.GetIValue ()
3324- : (gb.Seen (' H' )) ? gb.GetIValue () : 1 ; // default to extruder 1 if no heater number provided
3325- if ((index < 0 || index >= (int )MaxHeaters) && (index < (int )FirstExtraHeaterProtection || index >= (int )(FirstExtraHeaterProtection + NumExtraHeaterProtections)))
3326- {
3327- reply.printf (" Invalid heater protection item '%d'" , index);
3328- return GCodeResult::error;
3329- }
3330-
3331- HeaterProtection &item = reprap.GetHeat ().AccessHeaterProtection (index);
3332-
3333- // Set heater to control
3334- bool seen = false ;
3335- if (gb.Seen (' P' ) && gb.Seen (' H' ))
3336- {
3337- const int heater = gb.GetIValue ();
3338- if (heater > (int )MaxHeaters) // allow negative values to disable heater protection
3339- {
3340- reply.printf (" Invalid heater number '%d'" , heater);
3341- return GCodeResult::error;
3342- }
3343-
3344- seen = true ;
3345- item.SetHeater (heater);
3346- }
3347-
3348- // Set sensor that supervises the heater
3349- if (gb.Seen (' X' ))
3350- {
3351- item.SetSensorNumber (gb.GetIValue ());
3352- seen = true ;
3353- }
3354-
3355- // Set trigger action
3356- if (gb.Seen (' A' ))
3357- {
3358- const int action = gb.GetIValue ();
3359- if (action < 0 || action > (int )MaxHeaterProtectionAction)
3360- {
3361- reply.printf (" Invalid heater protection action '%d'" , action);
3362- }
3363-
3364- seen = true ;
3365- item.SetAction (static_cast <HeaterProtectionAction>(action));
3366- }
3367-
3368- // Set trigger condition
3369- if (gb.Seen (' C' ))
3370- {
3371- const int trigger = gb.GetIValue ();
3372- if (trigger < 0 || trigger > (int )MaxHeaterProtectionTrigger)
3373- {
3374- reply.printf (" Invalid heater protection trigger '%d'" , trigger);
3375- }
3376-
3377- seen = true ;
3378- item.SetTrigger (static_cast <HeaterProtectionTrigger>(trigger));
3379- }
3380-
3381- // Set temperature limit
3382- if (gb.Seen (' S' ))
3383- {
3384- const float limit = gb.GetFValue ();
3385- if (limit <= BadLowTemperature || limit >= BadErrorTemperature)
3386- {
3387- reply.copy (" Invalid temperature limit" );
3388- return GCodeResult::error;
3389- }
3390-
3391- seen = true ;
3392- item.SetTemperatureLimit (limit);
3393- }
3394-
3395- // Report current parameters
3396- if (!seen)
3397- {
3398- if (item.GetHeater () < 0 )
3399- {
3400- reply.printf (" Temperature protection item %d is not configured" , index);
3401- }
3402- else
3403- {
3404- const char *actionString, *triggerString;
3405- switch (item.GetAction ())
3406- {
3407- case HeaterProtectionAction::GenerateFault:
3408- actionString = " generate a heater fault" ;
3409- break ;
3410- case HeaterProtectionAction::PermanentSwitchOff:
3411- actionString = " permanently switch off" ;
3412- break ;
3413- case HeaterProtectionAction::TemporarySwitchOff:
3414- actionString = " temporarily switch off" ;
3415- break ;
3416- default :
3417- actionString = " (undefined)" ;
3418- break ;
3419- }
3420-
3421- switch (item.GetTrigger ())
3422- {
3423- case HeaterProtectionTrigger::TemperatureExceeded:
3424- triggerString = " exceeds" ;
3425- break ;
3426- case HeaterProtectionTrigger::TemperatureTooLow:
3427- triggerString = " falls below" ;
3428- break ;
3429- default :
3430- triggerString = " (undefined)" ;
3431- break ;
3432- }
3433-
3434- reply.printf (" Temperature protection item %d is configured for heater %d and uses sensor %d to %s if the temperature %s %.1f" DEGREE_SYMBOL " C" ,
3435- index, item.GetHeater (), item.GetSensorNumber (), actionString, triggerString, (double )item.GetTemperatureLimit ());
3436- }
3437- }
3438-
3439- return GCodeResult::ok;
3440- }
3441-
34423319void GCodes::SetToolHeaters (Tool *tool, float temperature, bool both)
34433320{
34443321 if (tool == nullptr )
0 commit comments