sorting out preprocessor interactions

This commit is contained in:
Michael Moon 2011-02-02 18:20:36 +11:00
parent 97f344f0fa
commit d1b2754aba
4 changed files with 30 additions and 27 deletions

View File

@ -232,12 +232,7 @@
* * * *
* Define your temperature sensors here * * Define your temperature sensors here *
* * * *
* If your temperature sensor has no associated heater, enter '255' as the * * for GEN3 set temp_type to TT_INTERCOM and temp_pin to 0 *
* 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 *
* * * *
* Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, * * Types are same as TEMP_ list above- TT_MAX6675, TT_THERMISTOR, TT_AD595, *
* TT_PT100, TT_INTERCOM. See list in temp.c. * * TT_PT100, TT_INTERCOM. See list in temp.c. *
@ -248,8 +243,8 @@
#define DEFINE_TEMP_SENSOR(...) #define DEFINE_TEMP_SENSOR(...)
#endif #endif
// name type pin heater index // name type pin
DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255) 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 // check if heater responds to changes in target temperature, disable and spit errors if not
// #define HEATER_SANITY_CHECK // #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 * * If a heater isn't attached to a temperature sensor above, it can still be *
* controlled by host but otherwise is ignored by firmware * * 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 #ifndef DEFINE_HEATER
@ -283,8 +280,8 @@ DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0, 255)
#endif #endif
// name port pin pwm // name port pin pwm
// DEFINE_HEATER(extruder, PORTD, PIND6, OCR0A) DEFINE_HEATER(extruder, PORTD, PIND6, OCR0A)
// DEFINE_HEATER(bed, PORTD, PIND5, OCR0B) DEFINE_HEATER(bed, PORTD, PIND5, OCR0B)
/***************************************************************************\ /***************************************************************************\

View File

@ -275,15 +275,15 @@ void process_gcode_command() {
// M7/M106- fan on // M7/M106- fan on
case 7: case 7:
case 106: case 106:
#if NUM_HEATERS >= 1 #ifdef HEATER_fan
heater_set(1, 255); heater_set(HEATER_fan, 255);
#endif #endif
break; break;
// M107- fan off // M107- fan off
case 9: case 9:
case 107: case 107:
#if NUM_HEATERS >= 1 #ifdef HEATER_fan
heater_set(1, 0); heater_set(HEATER_fan, 0);
#endif #endif
break; break;
@ -359,9 +359,11 @@ void process_gcode_command() {
break; break;
case 140: //Set heated bed temperature case 140: //Set heated bed temperature
temp_set(BED_HEATER, next_target.S); #ifdef HEATER_bed
if (next_target.S) temp_set(HEATER_bed, next_target.S);
power_on(); if (next_target.S)
power_on();
#endif
break; break;
// M190- power on // M190- power on

View File

@ -9,7 +9,7 @@
#define disable_heater() heater_set(0, 0) #define disable_heater() heater_set(0, 0)
#undef DEFINE_HEATER #undef DEFINE_HEATER
#define DEFINE_HEATER(name, port, pin, pwm) HEATER_##name, #define DEFINE_HEATER(name, port, pin, pwm) HEATER_ ## name,
typedef enum typedef enum
{ {
#include "config.h" #include "config.h"
@ -18,6 +18,10 @@ typedef enum
} heater_t; } heater_t;
#undef DEFINE_HEATER #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_init(void);
void heater_save_settings(void); void heater_save_settings(void);

12
temp.c
View File

@ -307,14 +307,14 @@ void temp_print(temp_sensor_t index) {
c = (temp_sensors_runtime[index].last_read_temp & 3) * 25; 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; 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); sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_bed].last_read_temp >> 2 , b);
} else { #endif
sersendf_P(PSTR("T:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c);
}
} }
#endif #endif