Skip to content

Commit 9632828

Browse files
Update - optimization
1 parent 32ae43d commit 9632828

File tree

11 files changed

+49
-85
lines changed

11 files changed

+49
-85
lines changed

Marlin/src/feature/bedlevel/abl/bbl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,12 @@ void LevelingBilinear::reset() {
111111
*/
112112
void LevelingBilinear::set_grid(const xy_pos_t& _grid_spacing, const xy_pos_t& _grid_start) {
113113
#if ENABLED(PROUI_MESH_EDIT)
114-
grid_start.x = MESH_MIN_X;
115-
grid_start.y = MESH_MIN_Y;
114+
UNUSED(_grid_spacing);
115+
UNUSED(_grid_start);
116116
grid_spacing.x = MESH_X_DIST;
117117
grid_spacing.y = MESH_Y_DIST;
118+
grid_start.x = MESH_MIN_X;
119+
grid_start.y = MESH_MIN_Y;
118120
#else
119121
grid_spacing = _grid_spacing;
120122
grid_start = _grid_start;

Marlin/src/feature/bedlevel/ubl/ubl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class unified_bed_leveling {
110110
static bool sanity_check();
111111
static void smart_mesh_fill();
112112

113-
static void G29() __O0; // O0 for no optimization
114-
static void smart_fill_wlsf(const float ) __O2; // O2 gives smaller code than Os on A2560
113+
static void G29() __O0; // O0 for no optimization
114+
static void smart_fill_wlsf(const float weight_factor) __Os; // O2 gives smaller code than Os on A2560
115115

116116
static int8_t storage_slot;
117117

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ void unified_bed_leveling::shift_mesh_height(const float zoffs) {
831831
#endif
832832
TERN_(DWIN_LCD_PROUI, MeshViewer.DrawMeshPoint(best.pos.x, best.pos.y, measured_z);)
833833
}
834-
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
834+
DEBUG_FLUSH(); // Prevent host M105 buffer overrun.
835835

836836
} while (best.pos.x >= 0 && --count);
837837

@@ -890,7 +890,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
890890
}
891891
}
892892
}
893-
serial_delay(15);
893+
DEBUG_DELAY(15);
894894
return false;
895895
}
896896

@@ -1032,7 +1032,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
10321032

10331033
if (param.V_verbosity > 2)
10341034
DEBUG_ECHOLNPGM("Mesh Point Measured at: ", p_float_t(z_values[lpos.x][lpos.y], 6));
1035-
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
1035+
DEBUG_FLUSH(); // Prevent host M105 buffer overrun.
10361036
} while (location.valid());
10371037

10381038
if (do_ubl_mesh_map) display_map(param.T_map_type); // show user where we're probing
@@ -1116,7 +1116,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
11161116
marlin.idle_no_sleep();
11171117
new_z = ui.ubl_mesh_value();
11181118
TERN_(UBL_MESH_EDIT_MOVES_Z, motion.blocking_move_z(h_offset + new_z)); // Move the nozzle as the point is edited
1119-
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
1119+
DEBUG_FLUSH(); // Prevent host M105 buffer overrun.
11201120
} while (!ui.button_pressed());
11211121

11221122
motion.set_soft_endstop_loose(false);
@@ -1138,7 +1138,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
11381138

11391139
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, new_z));
11401140

1141-
serial_delay(20); // No switch noise
1141+
DEBUG_DELAY(20); // No switch noise
11421142
ui.refresh();
11431143

11441144
} while (lpos.x >= 0 && --param.R_repetition > 0);
@@ -1790,7 +1790,7 @@ void unified_bed_leveling::smart_mesh_fill() {
17901790
DEBUG_ECHOLNPGM("No Mesh Loaded.");
17911791
else
17921792
DEBUG_ECHOLNPGM("Mesh ", storage_slot, " Loaded.");
1793-
serial_delay(50);
1793+
DEBUG_DELAY(50);
17941794

17951795
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
17961796
DEBUG_ECHOLN(F("Fade Height M420 Z"), p_float_t(planner.z_fade_height, 4));
@@ -1802,51 +1802,51 @@ void unified_bed_leveling::smart_mesh_fill() {
18021802
DEBUG_ECHOLNPGM("Probe Offset M851 Z", p_float_t(probe.offset.z, 7));
18031803
#endif
18041804

1805-
DEBUG_ECHOLNPGM("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);
1806-
DEBUG_ECHOLNPGM("MESH_MIN_Y " STRINGIFY(MESH_MIN_Y) "=", MESH_MIN_Y); serial_delay(50);
1807-
DEBUG_ECHOLNPGM("MESH_MAX_X " STRINGIFY(MESH_MAX_X) "=", MESH_MAX_X); serial_delay(50);
1808-
DEBUG_ECHOLNPGM("MESH_MAX_Y " STRINGIFY(MESH_MAX_Y) "=", MESH_MAX_Y); serial_delay(50);
1809-
DEBUG_ECHOLNPGM("GRID_MAX_POINTS_X ", GRID_MAX_POINTS_X); serial_delay(50);
1810-
DEBUG_ECHOLNPGM("GRID_MAX_POINTS_Y ", GRID_MAX_POINTS_Y); serial_delay(50);
1805+
DEBUG_ECHOLNPGM("MESH_MIN_X " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); DEBUG_DELAY(50);
1806+
DEBUG_ECHOLNPGM("MESH_MIN_Y " STRINGIFY(MESH_MIN_Y) "=", MESH_MIN_Y); DEBUG_DELAY(50);
1807+
DEBUG_ECHOLNPGM("MESH_MAX_X " STRINGIFY(MESH_MAX_X) "=", MESH_MAX_X); DEBUG_DELAY(50);
1808+
DEBUG_ECHOLNPGM("MESH_MAX_Y " STRINGIFY(MESH_MAX_Y) "=", MESH_MAX_Y); DEBUG_DELAY(50);
1809+
DEBUG_ECHOLNPGM("GRID_MAX_POINTS_X ", GRID_MAX_POINTS_X); DEBUG_DELAY(50);
1810+
DEBUG_ECHOLNPGM("GRID_MAX_POINTS_Y ", GRID_MAX_POINTS_Y); DEBUG_DELAY(50);
18111811
DEBUG_ECHOLNPGM("MESH_X_DIST ", MESH_X_DIST);
1812-
DEBUG_ECHOLNPGM("MESH_Y_DIST ", MESH_Y_DIST); serial_delay(50);
1812+
DEBUG_ECHOLNPGM("MESH_Y_DIST ", MESH_Y_DIST); DEBUG_DELAY(50);
18131813

18141814
DEBUG_ECHOPGM("X-Axis Mesh Points at: ");
18151815
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; ++i) {
18161816
DEBUG_ECHO(p_float_t(motion.logical_x(get_mesh_x(i)), 3), F(" "));
1817-
serial_delay(25);
1817+
DEBUG_DELAY(25);
18181818
}
1819-
SERIAL_EOL();
1819+
DEBUG_EOL();
18201820

18211821
DEBUG_ECHOPGM("Y-Axis Mesh Points at: ");
18221822
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; ++j) {
18231823
DEBUG_ECHO(p_float_t(motion.logical_y(get_mesh_y(j)), 3), F(" "));
1824-
serial_delay(25);
1824+
DEBUG_DELAY(25);
18251825
}
1826-
SERIAL_EOL();
1826+
DEBUG_EOL();
18271827

18281828
#if HAS_KILL
18291829
DEBUG_ECHOLNPGM("Kill pin on :", KILL_PIN, " state:", marlin.kill_state());
18301830
#endif
18311831

1832-
SERIAL_EOL();
1833-
serial_delay(50);
1832+
DEBUG_EOL();
1833+
DEBUG_DELAY(50);
18341834

18351835
DEBUG_ECHOLNPGM("ubl_state_at_invocation :", ubl_state_at_invocation, "\nubl_state_recursion_chk :", ubl_state_recursion_chk);
1836-
serial_delay(50);
1836+
DEBUG_DELAY(50);
18371837

18381838
DEBUG_ECHOLNPGM("Meshes go from ", _hex_word(settings.meshes_start_index()), " to ", _hex_word(settings.meshes_end_index()));
1839-
serial_delay(50);
1839+
DEBUG_DELAY(50);
18401840

18411841
DEBUG_ECHOLNPGM("sizeof(unified_bed_leveling) : ", sizeof(unified_bed_leveling));
18421842
DEBUG_ECHOLNPGM("z_value[][] size: ", sizeof(z_values));
1843-
serial_delay(25);
1843+
DEBUG_DELAY(25);
18441844

18451845
DEBUG_ECHOLNPGM("EEPROM free for UBL: ", _hex_word(settings.meshes_end_index() - settings.meshes_start_index()));
1846-
serial_delay(50);
1846+
DEBUG_DELAY(50);
18471847

18481848
DEBUG_ECHOLNPGM("EEPROM can hold ", settings.calc_num_meshes(), " meshes.\n");
1849-
serial_delay(25);
1849+
DEBUG_DELAY(25);
18501850

18511851
if (!sanity_check()) {
18521852
echo_name();
@@ -1873,9 +1873,9 @@ void unified_bed_leveling::smart_mesh_fill() {
18731873
print_hex_byte(cccc);
18741874
DEBUG_CHAR(' ');
18751875
}
1876-
SERIAL_EOL();
1876+
DEBUG_EOL();
18771877
}
1878-
SERIAL_EOL();
1878+
DEBUG_EOL();
18791879
persistentStore.access_finish();
18801880
}
18811881

Marlin/src/inc/Conditionals-2-LCD.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@
923923
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35, ANYCUBIC_LCD_VYPER) \
924924
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) \
925925
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
926-
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE, SOVOL_SV06_RTS) \
926+
+ COUNT_ENABLED(DWIN_LCD_PROUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE, SOVOL_SV06_RTS) \
927927
+ COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \
928928
+ COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
929929
+ COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \

Marlin/src/inc/SanityCheck.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
417417
* SD File Sorting
418418
*/
419419
#if ENABLED(SDCARD_SORT_ALPHA)
420-
#if NONE(EXTENSIBLE_UI, HAS_MARLINUI_MENU, DWIN_CREALITY_LCD, DWIN_LCD_PROUI)
420+
#if NONE(EXTENSIBLE_UI, HAS_MARLINUI_MENU, DWIN_LCD_PROUI)
421421
#error "SDCARD_SORT_ALPHA requires an LCD that supports it. (It doesn't apply to M20, etc.)"
422422
#elif SDSORT_LIMIT > 256
423423
#error "SDSORT_LIMIT must be 256 or smaller."
@@ -2917,19 +2917,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
29172917
/**
29182918
* Ender-3 V2 controller has some limitations
29192919
*/
2920-
#if ENABLED(DWIN_CREALITY_LCD)
2921-
#if !HAS_MEDIA
2922-
#error "DWIN_CREALITY_LCD requires SDSUPPORT to be enabled."
2923-
#elif ANY(PID_EDIT_MENU, PID_AUTOTUNE_MENU)
2924-
#error "DWIN_CREALITY_LCD does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU."
2925-
#elif ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
2926-
#error "DWIN_CREALITY_LCD does not support MPC_EDIT_MENU or MPC_AUTOTUNE_MENU."
2927-
#elif ENABLED(LCD_BED_TRAMMING)
2928-
#error "DWIN_CREALITY_LCD does not support LCD_BED_TRAMMING."
2929-
#elif ALL(LCD_BED_LEVELING, PROBE_MANUALLY)
2930-
#error "DWIN_CREALITY_LCD does not support LCD_BED_LEVELING with PROBE_MANUALLY."
2931-
#endif
2932-
#elif ENABLED(DWIN_LCD_PROUI)
2920+
#if ENABLED(DWIN_LCD_PROUI)
29332921
#if !HAS_MEDIA
29342922
#error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled."
29352923
#elif ALL(LCD_BED_LEVELING, PROBE_MANUALLY)

Marlin/src/lcd/dwin/proui/dwin.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,6 @@ void DWIN_SetDataDefaults() {
22002200
TERN_(NOZZLE_PARK_FEATURE, PRO_data.Park_point = DEF_NOZZLE_PARK_POINT;)
22012201
#if HAS_FILAMENT_SENSOR
22022202
PRO_data.Runout_active_state = FIL_RUNOUT_STATE;
2203-
PRO_data.FilamentMotionSensor = DEF_FIL_MOTION_SENSOR;
22042203
#endif
22052204
PRO_data.hotend_maxtemp = HEATER_0_MAXTEMP;
22062205
#if HAS_TOOLBAR
@@ -2686,16 +2685,13 @@ void ApplyMove() {
26862685
void LiveRunoutActive() { ProEx.DrawRunoutActive(true); }
26872686
void SetRunoutActive() {
26882687
uint8_t val;
2689-
val = PRO_data.FilamentMotionSensor ? 2 : PRO_data.Runout_active_state ? 1 : 0;
2690-
SetOnClick(SetIntNoDraw, 0, 2, 0, val, ProEx.ApplyRunoutActive, LiveRunoutActive);
2688+
val = PRO_data.Runout_active_state ? 1 : 0;
2689+
SetOnClick(SetIntNoDraw, 0, 1, 0, val, ProEx.ApplyRunoutActive, LiveRunoutActive);
26912690
ProEx.DrawRunoutActive(true);
26922691
}
26932692
void onDrawRunoutActive(MenuItemClass* menuitem, int8_t line) {
26942693
onDrawMenuItem(menuitem, line);
2695-
if (PRO_data.FilamentMotionSensor)
2696-
{ DWINUI::Draw_String(VALX - MENU_CHR_W, MBASE(line), GET_TEXT_F(MSG_MOTION)); }
2697-
else
2698-
{ DWINUI::Draw_String(VALX + MENU_CHR_W, MBASE(line), PRO_data.Runout_active_state ? GET_TEXT_F(MSG_HIGH) : GET_TEXT_F(MSG_LOW)); }
2694+
DWINUI::Draw_String(VALX + MENU_CHR_W, MBASE(line), PRO_data.Runout_active_state ? GET_TEXT_F(MSG_HIGH) : GET_TEXT_F(MSG_LOW));
26992695
}
27002696
#endif
27012697

Marlin/src/lcd/dwin/proui/dwinui.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -244,32 +244,18 @@ void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) {
244244
// x: the abscissa of the center of the circle
245245
// y: ordinate of the center of the circle
246246
// r: circle radius
247-
void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x, uint16_t y, uint8_t r) {
247+
void DWINUI::Draw_FillCircle(const uint16_t bcolor, const uint16_t x, const uint16_t y, const uint8_t r) {
248+
const uint16_t r2 = sq(r);
248249
DWIN_Draw_Line(bcolor, x - r, y, x + r, y);
249-
uint16_t b = 1;
250-
while (b <= r) {
251-
uint16_t a = SQRT(sq(r) - sq(b));
250+
251+
const uint8_t step = TERN(TJC_DISPLAY, 2, 1);
252+
for (uint16_t b = step; b <= r; b += step) {
253+
const uint16_t a = SQRT(r2 - sq(b));
252254
DWIN_Draw_Line(bcolor, x - a, y + b, x + a, y + b);
253255
DWIN_Draw_Line(bcolor, x - a, y - b, x + a, y - b);
254-
b += TERN(TJC_DISPLAY, 2, 1);
255256
}
256257
}
257258

258-
// Color Interpolator
259-
// val : Interpolator minv..maxv
260-
// minv : Minimum value
261-
// maxv : Maximum value
262-
// color1 : Start color
263-
// color2 : End color
264-
uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
265-
uint8_t B, G, R;
266-
const float n = (float)(val - minv) / (maxv - minv + 1);
267-
R = (1.0f - n) * GetRColor(color1) + n * GetRColor(color2);
268-
G = (1.0f - n) * GetGColor(color1) + n * GetGColor(color2);
269-
B = (1.0f - n) * GetBColor(color1) + n * GetBColor(color2);
270-
return RGB(R, G, B);
271-
}
272-
273259
// Color Interpolator through Red->Orange->Yellow->Green->Blue (Pro UI)
274260
// val : Interpolator minv..maxv
275261
// minv : Minimum value

Marlin/src/lcd/dwin/proui/dwinui.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,14 +560,6 @@ namespace DWINUI {
560560
Draw_Checkbox(textcolor, backcolor, x, y, checked);
561561
}
562562

563-
// Color Interpolator
564-
// val : Interpolator minv..maxv
565-
// minv : Minimum value
566-
// maxv : Maximum value
567-
// color1 : Start color
568-
// color2 : End color
569-
uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
570-
571563
// ------------------------- Buttons ------------------------------//
572564

573565
void Draw_Select_Box(uint16_t xpos, uint16_t ypos);
@@ -592,8 +584,8 @@ namespace DWINUI {
592584
// x: abscissa of the center of the circle
593585
// y: ordinate of the center of the circle
594586
// r: circle radius
595-
void Draw_FillCircle(uint16_t bcolor, uint16_t x, uint16_t y, uint8_t r);
596-
inline void Draw_FillCircle(uint16_t bcolor, uint8_t r) {
587+
void Draw_FillCircle(const uint16_t bcolor, const uint16_t x, const uint16_t y, const uint8_t r);
588+
inline void Draw_FillCircle(const uint16_t bcolor, const uint8_t r) {
597589
Draw_FillCircle(bcolor, cursor.x, cursor.y, r);
598590
}
599591

Marlin/src/lcd/dwin/proui/proui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ constexpr bool DEF_INVERT_E0_DIR = INVERT_E0_DIR;
4545
#ifndef MULTIPLE_PROBING
4646
#define MULTIPLE_PROBING 2
4747
#endif
48-
#define DEF_FIL_MOTION_SENSOR ENABLED(FILAMENT_MOTION_SENSOR)
48+
constexpr bool DEF_FIL_MOTION_SENSOR = ENABLED(FILAMENT_MOTION_SENSOR);
4949
#if DISABLED(FILAMENT_RUNOUT_SENSOR) // must be defined as opposite FIL_RUNOUT_STATE in Configuration.h
5050
#if MOTHERBOARD == BOARD_CREALITY_V427 || MOTHERBOARD == BOARD_CREALITY_V24S1_301F4 || MOTHERBOARD == BOARD_CREALITY_V24S1_301 || MOTHERBOARD == BOARD_VOXELAB_AQUILA || MOTHERBOARD == BOARD_AQUILA_V101
5151
#define FIL_RUNOUT_STATE LOW

Marlin/src/module/motion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ class Motion {
523523
#elif defined(XY_PROBE_FEEDRATE)
524524
#define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS(XY_PROBE_FEEDRATE)
525525
#else
526-
#define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS((homing_feedrate_mm_m.x + homing_feedrate_mm_m.y) * 1.5)
526+
#define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS((motion.homing_feedrate_mm_m.x + motion.homing_feedrate_mm_m.y) * 1.5)
527527
#endif
528528

529529
#ifdef Z_PROBE_FEEDRATE_SLOW

0 commit comments

Comments
 (0)