From 6d1256eaadee5e568ac285f13e69e3b63ae68646 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 25 Jan 2019 18:06:30 +0100 Subject: [PATCH 1/4] Internationalize "Calibrating home". --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 64899d39..7d07ccf2 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7245,7 +7245,7 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo if (_step == 10) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); if (_step == 11) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0 if (_step == 12) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); - if (_step == 13) lcd_puts_P(PSTR("Calibrating home")); + if (_step == 13) lcd_puts_P(_i("Calibrating home"));////c=20 r=1 lcd_set_cursor(0, 1); lcd_puts_P(separator); From b167896c6da029742bfa6e300670af68009d7248 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 25 Jan 2019 20:00:12 +0100 Subject: [PATCH 2/4] Convert lcd_selftest_screen parameter int _step to enum class testScreen screen. --- Firmware/ultralcd.cpp | 132 ++++++++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7d07ccf2..18e864f4 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -158,7 +158,26 @@ static bool lcd_selfcheck_pulleys(int axis); #endif //TMC2130 static bool lcd_selfcheck_check_heater(bool _isbed); -static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay); +enum class testScreen +{ + extruderFan = -1, + printFan, + fansOk, + endStops, + axisX, + axisY, + axisZ, + bed, + hotend, + hotendOk, + fsensor, + fsensorOk, + allCorrect, + failed, + home, +}; + +static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite); static bool lcd_selftest_fan_dialog(int _fan); @@ -6286,7 +6305,7 @@ bool lcd_selftest() delay(2000); KEEPALIVE_STATE(IN_HANDLER); - _progress = lcd_selftest_screen(-1, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(testScreen::extruderFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_0)) _result = lcd_selftest_fan_dialog(0); #else //defined(TACH_0) @@ -6301,7 +6320,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(0, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(testScreen::printFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_1)) _result = lcd_selftest_fan_dialog(1); #else //defined(TACH_1) @@ -6317,7 +6336,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(1, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(testScreen::fansOk, _progress, 3, true, 2000); #ifndef TMC2130 _result = lcd_selfcheck_endstops(); #else @@ -6328,7 +6347,7 @@ bool lcd_selftest() if (_result) { //current_position[Z_AXIS] += 15; //move Z axis higher to avoid false triggering of Z end stop in case that we are very low - just above heatbed - _progress = lcd_selftest_screen(3, _progress, 3, true, 2000); + _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 2000); #ifdef TMC2130 _result = lcd_selfcheck_axis_sg(X_AXIS); #else @@ -6341,7 +6360,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(3, _progress, 3, true, 0); + _progress = lcd_selftest_screen(testScreen::axisX, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(X_AXIS); @@ -6351,7 +6370,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(4, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(testScreen::axisY, _progress, 3, true, 1500); #ifdef TMC2130 _result = lcd_selfcheck_axis_sg(Y_AXIS); #else @@ -6361,7 +6380,7 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(4, _progress, 3, true, 0); + _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 0); #ifndef TMC2130 _result = lcd_selfcheck_pulleys(Y_AXIS); #endif // TMC2130 @@ -6382,7 +6401,7 @@ bool lcd_selftest() current_position[Z_AXIS] = current_position[Z_AXIS] + 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); - _progress = lcd_selftest_screen(5, _progress, 3, true, 1500); + _progress = lcd_selftest_screen(testScreen::axisZ, _progress, 3, true, 1500); _result = lcd_selfcheck_axis(2, Z_MAX_POS); if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) != 1) { enquecommand_P(PSTR("G28 W")); @@ -6396,11 +6415,11 @@ bool lcd_selftest() current_position[Z_AXIS] = current_position[Z_AXIS] + 10; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[3], manual_feedrate[0] / 60, active_extruder); st_synchronize(); - _progress = lcd_selftest_screen(13, 0, 2, true, 0); + _progress = lcd_selftest_screen(testScreen::home, 0, 2, true, 0); bool bres = tmc2130_home_calibrate(X_AXIS); - _progress = lcd_selftest_screen(13, 1, 2, true, 0); + _progress = lcd_selftest_screen(testScreen::home, 1, 2, true, 0); bres &= tmc2130_home_calibrate(Y_AXIS); - _progress = lcd_selftest_screen(13, 2, 2, true, 0); + _progress = lcd_selftest_screen(testScreen::home, 2, 2, true, 0); if (bres) eeprom_update_byte((uint8_t*)EEPROM_TMC2130_HOME_ENABLED, 1); _result = bres; @@ -6409,24 +6428,24 @@ bool lcd_selftest() if (_result) { - _progress = lcd_selftest_screen(6, _progress, 3, true, 2000); //check bed + _progress = lcd_selftest_screen(testScreen::bed, _progress, 3, true, 2000); _result = lcd_selfcheck_check_heater(true); } if (_result) { - _progress = lcd_selftest_screen(7, _progress, 3, true, 1000); //check nozzle + _progress = lcd_selftest_screen(testScreen::hotend, _progress, 3, true, 1000); _result = lcd_selfcheck_check_heater(false); } if (_result) { - _progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //nozzle ok + _progress = lcd_selftest_screen(testScreen::hotendOk, _progress, 3, true, 2000); //nozzle ok } #ifdef FILAMENT_SENSOR if (_result) { - _progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor + _progress = lcd_selftest_screen(testScreen::fsensor, _progress, 3, true, 2000); //check filaments sensor if (mmu_enabled) { _result = selftest_irsensor(); @@ -6437,17 +6456,17 @@ bool lcd_selftest() } if (_result) { - _progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK + _progress = lcd_selftest_screen(testScreen::fsensorOk, _progress, 3, true, 2000); //fil sensor OK } #endif // FILAMENT_SENSOR if (_result) { - _progress = lcd_selftest_screen(11, _progress, 3, true, 5000); //all correct + _progress = lcd_selftest_screen(testScreen::allCorrect, _progress, 3, true, 5000); //all correct } else { - _progress = lcd_selftest_screen(12, _progress, 3, true, 5000); + _progress = lcd_selftest_screen(testScreen::failed, _progress, 3, true, 5000); } lcd_reset_alert_level(); enquecommand_P(PSTR("M84")); @@ -6654,7 +6673,7 @@ static bool lcd_selfcheck_axis(int _axis, int _travel) } else { - _progress = lcd_selftest_screen(3 + _axis, _progress, 3, false, 0); + _progress = lcd_selftest_screen(static_cast(static_cast(testScreen::axisX) + _axis), _progress, 3, false, 0); _lcd_refresh = 0; } @@ -6821,7 +6840,7 @@ static bool lcd_selfcheck_check_heater(bool _isbed) manage_heater(); manage_inactivity(true); - _progress = (_isbed) ? lcd_selftest_screen(6, _progress, 2, false, 400) : lcd_selftest_screen(7, _progress, 2, false, 400); + _progress = (_isbed) ? lcd_selftest_screen(testScreen::bed, _progress, 2, false, 400) : lcd_selftest_screen(testScreen::hotend, _progress, 2, false, 400); /*if (_isbed) { MYSERIAL.print("Bed temp:"); MYSERIAL.println(degBed()); @@ -7031,16 +7050,16 @@ static bool selftest_irsensor() TempBackup tempBackup; setTargetHotend(ABS_PREHEAT_HOTEND_TEMP,active_extruder); mmu_wait_for_heater_blocking(); - progress = lcd_selftest_screen(9, 0, 1, true, 0); + progress = lcd_selftest_screen(testScreen::fsensor, 0, 1, true, 0); mmu_filament_ramming(); } - progress = lcd_selftest_screen(9, progress, 1, true, 0); + progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0); mmu_command(MMU_CMD_U0); manage_response(false, false); for(uint_least8_t i = 0; i < 200; ++i) { - if (0 == (i % 32)) progress = lcd_selftest_screen(9, progress, 1, true, 0); + if (0 == (i % 32)) progress = lcd_selftest_screen(testScreen::fsensor, progress, 1, true, 0); mmu_load_step(false); while (blocks_queued()) @@ -7218,12 +7237,11 @@ static bool lcd_selftest_fan_dialog(int _fan) return _result; } -static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bool _clear, int _delay) +static int lcd_selftest_screen(testScreen screen, int _progress, int _progress_scale, bool _clear, int _delay) { lcd_update_enable(false); - int _step_block = 0; const char *_indicator = (_progress >= _progress_scale) ? "-" : "|"; if (_clear) lcd_clear(); @@ -7231,58 +7249,58 @@ static int lcd_selftest_screen(int _step, int _progress, int _progress_scale, bo lcd_set_cursor(0, 0); - if (_step == -1) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (_step == 0) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (_step == 1) lcd_puts_P(_T(MSG_SELFTEST_FAN)); - if (_step == 2) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 r=0 - if (_step == 3) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0 - if (_step == 4) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0 - if (_step == 5) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0 - if (_step == 6) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); - if (_step == 7 - || _step == 8) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0 - if (_step == 9) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); - if (_step == 10) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); - if (_step == 11) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0 - if (_step == 12) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); - if (_step == 13) lcd_puts_P(_i("Calibrating home"));////c=20 r=1 + if (screen == testScreen::extruderFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == testScreen::printFan) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == testScreen::fansOk) lcd_puts_P(_T(MSG_SELFTEST_FAN)); + if (screen == testScreen::endStops) lcd_puts_P(_i("Checking endstops"));////MSG_SELFTEST_CHECK_ENDSTOPS c=20 r=0 + if (screen == testScreen::axisX) lcd_puts_P(_i("Checking X axis "));////MSG_SELFTEST_CHECK_X c=20 r=0 + if (screen == testScreen::axisY) lcd_puts_P(_i("Checking Y axis "));////MSG_SELFTEST_CHECK_Y c=20 r=0 + if (screen == testScreen::axisZ) lcd_puts_P(_i("Checking Z axis "));////MSG_SELFTEST_CHECK_Z c=20 r=0 + if (screen == testScreen::bed) lcd_puts_P(_T(MSG_SELFTEST_CHECK_BED)); + if (screen == testScreen::hotend + || screen == testScreen::hotendOk) lcd_puts_P(_i("Checking hotend "));////MSG_SELFTEST_CHECK_HOTEND c=20 r=0 + if (screen == testScreen::fsensor) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); + if (screen == testScreen::fsensorOk) lcd_puts_P(_T(MSG_SELFTEST_CHECK_FSENSOR)); + if (screen == testScreen::allCorrect) lcd_puts_P(_i("All correct "));////MSG_SELFTEST_CHECK_ALLCORRECT c=20 r=0 + if (screen == testScreen::failed) lcd_puts_P(_T(MSG_SELFTEST_FAILED)); + if (screen == testScreen::home) lcd_puts_P(_i("Calibrating home"));////c=20 r=1 lcd_set_cursor(0, 1); lcd_puts_P(separator); - if ((_step >= -1) && (_step <= 1)) + if ((screen >= testScreen::extruderFan) && (screen <= testScreen::fansOk)) { //SERIAL_ECHOLNPGM("Fan test"); lcd_puts_at_P(0, 2, _i("Extruder fan:"));////MSG_SELFTEST_EXTRUDER_FAN_SPEED c=18 r=0 lcd_set_cursor(18, 2); - (_step < 0) ? lcd_print(_indicator) : lcd_print("OK"); + (screen < testScreen::printFan) ? lcd_print(_indicator) : lcd_print("OK"); lcd_puts_at_P(0, 3, _i("Print fan:"));////MSG_SELFTEST_PRINT_FAN_SPEED c=18 r=0 lcd_set_cursor(18, 3); - (_step < 1) ? lcd_print(_indicator) : lcd_print("OK"); + (screen < testScreen::fansOk) ? lcd_print(_indicator) : lcd_print("OK"); } - else if (_step >= 9 && _step <= 10) + else if (screen >= testScreen::fsensor && screen <= testScreen::fsensorOk) { lcd_puts_at_P(0, 2, _i("Filament sensor:"));////MSG_SELFTEST_FILAMENT_SENSOR c=18 r=0 lcd_set_cursor(18, 2); - (_step == 9) ? lcd_print(_indicator) : lcd_print("OK"); + (screen == testScreen::fsensor) ? lcd_print(_indicator) : lcd_print("OK"); } - else if (_step < 9) + else if (screen < testScreen::fsensor) { //SERIAL_ECHOLNPGM("Other tests"); - _step_block = 3; - lcd_selftest_screen_step(2, 2, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "X", _indicator); + testScreen _step_block = testScreen::axisX; + lcd_selftest_screen_step(2, 2, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "X", _indicator); - _step_block = 4; - lcd_selftest_screen_step(2, 8, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Y", _indicator); + _step_block = testScreen::axisY; + lcd_selftest_screen_step(2, 8, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Y", _indicator); - _step_block = 5; - lcd_selftest_screen_step(2, 14, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Z", _indicator); + _step_block = testScreen::axisZ; + lcd_selftest_screen_step(2, 14, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Z", _indicator); - _step_block = 6; - lcd_selftest_screen_step(3, 0, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Bed", _indicator); + _step_block = testScreen::bed; + lcd_selftest_screen_step(3, 0, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Bed", _indicator); - _step_block = 7; - lcd_selftest_screen_step(3, 9, ((_step == _step_block) ? 1 : (_step < _step_block) ? 0 : 2), "Hotend", _indicator); + _step_block = testScreen::hotend; + lcd_selftest_screen_step(3, 9, ((screen == _step_block) ? 1 : (screen < _step_block) ? 0 : 2), "Hotend", _indicator); } if (_delay > 0) delay_keep_alive(_delay); From aaa2670ef8d8c2d2d86111c8518f44bdb12b99c9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 25 Jan 2019 20:14:29 +0100 Subject: [PATCH 3/4] Remove redundant enum numbering. --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 18e864f4..530f07dd 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -160,7 +160,7 @@ static bool lcd_selfcheck_pulleys(int axis); static bool lcd_selfcheck_check_heater(bool _isbed); enum class testScreen { - extruderFan = -1, + extruderFan, printFan, fansOk, endStops, From 41f103c28f0ba5f3a58af7205af6be7e331c8f26 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 28 Jan 2019 10:53:51 +0100 Subject: [PATCH 4/4] Revert "Mk3 bed fast pwm" --- Firmware/temperature.cpp | 37 +++----------- Firmware/temperature.h | 4 +- Firmware/timer02.c | 103 --------------------------------------- 3 files changed, 9 insertions(+), 135 deletions(-) delete mode 100644 Firmware/timer02.c diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index ddffcfac..eb29b810 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -45,12 +45,6 @@ #include "Configuration_prusa.h" -extern "C" { -extern void timer02_init(void); -extern void timer02_set_pwm0(uint8_t pwm0); -} - - //=========================================================================== //=============================public variables============================ //=========================================================================== @@ -263,7 +257,6 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); if (extruder<0) { soft_pwm_bed = (MAX_BED_POWER)/2; - timer02_set_pwm0(soft_pwm_bed << 1); bias = d = (MAX_BED_POWER)/2; } else @@ -300,10 +293,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); if(millis() - t2 > 5000) { heating=false; if (extruder<0) - { soft_pwm_bed = (bias - d) >> 1; - timer02_set_pwm0(soft_pwm_bed << 1); - } else soft_pwm[extruder] = (bias - d) >> 1; t1=millis(); @@ -357,10 +347,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); } } if (extruder<0) - { soft_pwm_bed = (bias + d) >> 1; - timer02_set_pwm0(soft_pwm_bed << 1); - } else soft_pwm[extruder] = (bias + d) >> 1; pid_cycle++; @@ -794,11 +781,9 @@ void manage_heater() if(current_temperature_bed < BED_MAXTEMP) { soft_pwm_bed = (int)pid_output >> 1; - timer02_set_pwm0(soft_pwm_bed << 1); } else { soft_pwm_bed = 0; - timer02_set_pwm0(soft_pwm_bed << 1); } #elif !defined(BED_LIMIT_SWITCHING) @@ -808,18 +793,15 @@ void manage_heater() if(current_temperature_bed >= target_temperature_bed) { soft_pwm_bed = 0; - timer02_set_pwm0(soft_pwm_bed << 1); } else { soft_pwm_bed = MAX_BED_POWER>>1; - timer02_set_pwm0(soft_pwm_bed << 1); } } else { soft_pwm_bed = 0; - timer02_set_pwm0(soft_pwm_bed << 1); WRITE(HEATER_BED_PIN,LOW); } #else //#ifdef BED_LIMIT_SWITCHING @@ -829,18 +811,15 @@ void manage_heater() if(current_temperature_bed > target_temperature_bed + BED_HYSTERESIS) { soft_pwm_bed = 0; - timer02_set_pwm0(soft_pwm_bed << 1); } else if(current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS) { soft_pwm_bed = MAX_BED_POWER>>1; - timer02_set_pwm0(soft_pwm_bed << 1); } } else { soft_pwm_bed = 0; - timer02_set_pwm0(soft_pwm_bed << 1); WRITE(HEATER_BED_PIN,LOW); } #endif @@ -1017,6 +996,7 @@ static void updateTemperaturesFromRawValues() CRITICAL_SECTION_END; } + void tp_init() { #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) @@ -1083,12 +1063,10 @@ void tp_init() adc_init(); - timer02_init(); - // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt - OCR2B = 128; - TIMSK2 |= (1< -1 target_temperature_bed=0; soft_pwm_bed=0; - timer02_set_pwm0(soft_pwm_bed << 1); #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 WRITE(HEATER_BED_PIN,LOW); #endif @@ -1561,8 +1538,8 @@ void adc_ready(void) //callback from adc when sampling finished } // extern "C" -// Timer2 (originaly timer0) is shared with millies -ISR(TIMER2_COMPB_vect) +// Timer 0 is shared with millies +ISR(TIMER0_COMPB_vect) // @ 1kHz ~ 1ms { static bool _lock = false; if (_lock) return; @@ -1629,7 +1606,7 @@ ISR(TIMER2_COMPB_vect) #endif #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 soft_pwm_b = soft_pwm_bed; - //if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); + if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); #endif #ifdef FAN_SOFT_PWM soft_pwm_fan = fanSpeedSoftPwm / 2; @@ -1763,7 +1740,7 @@ ISR(TIMER2_COMPB_vect) state_timer_heater_b = MIN_STATE_TIME; } state_heater_b = 1; - //WRITE(HEATER_BED_PIN, 1); + WRITE(HEATER_BED_PIN, 1); } } else { // turn OFF heather only if the minimum time is up diff --git a/Firmware/temperature.h b/Firmware/temperature.h index e94629d1..9697f440 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -27,8 +27,8 @@ #include "stepper.h" #endif -#define ENABLE_TEMPERATURE_INTERRUPT() TIMSK2 |= (1< -#include -#include - - -uint8_t timer02_pwm0 = 0; - -void timer02_set_pwm0(uint8_t pwm0) -{ - if (timer02_pwm0 == pwm0) return; - if (pwm0) - { - TCCR0A |= (2 << COM0B0); - OCR0B = pwm0 - 1; - } - else - { - TCCR0A &= ~(2 << COM0B0); - OCR0B = 0; - } -} - -void timer02_init(void) -{ - //save sreg - uint8_t _sreg = SREG; - //disable interrupts for sure - cli(); - //mask timer0 interrupts - disable all - TIMSK0 &= ~(1<> 3) -#define FRACT_MAX (1000 >> 3) - -extern volatile unsigned long timer0_overflow_count; -extern volatile unsigned long timer0_millis; -unsigned char timer0_fract = 0; - -ISR(TIMER2_OVF_vect) -{ - // copy these to local variables so they can be stored in registers - // (volatile variables must be read from memory on every access) - unsigned long m = timer0_millis; - unsigned char f = timer0_fract; - - m += MILLIS_INC; - f += FRACT_INC; - if (f >= FRACT_MAX) - { - f -= FRACT_MAX; - m += 1; - } - - timer0_fract = f; - timer0_millis = m; - timer0_overflow_count++; -} -