use constants for conditional compilation since preprocessor can't work out enums and we can't define in macros

This commit is contained in:
Michael Moon 2011-02-06 21:34:44 +11:00
parent 1c723f7656
commit e4fc55289b
4 changed files with 69 additions and 74 deletions

View File

@ -30,11 +30,6 @@
#define F_CPU 16000000L
#endif
/*
Are you using the official GEN3 motherboard with separate extruder controller?
*/
#define GEN3
/*
This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware
*/
@ -141,60 +136,58 @@
#include "arduino.h"
#ifndef GEN3
/*
/*
user defined pins
adjust to suit your electronics,
or adjust your electronics to suit this
*/
*/
#define X_STEP_PIN AIO0
#define X_DIR_PIN AIO1
#define X_MIN_PIN AIO2
#define X_STEP_PIN AIO0
#define X_DIR_PIN AIO1
#define X_MIN_PIN AIO2
#define Y_STEP_PIN AIO3
#define Y_DIR_PIN AIO4
#define Y_MIN_PIN AIO5
#define Y_STEP_PIN AIO3
#define Y_DIR_PIN AIO4
#define Y_MIN_PIN AIO5
#define Z_STEP_PIN DIO2
#define Z_DIR_PIN DIO3
#define Z_MIN_PIN DIO4
#define Z_STEP_PIN DIO2
#define Z_DIR_PIN DIO3
#define Z_MIN_PIN DIO4
#define E_STEP_PIN DIO7
#define E_DIR_PIN DIO8
#define E_STEP_PIN DIO7
#define E_DIR_PIN DIO8
#define PS_ON_PIN DIO9
#else
/*
#define PS_ON_PIN DIO9
/*
this is the official gen3 reprap motherboard pinout
*/
#define TX_ENABLE_PIN DIO12
#define RX_ENABLE_PIN DIO13
#define X_STEP_PIN DIO15
#define X_DIR_PIN DIO18
#define X_MIN_PIN DIO20
#define X_MAX_PIN DIO21
#define X_ENABLE_PIN DIO19
#define Y_STEP_PIN DIO23
#define Y_DIR_PIN DIO22
#define Y_MIN_PIN AIO6
#define Y_MAX_PIN AIO5
#define Y_ENABLE_PIN DIO7
#define Z_STEP_PIN AIO4
#define Z_DIR_PIN AIO3
#define Z_MIN_PIN AIO1
#define Z_MAX_PIN AIO0
#define Z_ENABLE_PIN AIO2
#define E_STEP_PIN DIO16
#define E_DIR_PIN DIO17
#define SD_CARD_DETECT DIO2
#define SD_WRITE_PROTECT DIO3
#endif
*/
// #define TX_ENABLE_PIN DIO12
// #define RX_ENABLE_PIN DIO13
//
// #define X_STEP_PIN DIO15
// #define X_DIR_PIN DIO18
// #define X_MIN_PIN DIO20
// #define X_MAX_PIN DIO21
// #define X_ENABLE_PIN DIO19
//
// #define Y_STEP_PIN DIO23
// #define Y_DIR_PIN DIO22
// #define Y_MIN_PIN AIO6
// #define Y_MAX_PIN AIO5
// #define Y_ENABLE_PIN DIO7
//
// #define Z_STEP_PIN AIO4
// #define Z_DIR_PIN AIO3
// #define Z_MIN_PIN AIO1
// #define Z_MAX_PIN AIO0
// #define Z_ENABLE_PIN AIO2
//
// #define E_STEP_PIN DIO16
// #define E_DIR_PIN DIO17
//
// #define SD_CARD_DETECT DIO2
// #define SD_WRITE_PROTECT DIO3
@ -217,16 +210,13 @@
// which temperature sensors are you using? (intercom is the gen3-style separate extruder board)
// #define TEMP_MAX6675
// #define TEMP_THERMISTOR
#define TEMP_THERMISTOR
// #define TEMP_AD595
// #define TEMP_PT100
#define TEMP_INTERCOM
// #define TEMP_INTERCOM
// if you selected thermistor or AD595, what pin is it on? (this value only used to fill ANALOG_MASK for you)
#define TEMP_PIN_CHANNEL AIO0_PIN
// ANALOG_MASK is a bitmask of all analog channels used- if you use more than one analog input (more than one temp sensor?), bitwise-or them all together
#define ANALOG_MASK MASK(TEMP_PIN_CHANNEL)
// ANALOG_MASK is a bitmask of all analog channels used- bitwise-or them all together
#define ANALOG_MASK MASK(AIO0_PIN)
/***************************************************************************\
* *
@ -283,6 +273,12 @@ DEFINE_TEMP_SENSOR(extruder, TT_INTERCOM, 0)
DEFINE_HEATER(extruder, PORTD, PIND6, OCR0A)
DEFINE_HEATER(bed, PORTD, PIND5, OCR0B)
// and now because the c preprocessor isn't as smart as it could be,
// uncomment the ones you've listed above and comment the rest
#define HEATER_EXTRUDER HEATER_extruder
#define HEATER_BED HEATER_bed
// #define HEATER_FAN HEATER_fan
/***************************************************************************\
* *

View File

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

View File

@ -5,7 +5,7 @@
#include "config.h"
#include "delay.h"
#ifdef GEN3
#ifdef TEMP_INTERCOM
#define INTERCOM_BAUD 57600
#define enable_transmit() do { WRITE(TX_ENABLE_PIN,1); WRITE(RX_ENABLE_PIN,0); } while(0)
@ -216,4 +216,4 @@ ISR(USART_UDRE_vect)
}
}
#endif /* GEN3 */
#endif /* TEMP_INTERCOM */

11
temp.c
View File

@ -11,7 +11,7 @@
#include "sersendf.h"
#endif
#include "heater.h"
#ifdef GEN3
#ifdef TEMP_INTERCOM
#include "intercom.h"
#endif
@ -112,7 +112,7 @@ void temp_init() {
break;*/
#endif
#ifdef GEN3
#ifdef TEMP_INTERCOM
case TT_INTERCOM:
intercom_init();
update_send_cmd(0);
@ -284,7 +284,7 @@ void temp_set(temp_sensor_t index, uint16_t temperature) {
temp_sensors_runtime[index].target_temp = temperature;
temp_sensors_runtime[index].temp_residency = 0;
#ifdef GEN3
#ifdef TEMP_INTERCOM
if (temp_sensors[index].temp_type == TT_INTERCOM)
update_send_cmd(temperature >> 2);
#endif
@ -308,10 +308,9 @@ void temp_print(temp_sensor_t index) {
c = (temp_sensors_runtime[index].last_read_temp & 3) * 25;
sersendf_P(PSTR("T:%u.%u"), temp_sensors_runtime[index].last_read_temp >> 2, c);
#ifdef _HEATER_bed
#warning heated bed enabled!
#ifdef HEATER_BED
uint8_t b = 0;
b = (temp_sensors_runtime[HEATER_bed].last_read_temp & 3) * 25;
b = (temp_sensors_runtime[HEATER_BED].last_read_temp & 3) * 25;
sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_bed].last_read_temp >> 2 , b);
#endif