This commit is contained in:
Andrew 2024-11-24 18:55:42 -06:00 committed by GitHub
commit 6e496621c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 107 additions and 37 deletions

View File

@ -1884,6 +1884,7 @@ void dwinSetDataDefaults() {
applyLEDColor();
#endif
TERN_(HAS_GCODE_PREVIEW, hmiData.enablePreview = true);
TERN_(REVERSIBLE_ENCODER, ui.reverse_encoder = false);
}
void dwinCopySettingsTo(char * const buff) {
@ -2693,6 +2694,10 @@ void applyMaxAccel() { planner.set_max_acceleration(hmiValue.axis, menuData.valu
void setAddRecover() { setPFloatOnClick(-5, 5, UNITFDIGITS); }
#endif
#if ENABLED(REVERSIBLE_ENCODER)
void toggleReverseEncoder() { toggleCheckboxLine(ui.reverse_encoder); }
#endif
// Special Menuitem Drawing functions =================================================
void onDrawBack(MenuItem* menuitem, int8_t line) {
@ -3192,9 +3197,19 @@ void drawControlMenu() {
updateMenu(controlMenu);
}
constexpr int advItems = 3 + COUNT_ENABLED( \
EEPROM_SETTINGS, HAS_MESH, HAS_BED_PROBE, HAS_HOME_OFFSET, HAS_TRINAMIC_CONFIG, HAS_ESDIAG, \
HAS_LOCKSCREEN, EDITABLE_DISPLAY_TIMEOUT, SOUND_MENU_ITEM, POWER_LOSS_RECOVERY, HAS_GCODE_PREVIEW, \
PROUI_MEDIASORT, BAUD_RATE_GCODE, HAS_CUSTOM_COLORS, REVERSIBLE_ENCODER) \
+ (2 * ENABLED(PRINTCOUNTER)) \
+ (2 * ENABLED(HAS_LCD_BRIGHTNESS)) \
+ (ENABLED(PIDTEMP) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU)) \
+ ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) \
+ (ENABLED(PIDTEMPBED) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU));
void drawAdvancedSettingsMenu() {
checkkey = ID_Menu;
if (SET_MENU(advancedSettingsMenu, MSG_ADVANCED_SETTINGS, 24)) {
if (SET_MENU(advancedSettingsMenu, MSG_ADVANCED_SETTINGS, advItems)) {
BACK_ITEM(gotoMainMenu);
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, writeEEPROM);
@ -3257,6 +3272,9 @@ void drawAdvancedSettingsMenu() {
#if HAS_CUSTOM_COLORS
MENU_ITEM(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, drawSelectColorsMenu);
#endif
#if ENABLED(REVERSIBLE_ENCODER)
EDIT_ITEM(ICON_Motion, MSG_REVERSE_ENCODER, onDrawChkbMenu, toggleReverseEncoder, &ui.reverse_encoder);
#endif
}
ui.reset_status(true);
updateMenu(advancedSettingsMenu);

View File

@ -222,6 +222,9 @@ namespace ExtUI {
case MPC_STARTED:
StatusScreen::setStatusMessage(GET_TEXT_F(MSG_MPC_AUTOTUNE));
break;
case MPC_TEMP_ERROR: break;
case MPC_INTERRUPTED: break;
case MPC_DONE: break;
}
GOTO_SCREEN(StatusScreen);
}

View File

@ -102,38 +102,6 @@ namespace ExtUI {
set_lcd_error(error, component);
}
#if HAS_PID_HEATING
void onPIDTuning(const pidresult_t rst) {
// Called for temperature PID tuning result
//SERIAL_ECHOLNPGM("OnPIDTuning:", rst);
switch (rst) {
case PID_STARTED:
case PID_BED_STARTED:
case PID_CHAMBER_STARTED:
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE));
break;
case PID_BAD_HEATER_ID:
set_lcd_error(GET_TEXT_F(MSG_PID_BAD_HEATER_ID));
break;
case PID_TEMP_TOO_HIGH:
set_lcd_error(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
break;
case PID_TUNING_TIMEOUT:
set_lcd_error(GET_TEXT_F(MSG_PID_TIMEOUT));
break;
case PID_DONE:
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
break;
}
}
void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) {
// Called by M303 to update the UI
}
#endif
void onPrintTimerStarted() { write_to_lcd(F("{SYS:BUILD}")); }
void onPrintTimerPaused() {}
void onPrintTimerStopped() { write_to_lcd(F("{TQ:100}")); }
@ -207,9 +175,47 @@ namespace ExtUI {
}
#endif
#if HAS_PID_HEATING
void onPIDTuning(const pidresult_t rst) {
// Called for temperature PID tuning result
//SERIAL_ECHOLNPGM("OnPIDTuning:", rst);
switch (rst) {
case PID_STARTED:
case PID_BED_STARTED:
case PID_CHAMBER_STARTED:
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE));
break;
case PID_BAD_HEATER_ID:
set_lcd_error(GET_TEXT_F(MSG_PID_BAD_HEATER_ID));
break;
case PID_TEMP_TOO_HIGH:
set_lcd_error(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
break;
case PID_TUNING_TIMEOUT:
set_lcd_error(GET_TEXT_F(MSG_PID_TIMEOUT));
break;
case PID_DONE:
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
break;
}
}
void onStartM303(const int count, const heater_id_t hid, const celsius_t temp) {
// Called by M303 to update the UI
}
#endif // HAS_PID_HEATING
#if ENABLED(MPC_AUTOTUNE)
void onMPCTuning(const mpcresult_t rst) {
// Called for temperature PID tuning result
// Called for temperature MPC tuning result
switch (rst) {
case MPC_STARTED: break;
case MPC_TEMP_ERROR: break;
case MPC_INTERRUPTED: break;
case MPC_DONE: break;
}
}
#endif

View File

@ -68,6 +68,10 @@ MarlinUI ui;
constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#if ENABLED(REVERSIBLE_ENCODER)
bool MarlinUI::reverse_encoder; // = false
#endif
#if HAS_STATUS_MESSAGE
#if ENABLED(STATUS_MESSAGE_SCROLLING)
uint8_t MarlinUI::status_scroll_offset; // = 0

View File

@ -203,6 +203,10 @@ public:
TERN_(HAS_MARLINUI_MENU, currentScreen = status_screen);
}
#if ENABLED(REVERSIBLE_ENCODER)
static bool reverse_encoder; // Flag to reverse the encoder direction
#endif
static void init();
#if HAS_DISPLAY || HAS_DWIN_E3V2
@ -853,20 +857,26 @@ public:
#define ENCODERBASE (TERN(REVERSE_ENCODER_DIRECTION, -1, +1))
#if ANY(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION)
#if ANY(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION, REVERSIBLE_ENCODER)
static int8_t encoderDirection;
#else
static constexpr int8_t encoderDirection = ENCODERBASE;
#endif
FORCE_INLINE static void encoder_direction_normal() {
#if ANY(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION)
#if ANY(REVERSE_MENU_DIRECTION, REVERSE_SELECT_DIRECTION, REVERSIBLE_ENCODER)
encoderDirection = ENCODERBASE;
#endif
}
FORCE_INLINE static void encoder_direction_menus() {
TERN_(REVERSE_MENU_DIRECTION, encoderDirection = -(ENCODERBASE));
constexpr int8_t dir = TERN(REVERSE_MENU_DIRECTION, -(ENCODERBASE), ENCODERBASE);
#if ENABLED(REVERSIBLE_ENCODER)
encoderDirection = reverse_encoder ? -dir : dir;
#elif ENABLED(REVERSE_MENU_DIRECTION)
encoderDirection = dir;
#endif
UNUSED(dir);
}
FORCE_INLINE static void encoder_direction_select() {

View File

@ -601,6 +601,13 @@ typedef struct SettingsDataStruct {
bool sound_on;
#endif
//
// Encoder Reverse
//
#if ENABLED(REVERSIBLE_ENCODER)
bool reverse_encoder; // ProUI
#endif
//
// Fan tachometer check
//
@ -1727,6 +1734,13 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(ui.sound_on);
#endif
//
// Encoder Reverse
//
#if ENABLED(REVERSIBLE_ENCODER)
EEPROM_WRITE(ui.reverse_encoder);
#endif
//
// Fan tachometer check
//
@ -2848,6 +2862,14 @@ void MarlinSettings::postprocess() {
EEPROM_READ(ui.sound_on);
#endif
//
// Encoder Reverse
//
#if ENABLED(REVERSIBLE_ENCODER)
_FIELD_TEST(reverse_encoder);
EEPROM_READ(ui.reverse_encoder);
#endif
//
// Fan tachometer check
//
@ -3411,6 +3433,13 @@ void MarlinSettings::reset() {
ui.sound_on = ENABLED(SOUND_ON_DEFAULT);
#endif
//
// Encoder Reverse
//
#if ENABLED(REVERSIBLE_ENCODER)
ui.reverse_encoder = false;
#endif
//
// Magnetic Parking Extruder
//