Tweaks to temperature code

This commit is contained in:
Scott Lahteine 2017-06-15 15:14:08 -05:00
parent d9da126776
commit 7769a22064
3 changed files with 22 additions and 22 deletions

View file

@ -421,13 +421,13 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
bedKp = workKp; \
bedKi = scalePID_i(workKi); \
bedKd = scalePID_d(workKd); \
updatePID(); } while(0)
updatePID(); }while(0)
#define _SET_EXTRUDER_PID() do { \
PID_PARAM(Kp, hotend) = workKp; \
PID_PARAM(Ki, hotend) = scalePID_i(workKi); \
PID_PARAM(Kd, hotend) = scalePID_d(workKd); \
updatePID(); } while(0)
updatePID(); }while(0)
// Use the result? (As with "M303 U1")
if (set_result) {
@ -505,7 +505,7 @@ int Temperature::getHeaterPower(int heater) {
//
// Temperature Error Handlers
//
void Temperature::_temp_error(int e, const char* serial_msg, const char* lcd_msg) {
void Temperature::_temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg) {
static bool killed = false;
if (IsRunning()) {
SERIAL_ERROR_START();
@ -524,7 +524,7 @@ void Temperature::_temp_error(int e, const char* serial_msg, const char* lcd_msg
#endif
}
void Temperature::max_temp_error(int8_t e) {
void Temperature::max_temp_error(const int8_t e) {
#if HAS_TEMP_BED
_temp_error(e, PSTR(MSG_T_MAXTEMP), e >= 0 ? PSTR(MSG_ERR_MAXTEMP) : PSTR(MSG_ERR_MAXTEMP_BED));
#else
@ -534,7 +534,7 @@ void Temperature::max_temp_error(int8_t e) {
#endif
#endif
}
void Temperature::min_temp_error(int8_t e) {
void Temperature::min_temp_error(const int8_t e) {
#if HAS_TEMP_BED
_temp_error(e, PSTR(MSG_T_MINTEMP), e >= 0 ? PSTR(MSG_ERR_MINTEMP) : PSTR(MSG_ERR_MINTEMP_BED));
#else
@ -545,7 +545,7 @@ void Temperature::min_temp_error(int8_t e) {
#endif
}
float Temperature::get_pid_output(int e) {
float Temperature::get_pid_output(const int8_t e) {
#if HOTENDS == 1
UNUSED(e);
#define _HOTEND_TEST true
@ -890,7 +890,7 @@ float Temperature::analog2temp(int raw, uint8_t e) {
// Derived from RepRap FiveD extruder::getTemperature()
// For bed temperature measurement.
float Temperature::analog2tempBed(int raw) {
float Temperature::analog2tempBed(const int raw) {
#if ENABLED(BED_USES_THERMISTOR)
float celsius = 0;
byte i;
@ -1148,7 +1148,7 @@ void Temperature::init() {
#define TEMP_MIN_ROUTINE(NR) \
minttemp[NR] = HEATER_ ##NR## _MINTEMP; \
while(analog2temp(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \
while (analog2temp(minttemp_raw[NR], NR) < HEATER_ ##NR## _MINTEMP) { \
if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \
minttemp_raw[NR] += OVERSAMPLENR; \
else \
@ -1156,7 +1156,7 @@ void Temperature::init() {
}
#define TEMP_MAX_ROUTINE(NR) \
maxttemp[NR] = HEATER_ ##NR## _MAXTEMP; \
while(analog2temp(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \
while (analog2temp(maxttemp_raw[NR], NR) > HEATER_ ##NR## _MAXTEMP) { \
if (HEATER_ ##NR## _RAW_LO_TEMP < HEATER_ ##NR## _RAW_HI_TEMP) \
maxttemp_raw[NR] -= OVERSAMPLENR; \
else \
@ -1203,7 +1203,7 @@ void Temperature::init() {
#endif // HOTENDS > 1
#ifdef BED_MINTEMP
while(analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
#if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
bed_minttemp_raw += OVERSAMPLENR;
#else
@ -1292,7 +1292,7 @@ void Temperature::init() {
SERIAL_EOL();
*/
int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
const int heater_index = heater_id >= 0 ? heater_id : HOTENDS;
#if HEATER_IDLE_HANDLER
// If the heater idle timeout expires, restart
@ -1922,7 +1922,7 @@ void Temperature::isr() {
case SensorsReady: {
// All sensors have been read. Stay in this state for a few
// ISRs to save on calls to temp update/checking code below.
constexpr int extra_loops = MIN_ADC_ISR_LOOPS - (int)SensorsReady;
constexpr int8_t extra_loops = MIN_ADC_ISR_LOOPS - (int8_t)SensorsReady;
static uint8_t delay_count = 0;
if (extra_loops > 0) {
if (delay_count == 0) delay_count = extra_loops; // Init this delay

View file

@ -535,15 +535,15 @@ class Temperature {
static void checkExtruderAutoFans();
static float get_pid_output(int e);
static float get_pid_output(const int8_t e);
#if ENABLED(PIDTEMPBED)
static float get_pid_output_bed();
#endif
static void _temp_error(int e, const char* serial_msg, const char* lcd_msg);
static void min_temp_error(int8_t e);
static void max_temp_error(int8_t e);
static void _temp_error(const int8_t e, const char * const serial_msg, const char * const lcd_msg);
static void min_temp_error(const int8_t e);
static void max_temp_error(const int8_t e);
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED

View file

@ -23,27 +23,27 @@
// PT100 with INA826 amp on Ultimaker v2.0 electronics
// The PT100 in the Ultimaker v2.0 electronics has a high sample value for a high temperature.
// This does not match the normal thermistor behaviour so we need to set the following defines
#if (THERMISTORHEATER_0 == 20)
#if THERMISTORHEATER_0 == 20
#define HEATER_0_RAW_HI_TEMP 16383
#define HEATER_0_RAW_LO_TEMP 0
#endif
#if (THERMISTORHEATER_1 == 20)
#if THERMISTORHEATER_1 == 20
#define HEATER_1_RAW_HI_TEMP 16383
#define HEATER_1_RAW_LO_TEMP 0
#endif
#if (THERMISTORHEATER_2 == 20)
#if THERMISTORHEATER_2 == 20
#define HEATER_2_RAW_HI_TEMP 16383
#define HEATER_2_RAW_LO_TEMP 0
#endif
#if (THERMISTORHEATER_3 == 20)
#if THERMISTORHEATER_3 == 20
#define HEATER_3_RAW_HI_TEMP 16383
#define HEATER_3_RAW_LO_TEMP 0
#endif
#if (THERMISTORHEATER_4 == 20)
#if THERMISTORHEATER_4 == 20
#define HEATER_4_RAW_HI_TEMP 16383
#define HEATER_4_RAW_LO_TEMP 0
#endif
#if (THERMISTORBED == 20)
#if THERMISTORBED == 20
#define HEATER_BED_RAW_HI_TEMP 16383
#define HEATER_BED_RAW_LO_TEMP 0
#endif