Farm monitoring

This commit is contained in:
akukan 2016-07-20 15:02:52 +02:00
parent ea6a948c6b
commit 1b2676baac
5 changed files with 416 additions and 47 deletions

View File

@ -31,6 +31,7 @@
// The offsets are saved as 16bit signed int, scaled to tenths of microns.
#define EEPROM_BED_CALIBRATION_Z_JITTER (EEPROM_BED_CALIBRATION_VEC_Y-2*8)
#define EEPROM_FARM_MODE (EEPROM_BED_CALIBRATION_Z_JITTER-4)
// Currently running firmware, each digit stored as uint16_t.
// The flavor differentiates a dev, alpha, beta, release candidate or a release version.

View File

@ -255,7 +255,7 @@ int extruder_multiply[EXTRUDERS] = {100
};
bool is_usb_printing = false;
bool _doMeshL = false;
unsigned int usb_printing_counter;
int lcd_change_fil_state = 0;
@ -933,22 +933,58 @@ void setup()
world2machine_reset();
lcd_init();
if(!READ(BTN_ENC) ){
_delay_ms(1000);
if(!READ(BTN_ENC) ){
SET_OUTPUT(BEEPER);
if (!READ(BTN_ENC))
{
_delay_ms(1000);
if (!READ(BTN_ENC))
{
SET_OUTPUT(BEEPER);
WRITE(BEEPER, HIGH);
WRITE(BEEPER,HIGH);
lcd_force_language_selection();
while(!READ(BTN_ENC));
lcd_force_language_selection();
farm_no = 0;
EEPROM_save_B(EEPROM_FARM_MODE, &farm_no);
farm_mode = false;
WRITE(BEEPER,LOW);
while (!READ(BTN_ENC));
}
}else{
_delay_ms(1000); // wait 1sec to display the splash screen
WRITE(BEEPER, LOW);
#ifdef MESH_BED_LEVELING
_delay_ms(2000);
if (!READ(BTN_ENC))
{
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
_delay_ms(200);
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
int _z = 0;
eeprom_write_byte((unsigned char*)EEPROM_BABYSTEP_Z_SET, 0x01);
EEPROM_save_B(EEPROM_BABYSTEP_X, &_z);
EEPROM_save_B(EEPROM_BABYSTEP_Y, &_z);
EEPROM_save_B(EEPROM_BABYSTEP_Z, &_z);
}
else
{
WRITE(BEEPER, HIGH);
_delay_ms(100);
WRITE(BEEPER, LOW);
}
#endif // mesh
}
}
else
{
_delay_ms(1000); // wait 1sec to display the splash screen
}
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
@ -964,6 +1000,20 @@ void setup()
enable_z();
#endif
EEPROM_read_B(EEPROM_FARM_MODE, &farm_no);
if (farm_no > 0)
{
farm_mode = true;
farm_no = farm_no;
prusa_statistics(8);
}
else
{
farm_mode = false;
farm_no = 0;
}
// In the future, somewhere here would one compare the current firmware version against the firmware version stored in the EEPROM.
// If they differ, an update procedure may need to be performed. At the end of this block, the current firmware version
// is being written into the EEPROM, so the update procedure will be triggered only once.
@ -1217,6 +1267,12 @@ void get_command()
card.printingHasFinished();
card.checkautostart(true);
if (farm_mode)
{
prusa_statistics(6);
lcd_commands_type = 4;
}
}
if(serial_char=='#')
stop_buffering=true;
@ -1833,7 +1889,7 @@ void process_commands()
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
#endif //ENABLE_AUTO_BED_LEVELING
_doMeshL = false;
// For mesh bed leveling deactivate the matrix temporarily
#ifdef MESH_BED_LEVELING
mbl.active = 0;
@ -1905,11 +1961,7 @@ void process_commands()
}
#endif /* QUICK_HOME */
if (home_all_axis)
{
_doMeshL = true;
}
if((home_all_axis) || (code_seen(axis_codes[X_AXIS])))
homeaxis(X_AXIS);
@ -1955,7 +2007,6 @@ void process_commands()
enable_endstops(true);
endstops_hit_on_purpose();
homeaxis(Z_AXIS);
_doMeshL = true;
#else // MESH_BED_LEVELING
homeaxis(Z_AXIS);
#endif // MESH_BED_LEVELING
@ -2042,22 +2093,21 @@ void process_commands()
world2machine_update_current();
#ifdef MESH_BED_LEVELING
if (code_seen('W'))
{
_doMeshL = false;
SERIAL_ECHOLN("G80 disabled");
}
if ( _doMeshL)
{
st_synchronize();
// Push the commands to the front of the message queue in the reverse order!
// There shall be always enough space reserved for these commands.
// enquecommand_front_P((PSTR("G80")));
goto case_G80;
if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS]))
{
}
else
{
st_synchronize();
// Push the commands to the front of the message queue in the reverse order!
// There shall be always enough space reserved for these commands.
// enquecommand_front_P((PSTR("G80")));
goto case_G80;
}
#endif
if (farm_mode) { prusa_statistics(20); };
break;
#ifdef ENABLE_AUTO_BED_LEVELING
@ -2502,6 +2552,25 @@ void process_commands()
}
}
break;
case 98:
farm_no = 21;
EEPROM_save_B(EEPROM_FARM_MODE, &farm_no);
farm_mode = true;
break;
case 99:
farm_no = 0;
EEPROM_save_B(EEPROM_FARM_MODE, &farm_no);
farm_mode = false;
break;
}
} // end if(code_seen('G'))
@ -3175,6 +3244,7 @@ Sigma_Exit:
}
LCD_MESSAGERPGM(MSG_HEATING);
heating_status = 1;
if (farm_mode) { prusa_statistics(1); };
#ifdef AUTOTEMP
autotemp_enabled=false;
@ -3253,6 +3323,7 @@ Sigma_Exit:
}
LCD_MESSAGERPGM(MSG_HEATING_COMPLETE);
heating_status = 2;
if (farm_mode) { prusa_statistics(2); };
starttime=millis();
previous_millis_cmd = millis();
@ -3262,7 +3333,7 @@ Sigma_Exit:
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
LCD_MESSAGERPGM(MSG_BED_HEATING);
heating_status = 3;
if (farm_mode) { prusa_statistics(1); };
if (code_seen('S'))
{
setTargetBed(code_value());

View File

@ -39,6 +39,10 @@ int8_t SilentModeMenu = 0;
int lcd_commands_type=0;
int lcd_commands_step=0;
bool isPrintPaused = false;
bool farm_mode = false;
int farm_no = 0;
int farm_timer = 30;
int farm_status = 0;
bool menuExiting = false;
@ -114,6 +118,11 @@ static void lcd_control_temperature_preheat_abs_settings_menu();
static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu();
static void prusa_stat_printerstatus(int _status);
static void prusa_stat_temperatures();
static void prusa_stat_printinfo();
static void lcd_farm_no();
#ifdef DOGLCD
static void lcd_set_contrast();
#endif
@ -340,7 +349,27 @@ static void lcd_status_screen()
lcd_implementation_status_screen();
//lcd_implementation_clear();
if (farm_mode)
{
farm_timer--;
if (farm_timer < 1)
{
farm_timer = 90;
prusa_statistics(0);
}
switch (farm_timer)
{
case 45:
prusa_statistics(21);
break;
case 10:
if (IS_SD_PRINTING)
{
prusa_statistics(20);
}
break;
}
}
@ -504,6 +533,7 @@ void lcd_commands()
if (lcd_commands_step == 4 && !blocks_queued())
{
enquecommand_P(PSTR("G90"));
enquecommand_P(PSTR("M83"));
#ifdef X_CANCEL_POS
enquecommand_P(PSTR("G1 X" STRINGIFY(X_CANCEL_POS) " Y" STRINGIFY(Y_CANCEL_POS) " E0 F7000"));
#else
@ -924,7 +954,7 @@ static void lcd_menu_statistics()
int _t = (millis() - starttime) / 1000;
int _h = _t / 3600;
int _m = (_t - (_h * 60)) / 60;
int _m = (_t - (_h * 3600)) / 60;
int _s = _t - ((_h * 3600) + (_m * 60));
lcd.setCursor(0, 0);
@ -1486,6 +1516,148 @@ void lcd_diag_show_end_stops()
lcd_return_to_status();
}
void prusa_statistics(int _message) {
switch (_message)
{
case 0: // default message
if (IS_SD_PRINTING)
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(4);
prusa_stat_printinfo();
SERIAL_ECHOLN("}");
}
else
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(1);
SERIAL_ECHOLN("}");
}
break;
case 1: // 1 heating
farm_status = 2;
SERIAL_ECHO("{");
prusa_stat_printerstatus(2);
SERIAL_ECHOLN("}");
farm_timer = 1;
break;
case 2: // heating done
farm_status = 3;
SERIAL_ECHO("{");
prusa_stat_printerstatus(3);
SERIAL_ECHOLN("}");
farm_timer = 1;
if (IS_SD_PRINTING)
{
farm_status = 4;
SERIAL_ECHO("{");
prusa_stat_printerstatus(4);
SERIAL_ECHOLN("}");
}
else
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(3);
SERIAL_ECHOLN("}");;
}
farm_timer = 1;
break;
case 3: // filament change
break;
case 4: // print succesfull
SERIAL_ECHOLN("{[RES:1]}");
farm_timer = 2;
break;
case 5: // print not succesfull
SERIAL_ECHOLN("{[RES:0]}");
farm_timer = 2;
break;
case 6: // print done
SERIAL_ECHOLN("{[PRN:8]}");
farm_timer = 2;
break;
case 7: // print done - stopped
SERIAL_ECHOLN("{[PRN:9]}");
farm_timer = 2;
break;
case 8: // printer started
SERIAL_ECHO("{[PRN:0][PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHOLN("]}");
farm_timer = 2;
break;
case 20: // echo farm no
SERIAL_ECHO("{[PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHOLN("]}");
farm_timer = 5;
break;
case 21: // temperatures
SERIAL_ECHO("{");
prusa_stat_temperatures();
SERIAL_ECHOLN("}");
break;
case 99: // heartbeat
SERIAL_ECHOLN("{[PRN:99]}");
break;
}
}
static void prusa_stat_printerstatus(int _status)
{
SERIAL_ECHO("[PRN:");
SERIAL_ECHO(_status);
SERIAL_ECHO("]");
}
static void prusa_stat_temperatures()
{
SERIAL_ECHO("[ST0:");
SERIAL_ECHO(target_temperature[0]);
SERIAL_ECHO("][STB:");
SERIAL_ECHO(target_temperature_bed);
SERIAL_ECHO("][AT0:");
SERIAL_ECHO(current_temperature[0]);
SERIAL_ECHO("][ATB:");
SERIAL_ECHO(current_temperature_bed);
SERIAL_ECHO("]");
}
static void prusa_stat_printinfo()
{
SERIAL_ECHO("[TFU:");
SERIAL_ECHO(total_filament_used);
SERIAL_ECHO("][PCD:");
SERIAL_ECHO(itostr3(card.percentDone()));
SERIAL_ECHO("][FEM:");
SERIAL_ECHO(itostr3(feedmultiply));
SERIAL_ECHO("][FNM:");
SERIAL_ECHO(longFilenameOLD);
SERIAL_ECHO("][TIM:");
if (starttime != 0)
{
SERIAL_ECHO(millis() / 1000 - starttime / 1000);
}
else
{
SERIAL_ECHO(0);
}
SERIAL_ECHO("][FWR:");
SERIAL_ECHO(FW_version);
SERIAL_ECHO("]");
}
void lcd_pick_babystep(){
int enc_dif = 0;
int cursor_pos = 1;
@ -1732,7 +1904,10 @@ static void lcd_settings_menu()
MENU_ITEM(submenu, MSG_CALIBRATE_BED, lcd_mesh_calibration);
MENU_ITEM(gcode, MSG_CALIBRATE_BED_RESET, PSTR("M44"));
}
if (farm_mode)
{
MENU_ITEM(submenu, PSTR("Farm number"), lcd_farm_no);
}
END_MENU();
}
/*
@ -1920,6 +2095,123 @@ void lcd_mylang() {
static void lcd_farm_no()
{
int enc_dif = 0;
int _farmno = farm_no;
int _ret = 0;
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd.print("Farm no");
do
{
if (abs((enc_dif - encoderDiff)) > 2) {
if (enc_dif > encoderDiff) {
_farmno--;
}
if (enc_dif < encoderDiff) {
_farmno++;
}
enc_dif = 0;
encoderDiff = 0;
}
if (_farmno > 254) { _farmno = 1; }
if (_farmno < 1) { _farmno = 254; }
lcd.setCursor(0, 2);
lcd.print(_farmno);
lcd.print(" ");
delay(100);
if (lcd_clicked())
{
_ret = 1;
farm_no = _farmno;
EEPROM_save_B(EEPROM_FARM_MODE, &farm_no);
prusa_statistics(20);
lcd_return_to_status();
}
manage_heater();
} while (_ret == 0);
}
void lcd_confirm_print()
{
int enc_dif = 0;
int cursor_pos = 1;
int _ret = 0;
int _t = 0;
lcd_implementation_clear();
lcd.setCursor(0, 0);
lcd.print("Print ok ?");
do
{
if (abs((enc_dif - encoderDiff)) > 2) {
if (enc_dif > encoderDiff) {
cursor_pos--;
}
if (enc_dif < encoderDiff) {
cursor_pos++;
}
}
if (cursor_pos > 2) { cursor_pos = 2; }
if (cursor_pos < 1) { cursor_pos = 1; }
lcd.setCursor(0, 2); lcd.print(" ");
lcd.setCursor(0, 3); lcd.print(" ");
lcd.setCursor(2, 2);
lcd_printPGM(MSG_YES);
lcd.setCursor(2, 3);
lcd_printPGM(MSG_NO);
lcd.setCursor(0, 1 + cursor_pos);
lcd.print(">");
delay(100);
_t = _t + 1;
if (_t>100)
{
prusa_statistics(99);
_t = 0;
}
if (lcd_clicked())
{
if (cursor_pos == 1)
{
_ret = 1;
prusa_statistics(20);
prusa_statistics(4);
}
if (cursor_pos == 2)
{
_ret = 2;
prusa_statistics(20);
prusa_statistics(5);
}
}
manage_heater();
manage_inactivity();
} while (_ret == 0);
}
static void lcd_main_menu()
{

View File

@ -26,6 +26,8 @@
void lcd_loading_color();
void lcd_force_language_selection();
void lcd_sdcard_stop();
void prusa_statistics(int _message);
void lcd_confirm_print();
bool lcd_detected(void);
@ -76,6 +78,7 @@
#else
FORCE_INLINE void lcd_buttons_update() {}
#endif
extern int lcd_commands_type;
extern int plaPreheatHotendTemp;
extern int plaPreheatHPBTemp;
@ -85,6 +88,11 @@
extern int absPreheatHPBTemp;
extern int absPreheatFanSpeed;
extern bool farm_mode;
extern int farm_no;
extern int farm_timer;
extern int farm_status;
extern bool cancel_heatup;
#ifdef FILAMENT_LCD_DISPLAY

View File

@ -711,7 +711,12 @@ static void lcd_implementation_status_screen()
lcd.print('%');
}
}
lcd.print(" ");
if (farm_mode)
{
lcd.print(" F");
lcd.print(farm_no);
lcd.print(" ");
}
//Print time elapsed
lcd.setCursor(LCD_WIDTH - 8 -2, 2);
@ -885,15 +890,7 @@ static void lcd_implementation_status_screen()
lcd.print(' ');
}
}
if (is_usb_printing==1 && custom_message==0)
{
lcd.setCursor(0, 3);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd_printPGM(MSG_USB_PRINTING);
}
}