diff options
author | midopple <mdoppler@gmx.at> | 2012-03-30 11:03:41 +0300 |
---|---|---|
committer | midopple <mdoppler@gmx.at> | 2012-03-30 11:03:41 +0300 |
commit | 52f7f3040874dc8b2ef4b0d570f7fa9d0291dfc3 (patch) | |
tree | 1b266eacb877b8bd29f9ceb6258cf8b0e1ca4b02 | |
parent | 1748e3258b23217803802e046947ff8b5de099c0 (diff) |
Command M106 / M107 for control the fan can use PWM
New function to check the used PWM pins
-rw-r--r-- | Sprinter/Sprinter.pde | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 53d42b8..308ee19 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -555,6 +555,39 @@ int FreeRam1(void) } //------------------------------------------------ +//Function the check the Analog OUT pin for not using the Timer1 +//------------------------------------------------ +void analogWrite_check(uint8_t check_pin, int val) +{ + #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) + //Atmega168 / 328 can not useed OCR1A and OCR1B + //This are PINS PB1 / PB2 or on Ardurino D9 / D10 + if((check_pin != 9) && (check_pin != 10)) + { + analogWrite(check_pin, val); + } + #endif + + #if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) + //Atmega664P / 1284P can not useed OCR1A and OCR1B + //This are PINS PD4 / PD5 or on Ardurino D12 / D13 + if((check_pin != 12) && (check_pin != 13)) + { + analogWrite(check_pin, val); + } + #endif + + #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + //Atmega1280 / 2560 can not useed OCR1A, OCR1B and OCR1C + //This are PINS PB5,PB6,PB7 or on Ardurino D11,D12,and D13 + if((check_pin != 11) && (check_pin != 12) && (check_pin != 13)) + { + analogWrite(check_pin, val); + } + #endif +} + +//------------------------------------------------ //Print a String from Flash to Serial (save RAM) //------------------------------------------------ void showString (PGM_P s) @@ -1499,16 +1532,16 @@ FORCE_INLINE void process_commands() if (code_seen('S')) { WRITE(FAN_PIN, HIGH); - //analogWrite(FAN_PIN, constrain(code_value(),0,255) ); + analogWrite_check(FAN_PIN, constrain(code_value(),0,255) ); } else { WRITE(FAN_PIN, HIGH); - //analogWrite(FAN_PIN, 255 ); + analogWrite_check(FAN_PIN, 255 ); } break; case 107: //M107 Fan Off - //analogWrite(FAN_PIN, 0); + analogWrite_check(FAN_PIN, 0); WRITE(FAN_PIN, LOW); break; #endif |