diff --git a/config.h.dist b/config.h.dist index c5fb5b3..ce3a6c4 100644 --- a/config.h.dist +++ b/config.h.dist @@ -171,6 +171,7 @@ // OC2A DIO11 // OC2B DIO3 +// comment out the ones you don't have #define HEATER_PIN DIO6 #define HEATER_PWM OCR0A diff --git a/gcode.c b/gcode.c index 3a83e93..40f257c 100644 --- a/gcode.c +++ b/gcode.c @@ -176,9 +176,11 @@ void scan_char(uint8_t c) { // but it takes less code, less memory and loses no precision if we do it here instead if ((next_target.M == 104) || (next_target.M == 109)) next_target.S = decfloat_to_int(&read_digit, 4, 1); + #ifdef HEATER_PIN // if this is heater PID stuff, multiply by PID_SCALE because we divide by PID_SCALE later on else if ((next_target.M >= 130) && (next_target.M <= 132)) next_target.S = decfloat_to_int(&read_digit, PID_SCALE, 1); + #endif else next_target.S = decfloat_to_int(&read_digit, 1, 1); if (debug_flags & DEBUG_ECHO) @@ -617,6 +619,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) { sersendf_P("X:%ld,Y:%ld,Z:%ld,E:%ld,F:%ld\n", current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F); break; + #ifdef HEATER_PIN // M130- heater P factor case 130: if (gcmd->seen_S) @@ -641,6 +644,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) { case 134: heater_save_settings(); break; + #endif /* HEATER_PIN */ #ifdef DEBUG // M140- echo off diff --git a/heater.c b/heater.c index bc63321..320d3c9 100644 --- a/heater.c +++ b/heater.c @@ -1,5 +1,7 @@ #include "heater.h" +#ifdef HEATER_PIN + #include #include "sersendf.h" @@ -101,3 +103,5 @@ void heater_tick(int16_t current_temp, int16_t target_temp) { disable_heater(); #endif } + +#endif /* HEATER_PIN */ \ No newline at end of file diff --git a/heater.h b/heater.h index 230bd6f..612da2f 100644 --- a/heater.h +++ b/heater.h @@ -3,6 +3,8 @@ #include "config.h" +#ifdef HEATER_PIN + #ifdef HEATER_PWM #define enable_heater() { TCCR0A |= MASK(COM0A1); } #define disable_heater() { TCCR0A &= ~MASK(COM0A1); } @@ -26,4 +28,14 @@ void heater_save_settings(void); void heater_tick(int16_t current_temp, int16_t target_temp); uint8_t temp_achieved(void); +#else /* HEATER_PIN */ + +// if there is no heater pin, there is no heater +#define enable_heater() /* empty */ +#define disable_heater() /* empty */ +#define heater_init() /* empty */ +#define heater_save_settings() /* empty */ +#define heater_tick(p1, p2) /* empty */ + +#endif /* HEATER_PIN */ #endif /* _HEATER_H */