Skip to content

Commit 96c882e

Browse files
committed
misc. inspection cleanup
1 parent 0923c13 commit 96c882e

File tree

14 files changed

+440
-603
lines changed

14 files changed

+440
-603
lines changed

Marlin/src/MarlinCore.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
829829
// Echo the LCD message to serial for extra context
830830
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
831831

832-
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD)
833-
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
834-
#else
835-
UNUSED(lcd_error); UNUSED(lcd_component);
836-
#endif
832+
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
837833

838834
TERN_(HAS_TFT_LVGL_UI, lv_draw_error_message(lcd_error));
839835

Marlin/src/core/language.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254

255255
#define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)"
256256
#define STR_WRONG_PASSWORD "Incorrect Password"
257+
#define STR_PASSWORD_REQUIRED "Password required"
257258
#define STR_PASSWORD_TOO_LONG "Password too long"
258259
#define STR_PASSWORD_REMOVED "Password removed"
259260
#define STR_REMINDER_SAVE_SETTINGS "Remember to save!"

Marlin/src/gcode/sd/M1001.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ void GcodeSuite::M1001() {
109109
gcode.process_subcommands_now_P(PSTR(SD_FINISHED_RELEASECOMMAND));
110110
#endif
111111

112-
TERN_(DWIN_CREALITY_LCD, DWIN_Stop_Print());
113112
TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished());
113+
TERN_(DWIN_CREALITY_LCD, DWIN_Print_Finished());
114114

115115
// Re-select the last printed file in the UI
116116
TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());

Marlin/src/gcode/stats/M75-M78.cpp

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
*/
3636
void GcodeSuite::M75() {
3737
startOrResumeJob();
38-
39-
TERN_(DWIN_CREALITY_LCD, DWIN_Print_Header((parser.string_arg && parser.string_arg[0]) ? parser.string_arg : (char*)"Host Print"));
40-
TERN_(DWIN_CREALITY_LCD, DWIN_Start_Print(false));
38+
#if ENABLED(DWIN_CREALITY_LCD)
39+
DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT));
40+
DWIN_Print_Started(false);
41+
#endif
4142
}
4243

4344
/**
@@ -52,30 +53,62 @@ void GcodeSuite::M76() {
5253
*/
5354
void GcodeSuite::M77() {
5455
print_job_timer.stop();
55-
TERN_(DWIN_CREALITY_LCD, DWIN_Stop_Print());
56+
TERN_(DWIN_CREALITY_LCD, DWIN_Print_Finished());
5657
}
5758

5859
#if ENABLED(PRINTCOUNTER)
5960

60-
/**
61-
* M78: Show print statistics
62-
*/
63-
void GcodeSuite::M78() {
64-
if (parser.intval('S') == 78) { // "M78 S78" will reset the statistics
65-
print_job_timer.initStats();
66-
ui.reset_status();
67-
return;
68-
}
61+
#if ENABLED(PASSWORD_FEATURE)
62+
#include "../../feature/password/password.h"
63+
#endif
6964

70-
#if HAS_SERVICE_INTERVALS
71-
if (parser.seenval('R')) {
72-
print_job_timer.resetServiceInterval(parser.value_int());
65+
/**
66+
* M78: Show print statistics
67+
*
68+
* Parameters:
69+
*
70+
* S78 Use M78 S78 to reset all statistics
71+
*
72+
* With SERVICE_INTERVALS:
73+
*
74+
* R<index> Reset service interval 1, 2, or 3 so warnings won't
75+
* appear until the next service interval expires.
76+
*
77+
* With PASSWORD_FEATURE:
78+
*
79+
* P<passcode> - The correct passcode is required for reset.
80+
*/
81+
void GcodeSuite::M78() {
82+
const bool reset_all = parser.intval('S') == 78,
83+
reset_some = TERN0(HAS_SERVICE_INTERVALS, parser.seenval('R'));
84+
85+
#if ENABLED(PASSWORD_FEATURE)
86+
bool authorized = false;
87+
if ((reset_all || reset_some) && password.is_set) {
88+
if (!parser.seenval('P'))
89+
SERIAL_ECHOLNPGM(STR_PASSWORD_REQUIRED);
90+
else if (parser.value_ulong() != password.value)
91+
SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD);
92+
else
93+
authorized = true;
94+
}
95+
#else
96+
constexpr bool authorized = true;
97+
#endif
98+
99+
if (authorized && reset_all) { // "M78 S78" will reset the statistics
100+
print_job_timer.initStats();
73101
ui.reset_status();
74-
return;
75102
}
76-
#endif
77103

78-
print_job_timer.showStats();
79-
}
104+
#if HAS_SERVICE_INTERVALS
105+
if (authorized && parser.seenval('R')) {
106+
print_job_timer.resetServiceInterval(parser.value_int());
107+
ui.reset_status();
108+
}
109+
#endif
110+
111+
print_job_timer.showStats();
112+
}
80113

81114
#endif // PRINTCOUNTER

Marlin/src/lcd/dwin/dwin_lcd.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ void DWIN_Draw_CenteredString(bool widthAdjust, bool bShow, uint8_t size,
255255
DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, string);
256256
}
257257

258-
259258
// Draw a positive integer
260259
// bShow: true=display background color; false=don't display background color
261260
// zeroFill: true=zero fill; false=no zero fill
@@ -445,26 +444,24 @@ void DWIN_ICON_AnimationControl(uint16_t state) {
445444
DWIN_Send(i);
446445
}
447446

448-
//Draw a circle
449-
//Color: circle color
450-
//x: the abscissa of the center of the circle
451-
//y: ordinate of the center of the circle
452-
//r: circle radius
453-
void DWIN_Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r) {
454-
int a,b;
455-
a=b=0;
456-
while(a<=b) {
457-
b=sqrt(r*r-a*a);
458-
while(a==0){ b=b-1;break;}
459-
DWIN_Draw_Point(color, 1,1,x+a,y+b); //Draw some sector 1
460-
DWIN_Draw_Point(color, 1,1,x+b,y+a); //Draw some sector 2
461-
DWIN_Draw_Point(color, 1,1,x+b,y-a); //Draw some sector 3
462-
DWIN_Draw_Point(color, 1,1,x+a,y-b); //Draw some sector 4
463-
464-
DWIN_Draw_Point(color, 1,1,x-a,y-b); //Draw some sector 5
465-
DWIN_Draw_Point(color, 1,1,x-b,y-a); //Draw some sector 6
466-
DWIN_Draw_Point(color, 1,1,x-b,y+a); //Draw some sector 7
467-
DWIN_Draw_Point(color, 1,1,x-a,y+b); //Draw some sector 8
447+
// Draw a circle
448+
// Color: circle color
449+
// x: the abscissa of the center of the circle
450+
// y: ordinate of the center of the circle
451+
// r: circle radius
452+
void DWIN_Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) {
453+
int a = 0, b = 0;
454+
while (a <= b) {
455+
b = HYPOT(r, a);
456+
if (a == 0) b--;
457+
DWIN_Draw_Point(color, 1, 1, x + a, y + b); // Draw some sector 1
458+
DWIN_Draw_Point(color, 1, 1, x + b, y + a); // Draw some sector 2
459+
DWIN_Draw_Point(color, 1, 1, x + b, y - a); // Draw some sector 3
460+
DWIN_Draw_Point(color, 1, 1, x + a, y - b); // Draw some sector 4
461+
DWIN_Draw_Point(color, 1, 1, x - a, y - b); // Draw some sector 5
462+
DWIN_Draw_Point(color, 1, 1, x - b, y - a); // Draw some sector 6
463+
DWIN_Draw_Point(color, 1, 1, x - b, y + a); // Draw some sector 7
464+
DWIN_Draw_Point(color, 1, 1, x - a, y + b); // Draw some sector 8
468465
a++;
469466
}
470467
}

Marlin/src/lcd/dwin/dwin_lcd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t pi
230230
// state: 16 bits, each bit is the state of an animation id
231231
void DWIN_ICON_AnimationControl(uint16_t state);
232232

233-
//Draw a circle
233+
// Draw a circle
234234
void DWIN_Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
235235

236236
// GUI extension

0 commit comments

Comments
 (0)