Add global state hive
+ solve many TODO's in the code (active slot/extruder and filament loaded flag)pull/25/head
parent
4d1a26aeea
commit
d6c9e58e66
|
|
@ -166,14 +166,12 @@ if(CMAKE_CROSSCOMPILING)
|
||||||
|
|
||||||
# produce ASM listing
|
# produce ASM listing
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET firmware POST_BUILD
|
TARGET firmware POST_BUILD COMMAND ${CMAKE_OBJDUMP} -CSd firmware > firmware.asm
|
||||||
COMMAND ${CMAKE_OBJDUMP} -CSd firmware > firmware.asm
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# inform about the firmware's size in terminal
|
# inform about the firmware's size in terminal
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET firmware POST_BUILD
|
TARGET firmware POST_BUILD COMMAND ${CMAKE_SIZE_UTIL} -C --mcu=atmega32u4 firmware
|
||||||
COMMAND ${CMAKE_SIZE_UTIL} -C --mcu=atmega32u4 firmware
|
|
||||||
)
|
)
|
||||||
report_size(firmware)
|
report_size(firmware)
|
||||||
|
|
||||||
|
|
@ -199,6 +197,7 @@ target_sources(
|
||||||
src/modules/debouncer.cpp
|
src/modules/debouncer.cpp
|
||||||
src/modules/finda.cpp
|
src/modules/finda.cpp
|
||||||
src/modules/fsensor.cpp
|
src/modules/fsensor.cpp
|
||||||
|
src/modules/globals.cpp
|
||||||
src/modules/idler.cpp
|
src/modules/idler.cpp
|
||||||
src/modules/leds.cpp
|
src/modules/leds.cpp
|
||||||
src/modules/motion.cpp
|
src/modules/motion.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "cut_filament.h"
|
#include "cut_filament.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -14,15 +15,14 @@ CutFilament cutFilament;
|
||||||
namespace mm = modules::motion;
|
namespace mm = modules::motion;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
namespace ms = modules::selector;
|
namespace ms = modules::selector;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void CutFilament::Reset(uint8_t param) {
|
void CutFilament::Reset(uint8_t param) {
|
||||||
error = ErrorCode::OK;
|
error = ErrorCode::OK;
|
||||||
|
|
||||||
bool isFilamentLoaded = true; //@@TODO
|
if (mg::globals.FilamentLoaded()) {
|
||||||
|
|
||||||
if (isFilamentLoaded) {
|
|
||||||
state = ProgressCode::UnloadingFilament;
|
state = ProgressCode::UnloadingFilament;
|
||||||
unl.Reset(param); //@@TODO probably only act on active_extruder
|
unl.Reset(mg::globals.ActiveSlot());
|
||||||
} else {
|
} else {
|
||||||
SelectFilamentSlot();
|
SelectFilamentSlot();
|
||||||
}
|
}
|
||||||
|
|
@ -30,8 +30,8 @@ void CutFilament::Reset(uint8_t param) {
|
||||||
|
|
||||||
void CutFilament::SelectFilamentSlot() {
|
void CutFilament::SelectFilamentSlot() {
|
||||||
state = ProgressCode::SelectingFilamentSlot;
|
state = ProgressCode::SelectingFilamentSlot;
|
||||||
uint8_t newFilamentSlot = 0; //@@TODO
|
uint8_t newFilamentSlot = mg::globals.ActiveSlot() + 1; // move 1 slot aside
|
||||||
mi::idler.Engage(newFilamentSlot);
|
mi::idler.Engage(newFilamentSlot); //@@TODO does this make sense?
|
||||||
ms::selector.MoveToSlot(newFilamentSlot);
|
ms::selector.MoveToSlot(newFilamentSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,16 +64,14 @@ bool CutFilament::Step() {
|
||||||
} else {
|
} else {
|
||||||
// move selector aside - prepare the blade into active position
|
// move selector aside - prepare the blade into active position
|
||||||
state = ProgressCode::PreparingBlade;
|
state = ProgressCode::PreparingBlade;
|
||||||
uint8_t newFilamentSlot = 1; //@@TODO
|
ms::selector.MoveToSlot(mg::globals.ActiveSlot());
|
||||||
ms::selector.MoveToSlot(newFilamentSlot + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::PreparingBlade:
|
case ProgressCode::PreparingBlade:
|
||||||
if (mm::motion.QueueEmpty()) {
|
if (mm::motion.QueueEmpty()) {
|
||||||
state = ProgressCode::EngagingIdler;
|
state = ProgressCode::EngagingIdler;
|
||||||
uint8_t newFilamentSlot = 0; //@@TODO
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
mi::idler.Engage(newFilamentSlot);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::EngagingIdler:
|
case ProgressCode::EngagingIdler:
|
||||||
|
|
@ -91,8 +89,7 @@ bool CutFilament::Step() {
|
||||||
case ProgressCode::PerformingCut:
|
case ProgressCode::PerformingCut:
|
||||||
if (mm::motion.QueueEmpty()) { // this may not be necessary if we want the selector and pulley move at once
|
if (mm::motion.QueueEmpty()) { // this may not be necessary if we want the selector and pulley move at once
|
||||||
state = ProgressCode::ReturningSelector;
|
state = ProgressCode::ReturningSelector;
|
||||||
uint8_t newFilamentSlot = 0; //@@TODO
|
ms::selector.MoveToSlot(mg::globals.ActiveSlot()); // return selector back
|
||||||
ms::selector.MoveToSlot(newFilamentSlot); // return selector back
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::ReturningSelector:
|
case ProgressCode::ReturningSelector:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#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/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -14,14 +15,13 @@ EjectFilament ejectFilament;
|
||||||
namespace mm = modules::motion;
|
namespace mm = modules::motion;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
namespace ms = modules::selector;
|
namespace ms = modules::selector;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void EjectFilament::Reset(uint8_t param) {
|
void EjectFilament::Reset(uint8_t param) {
|
||||||
error = ErrorCode::OK;
|
error = ErrorCode::OK;
|
||||||
slot = param;
|
slot = param;
|
||||||
|
|
||||||
bool isFilamentLoaded = true; //@@TODO
|
if (mg::globals.FilamentLoaded()) {
|
||||||
|
|
||||||
if (isFilamentLoaded) {
|
|
||||||
state = ProgressCode::UnloadingFilament;
|
state = ProgressCode::UnloadingFilament;
|
||||||
unl.Reset(param); //@@TODO probably act on active extruder only
|
unl.Reset(param); //@@TODO probably act on active extruder only
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "feed_to_bondtech.h"
|
#include "feed_to_bondtech.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/fsensor.h"
|
#include "../modules/fsensor.h"
|
||||||
|
#include "../modules/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -13,11 +14,12 @@ namespace mfs = modules::fsensor;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
namespace ml = modules::leds;
|
namespace ml = modules::leds;
|
||||||
namespace mp = modules::permanent_storage;
|
namespace mp = modules::permanent_storage;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void FeedToBondtech::Reset(uint8_t maxRetries) {
|
void FeedToBondtech::Reset(uint8_t maxRetries) {
|
||||||
state = EngagingIdler;
|
state = EngagingIdler;
|
||||||
this->maxRetries = maxRetries;
|
this->maxRetries = maxRetries;
|
||||||
mi::idler.Engage(0 /*active_extruder*/); // @@TODO
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedToBondtech::Step() {
|
bool FeedToBondtech::Step() {
|
||||||
|
|
@ -27,7 +29,7 @@ bool FeedToBondtech::Step() {
|
||||||
case EngagingIdler:
|
case EngagingIdler:
|
||||||
if (mi::idler.Engaged()) {
|
if (mi::idler.Engaged()) {
|
||||||
state = PushingFilament;
|
state = PushingFilament;
|
||||||
ml::leds.SetMode(0, ml::Color::green, ml::blink0); //@@TODO active slot index
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0);
|
||||||
mm::motion.PlanMove(steps, 0, 0, 4500, 0, 0); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
mm::motion.PlanMove(steps, 0, 0, 4500, 0, 0); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
||||||
// we can probably hand over some array of constants for hand-tuned acceleration + leverage some smoothing in the stepper as well
|
// we can probably hand over some array of constants for hand-tuned acceleration + leverage some smoothing in the stepper as well
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +48,7 @@ bool FeedToBondtech::Step() {
|
||||||
case DisengagingIdler:
|
case DisengagingIdler:
|
||||||
if (!mi::idler.Engaged()) {
|
if (!mi::idler.Engaged()) {
|
||||||
state = OK;
|
state = OK;
|
||||||
ml::leds.SetMode(0, ml::Color::green, ml::on); //@@TODO active slot index
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case OK:
|
case OK:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "feed_to_finda.h"
|
#include "feed_to_finda.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -13,11 +14,12 @@ namespace mf = modules::finda;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
namespace ml = modules::leds;
|
namespace ml = modules::leds;
|
||||||
namespace mb = modules::buttons;
|
namespace mb = modules::buttons;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void FeedToFinda::Reset(bool feedPhaseLimited) {
|
void FeedToFinda::Reset(bool feedPhaseLimited) {
|
||||||
state = EngagingIdler;
|
state = EngagingIdler;
|
||||||
this->feedPhaseLimited = feedPhaseLimited;
|
this->feedPhaseLimited = feedPhaseLimited;
|
||||||
mi::idler.Engage(0 /*active_extruder*/); // @@TODO
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FeedToFinda::Step() {
|
bool FeedToFinda::Step() {
|
||||||
|
|
@ -25,7 +27,7 @@ bool FeedToFinda::Step() {
|
||||||
case EngagingIdler:
|
case EngagingIdler:
|
||||||
if (mi::idler.Engaged()) {
|
if (mi::idler.Engaged()) {
|
||||||
state = PushingFilament;
|
state = PushingFilament;
|
||||||
ml::leds.SetMode(0, ml::Color::green, ml::blink0); //@@TODO active slot index
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0);
|
||||||
mm::motion.PlanMove(feedPhaseLimited ? 1500 : 65535, 0, 0, 4000, 0, 0); //@@TODO constants
|
mm::motion.PlanMove(feedPhaseLimited ? 1500 : 65535, 0, 0, 4000, 0, 0); //@@TODO constants
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -48,7 +50,7 @@ bool FeedToFinda::Step() {
|
||||||
case DisengagingIdler:
|
case DisengagingIdler:
|
||||||
if (!mi::idler.Engaged()) {
|
if (!mi::idler.Engaged()) {
|
||||||
state = OK;
|
state = OK;
|
||||||
ml::leds.SetMode(0, ml::Color::green, ml::on); //@@TODO active slot index
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case OK:
|
case OK:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "load_filament.h"
|
#include "load_filament.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -16,11 +17,13 @@ namespace mi = modules::idler;
|
||||||
namespace ms = modules::selector;
|
namespace ms = modules::selector;
|
||||||
namespace mf = modules::finda;
|
namespace mf = modules::finda;
|
||||||
namespace ml = modules::leds;
|
namespace ml = modules::leds;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void LoadFilament::Reset(uint8_t param) {
|
void LoadFilament::Reset(uint8_t param) {
|
||||||
state = ProgressCode::EngagingIdler;
|
state = ProgressCode::EngagingIdler;
|
||||||
error = ErrorCode::OK;
|
error = ErrorCode::OK;
|
||||||
mi::idler.Engage(param); // @@TODO
|
mg::globals.SetActiveSlot(param);
|
||||||
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadFilament::Step() {
|
bool LoadFilament::Step() {
|
||||||
|
|
@ -38,7 +41,7 @@ bool LoadFilament::Step() {
|
||||||
// @@TODO - try to repeat 6x - push/pull sequence - probably something to put into feed_to_finda as an option
|
// @@TODO - try to repeat 6x - push/pull sequence - probably something to put into feed_to_finda as an option
|
||||||
state = ProgressCode::ERR1DisengagingIdler;
|
state = ProgressCode::ERR1DisengagingIdler;
|
||||||
mi::idler.Disengage();
|
mi::idler.Disengage();
|
||||||
ml::leds.SetMode(0, ml::Color::red, ml::Mode::blink0); // signal loading error //@@TODO slot index
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::Mode::blink0); // signal loading error
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::FeedingToBondtech;
|
state = ProgressCode::FeedingToBondtech;
|
||||||
james.Reset(2);
|
james.Reset(2);
|
||||||
|
|
@ -46,7 +49,7 @@ bool LoadFilament::Step() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::FeedingToBondtech:
|
case ProgressCode::FeedingToBondtech:
|
||||||
if (james.Step()) {
|
if (james.Step()) { // No, Mr. Bond, I expect you to FEED
|
||||||
switch (james.State()) {
|
switch (james.State()) {
|
||||||
case FeedToBondtech::Failed:
|
case FeedToBondtech::Failed:
|
||||||
|
|
||||||
|
|
@ -62,6 +65,7 @@ bool LoadFilament::Step() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::OK:
|
case ProgressCode::OK:
|
||||||
|
mg::globals.SetFilamentLoaded(true);
|
||||||
return true;
|
return true;
|
||||||
case ProgressCode::ERR1DisengagingIdler: // couldn't unload to FINDA
|
case ProgressCode::ERR1DisengagingIdler: // couldn't unload to FINDA
|
||||||
error = ErrorCode::FINDA_DIDNT_TRIGGER;
|
error = ErrorCode::FINDA_DIDNT_TRIGGER;
|
||||||
|
|
@ -82,8 +86,8 @@ bool LoadFilament::Step() {
|
||||||
Reset(0); // @@TODO param
|
Reset(0); // @@TODO param
|
||||||
} else if (userResolved) {
|
} else if (userResolved) {
|
||||||
// problem resolved - the user pulled the fillament by hand
|
// problem resolved - the user pulled the fillament by hand
|
||||||
// modules::leds::leds.SetMode(active_extruder, modules::leds::red, modules::leds::off);
|
modules::leds::leds.SetMode(mg::globals.ActiveSlot(), modules::leds::red, modules::leds::off);
|
||||||
// modules::leds::leds.SetMode(active_extruder, modules::leds::green, modules::leds::on);
|
modules::leds::leds.SetMode(mg::globals.ActiveSlot(), modules::leds::green, modules::leds::on);
|
||||||
// mm::motion.PlanMove(mm::Pulley, 450, 5000); // @@TODO constants
|
// mm::motion.PlanMove(mm::Pulley, 450, 5000); // @@TODO constants
|
||||||
state = ProgressCode::AvoidingGrind;
|
state = ProgressCode::AvoidingGrind;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#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/globals.h"
|
||||||
#include "../modules/idler.h"
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
|
|
@ -14,18 +15,17 @@ ToolChange toolChange;
|
||||||
namespace mm = modules::motion;
|
namespace mm = modules::motion;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
namespace ms = modules::selector;
|
namespace ms = modules::selector;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void ToolChange::Reset(uint8_t param) {
|
void ToolChange::Reset(uint8_t param) {
|
||||||
// if( param == active_extruder ) // @@TODO
|
if (param == mg::globals.ActiveSlot())
|
||||||
// return true;
|
return;
|
||||||
|
|
||||||
plannedSlot = param;
|
plannedSlot = param;
|
||||||
|
|
||||||
bool isFilamentLoaded = true; //@@TODO
|
if (mg::globals.FilamentLoaded()) {
|
||||||
|
|
||||||
if (isFilamentLoaded) {
|
|
||||||
state = ProgressCode::UnloadingFilament;
|
state = ProgressCode::UnloadingFilament;
|
||||||
unl.Reset(0); //@@TODO act on active extruder only
|
unl.Reset(mg::globals.ActiveSlot());
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::LoadingFilament;
|
state = ProgressCode::LoadingFilament;
|
||||||
load.Reset(plannedSlot);
|
load.Reset(plannedSlot);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
#include "unload_filament.h"
|
#include "unload_filament.h"
|
||||||
#include "../modules/buttons.h"
|
#include "../modules/buttons.h"
|
||||||
#include "../modules/finda.h"
|
#include "../modules/finda.h"
|
||||||
|
#include "../modules/globals.h"
|
||||||
|
#include "../modules/idler.h"
|
||||||
#include "../modules/leds.h"
|
#include "../modules/leds.h"
|
||||||
#include "../modules/motion.h"
|
#include "../modules/motion.h"
|
||||||
#include "../modules/idler.h"
|
|
||||||
#include "../modules/permanent_storage.h"
|
#include "../modules/permanent_storage.h"
|
||||||
|
|
||||||
namespace logic {
|
namespace logic {
|
||||||
|
|
@ -12,13 +13,14 @@ UnloadFilament unloadFilament;
|
||||||
|
|
||||||
namespace mm = modules::motion;
|
namespace mm = modules::motion;
|
||||||
namespace mi = modules::idler;
|
namespace mi = modules::idler;
|
||||||
|
namespace mg = modules::globals;
|
||||||
|
|
||||||
void UnloadFilament::Reset(uint8_t param) {
|
void UnloadFilament::Reset(uint8_t param) {
|
||||||
// unloads filament from extruder - filament is above Bondtech gears
|
// unloads filament from extruder - filament is above Bondtech gears
|
||||||
mm::motion.InitAxis(mm::Pulley);
|
mm::motion.InitAxis(mm::Pulley);
|
||||||
state = ProgressCode::EngagingIdler;
|
state = ProgressCode::EngagingIdler;
|
||||||
error = ErrorCode::OK;
|
error = ErrorCode::OK;
|
||||||
modules::idler::idler.Engage(0); //@@TODO
|
modules::idler::idler.Engage(mg::globals.ActiveSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UnloadFilament::Step() {
|
bool UnloadFilament::Step() {
|
||||||
|
|
@ -34,7 +36,7 @@ bool UnloadFilament::Step() {
|
||||||
if (unl.state == UnloadToFinda::Failed) {
|
if (unl.state == UnloadToFinda::Failed) {
|
||||||
// couldn't unload to FINDA, report error and wait for user to resolve it
|
// couldn't unload to FINDA, report error and wait for user to resolve it
|
||||||
state = ProgressCode::ERR1DisengagingIdler;
|
state = ProgressCode::ERR1DisengagingIdler;
|
||||||
// modules::leds::leds.SetMode(active_extruder, modules::leds::red, modules::leds::blink0);
|
modules::leds::leds.SetMode(mg::globals.ActiveSlot(), modules::leds::red, modules::leds::blink0);
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::DisengagingIdler;
|
state = ProgressCode::DisengagingIdler;
|
||||||
}
|
}
|
||||||
|
|
@ -80,15 +82,15 @@ bool UnloadFilament::Step() {
|
||||||
Reset(0); // @@TODO param
|
Reset(0); // @@TODO param
|
||||||
} else if (userResolved) {
|
} else if (userResolved) {
|
||||||
// problem resolved - the user pulled the fillament by hand
|
// problem resolved - the user pulled the fillament by hand
|
||||||
// modules::leds::leds.SetMode(active_extruder, modules::leds::red, modules::leds::off);
|
modules::leds::leds.SetMode(mg::globals.ActiveSlot(), modules::leds::red, modules::leds::off);
|
||||||
// modules::leds::leds.SetMode(active_extruder, modules::leds::green, modules::leds::on);
|
modules::leds::leds.SetMode(mg::globals.ActiveSlot(), modules::leds::green, modules::leds::on);
|
||||||
// mm::motion.PlanMove(mm::Pulley, 450, 5000); // @@TODO constants
|
// mm::motion.PlanMove(mm::Pulley, 450, 5000); // @@TODO constants
|
||||||
state = ProgressCode::AvoidingGrind;
|
state = ProgressCode::AvoidingGrind;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case ProgressCode::OK:
|
case ProgressCode::OK:
|
||||||
// isFilamentLoaded = false; // filament unloaded
|
mg::globals.SetFilamentLoaded(false); // filament unloaded
|
||||||
return true; // successfully finished
|
return true; // successfully finished
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include "globals.h"
|
||||||
|
#include "permanent_storage.h"
|
||||||
|
|
||||||
|
namespace modules {
|
||||||
|
namespace globals {
|
||||||
|
|
||||||
|
void Globals::Init() {
|
||||||
|
modules::permanent_storage::FilamentLoaded::get(activeSlot); //@@TODO check for errors
|
||||||
|
// @@TODO where to obtain information whether a slot is loaded with a filament?
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Globals::ActiveSlot() const {
|
||||||
|
return activeSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Globals::SetActiveSlot(uint8_t newActiveSlot) {
|
||||||
|
activeSlot = newActiveSlot;
|
||||||
|
modules::permanent_storage::FilamentLoaded::set(activeSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Globals::FilamentLoaded() const {
|
||||||
|
return filamentLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Globals::SetFilamentLoaded(bool newFilamentLoaded) {
|
||||||
|
filamentLoaded = newFilamentLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace globals
|
||||||
|
} // namespace modules
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace modules {
|
||||||
|
namespace globals {
|
||||||
|
|
||||||
|
class Globals {
|
||||||
|
public:
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
uint8_t ActiveSlot() const;
|
||||||
|
void SetActiveSlot(uint8_t newActiveSlot);
|
||||||
|
|
||||||
|
bool FilamentLoaded() const;
|
||||||
|
void SetFilamentLoaded(bool newFilamentLoaded);
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8_t activeSlot;
|
||||||
|
bool filamentLoaded;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Globals globals;
|
||||||
|
|
||||||
|
} // namespace globals
|
||||||
|
} // namespace modules
|
||||||
Loading…
Reference in New Issue