Cheange LED modes to be consistent.
parent
f01d3a342f
commit
d3d992da5b
|
|
@ -22,7 +22,7 @@ bool FeedToBondtech::Step() {
|
||||||
case EngagingIdler:
|
case EngagingIdler:
|
||||||
if (mi::idler.Engaged()) {
|
if (mi::idler.Engaged()) {
|
||||||
state = PushingFilament;
|
state = PushingFilament;
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||||
mm::motion.PlanMove(mm::Pulley, steps, 4500); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
mm::motion.PlanMove(mm::Pulley, steps, 4500); //@@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
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ bool FeedToBondtech::Step() {
|
||||||
// case DisengagingIdler:
|
// case DisengagingIdler:
|
||||||
// if (!mi::idler.Engaged()) {
|
// if (!mi::idler.Engaged()) {
|
||||||
// state = OK;
|
// state = OK;
|
||||||
// ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on);
|
// ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||||
// }
|
// }
|
||||||
// return false;
|
// return false;
|
||||||
case OK:
|
case OK:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ bool FeedToFinda::Step() {
|
||||||
case EngagingIdler:
|
case EngagingIdler:
|
||||||
if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) {
|
if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) {
|
||||||
state = PushingFilament;
|
state = PushingFilament;
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||||
mm::motion.PlanMove(mm::Pulley, feedPhaseLimited ? 1500 : 32767, 4000); //@@TODO constants
|
mm::motion.PlanMove(mm::Pulley, feedPhaseLimited ? 1500 : 32767, 4000); //@@TODO constants
|
||||||
mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input
|
mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input
|
||||||
}
|
}
|
||||||
|
|
@ -37,8 +37,8 @@ bool FeedToFinda::Step() {
|
||||||
} else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on
|
} else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on
|
||||||
state = Failed;
|
state = Failed;
|
||||||
// @@TODO - shall we disengage the idler?
|
// @@TODO - shall we disengage the idler?
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::off);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::blink0);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -51,7 +51,7 @@ bool FeedToFinda::Step() {
|
||||||
// case DisengagingIdler:
|
// case DisengagingIdler:
|
||||||
// if (!mi::idler.Engaged()) {
|
// if (!mi::idler.Engaged()) {
|
||||||
state = OK;
|
state = OK;
|
||||||
// ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::on);
|
// ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||||
}
|
}
|
||||||
// @@TODO FINDA must be reported as OFF again as we are pulling the filament from it - is this correct?
|
// @@TODO FINDA must be reported as OFF again as we are pulling the filament from it - is this correct?
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ bool LoadFilament::StepInner() {
|
||||||
state = ProgressCode::ERRDisengagingIdler;
|
state = ProgressCode::ERRDisengagingIdler;
|
||||||
error = ErrorCode::FINDA_DIDNT_SWITCH_ON;
|
error = ErrorCode::FINDA_DIDNT_SWITCH_ON;
|
||||||
mi::idler.Disengage();
|
mi::idler.Disengage();
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::off);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::Mode::blink0); // signal loading error
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); // signal loading error
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::FeedingToBondtech;
|
state = ProgressCode::FeedingToBondtech;
|
||||||
james.Reset(config::feedToBondtechMaxRetries);
|
james.Reset(config::feedToBondtechMaxRetries);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ bool UnloadToFinda::Step() {
|
||||||
mm::motion.PlanMove(mm::Pulley, -1400, 6000); // @@TODO constants
|
mm::motion.PlanMove(mm::Pulley, -1400, 6000); // @@TODO constants
|
||||||
mm::motion.PlanMove(mm::Pulley, -1800 + 1400, 2500); // @@TODO constants 1800-1400 = 400
|
mm::motion.PlanMove(mm::Pulley, -1800 + 1400, 2500); // @@TODO constants 1800-1400 = 400
|
||||||
mm::motion.PlanMove(mm::Pulley, -second_point + 1800, 550); // @@TODO constants
|
mm::motion.PlanMove(mm::Pulley, -second_point + 1800, 550); // @@TODO constants
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::blink0);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case WaitingForFINDA:
|
case WaitingForFINDA:
|
||||||
|
|
|
||||||
14
src/main.cpp
14
src/main.cpp
|
|
@ -104,7 +104,7 @@ void setup() {
|
||||||
// watchdog init
|
// watchdog init
|
||||||
|
|
||||||
shr16::shr16.Init();
|
shr16::shr16.Init();
|
||||||
ml::leds.SetMode(4, ml::Color::green, ml::Mode::on);
|
ml::leds.SetMode(4, ml::green, ml::on);
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
|
|
||||||
// @@TODO if the shift register doesn't work we really can't signalize anything, only internal variables will be accessible if the UART works
|
// @@TODO if the shift register doesn't work we really can't signalize anything, only internal variables will be accessible if the UART works
|
||||||
|
|
@ -115,7 +115,7 @@ void setup() {
|
||||||
.baudrate = 115200,
|
.baudrate = 115200,
|
||||||
};
|
};
|
||||||
hu::usart1.Init(&usart_conf);
|
hu::usart1.Init(&usart_conf);
|
||||||
ml::leds.SetMode(3, ml::Color::green, ml::Mode::on);
|
ml::leds.SetMode(3, ml::green, ml::on);
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
|
|
||||||
// @@TODO if both shift register and the UART are dead, we are sitting ducks :(
|
// @@TODO if both shift register and the UART are dead, we are sitting ducks :(
|
||||||
|
|
@ -130,21 +130,21 @@ void setup() {
|
||||||
.cpol = 1,
|
.cpol = 1,
|
||||||
};
|
};
|
||||||
spi::Init(SPI0, &spi_conf);
|
spi::Init(SPI0, &spi_conf);
|
||||||
ml::leds.SetMode(2, ml::Color::green, ml::Mode::on);
|
ml::leds.SetMode(2, ml::green, ml::on);
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
|
|
||||||
mm::Init();
|
mm::Init();
|
||||||
ml::leds.SetMode(1, ml::Color::green, ml::Mode::on);
|
ml::leds.SetMode(1, ml::green, ml::on);
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
|
|
||||||
adc::Init();
|
adc::Init();
|
||||||
ml::leds.SetMode(0, ml::Color::green, ml::Mode::on);
|
ml::leds.SetMode(0, ml::green, ml::on);
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
|
|
||||||
/// Turn off all leds
|
/// Turn off all leds
|
||||||
for (uint8_t i = 0; i < config::toolCount; i++) {
|
for (uint8_t i = 0; i < config::toolCount; i++) {
|
||||||
ml::leds.SetMode(i, ml::Color::green, ml::Mode::off);
|
ml::leds.SetMode(i, ml::green, ml::off);
|
||||||
ml::leds.SetMode(i, ml::Color::red, ml::Mode::off);
|
ml::leds.SetMode(i, ml::red, ml::off);
|
||||||
}
|
}
|
||||||
ml::leds.Step();
|
ml::leds.Step();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
||||||
// idler engaged, selector in position, we'll start pushing filament
|
// idler engaged, selector in position, we'll start pushing filament
|
||||||
REQUIRE(fb.State() == FeedToBondtech::PushingFilament);
|
REQUIRE(fb.State() == FeedToBondtech::PushingFilament);
|
||||||
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
||||||
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green));
|
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green));
|
||||||
|
|
||||||
REQUIRE(WhileCondition(
|
REQUIRE(WhileCondition(
|
||||||
fb,
|
fb,
|
||||||
|
|
@ -77,7 +77,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
||||||
|
|
||||||
// state machine finished ok, the green LED should be on
|
// state machine finished ok, the green LED should be on
|
||||||
REQUIRE(fb.State() == FeedToBondtech::OK);
|
REQUIRE(fb.State() == FeedToBondtech::OK);
|
||||||
// REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green));
|
// REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green));
|
||||||
|
|
||||||
REQUIRE(fb.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true
|
REQUIRE(fb.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ TEST_CASE("feed_to_finda::feed_phase_unlimited", "[feed_to_finda]") {
|
||||||
// idler engaged, selector in position, we'll start pushing filament
|
// idler engaged, selector in position, we'll start pushing filament
|
||||||
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
||||||
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
||||||
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green));
|
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green));
|
||||||
|
|
||||||
// now let the filament be pushed into the FINDA - do 500 steps without triggering the condition
|
// now let the filament be pushed into the FINDA - do 500 steps without triggering the condition
|
||||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high);
|
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::high);
|
||||||
|
|
@ -117,7 +117,7 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
||||||
// idler engaged, we'll start pushing filament
|
// idler engaged, we'll start pushing filament
|
||||||
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
REQUIRE(ff.State() == FeedToFinda::PushingFilament);
|
||||||
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
// at least at the beginning the LED should shine green (it should be blinking, but this mode has been already verified in the LED's unit test)
|
||||||
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::green) == ml::blink0);
|
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::blink0);
|
||||||
|
|
||||||
// now let the filament be pushed into the FINDA - but we make sure the FINDA doesn't trigger at all
|
// now let the filament be pushed into the FINDA - but we make sure the FINDA doesn't trigger at all
|
||||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low);
|
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low);
|
||||||
|
|
@ -129,8 +129,8 @@ TEST_CASE("feed_to_finda::FINDA_failed", "[feed_to_finda]") {
|
||||||
|
|
||||||
// the FINDA didn't trigger, we should be in the Failed state
|
// the FINDA didn't trigger, we should be in the Failed state
|
||||||
REQUIRE(ff.State() == FeedToFinda::Failed);
|
REQUIRE(ff.State() == FeedToFinda::Failed);
|
||||||
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::green) == ml::off);
|
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::off);
|
||||||
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::Color::red) == ml::blink0);
|
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::red) == ml::blink0);
|
||||||
|
|
||||||
REQUIRE(ff.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true
|
REQUIRE(ff.Step() == true); // the automaton finished its work, any consecutive calls to Step must return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue