Merge remote-tracking branch 'upstream/MK3' into 7x7_polishing

This commit is contained in:
PavelSindler 2019-03-28 08:08:54 +01:00
commit e7900aeaa1
4 changed files with 35 additions and 39 deletions

View File

@ -6998,15 +6998,18 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
if (mmu_enabled) if (mmu_enabled)
{ {
tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT)); tmp_extruder = choose_menu_P(_T(MSG_CHOOSE_FILAMENT), _T(MSG_FILAMENT));
if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) { if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) //dont execute the same T-code twice in a row
printf_P(PSTR("Duplicit T-code ignored.\n")); {
return; //dont execute the same T-code twice in a row printf_P(PSTR("Duplicate T-code ignored.\n"));
} }
else
{
st_synchronize(); st_synchronize();
mmu_command(MmuCmd::T0 + tmp_extruder); mmu_command(MmuCmd::T0 + tmp_extruder);
manage_response(true, true, MMU_TCODE_MOVE); manage_response(true, true, MMU_TCODE_MOVE);
} }
} }
}
else if (*(strchr_pointer + index) == 'c') { //load to from bondtech gears to nozzle (nozzle should be preheated) else if (*(strchr_pointer + index) == 'c') { //load to from bondtech gears to nozzle (nozzle should be preheated)
if (mmu_enabled) if (mmu_enabled)
{ {
@ -7040,10 +7043,12 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
if (mmu_enabled) if (mmu_enabled)
{ {
if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) { if ((tmp_extruder == mmu_extruder) && mmu_fil_loaded) //dont execute the same T-code twice in a row
printf_P(PSTR("Duplicit T-code ignored.\n")); {
return; //dont execute the same T-code twice in a row printf_P(PSTR("Duplicate T-code ignored.\n"));
} }
else
{
mmu_command(MmuCmd::T0 + tmp_extruder); mmu_command(MmuCmd::T0 + tmp_extruder);
manage_response(true, true, MMU_TCODE_MOVE); manage_response(true, true, MMU_TCODE_MOVE);
@ -7055,6 +7060,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
mmu_load_to_nozzle(); mmu_load_to_nozzle();
} }
} }
}
else else
{ {
#ifdef SNMM #ifdef SNMM

View File

@ -58,9 +58,9 @@ static S mmu_state = S::Disabled;
MmuCmd mmu_cmd = MmuCmd::None; MmuCmd mmu_cmd = MmuCmd::None;
//idler ir sensor //idler ir sensor
uint8_t mmu_idl_sens = 0; static uint8_t mmu_idl_sens = 0;
bool ir_sensor_detected = false; bool ir_sensor_detected = false;
bool mmu_loading_flag = false; //when set to true, we assume that mmu2 unload was finished and loading phase is now performed; printer can send 'A' to mmu2 to abort loading process static bool mmu_loading_flag = false; //when set to true, we assume that mmu2 unload was finished and loading phase is now performed; printer can send 'A' to mmu2 to abort loading process
uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN; uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN;

View File

@ -15,7 +15,6 @@ extern uint8_t tmp_extruder;
extern int8_t mmu_finda; extern int8_t mmu_finda;
extern bool ir_sensor_detected; extern bool ir_sensor_detected;
extern bool mmu_loading_flag;
extern int16_t mmu_version; extern int16_t mmu_version;
extern int16_t mmu_buildnr; extern int16_t mmu_buildnr;

View File

@ -11,19 +11,11 @@
uint8_t timer02_pwm0 = 0; uint8_t timer02_pwm0 = 0;
void timer02_set_pwm0(uint8_t pwm0) void timer02_set_pwm0(uint8_t pwm0)
{ {
if (timer02_pwm0 == pwm0) return; TCCR0A |= (2 << COM0B0); //switch OC0B to OCR mode
if (pwm0) OCR0B = (uint16_t)OCR0A * pwm0 / 255;
{
TCCR0A |= (2 << COM0B0);
OCR0B = pwm0 - 1;
}
else
{
TCCR0A &= ~(2 << COM0B0);
OCR0B = 0;
}
timer02_pwm0 = pwm0; timer02_pwm0 = pwm0;
} }
@ -39,13 +31,12 @@ void timer02_init(void)
TIMSK0 &= ~(1<<OCIE0B); TIMSK0 &= ~(1<<OCIE0B);
//setup timer0 //setup timer0
TCCR0A = 0x00; //COM_A-B=00, WGM_0-1=00 TCCR0A = 0x00; //COM_A-B=00, WGM_0-1=00
TCCR0B = (1 << CS00); //WGM_2=0, CS_0-2=011 OCR0A = 200; //max PWM value (freq = 40kHz)
//switch timer0 to fast pwm mode OCR0B = 0; //current PWM value
TCCR0A |= (3 << WGM00); //WGM_0-1=11 //switch timer0 to mode 5 (Phase Correct PWM)
//set OCR0B register to zero TCCR0A |= (1 << WGM00); //WGM_0-1=01
OCR0B = 0; TCCR0B = (1 << CS00) | (1 << WGM02); //WGM_2=1, CS_0-2=001 (no prescaling)
//disable OCR0B output (will be enabled in timer02_set_pwm0) TCCR0A |= (2 << COM0B0); //switch OC0B to OCR mode
TCCR0A &= ~(2 << COM0B0);
//setup timer2 //setup timer2
TCCR2A = 0x00; //COM_A-B=00, WGM_0-1=00 TCCR2A = 0x00; //COM_A-B=00, WGM_0-1=00
TCCR2B = (4 << CS20); //WGM_2=0, CS_0-2=011 TCCR2B = (4 << CS20); //WGM_2=0, CS_0-2=011