Merge pull request #561 from PavelSindler/farm_mode_MK3
Farm mode for mk3
This commit is contained in:
commit
7f9687f532
9 changed files with 236 additions and 28987 deletions
|
@ -574,6 +574,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
|
||||
|
|
|
@ -316,6 +316,10 @@ extern unsigned int custom_message_type;
|
|||
extern unsigned int custom_message_state;
|
||||
extern char snmm_filaments_used;
|
||||
extern unsigned long PingTime;
|
||||
extern unsigned long NcTime;
|
||||
extern bool no_response;
|
||||
extern uint8_t important_status;
|
||||
extern uint8_t saved_filament_type;
|
||||
|
||||
extern bool fan_state[2];
|
||||
extern int fan_edge_counter[2];
|
||||
|
@ -442,3 +446,4 @@ void gcode_M701();
|
|||
#define UVLO !(PINE & (1<<4))
|
||||
|
||||
void extr_unload2();
|
||||
void proc_commands();
|
||||
|
|
|
@ -251,6 +251,8 @@ CardReader card;
|
|||
#endif
|
||||
|
||||
unsigned long PingTime = millis();
|
||||
unsigned long NcTime;
|
||||
|
||||
union Data
|
||||
{
|
||||
byte b[2];
|
||||
|
@ -414,6 +416,10 @@ bool cancel_heatup = false ;
|
|||
const char errormagic[] PROGMEM = "Error:";
|
||||
const char echomagic[] PROGMEM = "echo:";
|
||||
|
||||
bool no_response = false;
|
||||
uint8_t important_status;
|
||||
uint8_t saved_filament_type;
|
||||
|
||||
//===========================================================================
|
||||
//=============================Private Variables=============================
|
||||
//===========================================================================
|
||||
|
@ -956,16 +962,19 @@ 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;
|
||||
}
|
||||
|
@ -2484,6 +2493,7 @@ void gcode_M701()
|
|||
|
||||
void process_commands()
|
||||
{
|
||||
if (!buflen) return; //empty command
|
||||
#ifdef FILAMENT_RUNOUT_SUPPORT
|
||||
SET_INPUT(FR_SENS);
|
||||
#endif
|
||||
|
@ -2559,6 +2569,9 @@ void process_commands()
|
|||
MYSERIAL.println("Not in farm mode.");
|
||||
}
|
||||
|
||||
}
|
||||
else if (code_seen("thx")) {
|
||||
no_response = false;
|
||||
}else if (code_seen("fv")) {
|
||||
// get file version
|
||||
#ifdef SDSUPPORT
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -154,7 +154,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;
|
||||
|
@ -164,7 +164,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;
|
||||
|
@ -489,15 +489,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);
|
||||
|
@ -587,10 +587,10 @@ static void lcd_status_screen()
|
|||
feedmultiply = 999;
|
||||
#endif //ULTIPANEL
|
||||
|
||||
if (farm_mode && !printer_connected) {
|
||||
/*if (farm_mode && !printer_connected) {
|
||||
lcd.setCursor(0, 3);
|
||||
lcd_printPGM(MSG_PRINTER_DISCONNECTED);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
//#define FSENS_FACTOR (2580.8/50) //filament sensor factor [steps / encoder counts]
|
||||
|
@ -3076,7 +3076,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
|
||||
|
@ -3146,28 +3146,32 @@ 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("}");
|
||||
farm_timer = 2;
|
||||
break;
|
||||
case 6: // print done
|
||||
SERIAL_ECHOLN("{[PRN:8]");
|
||||
SERIAL_ECHO("{[PRN:8]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
status_number = 8;
|
||||
farm_timer = 2;
|
||||
break;
|
||||
case 7: // print done - stopped
|
||||
SERIAL_ECHOLN("{[PRN:9]");
|
||||
SERIAL_ECHO("{[PRN:9]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
status_number = 9;
|
||||
|
@ -3181,11 +3185,11 @@ void prusa_statistics(int _message) {
|
|||
farm_timer = 2;
|
||||
break;
|
||||
case 20: // echo farm no
|
||||
SERIAL_ECHOLN("{");
|
||||
SERIAL_ECHO("{");
|
||||
prusa_stat_printerstatus(status_number);
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
farm_timer = 5;
|
||||
farm_timer = 4;
|
||||
break;
|
||||
case 21: // temperatures
|
||||
SERIAL_ECHO("{");
|
||||
|
@ -3195,29 +3199,29 @@ void prusa_statistics(int _message) {
|
|||
SERIAL_ECHOLN("}");
|
||||
break;
|
||||
case 22: // waiting for filament change
|
||||
SERIAL_ECHOLN("{[PRN:5]");
|
||||
SERIAL_ECHO("{[PRN:5]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
status_number = 5;
|
||||
break;
|
||||
|
||||
case 90: // Error - Thermal Runaway
|
||||
SERIAL_ECHOLN("{[ERR:1]");
|
||||
SERIAL_ECHO("{[ERR:1]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
break;
|
||||
case 91: // Error - Thermal Runaway Preheat
|
||||
SERIAL_ECHOLN("{[ERR:2]");
|
||||
SERIAL_ECHO("{[ERR:2]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
break;
|
||||
case 92: // Error - Min temp
|
||||
SERIAL_ECHOLN("{[ERR:3]");
|
||||
SERIAL_ECHO("{[ERR:3]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
break;
|
||||
case 93: // Error - Max temp
|
||||
SERIAL_ECHOLN("{[ERR:4]");
|
||||
SERIAL_ECHO("{[ERR:4]");
|
||||
prusa_stat_farm_number();
|
||||
SERIAL_ECHOLN("}");
|
||||
break;
|
||||
|
@ -5286,14 +5290,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);
|
||||
|
@ -5301,8 +5390,7 @@ void lcd_confirm_print()
|
|||
|
||||
do
|
||||
{
|
||||
|
||||
if (abs((enc_dif - encoderDiff)) > 2) {
|
||||
if (abs(enc_dif - encoderDiff) > 12) {
|
||||
if (enc_dif > encoderDiff) {
|
||||
cursor_pos--;
|
||||
}
|
||||
|
@ -5310,6 +5398,7 @@ void lcd_confirm_print()
|
|||
if (enc_dif < encoderDiff) {
|
||||
cursor_pos++;
|
||||
}
|
||||
enc_dif = encoderDiff;
|
||||
}
|
||||
|
||||
if (cursor_pos > 2) { cursor_pos = 2; }
|
||||
|
@ -5336,19 +5425,28 @@ void lcd_confirm_print()
|
|||
if (cursor_pos == 1)
|
||||
{
|
||||
_ret = 1;
|
||||
prusa_statistics(20);
|
||||
prusa_statistics(4);
|
||||
filament_type = lcd_choose_color();
|
||||
prusa_statistics(4, filament_type);
|
||||
no_response = true; //we need confirmation by recieving PRUSA thx
|
||||
important_status = 4;
|
||||
saved_filament_type = filament_type;
|
||||
NcTime = millis();
|
||||
}
|
||||
if (cursor_pos == 2)
|
||||
{
|
||||
_ret = 2;
|
||||
prusa_statistics(20);
|
||||
prusa_statistics(5);
|
||||
filament_type = lcd_choose_color();
|
||||
prusa_statistics(5, filament_type);
|
||||
no_response = true; //we need confirmation by recieving PRUSA thx
|
||||
important_status = 5;
|
||||
saved_filament_type = filament_type;
|
||||
NcTime = millis();
|
||||
}
|
||||
}
|
||||
|
||||
manage_heater();
|
||||
manage_inactivity();
|
||||
proc_commands();
|
||||
|
||||
} while (_ret == 0);
|
||||
|
||||
|
@ -7301,6 +7399,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
|
|||
if (stepper_timer_overflow_state) stepper_timer_overflow();
|
||||
#endif /* DEBUG_STEPPER_TIMER_MISSED */
|
||||
lcd_ping(); //check that we have received ping command if we are in farm mode
|
||||
lcd_send_status();
|
||||
if (lcd_commands_type == LCD_COMMAND_V2_CAL) lcd_commands();
|
||||
}
|
||||
|
||||
|
@ -7308,6 +7407,49 @@ void lcd_printer_connected() {
|
|||
printer_connected = true;
|
||||
}
|
||||
|
||||
static void lcd_send_status() {
|
||||
if (farm_mode && no_response && ((millis() - NcTime) > (NC_TIME * 1000))) {
|
||||
//send important status messages periodicaly
|
||||
prusa_statistics(important_status, saved_filament_type);
|
||||
NcTime = millis();
|
||||
lcd_connect_printer();
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_connect_printer() {
|
||||
lcd_update_enable(false);
|
||||
lcd_implementation_clear();
|
||||
|
||||
bool pressed = false;
|
||||
int i = 0;
|
||||
int t = 0;
|
||||
lcd_set_custom_characters_progress();
|
||||
lcd_implementation_print_at(0, 0, "Connect printer to");
|
||||
lcd_implementation_print_at(0, 1, "monitoring or hold");
|
||||
lcd_implementation_print_at(0, 2, "the knob to continue");
|
||||
while (no_response) {
|
||||
i++;
|
||||
t++;
|
||||
delay_keep_alive(100);
|
||||
proc_commands();
|
||||
if (t == 10) {
|
||||
prusa_statistics(important_status, saved_filament_type);
|
||||
t = 0;
|
||||
}
|
||||
if (READ(BTN_ENC)) { //if button is not pressed
|
||||
i = 0;
|
||||
lcd_implementation_print_at(0, 3, " ");
|
||||
}
|
||||
if (i!=0) lcd_implementation_print_at((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\x01");
|
||||
if (i == NC_BUTTON_LONG_PRESS * 10) {
|
||||
no_response = false;
|
||||
}
|
||||
}
|
||||
lcd_set_custom_characters_degree();
|
||||
lcd_update_enable(true);
|
||||
lcd_update(2);
|
||||
}
|
||||
|
||||
void lcd_ping() { //chceck if printer is connected to monitoring when in farm mode
|
||||
if (farm_mode) {
|
||||
bool empty = is_buffer_empty();
|
||||
|
@ -7843,4 +7985,4 @@ void copy_and_scalePID_d()
|
|||
}
|
||||
*/
|
||||
|
||||
#endif //ULTRA_LCD
|
||||
#endif //ULTRA_LCD
|
|
@ -29,8 +29,9 @@
|
|||
void lcd_sdcard_stop();
|
||||
void lcd_sdcard_pause();
|
||||
void lcd_print_stop();
|
||||
void prusa_statistics(int _message);
|
||||
void prusa_statistics(int _message, uint8_t _col_nr = 0);
|
||||
void lcd_confirm_print();
|
||||
unsigned char lcd_choose_color();
|
||||
void lcd_mylang();
|
||||
bool lcd_detected(void);
|
||||
|
||||
|
@ -291,4 +292,7 @@ void lcd_service_mode_show_result();
|
|||
void lcd_wizard();
|
||||
void lcd_wizard(int state);
|
||||
|
||||
static void lcd_send_status();
|
||||
static void lcd_connect_printer();
|
||||
|
||||
#endif //ULTRALCD_H
|
|
@ -875,39 +875,38 @@ if (print_sd_status)
|
|||
|
||||
{
|
||||
if(strlen(card.longFilename) > LCD_WIDTH)
|
||||
{
|
||||
{
|
||||
|
||||
int inters = 0;
|
||||
int gh = scrollstuff;
|
||||
while( ((gh-scrollstuff)<LCD_WIDTH) && (inters == 0) )
|
||||
{
|
||||
|
||||
if(card.longFilename[gh] == '\0')
|
||||
{
|
||||
lcd.setCursor(gh-scrollstuff, 3);
|
||||
lcd.print(card.longFilename[gh-1]);
|
||||
scrollstuff = 0;
|
||||
gh = scrollstuff;
|
||||
inters = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.setCursor(gh-scrollstuff, 3);
|
||||
lcd.print(card.longFilename[gh-1]);
|
||||
gh++;
|
||||
}
|
||||
int inters = 0;
|
||||
int gh = scrollstuff;
|
||||
while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
scrollstuff++;
|
||||
if (card.longFilename[gh] == '\0')
|
||||
{
|
||||
lcd.setCursor(gh - scrollstuff, 3);
|
||||
lcd.print(card.longFilename[gh - 1]);
|
||||
scrollstuff = 0;
|
||||
gh = scrollstuff;
|
||||
inters = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.setCursor(gh - scrollstuff, 3);
|
||||
lcd.print(card.longFilename[gh - 1]);
|
||||
gh++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
scrollstuff++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd.print(longFilenameOLD);
|
||||
else
|
||||
{
|
||||
lcd.print(longFilenameOLD);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// If not, check for other special events
|
||||
else
|
||||
{
|
||||
|
@ -1408,6 +1407,7 @@ static uint8_t lcd_implementation_read_slow_buttons()
|
|||
// Reading these buttons this is likely to be too slow to call inside interrupt context
|
||||
// so they are called during normal lcd_update
|
||||
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
|
||||
|
||||
#if defined(LCD_I2C_VIKI)
|
||||
if(slow_buttons & (B_MI|B_RI)) { //LCD clicked
|
||||
if(blocking_enc > millis()) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue