diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 930bb5cd01120b79cace467e97279d69f68777d8..c7f9ae095cb90c7906cf5c90ee45dfcf57af4696 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -685,6 +685,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 3f2e0d31d11d8772587670810cd3c785945ed878..7e85c1eeed104d188a9fb752c2ef22d5dba11d4d 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -146,7 +146,6 @@ #include "utf_mapper.h" int lcd_contrast; -static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD static char currentfont = 0; static void lcd_setFont(char font_nr) { diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 9b2c4007aa673ec6ac71fc6d5d84c51065c7f5a4..6c397725f77951f9ead0264c5be98919814cddbb 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -668,6 +668,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/Felix/Configuration_DUAL.h b/Marlin/example_configurations/Felix/Configuration_DUAL.h index 6a6eccc27d12eba52c465f4ee61543e8ea5b9aee..674025b9dd932dd1c692f80ed9ab0021e6b6bdc8 100644 --- a/Marlin/example_configurations/Felix/Configuration_DUAL.h +++ b/Marlin/example_configurations/Felix/Configuration_DUAL.h @@ -665,6 +665,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 2f2a653cb7ce2f67a63a4bec72b94505cda55416..8f69858bd4d4d3abebb4cd91f4a3d68b34c1108b 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -677,6 +677,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 25cf538da1ac8dc307e5d2b6e0aecafdc30b383e..201a2865e7b40b7e2885a1c6bf526e9e2213504f 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -680,6 +680,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 9c00bcf20f1107ce34ca5ec6a4616ceb55301834..9687deac0e028cc31882e712ca5b96475a3610b8 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -685,6 +685,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index 288cb52fc4bd72234d8bd553f0d5b3407bc967cf..61d1df7fdd7cf704a650622f4465d065a2507c45 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -680,6 +680,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index c81f5b1d7d9ac5018e57527bbd43bd81affcecdd..ebaf29c861e1087c80732b7610ebf0165ddfd4d7 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -693,6 +693,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index 45c4ab70576b584d6f7eda393d4833375b741786..7067155e5a2512f814e0cbe853d156141647e03f 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -705,6 +705,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication #define ENCODER_PULSES_PER_STEP 2 // Increase if you have a high resolution encoder #define ENCODER_STEPS_PER_MENU_ITEM 1 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 4cb81a65bc58df9f042e81a91ef4b81fd7413897..f320e6ce2589fe033d612d5518cd1ababc6a1ba3 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -677,6 +677,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 741216710897d34f9e0515b0bcbf76052a1f85ad..2fb0e1e208198c8b63ada22ae6880925a2951268 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -685,6 +685,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index e0c7a6fc03f355cea114b18d7d2b9dd19dd1790d..65e42851260af168f1767b1a2e5d45cbf4ff1cf7 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -807,6 +807,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 6fe2c3f2e167e844d7c7ae9909d2aa2a31fcdce9..11e7e63ff80814464cb8266bcac2cd1fe15d7ccd 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -807,6 +807,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index f928e52acffcf51936c875eea1072a14f2bf0ee1..c65f5bebd6eae0ec77baa216d58467fc92c46ede 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -811,6 +811,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 2b99d46be936c00fe615dbe8ce4e2f828cf38b8e..b3dfc272ff841a3dbc297dd14cf40cd55da8347d 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -802,6 +802,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index fabc8e07d035ff458023d63c70fd1b4d6d62a3f6..987e35346f668d6f7fb58954a07a027c7ef8432f 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -721,6 +721,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 0689d6384515df513426a2ea4f888357eb931084..21229b29741f13dc6bd798b660b041f25d891700 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -688,6 +688,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 6e6855c97960dc66e97cea09603eb3618d1170a7..229ff16060a88e7720a5816ed591b532653ec7d7 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -679,6 +679,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking +//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. //#define ULTIPANEL //the UltiPanel as on Thingiverse //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency. diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index be54bcdf9484b720ac014c9bed9c8dd981068b7a..d86bacba7c38088f69e00a0aea8f22a1b4a11745 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -7,6 +7,27 @@ #include "stepper.h" #include "configuration_store.h" +/** + * REVERSE_MENU_DIRECTION + * + * To reverse the menu direction we need a general way to reverse + * the direction of the encoder everywhere. So encoderDirection is + * added to allow the encoder to go the other way. + * + * This behavior is limited to scrolling Menus and SD card listings, + * and is disabled in other contexts. + */ +#if ENABLED(REVERSE_MENU_DIRECTION) + int8_t encoderDirection = 1; + #define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1) + #define ENCODER_DIRECTION_MENUS() (encoderDirection = -1) +#else + #define ENCODER_DIRECTION_NORMAL() ; + #define ENCODER_DIRECTION_MENUS() ; +#endif + +uint8_t blink = 0; // Variable for animation + int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update bool encoderRateMultiplierEnabled; @@ -130,6 +151,7 @@ static void lcd_status_screen(); * START_MENU generates the init code for a menu function */ #define START_MENU() do { \ + ENCODER_DIRECTION_MENUS(); \ encoderRateMultiplierEnabled = false; \ if (encoderPosition > 0x8000) encoderPosition = 0; \ uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \ @@ -209,7 +231,7 @@ static void lcd_status_screen(); #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args) #endif //!ENCODER_RATE_MULTIPLIER #define END_MENU() \ - if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; }\ + if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; encoderLine = _menuItemNr - 1; }\ if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \ } } while(0) @@ -280,6 +302,7 @@ static void lcd_goto_previous_menu() { lcd_goto_menu(prevMenu, true, prevEncoder */ static void lcd_status_screen() { + ENCODER_DIRECTION_NORMAL(); encoderRateMultiplierEnabled = false; #if ENABLED(LCD_PROGRESS_BAR) @@ -464,6 +487,7 @@ void lcd_set_home_offsets() { #if ENABLED(BABYSTEPPING) static void _lcd_babystep(int axis, const char* msg) { + ENCODER_DIRECTION_NORMAL(); if (encoderPosition != 0) { babystepsTodo[axis] += (BABYSTEP_MULTIPLICATOR) * (int)encoderPosition; encoderPosition = 0; @@ -828,6 +852,7 @@ float move_menu_scale; static void lcd_move_menu_axis(); static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { + ENCODER_DIRECTION_NORMAL(); if ((encoderPosition != 0) && (movesplanned() <= 3)) { refresh_cmd_timeout(); current_position[axis] += float((int)encoderPosition) * move_menu_scale; @@ -855,6 +880,7 @@ static void lcd_move_e( uint8_t e #endif ) { + ENCODER_DIRECTION_NORMAL(); #if EXTRUDERS > 1 unsigned short original_active_extruder = active_extruder; active_extruder = e; @@ -1263,6 +1289,7 @@ static void lcd_control_volumetric_menu() { */ #if ENABLED(HAS_LCD_CONTRAST) static void lcd_set_contrast() { + ENCODER_DIRECTION_NORMAL(); if (encoderPosition != 0) { #if ENABLED(U8GLIB_LM6059_AF) lcd_contrast += encoderPosition; @@ -1331,6 +1358,7 @@ static void lcd_control_volumetric_menu() { * */ void lcd_sdcard_menu() { + ENCODER_DIRECTION_MENUS(); if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card) uint16_t fileCnt = card.getnrfilenames(); START_MENU(); @@ -1371,9 +1399,31 @@ static void lcd_control_volumetric_menu() { * * Functions for editing single values * + * The "menu_edit_type" macro generates the functions needed to edit a numerical value. + * + * For example, menu_edit_type(int, int3, itostr3, 1) expands into these functions: + * + * bool _menu_edit_int3(); + * void menu_edit_int3(); // edit int (interactively) + * void menu_edit_callback_int3(); // edit int (interactively) with callback on completion + * static void _menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue); + * static void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue); + * static void menu_action_setting_edit_callback_int3(const char* pstr, int* ptr, int minValue, int maxValue, menuFunc_t callback); // edit int with callback + * + * You can then use one of the menu macros to present the edit interface: + * MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999) + * + * This expands into a more primitive menu item: + * MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) + * + * + * Also: MENU_MULTIPLIER_ITEM_EDIT, MENU_ITEM_EDIT_CALLBACK, and MENU_MULTIPLIER_ITEM_EDIT_CALLBACK + * + * menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) */ #define menu_edit_type(_type, _name, _strFunc, scale) \ bool _menu_edit_ ## _name () { \ + ENCODER_DIRECTION_NORMAL(); \ bool isClicked = LCD_CLICKED; \ if ((int32_t)encoderPosition < 0) encoderPosition = 0; \ if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \ @@ -1937,28 +1987,25 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0 #endif //!NEWPANEL + #if ENABLED(REVERSE_MENU_DIRECTION) + #define ENCODER_DIFF_CW (encoderDiff += encoderDirection) + #define ENCODER_DIFF_CCW (encoderDiff -= encoderDirection) + #else + #define ENCODER_DIFF_CW (encoderDiff++) + #define ENCODER_DIFF_CCW (encoderDiff--) + #endif + #define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: ENCODER_DIFF_CW; break; case _E2: ENCODER_DIFF_CCW; } + //manage encoder rotation uint8_t enc = 0; if (buttons & EN_A) enc |= B01; if (buttons & EN_B) enc |= B10; if (enc != lastEncoderBits) { switch (enc) { - case encrot0: - if (lastEncoderBits == encrot3) encoderDiff++; - else if (lastEncoderBits == encrot1) encoderDiff--; - break; - case encrot1: - if (lastEncoderBits == encrot0) encoderDiff++; - else if (lastEncoderBits == encrot2) encoderDiff--; - break; - case encrot2: - if (lastEncoderBits == encrot1) encoderDiff++; - else if (lastEncoderBits == encrot3) encoderDiff--; - break; - case encrot3: - if (lastEncoderBits == encrot2) encoderDiff++; - else if (lastEncoderBits == encrot0) encoderDiff--; - break; + case encrot0: ENCODER_SPIN(encrot3, encrot1); break; + case encrot1: ENCODER_SPIN(encrot0, encrot2); break; + case encrot2: ENCODER_SPIN(encrot1, encrot3); break; + case encrot3: ENCODER_SPIN(encrot2, encrot0); break; } } lastEncoderBits = enc; @@ -2242,6 +2289,7 @@ char* ftostr52(const float& x) { * - Click saves the Z and goes to the next mesh point */ static void _lcd_level_bed() { + ENCODER_DIRECTION_NORMAL(); if ((encoderPosition != 0) && (movesplanned() <= 3)) { refresh_cmd_timeout(); current_position[Z_AXIS] += float((int)encoderPosition) * (MBL_Z_STEP); diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index ec18ac5cc49130660b16f28863ab1170b4cde45e..2d4075afc6765a23e3bf40196bc4f5b883d38f5a 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -54,6 +54,8 @@ extern bool cancel_heatup; + extern uint8_t blink; // Variable for animation + #if ENABLED(FILAMENT_LCD_DISPLAY) extern millis_t previous_lcd_status_ms; #endif diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 9ef7e93cb2690161912e39bc0f02f7abcd40338e..7dfa7f4595a4ed1c272171375bc47c8171d98537 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -5,7 +5,6 @@ * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays. **/ -static unsigned char blink = 0; // Variable for animation extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array. ////////////////////////////////////