Encoder direction: Wrangle, Revert select screen change (#14628)
This commit is contained in:
parent
9e19f004d0
commit
c9aa68ef7a
|
@ -56,7 +56,6 @@ void MarlinGame::draw_game_over() {
|
||||||
void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen) {
|
void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen) {
|
||||||
score = 0;
|
score = 0;
|
||||||
game_state = init_state;
|
game_state = init_state;
|
||||||
ui.encoder_direction_normal();
|
|
||||||
ui.goto_screen(screen);
|
ui.goto_screen(screen);
|
||||||
ui.defer_status_screen();
|
ui.defer_status_screen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ void MenuItem_gcode::action(PGM_P const pgcode) { queue.inject_P(pgcode); }
|
||||||
* MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
* MenuItem_int3::action_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
||||||
*/
|
*/
|
||||||
void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
|
void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
|
||||||
ui.encoder_direction_normal();
|
|
||||||
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
if (int16_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||||
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
if (int16_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
||||||
if (ui.should_draw())
|
if (ui.should_draw())
|
||||||
|
@ -276,7 +275,11 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
|
||||||
drawing_screen = false;
|
drawing_screen = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
set_ui_selection(false);
|
#if HAS_LCD_MENU
|
||||||
|
encoder_direction_normal();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
set_selection(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +374,6 @@ void MarlinUI::completion_feedback(const bool good/*=true*/) {
|
||||||
#else
|
#else
|
||||||
constexpr bool do_probe = true;
|
constexpr bool do_probe = true;
|
||||||
#endif
|
#endif
|
||||||
ui.encoder_direction_normal();
|
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
|
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
|
@ -448,14 +450,16 @@ void _lcd_draw_homing() {
|
||||||
//
|
//
|
||||||
// Selection screen presents a prompt and two options
|
// Selection screen presents a prompt and two options
|
||||||
//
|
//
|
||||||
bool ui_selection; // = false
|
bool MarlinUI::selection; // = false
|
||||||
void set_ui_selection(const bool sel) { ui_selection = sel; }
|
bool MarlinUI::update_selection() {
|
||||||
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
if (encoderPosition) {
|
||||||
if (ui.encoderPosition) {
|
selection = int16_t(encoderPosition) > 0;
|
||||||
ui_selection = ((ENCODERBASE) > 0) == (int16_t(ui.encoderPosition) > 0);
|
encoderPosition = 0;
|
||||||
ui.encoderPosition = 0;
|
|
||||||
}
|
}
|
||||||
const bool got_click = ui.use_click();
|
return selection;
|
||||||
|
}
|
||||||
|
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
||||||
|
const bool ui_selection = ui.update_selection(), got_click = ui.use_click();
|
||||||
if (got_click || ui.should_draw()) {
|
if (got_click || ui.should_draw()) {
|
||||||
draw_select_screen(yes, no, ui_selection, pref, string, suff);
|
draw_select_screen(yes, no, ui_selection, pref, string, suff);
|
||||||
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
|
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
|
||||||
|
|
|
@ -71,7 +71,6 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 123
|
||||||
|
|
||||||
typedef void (*selectFunc_t)();
|
typedef void (*selectFunc_t)();
|
||||||
void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
|
void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
|
||||||
void set_ui_selection(const bool sel);
|
|
||||||
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
|
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
|
||||||
inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
||||||
do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
||||||
|
|
|
@ -111,7 +111,7 @@ static inline void _lcd_level_bed_corners_homing() {
|
||||||
if (all_axes_homed()) {
|
if (all_axes_homed()) {
|
||||||
bed_corner = 0;
|
bed_corner = 0;
|
||||||
ui.goto_screen(menu_level_bed_corners);
|
ui.goto_screen(menu_level_bed_corners);
|
||||||
set_ui_selection(true);
|
ui.set_selection(true);
|
||||||
_lcd_goto_next_corner();
|
_lcd_goto_next_corner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@
|
||||||
// Step 7: Get the Z coordinate, click goes to the next point or exits
|
// Step 7: Get the Z coordinate, click goes to the next point or exits
|
||||||
//
|
//
|
||||||
void _lcd_level_bed_get_z() {
|
void _lcd_level_bed_get_z() {
|
||||||
ui.encoder_direction_normal();
|
|
||||||
|
|
||||||
if (ui.use_click()) {
|
if (ui.use_click()) {
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ static void lcd_factory_settings() {
|
||||||
#include "../lcdprint.h"
|
#include "../lcdprint.h"
|
||||||
|
|
||||||
static void progress_bar_test() {
|
static void progress_bar_test() {
|
||||||
ui.encoder_direction_normal();
|
|
||||||
static int8_t bar_percent = 0;
|
static int8_t bar_percent = 0;
|
||||||
if (ui.use_click()) {
|
if (ui.use_click()) {
|
||||||
ui.goto_previous_screen();
|
ui.goto_previous_screen();
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
void lcd_mixer_gradient_z_start_edit() {
|
void lcd_mixer_gradient_z_start_edit() {
|
||||||
ui.defer_status_screen();
|
ui.defer_status_screen();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
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(int16_t(ui.encoderPosition)) * 0.1;
|
||||||
|
@ -66,7 +65,6 @@
|
||||||
|
|
||||||
void lcd_mixer_gradient_z_end_edit() {
|
void lcd_mixer_gradient_z_end_edit() {
|
||||||
ui.defer_status_screen();
|
ui.defer_status_screen();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
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(int16_t(ui.encoderPosition)) * 0.1;
|
||||||
|
|
|
@ -74,7 +74,6 @@ inline void manual_move_to_current(AxisEnum axis
|
||||||
|
|
||||||
static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
|
static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
|
||||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
if (ui.encoderPosition && !ui.processing_manual_move) {
|
if (ui.encoderPosition && !ui.processing_manual_move) {
|
||||||
|
|
||||||
// Start with no limits to movement
|
// Start with no limits to movement
|
||||||
|
@ -158,7 +157,6 @@ static void _lcd_move_e(
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
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(int16_t(ui.encoderPosition)) * move_menu_scale;
|
||||||
|
|
|
@ -73,7 +73,6 @@
|
||||||
|
|
||||||
void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
|
void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
|
||||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
const int16_t steps = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
|
const int16_t steps = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
|
||||||
ui.encoderPosition = 0;
|
ui.encoderPosition = 0;
|
||||||
|
|
|
@ -468,7 +468,6 @@ void _lcd_ubl_output_map_lcd() {
|
||||||
static int16_t step_scaler = 0;
|
static int16_t step_scaler = 0;
|
||||||
|
|
||||||
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
||||||
ui.encoder_direction_normal();
|
|
||||||
|
|
||||||
if (ui.encoderPosition) {
|
if (ui.encoderPosition) {
|
||||||
step_scaler += int16_t(ui.encoderPosition);
|
step_scaler += int16_t(ui.encoderPosition);
|
||||||
|
|
|
@ -392,7 +392,7 @@ bool MarlinUI::get_blink() {
|
||||||
#if HAS_ENCODER_ACTION
|
#if HAS_ENCODER_ACTION
|
||||||
refresh(LCDVIEW_REDRAW_NOW);
|
refresh(LCDVIEW_REDRAW_NOW);
|
||||||
#if HAS_LCD_MENU
|
#if HAS_LCD_MENU
|
||||||
if (encoderDirection == -1) { // ADC_KEYPAD forces REVERSE_MENU_DIRECTION, so this indicates menu navigation
|
if (encoderDirection == -(ENCODERBASE)) { // ADC_KEYPAD forces REVERSE_MENU_DIRECTION, so this indicates menu navigation
|
||||||
if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
|
if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM;
|
||||||
else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
|
else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
|
||||||
else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); }
|
else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); }
|
||||||
|
@ -480,7 +480,6 @@ bool MarlinUI::get_blink() {
|
||||||
void MarlinUI::status_screen() {
|
void MarlinUI::status_screen() {
|
||||||
|
|
||||||
#if HAS_LCD_MENU
|
#if HAS_LCD_MENU
|
||||||
encoder_direction_normal();
|
|
||||||
ENCODER_RATE_MULTIPLY(false);
|
ENCODER_RATE_MULTIPLY(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -424,6 +424,11 @@ public:
|
||||||
static int16_t preheat_hotend_temp[2], preheat_bed_temp[2];
|
static int16_t preheat_hotend_temp[2], preheat_bed_temp[2];
|
||||||
static uint8_t preheat_fan_speed[2];
|
static uint8_t preheat_fan_speed[2];
|
||||||
|
|
||||||
|
// Select Screen (modal NO/YES style dialog)
|
||||||
|
static bool selection;
|
||||||
|
static void set_selection(const bool sel) { selection = sel; }
|
||||||
|
static bool update_selection();
|
||||||
|
|
||||||
static void manage_manual_move();
|
static void manage_manual_move();
|
||||||
|
|
||||||
static bool lcd_clicked;
|
static bool lcd_clicked;
|
||||||
|
|
Loading…
Reference in a new issue