Add Tool change operation
parent
29aa665e91
commit
e074c40969
|
|
@ -1,11 +1,11 @@
|
|||
#include "eject_filament.h"
|
||||
#include "../modules/buttons.h"
|
||||
#include "../modules/finda.h"
|
||||
#include "../modules/idler.h"
|
||||
#include "../modules/leds.h"
|
||||
#include "../modules/motion.h"
|
||||
#include "../modules/selector.h"
|
||||
#include "../modules/idler.h"
|
||||
#include "../modules/permanent_storage.h"
|
||||
#include "../modules/selector.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ enum class ProgressCode : uint_fast8_t {
|
|||
ERR1WaitingForUser,
|
||||
|
||||
UnloadingFilament,
|
||||
LoadingFilament,
|
||||
SelectingFilamentSlot,
|
||||
FeedingToFINDA,
|
||||
PreparingBlade,
|
||||
|
|
|
|||
|
|
@ -1,23 +1,68 @@
|
|||
#include "tool_change.h"
|
||||
#include "../modules/buttons.h"
|
||||
#include "../modules/finda.h"
|
||||
#include "../modules/idler.h"
|
||||
#include "../modules/leds.h"
|
||||
#include "../modules/motion.h"
|
||||
#include "../modules/permanent_storage.h"
|
||||
#include "../modules/selector.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
ToolChange toolChange;
|
||||
|
||||
namespace mm = modules::motion;
|
||||
namespace mi = modules::idler;
|
||||
namespace ms = modules::selector;
|
||||
|
||||
void ToolChange::Reset(uint8_t param) {
|
||||
namespace mm = modules::motion;
|
||||
state = ProgressCode::EngagingIdler;
|
||||
error = ErrorCode::OK;
|
||||
// if( param == active_extruder ) // @@TODO
|
||||
// return true;
|
||||
|
||||
plannedSlot = param;
|
||||
|
||||
bool isFilamentLoaded = true; //@@TODO
|
||||
|
||||
if (isFilamentLoaded) {
|
||||
state = ProgressCode::UnloadingFilament;
|
||||
unl.Reset(0); //@@TODO act on active extruder only
|
||||
} else {
|
||||
state = ProgressCode::LoadingFilament;
|
||||
load.Reset(plannedSlot);
|
||||
}
|
||||
}
|
||||
|
||||
bool ToolChange::Step() {
|
||||
namespace mm = modules::motion;
|
||||
switch (state) {
|
||||
case ProgressCode::UnloadingFilament:
|
||||
if (unl.Step()) {
|
||||
// unloading sequence finished
|
||||
switch (unl.Error()) {
|
||||
case ErrorCode::OK: // finished successfully
|
||||
state = ProgressCode::LoadingFilament;
|
||||
load.Reset(plannedSlot);
|
||||
break;
|
||||
case ErrorCode::UNLOAD_ERROR2: // @@TODO what shall we do in case of this error?
|
||||
case ErrorCode::UNLOAD_FINDA_DIDNT_TRIGGER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ProgressCode::LoadingFilament:
|
||||
if (load.Step()) {
|
||||
// unloading sequence finished
|
||||
switch (load.Error()) {
|
||||
case ErrorCode::OK: // finished successfully
|
||||
state = ProgressCode::OK;
|
||||
break;
|
||||
// case ErrorCode::LOAD_ERROR2: // @@TODO load errors?
|
||||
// case ErrorCode::LOAD_FINDA_DIDNT_TRIGGER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ProgressCode::OK:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "command_base.h"
|
||||
#include "unload_to_finda.h"
|
||||
#include "unload_filament.h"
|
||||
#include "load_filament.h"
|
||||
|
||||
namespace logic {
|
||||
|
||||
|
|
@ -19,6 +20,9 @@ public:
|
|||
bool Step() override;
|
||||
|
||||
private:
|
||||
UnloadFilament unl; ///< a high-level command/operation may be used as a building block of other operations as well
|
||||
LoadFilament load;
|
||||
uint8_t plannedSlot;
|
||||
};
|
||||
|
||||
extern ToolChange toolChange;
|
||||
|
|
|
|||
Loading…
Reference in New Issue