Skip to content

Commit

Permalink
misc. inspection cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 3, 2021
1 parent 0923c13 commit 96c882e
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 603 deletions.
6 changes: 1 addition & 5 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
// Echo the LCD message to serial for extra context
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }

#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD)
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
#else
UNUSED(lcd_error); UNUSED(lcd_component);
#endif
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);

TERN_(HAS_TFT_LVGL_UI, lv_draw_error_message(lcd_error));

Expand Down
1 change: 1 addition & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@

#define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)"
#define STR_WRONG_PASSWORD "Incorrect Password"
#define STR_PASSWORD_REQUIRED "Password required"
#define STR_PASSWORD_TOO_LONG "Password too long"
#define STR_PASSWORD_REMOVED "Password removed"
#define STR_REMINDER_SAVE_SETTINGS "Remember to save!"
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/sd/M1001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void GcodeSuite::M1001() {
gcode.process_subcommands_now_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif

TERN_(DWIN_CREALITY_LCD, DWIN_Stop_Print());
TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
TERN_(DWIN_CREALITY_LCD, DWIN_Print_Finished());

// Re-select the last printed file in the UI
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
Expand Down
73 changes: 53 additions & 20 deletions Marlin/src/gcode/stats/M75-M78.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
*/
void GcodeSuite::M75() {
startOrResumeJob();

TERN_(DWIN_CREALITY_LCD, DWIN_Print_Header((parser.string_arg && parser.string_arg[0]) ? parser.string_arg : (char*)"Host Print"));
TERN_(DWIN_CREALITY_LCD, DWIN_Start_Print(false));
#if ENABLED(DWIN_CREALITY_LCD)
DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
DWIN_Print_Started(false);
#endif
}

/**
Expand All @@ -52,30 +53,62 @@ void GcodeSuite::M76() {
*/
void GcodeSuite::M77() {
print_job_timer.stop();
TERN_(DWIN_CREALITY_LCD, DWIN_Stop_Print());
TERN_(DWIN_CREALITY_LCD, DWIN_Print_Finished());
}

#if ENABLED(PRINTCOUNTER)

/**
* M78: Show print statistics
*/
void GcodeSuite::M78() {
if (parser.intval('S') == 78) { // "M78 S78" will reset the statistics
print_job_timer.initStats();
ui.reset_status();
return;
}
#if ENABLED(PASSWORD_FEATURE)
#include "../../feature/password/password.h"
#endif

#if HAS_SERVICE_INTERVALS
if (parser.seenval('R')) {
print_job_timer.resetServiceInterval(parser.value_int());
/**
* M78: Show print statistics
*
* Parameters:
*
* S78 Use M78 S78 to reset all statistics
*
* With SERVICE_INTERVALS:
*
* R<index> Reset service interval 1, 2, or 3 so warnings won't
* appear until the next service interval expires.
*
* With PASSWORD_FEATURE:
*
* P<passcode> - The correct passcode is required for reset.
*/
void GcodeSuite::M78() {
const bool reset_all = parser.intval('S') == 78,
reset_some = TERN0(HAS_SERVICE_INTERVALS, parser.seenval('R'));

#if ENABLED(PASSWORD_FEATURE)
bool authorized = false;
if ((reset_all || reset_some) && password.is_set) {
if (!parser.seenval('P'))
SERIAL_ECHOLNPGM(STR_PASSWORD_REQUIRED);
else if (parser.value_ulong() != password.value)
SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD);
else
authorized = true;
}
#else
constexpr bool authorized = true;
#endif

if (authorized && reset_all) { // "M78 S78" will reset the statistics
print_job_timer.initStats();
ui.reset_status();
return;
}
#endif

print_job_timer.showStats();
}
#if HAS_SERVICE_INTERVALS
if (authorized && parser.seenval('R')) {
print_job_timer.resetServiceInterval(parser.value_int());
ui.reset_status();
}
#endif

print_job_timer.showStats();
}

#endif // PRINTCOUNTER
39 changes: 18 additions & 21 deletions Marlin/src/lcd/dwin/dwin_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ void DWIN_Draw_CenteredString(bool widthAdjust, bool bShow, uint8_t size,
DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, string);
}


// Draw a positive integer
// bShow: true=display background color; false=don't display background color
// zeroFill: true=zero fill; false=no zero fill
Expand Down Expand Up @@ -445,26 +444,24 @@ void DWIN_ICON_AnimationControl(uint16_t state) {
DWIN_Send(i);
}

//Draw a circle
//Color: circle color
//x: the abscissa of the center of the circle
//y: ordinate of the center of the circle
//r: circle radius
void DWIN_Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r) {
int a,b;
a=b=0;
while(a<=b) {
b=sqrt(r*r-a*a);
while(a==0){ b=b-1;break;}
DWIN_Draw_Point(color, 1,1,x+a,y+b); //Draw some sector 1
DWIN_Draw_Point(color, 1,1,x+b,y+a); //Draw some sector 2
DWIN_Draw_Point(color, 1,1,x+b,y-a); //Draw some sector 3
DWIN_Draw_Point(color, 1,1,x+a,y-b); //Draw some sector 4

DWIN_Draw_Point(color, 1,1,x-a,y-b); //Draw some sector 5
DWIN_Draw_Point(color, 1,1,x-b,y-a); //Draw some sector 6
DWIN_Draw_Point(color, 1,1,x-b,y+a); //Draw some sector 7
DWIN_Draw_Point(color, 1,1,x-a,y+b); //Draw some sector 8
// Draw a circle
// Color: circle color
// x: the abscissa of the center of the circle
// y: ordinate of the center of the circle
// r: circle radius
void DWIN_Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
int a = 0, b = 0;
while (a <= b) {
b = HYPOT(r, a);
if (a == 0) b--;
DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1
DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2
DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3
DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4
DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5
DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6
DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7
DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8
a++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dwin/dwin_lcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t pi
// state: 16 bits, each bit is the state of an animation id
void DWIN_ICON_AnimationControl(uint16_t state);

//Draw a circle
// Draw a circle
void DWIN_Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);

// GUI extension
Expand Down
Loading

0 comments on commit 96c882e

Please sign in to comment.