Commit 744b1137 authored by MagoKimbra's avatar MagoKimbra

Fix Serial Protocol

parent 93bf0686
......@@ -3385,7 +3385,7 @@ inline void gcode_G28() {
#if ENABLED(ULTIPANEL)
ECHO_LM(DB, "--LEVEL PLATE SCRIPT--");
while(!lcd_clicked()) {
idle(true);
idle();
}
saved_feedrate = feedrate;
saved_feedrate_multiplier = feedrate_multiplier;
......@@ -3425,7 +3425,7 @@ inline void gcode_G28() {
do_blocking_move_to(LEFT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
idle(true);
idle();
}
// PROBE SECOND POINT
......@@ -3434,7 +3434,7 @@ inline void gcode_G28() {
do_blocking_move_to(RIGHT_PROBE_BED_POSITION, FRONT_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
idle(true);
idle();
}
// PROBE THIRD POINT
......@@ -3443,7 +3443,7 @@ inline void gcode_G28() {
do_blocking_move_to(RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
idle(true);
idle();
}
// PROBE FOURTH POINT
......@@ -3452,7 +3452,7 @@ inline void gcode_G28() {
do_blocking_move_to(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
idle(true);
idle();
}
// PROBE CENTER
......@@ -3461,7 +3461,7 @@ inline void gcode_G28() {
do_blocking_move_to(((X_MAX_POS) - (X_MIN_POS)) / 2, ((Y_MAX_POS) - (Y_MIN_POS)) / 2, current_position[Z_AXIS]);
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_MIN_POS);
while(!lcd_clicked()) {
idle(true);
idle();
}
// FINISH MANUAL BED LEVEL
......@@ -6978,7 +6978,7 @@ inline void gcode_M503() {
KEEPALIVE_STATE(PAUSED_FOR_USER);
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
while (!lcd_clicked()) {
idle(true);
idle();
if ((millis() - last_set > 60000) && cnt <= FILAMENTCHANGE_PRINTEROFF) beep = true;
if (cnt >= FILAMENTCHANGE_PRINTEROFF && !sleep) {
disable_all_heaters();
......
/**
* MK 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* dogm_lcd_implementation.h
*
......@@ -7,7 +29,7 @@
*
* With the use of:
* u8glib by Oliver Kraus
* http://code.google.com/p/u8glib/
* https://github.com/olikraus/U8glib_Arduino
* License: http://opensource.org/licenses/BSD-3-Clause
*/
......@@ -173,7 +195,7 @@ char lcd_print(char c) {
return charset_mapper(c);
}
char lcd_print(char* str) {
char lcd_print(const char* str) {
char c;
int i = 0;
char n = 0;
......@@ -228,14 +250,14 @@ static void lcd_implementation_init() {
#endif
#if ENABLED(SHOW_BOOTSCREEN)
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
int offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2;
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
#endif
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * DOG_CHAR_WIDTH) / 2;
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
u8g.firstPage();
do {
......@@ -243,11 +265,11 @@ static void lcd_implementation_init() {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#if DISABLED(STRING_SPLASH_LINE2)
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT * 3 / 2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT * 1 / 2, STRING_SPLASH_LINE2);
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
#endif
}
} while (u8g.nextPage());
......@@ -261,6 +283,13 @@ static void lcd_implementation_init() {
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) {
int degsize = 6 * (temp >= 100 ? 3 : temp >= 10 ? 2 : 1); // number's pixel width
u8g.setPrintPos(x - (18 - degsize) / 2, y); // move left if shorter
lcd_print(itostr3(temp));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
}
static void _draw_heater_status(int x, int heater) {
bool isBed = heater < 0;
int y = 17 + (isBed ? 1 : 0);
......@@ -321,29 +350,30 @@ static void lcd_implementation_status_screen() {
// Symbols menu graphics, animated fan
u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp);
// Status Menu Font for SD info, Heater status, Fan, XYZ
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(SDSUPPORT)
// SD Card Symbol
u8g.drawBox(42, 42 - TALL_FONT_CORRECTION, 8, 7);
u8g.drawBox(50, 44 - TALL_FONT_CORRECTION, 2, 5);
u8g.drawFrame(42, 49 - TALL_FONT_CORRECTION, 10, 4);
u8g.drawPixel(50, 43 - TALL_FONT_CORRECTION);
u8g.drawBox(42, 42 - (TALL_FONT_CORRECTION), 8, 7);
u8g.drawBox(50, 44 - (TALL_FONT_CORRECTION), 2, 5);
u8g.drawFrame(42, 49 - (TALL_FONT_CORRECTION), 10, 4);
u8g.drawPixel(50, 43 - (TALL_FONT_CORRECTION));
// Progress bar frame
u8g.drawFrame(54, 49, 73, 4 - TALL_FONT_CORRECTION);
u8g.drawFrame(54, 49, 73, 4 - (TALL_FONT_CORRECTION));
// SD Card Progress bar and clock
lcd_setFont(FONT_STATUSMENU);
if (IS_SD_PRINTING) {
// Progress bar solid part
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION);
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - (TALL_FONT_CORRECTION));
}
u8g.setPrintPos(53, 47);
if (print_job_start_ms != 0) {
uint16_t time = print_job_timer.duration() / 60;
if (time != 0) {
#if HAS(LCD_POWER_SENSOR)
if (millis() < print_millis + 1000) {
uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
lcd_print('S');
lcd_print(itostr2(time/60));
......@@ -356,9 +386,9 @@ static void lcd_implementation_status_screen() {
u8g.print('E--:--');
else if (end_time > 0) {
u8g.print('E');
u8g.print(itostr2(end_time / 60));
u8g.print(itostr2(end_time/60));
u8g.print(':');
u8g.print(itostr2(end_time %60));
u8g.print(itostr2(end_time%60));
}
}
else {
......@@ -366,12 +396,11 @@ static void lcd_implementation_status_screen() {
lcd_print((char*)"Wh");
}
#else
uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
lcd_print('S');
lcd_print(itostr2(time / 60));
lcd_print(itostr2(time/60));
lcd_print(':');
lcd_print(itostr2(time %60));
lcd_print(itostr2(time%60));
u8g.setPrintPos(90, 47);
......@@ -379,9 +408,9 @@ static void lcd_implementation_status_screen() {
u8g.print('E--:--');
else if (end_time > 0) {
u8g.print('E');
u8g.print(itostr2(end_time / 60));
u8g.print(itostr2(end_time/60));
u8g.print(':');
u8g.print(itostr2(end_time %60));
u8g.print(itostr2(end_time%60));
}
#endif
}
......@@ -395,11 +424,12 @@ static void lcd_implementation_status_screen() {
// Hotends
for (int i = 0; i < HOTENDS; i++) _draw_heater_status(6 + i * 25, i);
// Heatbed
if (HOTENDS < 4) _draw_heater_status(81, -1);
// Heated bed
#if HOTENDS < 4 && HAS(TEMP_BED)
_draw_heater_status(81, -1);
#endif
// Fan
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(104, 27);
#if HAS(FAN)
int per = ((fanSpeed + 1) * 100) / 256;
......@@ -407,17 +437,13 @@ static void lcd_implementation_status_screen() {
lcd_print(itostr3(per));
lcd_print('%');
}
else
#endif
{
lcd_printPGM(PSTR("---"));
}
// Print XYZ Coordinates
// If the axis was not homed, show "---"
// If the position is untrusted, show "?"
// X, Y, Z-Coordinates
// Before homing the axis letters are blinking 'X' <-> '?'.
// When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
// When everything is ok you see a constant 'X'.
#define XYZ_BASELINE 38
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 10);
......@@ -461,20 +487,20 @@ static void lcd_implementation_status_screen() {
lcd_setFont(FONT_MENU);
u8g.setPrintPos(3, 49);
lcd_print(LCD_STR_FEEDRATE[0]);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(12, 49);
lcd_print(itostr3(feedrate_multiplier));
lcd_print('%');
// Status line
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
u8g.setPrintPos(0, 62);
#else
u8g.setPrintPos(0, 63);
#endif
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
if (millis() < previous_lcd_status_ms + 5000) //Display both Status message line and Filament display on the last line
if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) { //Display both Status message line and Filament display on the last line
lcd_print(lcd_status_message);
#if HAS(LCD_POWER_SENSOR)
#if HAS(LCD_FILAMENT_SENSOR)
......@@ -507,13 +533,13 @@ static void lcd_implementation_status_screen() {
static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
if (isSelected) {
u8g.setColorIndex(1); // black on white
u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3 - TALL_FONT_CORRECTION, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
u8g.drawBox(0, row * (DOG_CHAR_HEIGHT) + 3 - (TALL_FONT_CORRECTION), LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black
}
else {
u8g.setColorIndex(1); // unmarked text is black on white
}
u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
u8g.setPrintPos((START_ROW) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
}
static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
......@@ -527,7 +553,7 @@ static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, co
pstr++;
}
while (n--) lcd_print(' ');
u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
lcd_print(post_char);
lcd_print(' ');
}
......@@ -545,7 +571,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
}
lcd_print(':');
while (n--) lcd_print(' ');
u8g.setPrintPos(LCD_PIXEL_WIDTH - DOG_CHAR_WIDTH * vallen, (row + 1) * DOG_CHAR_HEIGHT);
u8g.setPrintPos(LCD_PIXEL_WIDTH - (DOG_CHAR_WIDTH) * vallen, (row + 1) * (DOG_CHAR_HEIGHT));
if (pgm) lcd_printPGM(data); else lcd_print((char*)data);
}
......@@ -592,14 +618,16 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
const float kHalfChar = (DOG_CHAR_HEIGHT_EDIT) / 2;
float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
u8g.setPrintPos(0, rowHeight + kHalfChar);
lcd_printPGM(pstr);
if (value != NULL) {
lcd_print(':');
u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
lcd_print(value);
}
}
#if ENABLED(SDSUPPORT)
......
......@@ -1716,7 +1716,7 @@ static void menu_action_function(menuFunc_t func) { (*func)(); }
char* c;
sprintf_P(cmd, PSTR("M23 %s"), longFilename);
for (c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueue_and_echo_command(cmd);
enqueue_and_echo_commands_P(PSTR("M24"));
lcd_return_to_status();
}
......
......@@ -726,11 +726,11 @@ static void lcd_implementation_status_screen() {
#endif // LCD_WIDTH > 19 && SDSUPPORT
lcd.setCursor(LCD_WIDTH - 6, 2);
if(print_job_start_ms != 0) {
uint16_t time = print_job_timer.duration() / 60;
if(time != 0) {
#if HAS(LCD_POWER_SENSOR)
if (millis() < print_millis + 1000) {
lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
......@@ -741,7 +741,6 @@ static void lcd_implementation_status_screen() {
}
#else
lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
......
......@@ -276,7 +276,7 @@
char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueue_and_echo_command(cmd);
enqueue_and_echo_commands_P(PSTR("M24"));
setpageInfo();
}
......@@ -647,7 +647,7 @@
NPlay.setPic(17);
// Estimate End Time
uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t time = print_job_timer.duration() / 60;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
if (end_time > (60 * 23)) {
lcd_setstatus("End --:--");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment