From 863fe1f054ba93fbe5d2cc6b4788b4fe65250772 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 14 Mar 2018 15:35:39 +0100 Subject: [PATCH] show message that printer is not connected to monitoring on printer start --- Firmware/Configuration_prusa.h | 2 + Firmware/Marlin_main.cpp | 11 ++-- Firmware/cmdqueue.cpp | 10 +++ Firmware/ultralcd.cpp | 116 +++++++++++++++++++++++++++++---- 4 files changed, 122 insertions(+), 17 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index 7cf413c37..4591db85b 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -543,6 +543,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define PING_TIME 60 //time in s #define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes #define PING_ALLERT_PERIOD 60 //time in s +#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring +#define NC_BUTTON_LONG_PRESS 15 //time in s #define LONG_PRESS_TIME 1000 //time in ms for button long press #define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bd444e108..8235f9145 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -942,18 +942,21 @@ void setup() lcd_splash(); setup_killpin(); setup_powerhold(); - + farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE); EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no); - if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode - if (farm_no == 0xFFFF) farm_no = 0; + if ((farm_mode == 0xFF && farm_no == 0) || ((uint16_t)farm_no == 0xFFFF)) + farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode + if ((uint16_t)farm_no == 0xFFFF) farm_no = 0; selectedSerialPort = eeprom_read_byte((uint8_t*)EEPROM_SECOND_SERIAL_ACTIVE); if (selectedSerialPort == 0xFF) selectedSerialPort = 0; if (farm_mode) { + no_response = true; //we need confirmation by recieving PRUSA thx + important_status = 8; prusa_statistics(8); - selectedSerialPort = 1; + //selectedSerialPort = 1; } MYSERIAL.begin(BAUDRATE); fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream diff --git a/Firmware/cmdqueue.cpp b/Firmware/cmdqueue.cpp index bdf4c3abf..7daec45b1 100644 --- a/Firmware/cmdqueue.cpp +++ b/Firmware/cmdqueue.cpp @@ -360,6 +360,16 @@ bool is_buffer_empty() else return false; } +void proc_commands() { + if (buflen) + { + process_commands(); + if (!cmdbuffer_front_already_processed) + cmdqueue_pop_front(); + cmdbuffer_front_already_processed = false; + } +} + void get_command() { // Test and reserve space for the new command string. diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 644f3e68f..2dbcafcb5 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -150,7 +150,7 @@ int lcd_commands_step=0; bool isPrintPaused = false; uint8_t farm_mode = 0; int farm_no = 0; -int farm_timer = 30; +int farm_timer = 8; int farm_status = 0; unsigned long allert_timer = millis(); bool printer_connected = true; @@ -160,7 +160,7 @@ float pid_temp = DEFAULT_PID_TEMP; bool long_press_active = false; long long_press_timer = millis(); -long button_blanking_time = millis(); +unsigned long button_blanking_time = millis(); bool button_pressed = false; bool menuExiting = false; @@ -467,15 +467,15 @@ static void lcd_status_screen() farm_timer--; if (farm_timer < 1) { - farm_timer = 180; + farm_timer = 10; prusa_statistics(0); } switch (farm_timer) { - case 45: + case 8: prusa_statistics(21); break; - case 10: + case 5: if (IS_SD_PRINTING) { prusa_statistics(20); @@ -2993,7 +2993,7 @@ void lcd_diag_show_end_stops() -void prusa_statistics(int _message) { +void prusa_statistics(int _message, uint8_t _fil_nr) { #ifdef DEBUG_DISABLE_PRUSA_STATISTICS return; #endif //DEBUG_DISABLE_PRUSA_STATISTICS @@ -3063,14 +3063,18 @@ void prusa_statistics(int _message) { break; case 4: // print succesfull - SERIAL_ECHOLN("{[RES:1]"); + SERIAL_ECHO("{[RES:1][FIL:"); + MYSERIAL.print(int(_fil_nr)); + SERIAL_ECHO("]"); prusa_stat_printerstatus(status_number); prusa_stat_farm_number(); SERIAL_ECHOLN("}"); farm_timer = 2; break; case 5: // print not succesfull - SERIAL_ECHOLN("{[RES:0]"); + SERIAL_ECHO("{[RES:0][FIL:"); + MYSERIAL.print(int(_fil_nr)); + SERIAL_ECHO("]"); prusa_stat_printerstatus(status_number); prusa_stat_farm_number(); SERIAL_ECHOLN("}"); @@ -3102,7 +3106,7 @@ void prusa_statistics(int _message) { prusa_stat_printerstatus(status_number); prusa_stat_farm_number(); SERIAL_ECHOLN("}"); - farm_timer = 5; + farm_timer = 4; break; case 21: // temperatures SERIAL_ECHO("{"); @@ -3129,7 +3133,7 @@ void prusa_statistics(int _message) { SERIAL_ECHOLN("}"); break; case 92: // Error - Min temp - SERIAL_ECHOLN("{[ERR:3]"); + SERIAL_ECHO("{[ERR:3]"); prusa_stat_farm_number(); SERIAL_ECHOLN("}"); break; @@ -5170,14 +5174,99 @@ static void lcd_farm_no() } + +unsigned char lcd_choose_color() { + //function returns index of currently chosen item + //following part can be modified from 2 to 255 items: + //----------------------------------------------------- + unsigned char items_no = 2; + const char *item[items_no]; + item[0] = "Orange"; + item[1] = "Black"; + //----------------------------------------------------- + unsigned char active_rows; + static int first = 0; + int enc_dif = 0; + unsigned char cursor_pos = 1; + enc_dif = encoderDiff; + lcd_implementation_clear(); + lcd.setCursor(0, 1); + lcd.print(">"); + + active_rows = items_no < 3 ? items_no : 3; + + while (1) { + lcd_print_at_PGM(0, 0, PSTR("Choose color:")); + for (int i = 0; i < active_rows; i++) { + lcd.setCursor(1, i+1); + lcd.print(item[first + i]); + } + + manage_heater(); + manage_inactivity(true); + proc_commands(); + if (abs((enc_dif - encoderDiff)) > 12) { + + if (enc_dif > encoderDiff) { + cursor_pos--; + } + + if (enc_dif < encoderDiff) { + cursor_pos++; + } + + if (cursor_pos > active_rows) { + cursor_pos = active_rows; + if (first < items_no - active_rows) { + first++; + lcd_implementation_clear(); + } + } + + if (cursor_pos < 1) { + cursor_pos = 1; + if (first > 0) { + first--; + lcd_implementation_clear(); + } + } + lcd.setCursor(0, 1); + lcd.print(" "); + lcd.setCursor(0, 2); + lcd.print(" "); + lcd.setCursor(0, 3); + lcd.print(" "); + lcd.setCursor(0, cursor_pos); + lcd.print(">"); + enc_dif = encoderDiff; + delay(100); + + } + + if (lcd_clicked()) { + while (lcd_clicked()); + delay(10); + while (lcd_clicked()); + switch(cursor_pos + first - 1) { + case 0: return 1; break; + case 1: return 0; break; + default: return 99; break; + } + } + + } + +} + void lcd_confirm_print() { + uint8_t filament_type; int enc_dif = 0; int cursor_pos = 1; int _ret = 0; int _t = 0; - + enc_dif = encoderDiff; lcd_implementation_clear(); lcd.setCursor(0, 0); @@ -5185,8 +5274,7 @@ void lcd_confirm_print() do { - - if (abs((enc_dif - encoderDiff)) > 2) { + if (abs(enc_dif - encoderDiff) > 12) { if (enc_dif > encoderDiff) { cursor_pos--; } @@ -5194,6 +5282,7 @@ void lcd_confirm_print() if (enc_dif < encoderDiff) { cursor_pos++; } + enc_dif = encoderDiff; } if (cursor_pos > 2) { cursor_pos = 2; } @@ -5241,6 +5330,7 @@ void lcd_confirm_print() manage_heater(); manage_inactivity(); + proc_commands(); } while (_ret == 0);