Add Tool change operation
parent
ea65b75120
commit
7cab9dc915
|
|
@ -1,11 +1,11 @@
|
||||||
#include "eject_filament.h"
|
#include "eject_filament.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
#include "../modules/selector.h"
|
|
||||||
#include "../modules/idler.h"
|
|
||||||
#include "../modules/permanent_storage.h"
|
#include "../modules/permanent_storage.h"
|
||||||
|
#include "../modules/selector.h"
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ enum class ProgressCode : uint_fast8_t {
|
||||||
ERR1WaitingForUser,
|
ERR1WaitingForUser,
|
||||||
|
|
||||||
UnloadingFilament,
|
UnloadingFilament,
|
||||||
|
LoadingFilament,
|
||||||
SelectingFilamentSlot,
|
SelectingFilamentSlot,
|
||||||
FeedingToFINDA,
|
FeedingToFINDA,
|
||||||
PreparingBlade,
|
PreparingBlade,
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,68 @@
|
||||||
#include "tool_change.h"
|
#include "tool_change.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
#include "../modules/permanent_storage.h"
|
#include "../modules/permanent_storage.h"
|
||||||
|
#include "../modules/selector.h"
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
ToolChange toolChange;
|
ToolChange toolChange;
|
||||||
|
|
||||||
|
namespace mm = modules::motion;
|
||||||
|
namespace mi = modules::idler;
|
||||||
|
namespace ms = modules::selector;
|
||||||
|
|
||||||
void ToolChange::Reset(uint8_t param) {
|
void ToolChange::Reset(uint8_t param) {
|
||||||
namespace mm = modules::motion;
|
// if( param == active_extruder ) // @@TODO
|
||||||
state = ProgressCode::EngagingIdler;
|
// return true;
|
||||||
error = ErrorCode::OK;
|
|
||||||
|
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() {
|
bool ToolChange::Step() {
|
||||||
namespace mm = modules::motion;
|
|
||||||
switch (state) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "command_base.h"
|
#include "command_base.h"
|
||||||
#include "unload_to_finda.h"
|
#include "unload_filament.h"
|
||||||
|
#include "load_filament.h"
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
||||||
|
|
@ -19,6 +20,9 @@ public:
|
||||||
bool Step() override;
|
bool Step() override;
|
||||||
|
|
||||||
private:
|
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;
|
extern ToolChange toolChange;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue