Convert MmuCmd to enum class.
This commit is contained in:
parent
8e23e7f322
commit
daaec0ef04
|
|
@ -6933,7 +6933,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
|
|||
return; //dont execute the same T-code twice in a row
|
||||
}
|
||||
st_synchronize();
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::T0 + tmp_extruder));
|
||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||
manage_response(true, true, MMU_TCODE_MOVE);
|
||||
}
|
||||
}
|
||||
|
|
@ -6974,7 +6974,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
|
|||
printf_P(PSTR("Duplicit T-code ignored.\n"));
|
||||
return; //dont execute the same T-code twice in a row
|
||||
}
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::T0 + tmp_extruder));
|
||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||
|
||||
manage_response(true, true, MMU_TCODE_MOVE);
|
||||
mmu_continue_loading();
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ void mmu_loop(void)
|
|||
}
|
||||
return;
|
||||
case S::Idle:
|
||||
if (mmu_cmd) //command request ?
|
||||
if (mmu_cmd != MmuCmd::None) //command request ?
|
||||
{
|
||||
if ((mmu_cmd >= MmuCmd::T0) && (mmu_cmd <= MmuCmd::T4))
|
||||
{
|
||||
|
|
@ -341,7 +341,7 @@ void mmu_loop(void)
|
|||
}
|
||||
}
|
||||
mmu_state = S::Idle;
|
||||
if (mmu_cmd == 0)
|
||||
if (mmu_cmd == MmuCmd::None)
|
||||
mmu_ready = true;
|
||||
}
|
||||
else if ((mmu_last_request + MMU_P0_TIMEOUT) < _millis())
|
||||
|
|
@ -372,7 +372,7 @@ void mmu_loop(void)
|
|||
}
|
||||
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis())
|
||||
{ //resend request after timeout (5 min)
|
||||
if (mmu_last_cmd)
|
||||
if (mmu_last_cmd != MmuCmd::None)
|
||||
{
|
||||
if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) {
|
||||
DEBUG_PRINTF_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1);
|
||||
|
|
@ -487,14 +487,14 @@ bool mmu_get_response(uint8_t move)
|
|||
|
||||
printf_P(PSTR("mmu_get_response - begin move:%d\n"), move);
|
||||
KEEPALIVE_STATE(IN_PROCESS);
|
||||
while (mmu_cmd != 0)
|
||||
while (mmu_cmd != MmuCmd::None)
|
||||
{
|
||||
delay_keep_alive(100);
|
||||
}
|
||||
|
||||
while (!mmu_ready)
|
||||
{
|
||||
if ((mmu_state != S::WaitCmd) && (mmu_last_cmd == 0))
|
||||
if ((mmu_state != S::WaitCmd) && (mmu_last_cmd == MmuCmd::None))
|
||||
break;
|
||||
|
||||
switch (move) {
|
||||
|
|
@ -786,7 +786,7 @@ void mmu_M600_load_filament(bool automatic)
|
|||
|
||||
// printf_P(PSTR("T code: %d \n"), tmp_extruder);
|
||||
// mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::T0 + tmp_extruder));
|
||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||
|
||||
manage_response(false, true, MMU_LOAD_MOVE);
|
||||
mmu_continue_loading();
|
||||
|
|
@ -877,7 +877,7 @@ void display_loading()
|
|||
void extr_adj(int extruder) //loading filament for SNMM
|
||||
{
|
||||
#ifndef SNMM
|
||||
MmuCmd cmd = static_cast<MmuCmd>(MmuCmd::L0 + extruder);
|
||||
MmuCmd cmd = MmuCmd::L0 + extruder;
|
||||
if (cmd > MmuCmd::L4)
|
||||
{
|
||||
printf_P(PSTR("Filament out of range %d \n"),extruder);
|
||||
|
|
@ -1295,7 +1295,7 @@ void lcd_mmu_load_to_nozzle(uint8_t filament_nr)
|
|||
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
|
||||
lcd_print(" ");
|
||||
lcd_print(tmp_extruder + 1);
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::T0 + tmp_extruder));
|
||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||
manage_response(true, true, MMU_TCODE_MOVE);
|
||||
mmu_continue_loading();
|
||||
mmu_extruder = tmp_extruder; //filament change is finished
|
||||
|
|
@ -1332,7 +1332,7 @@ void mmu_eject_filament(uint8_t filament, bool recover)
|
|||
current_position[E_AXIS] -= 80;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
|
||||
st_synchronize();
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::E0 + filament));
|
||||
mmu_command(MmuCmd::E0 + filament);
|
||||
manage_response(false, false, MMU_UNLOAD_MOVE);
|
||||
if (recover)
|
||||
{
|
||||
|
|
@ -1377,7 +1377,7 @@ void mmu_continue_loading()
|
|||
if(mmu_load_fail < 255) eeprom_update_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL, mmu_load_fail + 1);
|
||||
if(mmu_load_fail_tot < 65535) eeprom_update_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT, mmu_load_fail_tot + 1);
|
||||
|
||||
mmu_command(static_cast<MmuCmd>(MmuCmd::T0 + tmp_extruder));
|
||||
mmu_command(MmuCmd::T0 + tmp_extruder);
|
||||
manage_response(true, true, MMU_TCODE_MOVE);
|
||||
load_more();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ extern uint16_t mmu_power_failures;
|
|||
#define MMU_LOAD_FEEDRATE 19.02f //mm/s
|
||||
#define MMU_LOAD_TIME_MS 2000 //should be fine tuned to load time for shortest allowed PTFE tubing and maximum loading speed
|
||||
|
||||
enum MmuCmd : uint_least8_t
|
||||
enum class MmuCmd : uint_least8_t
|
||||
{
|
||||
None,
|
||||
T0,
|
||||
|
|
@ -56,6 +56,16 @@ enum MmuCmd : uint_least8_t
|
|||
S3,
|
||||
};
|
||||
|
||||
inline MmuCmd operator+ (MmuCmd cmd, uint8_t filament)
|
||||
{
|
||||
return static_cast<MmuCmd>(static_cast<uint8_t>(cmd) + filament );
|
||||
}
|
||||
|
||||
inline uint8_t operator- (MmuCmd cmda, MmuCmd cmdb)
|
||||
{
|
||||
return (static_cast<uint8_t>(cmda) - static_cast<uint8_t>(cmdb));
|
||||
}
|
||||
|
||||
extern int mmu_puts_P(const char* str);
|
||||
|
||||
extern int mmu_printf_P(const char* format, ...);
|
||||
|
|
|
|||
Loading…
Reference in New Issue