Skip to content

Commit

Permalink
✨ Status Screen flow adjustment (MarlinFirmware#26627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borisov-German authored Jan 19, 2024
1 parent 9f7d5bb commit 7d751a2
Show file tree
Hide file tree
Showing 5 changed files with 38 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 @@ -1474,6 +1474,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
1 change: 1 addition & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@
#define DETECT_I2C_LCD_DEVICE 1
#endif

// Encoder behavior
#ifndef STD_ENCODER_PULSES_PER_STEP
#if ENABLED(TOUCH_SCREEN)
#define STD_ENCODER_PULSES_PER_STEP 2
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 @@ -4147,6 +4147,10 @@ static_assert(WITHIN(MULTISTEPPING_LIMIT, 1, 128) && IS_POWER_OF_2(MULTISTEPPING
#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 @@ -888,7 +888,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 @@ -700,7 +700,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, SPEED_EDIT_MIN, SPEED_EDIT_MAX);
Expand All @@ -720,7 +720,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 7d751a2

Please sign in to comment.