Merge branch 'lufa-cmake' of github.com:DRracer/Prusa-Firmware-MMU-Private into lufa-cmake

pull/115/head
D.R.racer 2021-09-23 13:40:34 +02:00
commit c896031a62
9 changed files with 29 additions and 34 deletions

View File

@ -22,7 +22,7 @@ bool FeedToBondtech::Step() {
case EngagingIdler:
if (mi::idler.Engaged()) {
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,
// 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:
// if (!mi::idler.Engaged()) {
// 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;
case OK:

View File

@ -23,7 +23,7 @@ bool FeedToFinda::Step() {
case EngagingIdler:
if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) {
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
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
state = Failed;
// @@TODO - shall we disengage the idler?
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::off);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::blink0);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0);
}
}
return false;
@ -51,7 +51,7 @@ bool FeedToFinda::Step() {
// case DisengagingIdler:
// if (!mi::idler.Engaged()) {
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?
return false;

View File

@ -41,8 +41,8 @@ bool LoadFilament::StepInner() {
state = ProgressCode::ERRDisengagingIdler;
error = ErrorCode::FINDA_DIDNT_SWITCH_ON;
mi::idler.Disengage();
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::off);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::red, ml::Mode::blink0); // signal loading error
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); // signal loading error
} else {
state = ProgressCode::FeedingToBondtech;
james.Reset(config::feedToBondtechMaxRetries);

View File

@ -30,7 +30,7 @@ bool UnloadToFinda::Step() {
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, -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;
case WaitingForFINDA:

View File

@ -95,12 +95,13 @@ void setup() {
mt::timebase.Init();
// watchdog init
hwd::Enable(hwd::configuration::compute(8000)); //set 8s timeout
mg::globals.Init();
hal::shr16::shr16.Init();
ml::leds.SetMode(4, ml::Color::green, ml::Mode::on);
ml::leds.SetMode(4, ml::green, ml::on);
ml::leds.Step();
// if the shift register doesn't work we really can't signalize anything, only internal variables will be accessible if the UART works
@ -110,7 +111,7 @@ void setup() {
.baudrate = 115200,
};
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();
// @@TODO if both shift register and the UART are dead, we are sitting ducks :(
@ -125,15 +126,15 @@ void setup() {
.cpol = 1,
};
hal::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();
mm::Init();
ml::leds.SetMode(1, ml::Color::green, ml::Mode::on);
ml::leds.SetMode(1, ml::green, ml::on);
ml::leds.Step();
ha::Init();
ml::leds.SetMode(0, ml::Color::green, ml::Mode::on);
ml::leds.SetMode(0, ml::green, ml::on);
ml::leds.Step();
mu::cdc.Init();
@ -142,8 +143,8 @@ void setup() {
/// Turn off all leds
for (uint8_t i = 0; i < config::toolCount; i++) {
ml::leds.SetMode(i, ml::Color::green, ml::Mode::off);
ml::leds.SetMode(i, ml::Color::red, ml::Mode::off);
ml::leds.SetMode(i, ml::green, ml::off);
ml::leds.SetMode(i, ml::red, ml::off);
}
ml::leds.Step();
}

View File

@ -36,18 +36,6 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = {
},
};
// void testFunc1(uint8_t i) {
// char str[30];
// sprintf_P(str, PSTR("testFunc1(%hu)\n"), i);
// hal::usart::usart1.puts(str);
// }
// void testFunc2(uint8_t i) {
// char str[30];
// sprintf_P(str, PSTR("testFunc2(%hu)\n"), i);
// hal::usart::usart1.puts(str);
// }
/** Event handler for the library USB Connection event. */
void EVENT_USB_Device_Connect(void) {
hal::usart::usart1.puts("EVENT_USB_Device_Connect\n");

View File

@ -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
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)
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::Color::green));
REQUIRE(ml::leds.LedOn(mg::globals.ActiveSlot(), ml::green));
REQUIRE(WhileCondition(
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
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
}

View File

@ -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
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)
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
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
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)
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
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
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::Color::red) == ml::blink0);
REQUIRE(ml::leds.Mode(mg::globals.ActiveSlot(), ml::green) == ml::off);
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
}

View File

@ -1,5 +1,11 @@
#include <cstdio>
#ifndef __WIN32__
#include <sysexits.h>
#else
#define EX_OK 0
#define EX_USAGE 64
#define EX_OSERR 71
#endif
#include "motion.h"
using namespace modules::motion;