name_checksum= name;
pool_index= index;
waiting= false;
- min_temp_violated= false;
+ temp_violated= false;
sensor= nullptr;
readonly= false;
}
void TemperatureControl::on_main_loop(void *argument)
{
- if (this->min_temp_violated) {
- THEKERNEL->streams->printf("Error: MINTEMP triggered. Check your temperature sensors!\n");
- this->min_temp_violated = false;
+ if (this->temp_violated) {
+ this->temp_violated = false;
+ THEKERNEL->streams->printf("Error: MINTEMP or MAXTEMP triggered. Check your temperature sensors!\n");
+ THEKERNEL->streams->printf("HALT asserted - reset or M999 required\n");
+ THEKERNEL->call_event(ON_HALT, nullptr);
}
}
this->designator = THEKERNEL->config->value(temperature_control_checksum, this->name_checksum, designator_checksum)->by_default(string("T"))->as_string();
- // Max and min temperatures we are not allowed to set over (Safety)
- this->max_temp = THEKERNEL->config->value(temperature_control_checksum, this->name_checksum, max_temp_checksum)->by_default(1000)->as_number();
+ // Max and min temperatures we are not allowed to get over (Safety)
+ this->max_temp = THEKERNEL->config->value(temperature_control_checksum, this->name_checksum, max_temp_checksum)->by_default(300)->as_number();
this->min_temp = THEKERNEL->config->value(temperature_control_checksum, this->name_checksum, min_temp_checksum)->by_default(0)->as_number();
// Heater pin
// readonly sensors don't handle the rest
if(this->readonly) return;
- if (gcode->m == 301) {
+ if (gcode->m == 143) {
+ if (gcode->has_letter('S') && (gcode->get_value('S') == this->pool_index)) {
+ if(gcode->has_letter('P')) {
+ max_temp= gcode->get_value('P');
+
+ } else {
+ gcode->stream->printf("Nothing set NOTE Usage is M143 S0 P300 where <S> is the hotend index and <P> is the maximum temp to set\n");
+ }
+
+ }else if(gcode->get_num_args() == 0) {
+ gcode->stream->printf("Maximum temperature for %s(%d) is %f°C\n", this->designator.c_str(), this->pool_index, max_temp);
+ }
+
+ } else if (gcode->m == 301) {
if (gcode->has_letter('S') && (gcode->get_value('S') == this->pool_index)) {
if (gcode->has_letter('P'))
setPIDp( gcode->get_value('P') );
} else if (gcode->m == 500 || gcode->m == 503) { // M500 saves some volatile settings to config override file, M503 just prints the settings
gcode->stream->printf(";PID settings:\nM301 S%d P%1.4f I%1.4f D%1.4f X%1.4f Y%d\n", this->pool_index, this->p_factor, this->i_factor / this->PIDdt, this->d_factor * this->PIDdt, this->i_max, this->heater_pin.max_pwm());
+ gcode->stream->printf(";Max temperature setting:\nM143 S%d P%1.4f\n", this->pool_index, this->max_temp);
+
if(this->sensor_settings) {
// get or save any sensor specific optional values
TempSensor::sensor_options_t options;
}
return;
- }else if(!pdr->second_element_is(this->name_checksum)) return;
+ }else if(!pdr->second_element_is(poll_controls_checksum)) {
+ // polling for all temperature controls
+ // add our data to the list
+ std::vector<struct pad_temperature*> *v;
+ void *data= pdr->get_data_ptr();
+ if(data == nullptr) {
+ // first one allocates a vector for the return data
+ v= new std::vector<struct pad_temperature*> ;
+ pdr->set_data_ptr(v);
+
+ }else{
+ v= static_cast<std::vector<pad_temperature*>*>(data);
+ }
+
+ // setup data
+ this->public_data_return.current_temperature = this->get_temperature();
+ this->public_data_return.target_temperature = (target_temperature <= 0) ? 0 : this->target_temperature;
+ this->public_data_return.pwm = this->o;
+ this->public_data_return.designator= this->designator;
+ this->public_data_return.id= this->name_checksum;
+ v->push_back(&this->public_data_return);
+ return;
+ }
+
+ // not targeted at us
+ if(!pdr->second_element_is(this->name_checksum)) return;
// ok this is targeted at us, so send back the requested data
if(pdr->third_element_is(current_temperature_checksum)) {
this->public_data_return.target_temperature = (target_temperature <= 0) ? 0 : this->target_temperature;
this->public_data_return.pwm = this->o;
this->public_data_return.designator= this->designator;
+ this->public_data_return.id= this->name_checksum;
pdr->set_data_ptr(&this->public_data_return);
pdr->set_taken();
}
{
float temperature = sensor->get_temperature();
if(!this->readonly && target_temperature > 2) {
- if (isinf(temperature) || temperature < min_temp) {
- this->min_temp_violated = true;
+ if (isinf(temperature) || temperature < min_temp || temperature > max_temp) {
+ this->temp_violated = true;
target_temperature = UNDEFINED;
heater_pin.set((this->o = 0));
} else {