@ -10,6 +10,9 @@
int8_t encoderDiff ; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
int8_t encoderDiff ; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
bool encoderRateMultiplierEnabled ;
int32_t lastEncoderMovementMillis ;
/* Configuration settings */
/* Configuration settings */
int plaPreheatHotendTemp ;
int plaPreheatHotendTemp ;
int plaPreheatHPBTemp ;
int plaPreheatHPBTemp ;
@ -119,6 +122,7 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
/* Helper macros for menus */
/* Helper macros for menus */
# define START_MENU() do { \
# define START_MENU() do { \
encoderRateMultiplierEnabled = false ; \
if ( encoderPosition > 0x8000 ) encoderPosition = 0 ; \
if ( encoderPosition > 0x8000 ) encoderPosition = 0 ; \
if ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset ) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ; \
if ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset ) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ; \
uint8_t _lineNr = currentMenuViewOffset , _menuItemNr ; \
uint8_t _lineNr = currentMenuViewOffset , _menuItemNr ; \
@ -143,9 +147,38 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
} \
} \
_menuItemNr + + ; \
_menuItemNr + + ; \
} while ( 0 )
} while ( 0 )
# ifdef ENCODER_RATE_MULTIPLIER
# define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
if ( _menuItemNr = = _lineNr ) { \
if ( lcdDrawUpdate ) { \
const char * _label_pstr = PSTR ( label ) ; \
if ( ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) = = _menuItemNr ) { \
lcd_implementation_drawmenu_ # # type # # _selected ( _drawLineNr , _label_pstr , # # args ) ; \
} else { \
lcd_implementation_drawmenu_ # # type ( _drawLineNr , _label_pstr , # # args ) ; \
} \
} \
if ( wasClicked & & ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) = = _menuItemNr ) { \
lcd_quick_feedback ( ) ; \
encoderRateMultiplierEnabled = true ; \
lastEncoderMovementMillis = 0 ; \
menu_action_ # # type ( args ) ; \
return ; \
} \
} \
_menuItemNr + + ; \
} while ( 0 )
# endif
# define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
# define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
# define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
# define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
# define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
# define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
# ifdef ENCODER_RATE_MULTIPLIER
# define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
# define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
# else
# define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
# define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
# endif
# define END_MENU() \
# define END_MENU() \
if ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM > = _menuItemNr ) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1 ; \
if ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM > = _menuItemNr ) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1 ; \
if ( ( uint8_t ) ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) > = currentMenuViewOffset + LCD_HEIGHT ) { currentMenuViewOffset = ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) - LCD_HEIGHT + 1 ; lcdDrawUpdate = 1 ; _lineNr = currentMenuViewOffset - 1 ; _drawLineNr = - 1 ; } \
if ( ( uint8_t ) ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) > = currentMenuViewOffset + LCD_HEIGHT ) { currentMenuViewOffset = ( encoderPosition / ENCODER_STEPS_PER_MENU_ITEM ) - LCD_HEIGHT + 1 ; lcdDrawUpdate = 1 ; _lineNr = currentMenuViewOffset - 1 ; _drawLineNr = - 1 ; } \
@ -205,6 +238,7 @@ static void lcd_goto_menu(menuFunc_t menu, const uint32_t encoder=0, const bool
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */
static void lcd_status_screen ( )
static void lcd_status_screen ( )
{
{
encoderRateMultiplierEnabled = false ;
# if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
# if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
uint16_t mil = millis ( ) ;
uint16_t mil = millis ( ) ;
# ifndef PROGRESS_MSG_ONCE
# ifndef PROGRESS_MSG_ONCE
@ -423,23 +457,23 @@ static void lcd_tune_menu()
MENU_ITEM ( back , MSG_MAIN , lcd_main_menu ) ;
MENU_ITEM ( back , MSG_MAIN , lcd_main_menu ) ;
MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedmultiply , 10 , 999 ) ;
MENU_ITEM_EDIT ( int3 , MSG_SPEED , & feedmultiply , 10 , 999 ) ;
# if TEMP_SENSOR_0 != 0
# if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_1 != 0
# if TEMP_SENSOR_1 != 0
MENU _ITEM_EDIT ( int3 , MSG_NOZZLE " 2 " , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 ) ;
MENU_MULTIPLIER _ITEM_EDIT ( int3 , MSG_NOZZLE " 2 " , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_2 != 0
# if TEMP_SENSOR_2 != 0
MENU _ITEM_EDIT ( int3 , MSG_NOZZLE " 3 " , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 ) ;
MENU_MULTIPLIER _ITEM_EDIT ( int3 , MSG_NOZZLE " 3 " , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_3 != 0
# if TEMP_SENSOR_3 != 0
MENU _ITEM_EDIT ( int3 , MSG_NOZZLE " 4 " , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 ) ;
MENU_MULTIPLIER _ITEM_EDIT ( int3 , MSG_NOZZLE " 4 " , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_BED != 0
# if TEMP_SENSOR_BED != 0
MENU _ITEM_EDIT ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ;
MENU_MULTIPLIER _ITEM_EDIT ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ;
# endif
# endif
MENU _ITEM_EDIT ( int3 , MSG_FAN_SPEED , & fanSpeed , 0 , 255 ) ;
MENU_MULTIPLIER _ITEM_EDIT ( int3 , MSG_FAN_SPEED , & fanSpeed , 0 , 255 ) ;
MENU_ITEM_EDIT ( int3 , MSG_FLOW , & extrudemultiply , 10 , 999 ) ;
MENU_ITEM_EDIT ( int3 , MSG_FLOW , & extrudemultiply , 10 , 999 ) ;
MENU_ITEM_EDIT ( int3 , MSG_FLOW " 0 " , & extruder_multiply [ 0 ] , 10 , 999 ) ;
MENU_ITEM_EDIT ( int3 , MSG_FLOW " 0 " , & extruder_multiply [ 0 ] , 10 , 999 ) ;
# if TEMP_SENSOR_1 != 0
# if TEMP_SENSOR_1 != 0
@ -816,21 +850,21 @@ static void lcd_control_temperature_menu()
START_MENU ( ) ;
START_MENU ( ) ;
MENU_ITEM ( back , MSG_CONTROL , lcd_control_menu ) ;
MENU_ITEM ( back , MSG_CONTROL , lcd_control_menu ) ;
# if TEMP_SENSOR_0 != 0
# if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_NOZZLE , & target_temperature [ 0 ] , 0 , HEATER_0_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_1 != 0 && EXTRUDERS > 1
# if TEMP_SENSOR_1 != 0 && EXTRUDERS > 1
MENU_ITEM_EDIT ( int3 , MSG_NOZZLE " 2 " , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_NOZZLE " 2 " , & target_temperature [ 1 ] , 0 , HEATER_1_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_2 != 0 && EXTRUDERS > 2
# if TEMP_SENSOR_2 != 0 && EXTRUDERS > 2
MENU_ITEM_EDIT ( int3 , MSG_NOZZLE " 3 " , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_NOZZLE " 3 " , & target_temperature [ 2 ] , 0 , HEATER_2_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_3 != 0 && EXTRUDERS > 3
# if TEMP_SENSOR_3 != 0 && EXTRUDERS > 3
MENU_ITEM_EDIT ( int3 , MSG_NOZZLE " 4 " , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_NOZZLE " 4 " , & target_temperature [ 3 ] , 0 , HEATER_3_MAXTEMP - 15 ) ;
# endif
# endif
# if TEMP_SENSOR_BED != 0
# if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_BED , & target_temperature_bed , 0 , BED_MAXTEMP - 15 ) ;
# endif
# endif
MENU_ITEM_EDIT ( int3 , MSG_FAN_SPEED , & fanSpeed , 0 , 255 ) ;
MENU_MULTIPLIER_ ITEM_EDIT ( int3 , MSG_FAN_SPEED , & fanSpeed , 0 , 255 ) ;
# if defined AUTOTEMP && (TEMP_SENSOR_0 != 0)
# if defined AUTOTEMP && (TEMP_SENSOR_0 != 0)
MENU_ITEM_EDIT ( bool , MSG_AUTOTEMP , & autotemp_enabled ) ;
MENU_ITEM_EDIT ( bool , MSG_AUTOTEMP , & autotemp_enabled ) ;
MENU_ITEM_EDIT ( float3 , MSG_MIN , & autotemp_min , 0 , HEATER_0_MAXTEMP - 15 ) ;
MENU_ITEM_EDIT ( float3 , MSG_MIN , & autotemp_min , 0 , HEATER_0_MAXTEMP - 15 ) ;
@ -961,13 +995,13 @@ static void lcd_control_volumetric_menu()
MENU_ITEM_EDIT_CALLBACK ( bool , MSG_VOLUMETRIC_ENABLED , & volumetric_enabled , calculate_volumetric_multipliers ) ;
MENU_ITEM_EDIT_CALLBACK ( bool , MSG_VOLUMETRIC_ENABLED , & volumetric_enabled , calculate_volumetric_multipliers ) ;
if ( volumetric_enabled ) {
if ( volumetric_enabled ) {
MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_0 , & filament_size [ 0 ] , DEFAULT_NOMINAL_FILAMENT_DIA - .5 , DEFAULT_NOMINAL_FILAMENT_DIA + .5 , calculate_volumetric_multipliers ) ;
MENU_MULTIPLIER_ ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_0 , & filament_size [ 0 ] , 1 .5, 3 .2 5, calculate_volumetric_multipliers ) ;
# if EXTRUDERS > 1
# if EXTRUDERS > 1
MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_1 , & filament_size [ 1 ] , DEFAULT_NOMINAL_FILAMENT_DIA - .5 , DEFAULT_NOMINAL_FILAMENT_DIA + .5 , calculate_volumetric_multipliers ) ;
MENU_MULTIPLIER_ ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_1 , & filament_size [ 1 ] , 1 .5, 3 .2 5, calculate_volumetric_multipliers ) ;
# if EXTRUDERS > 2
# if EXTRUDERS > 2
MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_2 , & filament_size [ 2 ] , DEFAULT_NOMINAL_FILAMENT_DIA - .5 , DEFAULT_NOMINAL_FILAMENT_DIA + .5 , calculate_volumetric_multipliers ) ;
MENU_MULTIPLIER_ ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_2 , & filament_size [ 2 ] , 1 .5, 3 .2 5, calculate_volumetric_multipliers ) ;
# if EXTRUDERS > 3
# if EXTRUDERS > 3
MENU_ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_3 , & filament_size [ 3 ] , DEFAULT_NOMINAL_FILAMENT_DIA - .5 , DEFAULT_NOMINAL_FILAMENT_DIA + .5 , calculate_volumetric_multipliers ) ;
MENU_MULTIPLIER_ ITEM_EDIT_CALLBACK ( float43 , MSG_FILAMENT_SIZE_EXTRUDER_3 , & filament_size [ 3 ] , 1 .5, 3 .2 5, calculate_volumetric_multipliers ) ;
# endif //EXTRUDERS > 3
# endif //EXTRUDERS > 3
# endif //EXTRUDERS > 2
# endif //EXTRUDERS > 2
# endif //EXTRUDERS > 1
# endif //EXTRUDERS > 1
@ -1322,8 +1356,47 @@ void lcd_update()
# endif
# endif
if ( abs ( encoderDiff ) > = ENCODER_PULSES_PER_STEP )
if ( abs ( encoderDiff ) > = ENCODER_PULSES_PER_STEP )
{
{
int32_t encoderMultiplier = 1 ;
# ifdef ENCODER_RATE_MULTIPLIER
if ( encoderRateMultiplierEnabled )
{
int32_t encoderMovementSteps = abs ( encoderDiff ) / ENCODER_PULSES_PER_STEP ;
if ( lastEncoderMovementMillis ! = 0 )
{
// Note that the rate is always calculated between to passes through the
// loop and that the abs of the encoderDiff value is tracked.
float encoderStepRate =
( float ) ( encoderMovementSteps ) / ( ( float ) ( millis ( ) - lastEncoderMovementMillis ) ) * 1000.0 ;
if ( encoderStepRate > = ENCODER_100X_STEPS_PER_SEC )
{
encoderMultiplier = 100 ;
}
else if ( encoderStepRate > = ENCODER_10X_STEPS_PER_SEC )
{
encoderMultiplier = 10 ;
}
# ifdef ENCODER_RATE_MULTIPLIER_DEBUG
SERIAL_ECHO_START ;
SERIAL_ECHO ( " Enc Step Rate: " ) ;
SERIAL_ECHO ( encoderStepRate ) ;
SERIAL_ECHO ( " Multiplier: " ) ;
SERIAL_ECHO ( encoderMultiplier ) ;
SERIAL_ECHO ( " ENCODER_10X_STEPS_PER_SEC: " ) ;
SERIAL_ECHO ( ENCODER_10X_STEPS_PER_SEC ) ;
SERIAL_ECHO ( " ENCODER_100X_STEPS_PER_SEC: " ) ;
SERIAL_ECHOLN ( ENCODER_100X_STEPS_PER_SEC ) ;
# endif
}
lastEncoderMovementMillis = millis ( ) ;
}
# endif
lcdDrawUpdate = 1 ;
lcdDrawUpdate = 1 ;
encoderPosition + = encoderDiff / ENCODER_PULSES_PER_STEP ;
encoderPosition + = ( encoderDiff * encoderMultiplier ) / ENCODER_PULSES_PER_STEP ;
encoderDiff = 0 ;
encoderDiff = 0 ;
timeoutToStatus = millis ( ) + LCD_TIMEOUT_TO_STATUS ;
timeoutToStatus = millis ( ) + LCD_TIMEOUT_TO_STATUS ;
}
}