/* temperature.h - temperature controller Part of Marlin Copyright (c) 2011 Erik van der Zalm Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Grbl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grbl. If not, see . */ #ifndef temperature_h #define temperature_h #include "Marlin.h" #include "config.h" #ifdef SYSTEM_TIMER_2 #define ENABLE_SOFT_PWM_INTERRUPT() TIMSK2 |= (1< current_temperature[extruder]; }; FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }; FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }; FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }; #define degHotend0() degHotend(0) #define degTargetHotend0() degTargetHotend(0) #define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0) #define isHeatingHotend0() isHeatingHotend(0) #define isCoolingHotend0() isCoolingHotend(0) #if EXTRUDERS > 1 #define degHotend1() degHotend(1) #define degTargetHotend1() degTargetHotend(1) #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1) #define isHeatingHotend1() isHeatingHotend(1) #define isCoolingHotend1() isCoolingHotend(1) #else #define setTargetHotend1(_celsius) do{}while(0) #endif #if EXTRUDERS > 2 #define degHotend2() degHotend(2) #define degTargetHotend2() degTargetHotend(2) #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2) #define isHeatingHotend2() isHeatingHotend(2) #define isCoolingHotend2() isCoolingHotend(2) #else #define setTargetHotend2(_celsius) do{}while(0) #endif #if EXTRUDERS > 3 #error Invalid number of extruders #endif // return "false", if all heaters are 'off' (ie. "true", if any heater is 'on') #define CHECK_ALL_HEATERS (checkAllHotends()||(target_temperature_bed!=0)) int getHeaterPower(int heater); void disable_heater(); // Disable all heaters *instantaneously* void updatePID(); FORCE_INLINE void autotempShutdown(){ #ifdef AUTOTEMP if(autotemp_enabled) { autotemp_enabled=false; if(degTargetHotend(active_extruder)>autotemp_min) setTargetHotend(0,active_extruder); } #endif } 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); void temp_model_report_settings(); void temp_model_reset_settings(); void temp_model_load_settings(); void temp_model_save_settings(); void temp_model_autotune(int16_t temp = 0); #ifdef TEMP_MODEL_DEBUG void temp_model_log_enable(bool enable); #endif #endif #ifdef FAN_SOFT_PWM extern unsigned char fanSpeedSoftPwm; #endif extern uint8_t fanSpeedBckp; #endif