diff --git a/coolant_control.c b/coolant_control.c index b866aef..90cde68 100644 --- a/coolant_control.c +++ b/coolant_control.c @@ -39,10 +39,17 @@ void coolant_init() void coolant_stop() { +#ifdef INVERT_COOLANT #ifdef ENABLE_M7 - COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT); - #endif - COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT); + COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT); + #endif + COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT); +#else +#ifdef ENABLE_M7 + COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT); +#endif + COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT); +#endif } @@ -51,11 +58,19 @@ void coolant_run(uint8_t mode) if (mode != current_coolant_mode) { plan_synchronize(); // Ensure coolant turns on when specified in program. - if (mode == COOLANT_FLOOD_ENABLE) { - COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT); + if (mode == COOLANT_FLOOD_ENABLE) { +#ifdef INVERT_COOLANT + COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT); +#else + COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT); +#endif #ifdef ENABLE_M7 } else if (mode == COOLANT_MIST_ENABLE) { +#ifdef INVERT_COOLANT + COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT); +#else COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT); +#endif #endif } else { coolant_stop(); diff --git a/cpu_map.h b/cpu_map.h index ed97275..70a3984 100644 --- a/cpu_map.h +++ b/cpu_map.h @@ -34,6 +34,9 @@ #define SERIAL_RX USART_RX_vect #define SERIAL_UDRE USART_UDRE_vect + // Start of PWM & Stepper Enabled Spindle + // #define VARIABLE_SPINDLE // comment this out to disable PWM & Stepper on the spindle + // NOTE: All step bit and direction pins must be on the same port. #define STEPPING_DDR DDRD #define STEPPING_PORT PORTD @@ -54,6 +57,20 @@ #define STEPPERS_DISABLE_BIT 0 // Uno Digital Pin 8 #define STEPPERS_DISABLE_MASK (1< 0) { - SPINDLE_DIRECTION_PORT &= ~(1< 0) { + SPINDLE_DIRECTION_PORT &= ~(1< void spindle_init(); -void spindle_run(int8_t direction); //, uint16_t rpm); +void spindle_run(int8_t direction, uint16_t rpm); void spindle_stop(); +uint8_t spindle_pwm(); +void spindle_pwm_update(uint8_t pwm); #endif