From d1b2754aba7cc4387d7f2a15403dca335561c990 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Wed, 2 Feb 2011 18:20:36 +1100 Subject: [PATCH] sorting out preprocessor interactions --- config.h.dist | 23 ++++++++++------------- gcode_process.c | 16 +++++++++------- heater.h | 6 +++++- temp.c | 12 ++++++------ 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/config.h.dist b/config.h.dist index c4bf146..aa8d1cb 100644 --- a/config.h.dist +++ b/config.h.dist @@ -232,12 +232,7 @@ * * * Define your temperature sensors here * * * -* If your temperature sensor has no associated heater, enter '255' as the * -* heater index. Unassociated temperature sensors are still read, but they * -* do not affect firmware operation * -* * -* for GEN3 set temp_type to TT_INTERCOM, temp_pin to 0 and heater index to * -* 255 - the extruder manages the heater for us * +* for GEN3 set temp_type to TT_INTERCOM and temp_pin to 0 * * * * Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, * * TT_PT100, TT_INTERCOM. See list in temp.c. * @@ -248,8 +243,8 @@ #define DEFINE_TEMP_SENSOR(...) #endif -// name type pin heater index -DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255) +// name type pin +DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0) /***************************************************************************\ @@ -258,9 +253,6 @@ DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255) * * \***************************************************************************/ -// index of bed heater for M105 and M140 commands. set to 255 if no bed heater -#define BED_HEATER 1 - // check if heater responds to changes in target temperature, disable and spit errors if not // #define HEATER_SANITY_CHECK @@ -276,6 +268,11 @@ DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255) * If a heater isn't attached to a temperature sensor above, it can still be * * controlled by host but otherwise is ignored by firmware * * * +* To attach a heater to a temp sensor above, simply use exactly the same * +* name - copy+paste is your friend * +* * +* Some common names are 'extruder', 'bed', 'fan' * +* * \***************************************************************************/ #ifndef DEFINE_HEATER @@ -283,8 +280,8 @@ DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255) #endif // name port pin pwm -// DEFINE_HEATER(extruder, PORTD, PIND6, OCR0A) -// DEFINE_HEATER(bed, PORTD, PIND5, OCR0B) +DEFINE_HEATER(extruder, PORTD, PIND6, OCR0A) +DEFINE_HEATER(bed, PORTD, PIND5, OCR0B) /***************************************************************************\ diff --git a/gcode_process.c b/gcode_process.c index 954b03d..1131d63 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -275,15 +275,15 @@ void process_gcode_command() { // M7/M106- fan on case 7: case 106: - #if NUM_HEATERS >= 1 - heater_set(1, 255); + #ifdef HEATER_fan + heater_set(HEATER_fan, 255); #endif break; // M107- fan off case 9: case 107: - #if NUM_HEATERS >= 1 - heater_set(1, 0); + #ifdef HEATER_fan + heater_set(HEATER_fan, 0); #endif break; @@ -359,9 +359,11 @@ void process_gcode_command() { break; case 140: //Set heated bed temperature - temp_set(BED_HEATER, next_target.S); - if (next_target.S) - power_on(); + #ifdef HEATER_bed + temp_set(HEATER_bed, next_target.S); + if (next_target.S) + power_on(); + #endif break; // M190- power on diff --git a/heater.h b/heater.h index 1251383..11b3cdd 100644 --- a/heater.h +++ b/heater.h @@ -9,7 +9,7 @@ #define disable_heater() heater_set(0, 0) #undef DEFINE_HEATER -#define DEFINE_HEATER(name, port, pin, pwm) HEATER_##name, +#define DEFINE_HEATER(name, port, pin, pwm) HEATER_ ## name, typedef enum { #include "config.h" @@ -18,6 +18,10 @@ typedef enum } heater_t; #undef DEFINE_HEATER +#define DEFINE_HEATER(name, port, pin, pwm) #define HEATER_ ## name; +#include "config.h" +#undef DEFINE_HEATER + void heater_init(void); void heater_save_settings(void); diff --git a/temp.c b/temp.c index bc4b954..90db9cb 100644 --- a/temp.c +++ b/temp.c @@ -307,14 +307,14 @@ void temp_print(temp_sensor_t index) { c = (temp_sensors_runtime[index].last_read_temp & 3) * 25; - if (BED_HEATER < NUM_HEATERS) { + sersendf_P(PSTR("T:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c); + #ifdef _HEATER_bed + #warning heated bed enabled! uint8_t b = 0; - b = (temp_sensors_runtime[BED_HEATER].last_read_temp & 3) * 25; + b = (temp_sensors_runtime[HEATER_bed].last_read_temp & 3) * 25; - sersendf_P(PSTR("T:%u.%u B:%u.%u\n"), temp_sensors_runtime[index].last_read_temp >> 2, c, temp_sensors_runtime[BED_HEATER].last_read_temp >> 2 , b); - } else { - sersendf_P(PSTR("T:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c); - } + sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_bed].last_read_temp >> 2 , b); + #endif } #endif