Merge branch 'MK3' into MK3_dev

This commit is contained in:
Marek Bel 2018-09-12 15:22:12 +02:00
commit de2100ac7b
22 changed files with 2738 additions and 406 deletions
Firmware

View file

@ -114,8 +114,10 @@ void mmu_loop(void)
case -1:
if (mmu_rx_start() > 0)
{
#ifdef MMU_DEBUG
puts_P(PSTR("MMU => 'start'"));
puts_P(PSTR("MMU <= 'S1'"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("S1\n")); //send 'read version' request
mmu_state = -2;
}
@ -129,9 +131,11 @@ void mmu_loop(void)
if (mmu_rx_ok() > 0)
{
fscanf_P(uart2io, PSTR("%u"), &mmu_version); //scan version from buffer
#ifdef MMU_DEBUG
printf_P(PSTR("MMU => '%dok'\n"), mmu_version);
puts_P(PSTR("MMU <= 'S2'"));
mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request
#endif //MMU_DEBUG
mmu_puts_P(PSTR("S2\n")); //send 'read buildnr' request
mmu_state = -3;
}
return;
@ -139,11 +143,15 @@ void mmu_loop(void)
if (mmu_rx_ok() > 0)
{
fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer
#ifdef MMU_DEBUG
printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr);
#endif //MMU_DEBUG
bool version_valid = mmu_check_version();
if (!version_valid) mmu_show_warning();
else puts_P(PSTR("MMU version valid"));
#ifdef MMU_DEBUG
puts_P(PSTR("MMU <= 'P0'"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
mmu_state = -4;
}
@ -152,7 +160,9 @@ void mmu_loop(void)
if (mmu_rx_ok() > 0)
{
fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
#ifdef MMU_DEBUG
printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
#endif //MMU_DEBUG
puts_P(PSTR("MMU - ENABLED"));
mmu_enabled = true;
mmu_state = 1;
@ -164,39 +174,51 @@ void mmu_loop(void)
if ((mmu_cmd >= MMU_CMD_T0) && (mmu_cmd <= MMU_CMD_T4))
{
filament = mmu_cmd - MMU_CMD_T0;
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'T%d'\n"), filament);
#endif //MMU_DEBUG
mmu_printf_P(PSTR("T%d\n"), filament);
mmu_state = 3; // wait for response
}
else if ((mmu_cmd >= MMU_CMD_L0) && (mmu_cmd <= MMU_CMD_L4))
{
filament = mmu_cmd - MMU_CMD_L0;
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'L%d'\n"), filament);
#endif //MMU_DEBUG
mmu_printf_P(PSTR("L%d\n"), filament);
mmu_state = 3; // wait for response
}
else if (mmu_cmd == MMU_CMD_C0)
{
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'C0'\n"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("C0\n")); //send 'continue loading'
mmu_state = 3;
}
else if (mmu_cmd == MMU_CMD_U0)
{
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'U0'\n"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("U0\n")); //send 'unload current filament'
mmu_state = 3;
}
else if ((mmu_cmd >= MMU_CMD_E0) && (mmu_cmd <= MMU_CMD_E4))
{
int filament = mmu_cmd - MMU_CMD_E0;
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'E%d'\n"), filament);
#endif //MMU_DEBUG
mmu_printf_P(PSTR("E%d\n"), filament); //send eject filament
mmu_state = 3; // wait for response
}
else if (mmu_cmd == MMU_CMD_R0)
{
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'R0'\n"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("R0\n")); //send recover after eject
mmu_state = 3; // wait for response
}
@ -204,7 +226,9 @@ void mmu_loop(void)
}
else if ((mmu_last_response + 300) < millis()) //request every 300ms
{
#ifdef MMU_DEBUG
puts_P(PSTR("MMU <= 'P0'"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
mmu_state = 2;
}
@ -213,7 +237,9 @@ void mmu_loop(void)
if (mmu_rx_ok() > 0)
{
fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
#ifdef MMU_DEBUG
printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
#endif //MMU_DEBUG
//printf_P(PSTR("Eact: %d\n"), int(e_active()));
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
fsensor_stop_and_save_print();
@ -233,7 +259,9 @@ void mmu_loop(void)
case 3: //response to mmu commands
if (mmu_rx_ok() > 0)
{
#ifdef MMU_DEBUG
printf_P(PSTR("MMU => 'ok'\n"));
#endif //MMU_DEBUG
mmu_ready = true;
mmu_state = 1;
}