Skip to content

Commit

Permalink
Add IsOk LED signalization to Wait states.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkbel committed Feb 13, 2019
1 parent 07a7578 commit e908a2b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
32 changes: 31 additions & 1 deletion MM-control-01/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum class S
Printing,
SignalFilament,
Wait,
WaitOk,
};
}

Expand All @@ -63,6 +64,9 @@ enum class S
//! Any --> Wait : W0
//! Setup --> Idle
//! Wait --> Idle : RightButton
//! WaitOk --> Idle : RightButton
//! Wait --> WaitOk : MiddleButton && mmctl_IsOk
//! WaitOk --> Wait : MiddleButton && !mmctl_IsOk
//! }
//! @enduml
static S state;
Expand Down Expand Up @@ -112,6 +116,17 @@ void signal_load_failure()
delay(800);
}

void signal_ok_after_load_failure()
{
shr16_set_led(0x000);
delay(800);
shr16_set_led(1 << 2 * (4 - active_extruder));
delay(100);
shr16_set_led(2 << 2 * (4 - active_extruder));
delay(100);
delay(800);
}

//! @brief Signal filament presence
//!
//! @retval true still present
Expand Down Expand Up @@ -386,7 +401,22 @@ void loop()
switch(buttonClicked())
{
case Btn::middle:
mmctl_checkOk();
if (mmctl_IsOk()) state = S::WaitOk;
break;
case Btn::right:
state = S::Idle;
fprintf_P(uart_com, PSTR("ok\n"));
break;
default:
break;
}
break;
case S::WaitOk:
signal_ok_after_load_failure();
switch(buttonClicked())
{
case Btn::middle:
if (!mmctl_IsOk()) state = S::Wait;
break;
case Btn::right:
state = S::Idle;
Expand Down
1 change: 1 addition & 0 deletions MM-control-01/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void unrecoverable_error();
void drive_error();
void check_filament_not_present();
void signal_load_failure();
void signal_ok_after_load_failure();

extern uint8_t tmc2130_mode;
extern FILE* uart_com;
Expand Down
18 changes: 9 additions & 9 deletions MM-control-01/mmctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,19 @@ static bool checkOk()
return _ret;
}

void mmctl_checkOk()
//! @brief Can FINDA detect filament tip
//!
//! Move filament back and forth to align it by FINDA.
//! @retval true success
//! @retval false failure
bool mmctl_IsOk()
{
tmc2130_init_axis(AX_PUL, tmc2130_mode);
motion_engage_idler();
checkOk();
const bool retval = checkOk();
motion_disengage_idler();
tmc2130_disable_axis(AX_PUL, tmc2130_mode);
return retval;
}

void load_filament_withSensor()
Expand Down Expand Up @@ -308,13 +314,7 @@ void load_filament_withSensor()
}
else
{
shr16_set_led(0x000);
delay(800);
shr16_set_led(1 << 2 * (4 - active_extruder));
delay(100);
shr16_set_led(2 << 2 * (4 - active_extruder));
delay(100);
delay(800);
signal_ok_after_load_failure();
}

switch (buttonClicked())
Expand Down
2 changes: 1 addition & 1 deletion MM-control-01/mmctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ void load_filament_inPrinter();
void unload_filament_withSensor();
void eject_filament(uint8_t filament);
void recover_after_eject();
void mmctl_checkOk();
bool mmctl_IsOk();

#endif //_MMCTL_H

0 comments on commit e908a2b

Please sign in to comment.