Expand encoder value range
This commit is contained in:
parent
160c8be191
commit
f00b48f9a8
|
@ -132,7 +132,7 @@ void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pg
|
||||||
*
|
*
|
||||||
* bool MenuItem_int3::_edit();
|
* bool MenuItem_int3::_edit();
|
||||||
* void MenuItem_int3::edit(); // edit int16_t (interactively)
|
* void MenuItem_int3::edit(); // edit int16_t (interactively)
|
||||||
* void MenuItem_int3::action(PGM_P const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback = null, const bool live = false);
|
* void MenuItem_int3::action(PGM_P const pstr, int16_t * const ptr, const int32_t minValue, const int32_t maxValue, const screenFunc_t callback = null, const bool live = false);
|
||||||
*
|
*
|
||||||
* You can then use one of the menu macros to present the edit interface:
|
* You can then use one of the menu macros to present the edit interface:
|
||||||
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
||||||
|
@ -148,8 +148,8 @@ void MenuEditItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
|
||||||
#if ENABLED(TOUCH_BUTTONS)
|
#if ENABLED(TOUCH_BUTTONS)
|
||||||
ui.repeat_delay = BUTTON_DELAY_EDIT;
|
ui.repeat_delay = BUTTON_DELAY_EDIT;
|
||||||
#endif
|
#endif
|
||||||
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||||
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
||||||
if (ui.should_draw())
|
if (ui.should_draw())
|
||||||
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
|
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
|
||||||
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
||||||
|
@ -341,7 +341,7 @@ void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
|
||||||
void scroll_screen(const uint8_t limit, const bool is_menu) {
|
void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||||
ui.encoder_direction_menus();
|
ui.encoder_direction_menus();
|
||||||
ENCODER_RATE_MULTIPLY(false);
|
ENCODER_RATE_MULTIPLY(false);
|
||||||
if (ui.encoderPosition > 0x8000) ui.encoderPosition = 0;
|
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||||
if (ui.first_page) {
|
if (ui.first_page) {
|
||||||
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
||||||
screen_changed = false;
|
screen_changed = false;
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
// Encoder knob or keypad buttons adjust the Z position
|
// Encoder knob or keypad buttons adjust the Z position
|
||||||
//
|
//
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
const float z = current_position.z + float(int16_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
const float z = current_position.z + float(int32_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
||||||
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
||||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
void _lcd_level_bed_moving() {
|
void _lcd_level_bed_moving() {
|
||||||
if (ui.should_draw()) {
|
if (ui.should_draw()) {
|
||||||
char msg[10];
|
char msg[10];
|
||||||
sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
|
sprintf_P(msg, PSTR("%i / %u"), int(manual_probe_index + 1), total_probe_points);
|
||||||
draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg);
|
draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg);
|
||||||
}
|
}
|
||||||
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
|
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
ui.defer_status_screen();
|
ui.defer_status_screen();
|
||||||
ENCODER_RATE_MULTIPLY(true);
|
ENCODER_RATE_MULTIPLY(true);
|
||||||
if (ui.encoderPosition != 0) {
|
if (ui.encoderPosition != 0) {
|
||||||
mixer.gradient.start_z += float(int16_t(ui.encoderPosition)) * 0.1;
|
mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
NOLESS(mixer.gradient.start_z, 0);
|
NOLESS(mixer.gradient.start_z, 0);
|
||||||
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
|
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
ui.defer_status_screen();
|
ui.defer_status_screen();
|
||||||
ENCODER_RATE_MULTIPLY(true);
|
ENCODER_RATE_MULTIPLY(true);
|
||||||
if (ui.encoderPosition != 0) {
|
if (ui.encoderPosition != 0) {
|
||||||
mixer.gradient.end_z += float(int16_t(ui.encoderPosition)) * 0.1;
|
mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
NOLESS(mixer.gradient.end_z, 0);
|
NOLESS(mixer.gradient.end_z, 0);
|
||||||
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
|
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
|
||||||
|
@ -187,7 +187,7 @@ void lcd_mixer_mix_edit() {
|
||||||
#elif DUAL_MIXING_EXTRUDER
|
#elif DUAL_MIXING_EXTRUDER
|
||||||
|
|
||||||
if (ui.encoderPosition != 0) {
|
if (ui.encoderPosition != 0) {
|
||||||
mixer.mix[0] += int16_t(ui.encoderPosition);
|
mixer.mix[0] += int32_t(ui.encoderPosition);
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
if (mixer.mix[0] < 0) mixer.mix[0] += 101;
|
if (mixer.mix[0] < 0) mixer.mix[0] += 101;
|
||||||
if (mixer.mix[0] > 100) mixer.mix[0] -= 101;
|
if (mixer.mix[0] > 100) mixer.mix[0] -= 101;
|
||||||
|
|
|
@ -127,16 +127,16 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get the new position
|
// Get the new position
|
||||||
const float diff = float(int16_t(ui.encoderPosition)) * move_menu_scale;
|
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
|
||||||
#if IS_KINEMATIC
|
#if IS_KINEMATIC
|
||||||
manual_move_offset += diff;
|
manual_move_offset += diff;
|
||||||
if (int16_t(ui.encoderPosition) < 0)
|
if (int32_t(ui.encoderPosition) < 0)
|
||||||
NOLESS(manual_move_offset, min - current_position[axis]);
|
NOLESS(manual_move_offset, min - current_position[axis]);
|
||||||
else
|
else
|
||||||
NOMORE(manual_move_offset, max - current_position[axis]);
|
NOMORE(manual_move_offset, max - current_position[axis]);
|
||||||
#else
|
#else
|
||||||
current_position[axis] += diff;
|
current_position[axis] += diff;
|
||||||
if (int16_t(ui.encoderPosition) < 0)
|
if (int32_t(ui.encoderPosition) < 0)
|
||||||
NOLESS(current_position[axis], min);
|
NOLESS(current_position[axis], min);
|
||||||
else
|
else
|
||||||
NOMORE(current_position[axis], max);
|
NOMORE(current_position[axis], max);
|
||||||
|
@ -169,7 +169,7 @@ void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
|
||||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
if (!ui.processing_manual_move) {
|
if (!ui.processing_manual_move) {
|
||||||
const float diff = float(int16_t(ui.encoderPosition)) * move_menu_scale;
|
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
|
||||||
#if IS_KINEMATIC
|
#if IS_KINEMATIC
|
||||||
manual_move_offset += diff;
|
manual_move_offset += diff;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -462,7 +462,7 @@ void _lcd_ubl_output_map_lcd() {
|
||||||
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
||||||
|
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
step_scaler += int16_t(ui.encoderPosition);
|
step_scaler += int32_t(ui.encoderPosition);
|
||||||
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
|
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
ui.refresh(LCDVIEW_REDRAW_NOW);
|
ui.refresh(LCDVIEW_REDRAW_NOW);
|
||||||
|
|
|
@ -137,7 +137,7 @@ millis_t MarlinUI::next_button_update_ms; // = 0
|
||||||
|
|
||||||
// Encoder Handling
|
// Encoder Handling
|
||||||
#if HAS_ENCODER_ACTION
|
#if HAS_ENCODER_ACTION
|
||||||
uint16_t MarlinUI::encoderPosition;
|
uint32_t MarlinUI::encoderPosition;
|
||||||
volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
|
volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -552,7 +552,7 @@ public:
|
||||||
static void wait_for_release();
|
static void wait_for_release();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint16_t encoderPosition;
|
static uint32_t encoderPosition;
|
||||||
|
|
||||||
#if ENABLED(REVERSE_ENCODER_DIRECTION)
|
#if ENABLED(REVERSE_ENCODER_DIRECTION)
|
||||||
#define ENCODERBASE -1
|
#define ENCODERBASE -1
|
||||||
|
|
Loading…
Reference in a new issue