Browse Source

Expand encoder value range

pull/1/head
Scott Lahteine 5 years ago
parent
commit
f00b48f9a8
  1. 8
      Marlin/src/lcd/menu/menu.cpp
  2. 4
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  3. 6
      Marlin/src/lcd/menu/menu_mixer.cpp
  4. 8
      Marlin/src/lcd/menu/menu_motion.cpp
  5. 2
      Marlin/src/lcd/menu/menu_ubl.cpp
  6. 2
      Marlin/src/lcd/ultralcd.cpp
  7. 2
      Marlin/src/lcd/ultralcd.h

8
Marlin/src/lcd/menu/menu.cpp

@ -132,7 +132,7 @@ void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pg
*
* bool MenuItem_int3::_edit();
* 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:
* 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)
ui.repeat_delay = BUTTON_DELAY_EDIT;
#endif
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw())
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
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) {
ui.encoder_direction_menus();
ENCODER_RATE_MULTIPLY(false);
if (ui.encoderPosition > 0x8000) ui.encoderPosition = 0;
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
if (ui.first_page) {
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
screen_changed = false;

4
Marlin/src/lcd/menu/menu_bed_leveling.cpp

@ -121,7 +121,7 @@
// Encoder knob or keypad buttons adjust the Z position
//
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));
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
ui.encoderPosition = 0;
@ -142,7 +142,7 @@
void _lcd_level_bed_moving() {
if (ui.should_draw()) {
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);
}
ui.refresh(LCDVIEW_CALL_NO_REDRAW);

6
Marlin/src/lcd/menu/menu_mixer.cpp

@ -43,7 +43,7 @@
ui.defer_status_screen();
ENCODER_RATE_MULTIPLY(true);
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;
NOLESS(mixer.gradient.start_z, 0);
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
@ -68,7 +68,7 @@
ui.defer_status_screen();
ENCODER_RATE_MULTIPLY(true);
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;
NOLESS(mixer.gradient.end_z, 0);
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
@ -187,7 +187,7 @@ void lcd_mixer_mix_edit() {
#elif DUAL_MIXING_EXTRUDER
if (ui.encoderPosition != 0) {
mixer.mix[0] += int16_t(ui.encoderPosition);
mixer.mix[0] += int32_t(ui.encoderPosition);
ui.encoderPosition = 0;
if (mixer.mix[0] < 0) mixer.mix[0] += 101;
if (mixer.mix[0] > 100) mixer.mix[0] -= 101;

8
Marlin/src/lcd/menu/menu_motion.cpp

@ -127,16 +127,16 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
#endif
// 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
manual_move_offset += diff;
if (int16_t(ui.encoderPosition) < 0)
if (int32_t(ui.encoderPosition) < 0)
NOLESS(manual_move_offset, min - current_position[axis]);
else
NOMORE(manual_move_offset, max - current_position[axis]);
#else
current_position[axis] += diff;
if (int16_t(ui.encoderPosition) < 0)
if (int32_t(ui.encoderPosition) < 0)
NOLESS(current_position[axis], min);
else
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.encoderPosition) {
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
manual_move_offset += diff;
#else

2
Marlin/src/lcd/menu/menu_ubl.cpp

@ -462,7 +462,7 @@ void _lcd_ubl_output_map_lcd() {
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
if (ui.encoderPosition) {
step_scaler += int16_t(ui.encoderPosition);
step_scaler += int32_t(ui.encoderPosition);
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_REDRAW_NOW);

2
Marlin/src/lcd/ultralcd.cpp

@ -137,7 +137,7 @@ millis_t MarlinUI::next_button_update_ms; // = 0
// Encoder Handling
#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
#endif

2
Marlin/src/lcd/ultralcd.h

@ -552,7 +552,7 @@ public:
static void wait_for_release();
#endif
static uint16_t encoderPosition;
static uint32_t encoderPosition;
#if ENABLED(REVERSE_ENCODER_DIRECTION)
#define ENCODERBASE -1

Loading…
Cancel
Save