Skip to content

Commit

Permalink
✨ Status Screen flow adjustment (MarlinFirmware#26627)
Browse files Browse the repository at this point in the history
Перенос коммита из bugfix-ветки
  • Loading branch information
Borisov-German committed Mar 9, 2024
1 parent 1188aa3 commit a9e83a7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@
#if IS_ULTIPANEL
#define MANUAL_E_MOVES_RELATIVE // Display extruder move distance rather than "position"
#define ULTIPANEL_FEEDMULTIPLY // Encoder sets the feedrate multiplier on the Status Screen
//#define ULTIPANEL_FLOWPERCENT // Encoder sets the flow percentage on the Status Screen
#endif
#endif

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -3900,6 +3900,10 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."
#endif
#endif

#if ALL(ULTIPANEL_FEEDMULTIPLY, ULTIPANEL_FLOWPERCENT)
#error "Only enable ULTIPANEL_FEEDMULTIPLY or ULTIPANEL_FLOWPERCENT, but not both."
#endif

// Misc. Cleanup
#undef _TEST_PWM
#undef _NUM_AXES_STR
Expand Down
7 changes: 6 additions & 1 deletion Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,12 @@ void MarlinUI::draw_status_screen() {
lcd_put_lchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]);

set_font(FONT_STATUSMENU);
lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));

#if ENABLED(ULTIPANEL_FLOWPERCENT)
lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(planner.flow_percentage[active_extruder]));
#else
lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage));
#endif
lcd_put_u8str(F("%"));

//
Expand Down
28 changes: 26 additions & 2 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void MarlinUI::init() {
else
new_frm = old_frm;
}
else if ((old_frm < 100 && new_frm > 100) || (old_frm > 100 && new_frm < 100))
else if ((old_frm < 100) == (new_frm > 100)) // Crossing 100? Stick at 100.
new_frm = 100;

LIMIT(new_frm, 10, 999);
Expand All @@ -707,7 +707,31 @@ void MarlinUI::init() {
#endif
}

#endif // ULTIPANEL_FEEDMULTIPLY
#elif ENABLED(ULTIPANEL_FLOWPERCENT)

const int16_t old_fp = planner.flow_percentage[active_extruder];
int16_t new_fp = old_fp + int16_t(encoderPosition);

// Dead zone at 100% flow percentage
if (old_fp == 100) {
if (int16_t(encoderPosition) > ENCODER_FEEDRATE_DEADZONE)
new_fp -= ENCODER_FEEDRATE_DEADZONE;
else if (int16_t(encoderPosition) < -(ENCODER_FEEDRATE_DEADZONE))
new_fp += ENCODER_FEEDRATE_DEADZONE;
else
new_fp = old_fp;
}
else if ((old_fp < 100) == (new_fp > 100)) // Crossing 100? Stick at 100.
new_fp = 100;

LIMIT(new_fp, FLOW_EDIT_MIN, FLOW_EDIT_MAX);

if (old_fp != new_fp) {
planner.set_flow(active_extruder, new_fp);
encoderPosition = 0;
}

#endif // ULTIPANEL_FLOWPERCENT

draw_status_screen();
}
Expand Down

0 comments on commit a9e83a7

Please sign in to comment.