Merge pull request #1125 from PavelSindler/messages_corrections

MM messages corrections; no debug messages when printer communicates with MMU2
This commit is contained in:
PavelSindler 2018-09-11 09:43:52 +02:00 committed by GitHub
commit dad8017ae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 10 deletions

View file

@ -113,8 +113,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;
}
@ -128,9 +130,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;
@ -138,11 +142,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;
}
@ -151,7 +159,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;
@ -163,39 +173,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
}
@ -203,7 +225,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;
}
@ -212,7 +236,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();
@ -232,7 +258,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;
}

View file

@ -530,7 +530,7 @@ void lcdui_print_extruder(void)
{
int chars = 0;
if (mmu_extruder == tmp_extruder)
chars = lcd_printf_P(_N(" T%u"), mmu_extruder+1);
chars = lcd_printf_P(_N(" F%u"), mmu_extruder+1);
else
chars = lcd_printf_P(_N(" %u>%u"), mmu_extruder+1, tmp_extruder+1);
lcd_space(5 - chars);
@ -5014,18 +5014,18 @@ char choose_extruder_menu()
enc_dif = lcd_encoder_diff;
lcd_clear();
lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
if (mmu_enabled) lcd_puts_P(_T(MSG_CHOOSE_FILAMENT));
else lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
lcd_set_cursor(0, 1);
lcd_print(">");
for (int i = 0; i < 3; i++) {
lcd_puts_at_P(1, i + 1, _T(MSG_EXTRUDER));
lcd_puts_at_P(1, i + 1, mmu_enabled ? _T(MSG_FILAMENT) : _T(MSG_EXTRUDER));
}
KEEPALIVE_STATE(PAUSED_FOR_USER);
while (1) {
for (int i = 0; i < 3; i++) {
lcd_set_cursor(2 + strlen_P(_T(MSG_EXTRUDER)), i+1);
lcd_set_cursor(2 + strlen_P( mmu_enabled ? _T(MSG_FILAMENT) : _T(MSG_EXTRUDER)), i+1);
lcd_print(first + i + 1);
}
@ -5048,9 +5048,10 @@ char choose_extruder_menu()
if (first < items_no - 3) {
first++;
lcd_clear();
lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
if (mmu_enabled) lcd_puts_P(_T(MSG_CHOOSE_FILAMENT));
else lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
for (int i = 0; i < 3; i++) {
lcd_puts_at_P(1, i + 1, _T(MSG_EXTRUDER));
lcd_puts_at_P(1, i + 1, mmu_enabled ? _T(MSG_FILAMENT) : _T(MSG_EXTRUDER));
}
}
}
@ -5060,9 +5061,10 @@ char choose_extruder_menu()
if (first > 0) {
first--;
lcd_clear();
lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
if (mmu_enabled) lcd_puts_P(_T(MSG_CHOOSE_FILAMENT));
else lcd_puts_P(_T(MSG_CHOOSE_EXTRUDER));
for (int i = 0; i < 3; i++) {
lcd_puts_at_P(1, i + 1, _T(MSG_EXTRUDER));
lcd_puts_at_P(1, i + 1, mmu_enabled ? _T(MSG_FILAMENT) : _T(MSG_EXTRUDER));
}
}
}

View file

@ -481,4 +481,6 @@
//#define SUPPORT_VERBOSITY
//#define MMU_DEBUG //print communication between MMU2 and printer on serial
#endif //__CONFIGURATION_PRUSA_H

View file

@ -482,4 +482,6 @@
//#define SUPPORT_VERBOSITY
//#define MMU_DEBUG //print communication between MMU2 and printer on serial
#endif //__CONFIGURATION_PRUSA_H

View file

@ -613,4 +613,6 @@
//#define SUPPORT_VERBOSITY
//#define MMU_DEBUG //print communication between MMU2 and printer on serial
#endif //__CONFIGURATION_PRUSA_H