Merge pull request #122 from XPila/MK3s_upg

Mk3s upg
This commit is contained in:
PavelSindler 2018-12-10 15:16:18 +01:00 committed by GitHub
commit b18ffdffc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 13 deletions

View file

@ -477,7 +477,8 @@ your extruder heater takes 2 minutes to hit the target on heating.
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not ass annoying as with the hardware PWM. On the other hand, if this frequency
// is too low, you should also increment SOFT_PWM_SCALE.
//#define FAN_SOFT_PWM
#define FAN_SOFT_PWM
#define FAN_SOFT_PWM_BITS 4 //PWM bit resolution = 4bits, freq = 62.5Hz
// Incrementing this by 1 will double the software PWM frequency,
// affecting heaters, and the fan if FAN_SOFT_PWM is enabled.

View file

@ -974,6 +974,10 @@ void setup()
ultralcd_init();
#if (LCD_BL_PIN != -1)
analogWrite(LCD_BL_PIN, 255); //set full brightnes
#endif //(LCD_BL_PIN != -1)
spi_init();
lcd_splash();
@ -1809,6 +1813,15 @@ void loop()
isPrintPaused ? manage_inactivity(true) : manage_inactivity(false);
checkHitEndstops();
lcd_update(0);
#ifdef NEW_FILAMENT_SENSOR
if (mcode_in_progress != 600 && !mmu_enabled) //M600 not in progress
{
if (IS_SD_PRINTING)
{
fsensor_update();
}
}
#endif //NEW_FILAMENT_SENSOR
#ifdef TMC2130
tmc2130_check_overtemp();
if (tmc2130_sg_crash)

View file

@ -477,6 +477,18 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
//! If there is still no plausible signal from filament sensor plans M600 (Filament change).
void fsensor_update(void)
{
#ifdef NEW_FILAMENT_SENSOR
if (digitalRead(A8) == 1)
{
fsensor_stop_and_save_print();
printf_P(PSTR("fsensor_update - M600\n"));
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
enquecommand_front_P(PSTR("FSENSOR_RECOVER"));
enquecommand_front_P((PSTR("M600")));
fsensor_watch_runout = false;
}
#else //NEW_FILAMENT_SENSOR
if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
{
bool autoload_enabled_tmp = fsensor_autoload_enabled;
@ -527,6 +539,7 @@ void fsensor_update(void)
fsensor_autoload_enabled = autoload_enabled_tmp;
fsensor_oq_meassure_enabled = oq_meassure_enabled_tmp;
}
#endif //NEW_FILAMENT_SENSOR
}
void fsensor_setup_interrupt(void)

View file

@ -99,10 +99,7 @@
//#define KILL_PIN 32
//#define LCD_PWM_PIN -1//32 // lcd backlight brightnes pwm control pin
//#define LCD_PWM_MAX 0x0f // lcd pwm maximum value (0x07=64Hz, 0x0f=32Hz, 0x1f=16Hz)
#define LCD_BL_PIN 5 //backlight control pin
#define BEEPER 84 // Beeper on AUX-4
#define LCD_PINS_RS 82
#define LCD_PINS_ENABLE 61 // !!! changed from 18 (EINY03)

View file

@ -1024,7 +1024,7 @@ void tp_init()
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif
#ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2;
soft_pwm_fan = fanSpeedSoftPwm / (1 << (8 - FAN_SOFT_PWM_BITS));
#endif
#endif
@ -1599,12 +1599,15 @@ ISR(TIMER0_COMPB_vect)
#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);
#endif
#ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2;
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
#endif
}
#ifdef FAN_SOFT_PWM
if ((pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1)) == 0)
{
soft_pwm_fan = fanSpeedSoftPwm / (1 << (8 - FAN_SOFT_PWM_BITS));
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
}
#endif
if(soft_pwm_0 < pwm_count)
{
WRITE(HEATER_0_PIN,0);
@ -1623,7 +1626,7 @@ ISR(TIMER0_COMPB_vect)
if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0);
#endif
#ifdef FAN_SOFT_PWM
if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
if (soft_pwm_fan < (pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1))) WRITE(FAN_PIN,0);
#endif
pwm_count += (1 << SOFT_PWM_SCALE);
@ -1810,8 +1813,8 @@ ISR(TIMER0_COMPB_vect)
#endif
#ifdef FAN_SOFT_PWM
if (pwm_count == 0){
soft_pwm_fan = fanSpeedSoftPwm / 2;
if ((pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1)) == 0)
soft_pwm_fan = fanSpeedSoftPwm / (1 << (8 - FAN_SOFT_PWM_BITS));
if (soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
}
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);

View file

@ -134,6 +134,7 @@
// Filament sensor
#define PAT9125
#define FILAMENT_SENSOR
//#define NEW_FILAMENT_SENSOR
// Backlash -
//#define BACKLASH_X