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 *
* *
* 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)
/***************************************************************************\

View File

@ -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

View File

@ -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);

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;
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