Encoder direction: Wrangle, Revert select screen change (#14628)

This commit is contained in:
Robby Candra 2019-07-18 07:41:15 +07:00 committed by Scott Lahteine
parent 9e19f004d0
commit c9aa68ef7a
12 changed files with 21 additions and 23 deletions

View file

@ -56,7 +56,6 @@ void MarlinGame::draw_game_over() {
void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen) {
score = 0;
game_state = init_state;
ui.encoder_direction_normal();
ui.goto_screen(screen);
ui.defer_status_screen();
}

View file

@ -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)
*/
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) > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw())
@ -276,7 +275,11 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
drawing_screen = false;
#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
constexpr bool do_probe = true;
#endif
ui.encoder_direction_normal();
if (ui.encoderPosition) {
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
ui.encoderPosition = 0;
@ -448,14 +450,16 @@ void _lcd_draw_homing() {
//
// Selection screen presents a prompt and two options
//
bool ui_selection; // = false
void set_ui_selection(const bool sel) { ui_selection = 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*/) {
if (ui.encoderPosition) {
ui_selection = ((ENCODERBASE) > 0) == (int16_t(ui.encoderPosition) > 0);
ui.encoderPosition = 0;
bool MarlinUI::selection; // = false
bool MarlinUI::update_selection() {
if (encoderPosition) {
selection = int16_t(encoderPosition) > 0;
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()) {
draw_select_screen(yes, no, ui_selection, pref, string, suff);
if (got_click) { ui_selection ? yesFunc() : noFunc(); }

View file

@ -71,7 +71,6 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 123
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 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);
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);

View file

@ -111,7 +111,7 @@ static inline void _lcd_level_bed_corners_homing() {
if (all_axes_homed()) {
bed_corner = 0;
ui.goto_screen(menu_level_bed_corners);
set_ui_selection(true);
ui.set_selection(true);
_lcd_goto_next_corner();
}
}

View file

@ -89,7 +89,6 @@
// Step 7: Get the Z coordinate, click goes to the next point or exits
//
void _lcd_level_bed_get_z() {
ui.encoder_direction_normal();
if (ui.use_click()) {

View file

@ -62,7 +62,6 @@ static void lcd_factory_settings() {
#include "../lcdprint.h"
static void progress_bar_test() {
ui.encoder_direction_normal();
static int8_t bar_percent = 0;
if (ui.use_click()) {
ui.goto_previous_screen();

View file

@ -41,7 +41,6 @@
void lcd_mixer_gradient_z_start_edit() {
ui.defer_status_screen();
ui.encoder_direction_normal();
ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.start_z += float(int16_t(ui.encoderPosition)) * 0.1;
@ -66,7 +65,6 @@
void lcd_mixer_gradient_z_end_edit() {
ui.defer_status_screen();
ui.encoder_direction_normal();
ENCODER_RATE_MULTIPLY(true);
if (ui.encoderPosition != 0) {
mixer.gradient.end_z += float(int16_t(ui.encoderPosition)) * 0.1;

View file

@ -74,7 +74,6 @@ inline void manual_move_to_current(AxisEnum axis
static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition && !ui.processing_manual_move) {
// Start with no limits to movement
@ -158,7 +157,6 @@ static void _lcd_move_e(
#endif
) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition) {
if (!ui.processing_manual_move) {
const float diff = float(int16_t(ui.encoderPosition)) * move_menu_scale;

View file

@ -73,7 +73,6 @@
void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition) {
const int16_t steps = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR);
ui.encoderPosition = 0;

View file

@ -468,7 +468,6 @@ void _lcd_ubl_output_map_lcd() {
static int16_t step_scaler = 0;
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
ui.encoder_direction_normal();
if (ui.encoderPosition) {
step_scaler += int16_t(ui.encoderPosition);

View file

@ -392,7 +392,7 @@ bool MarlinUI::get_blink() {
#if HAS_ENCODER_ACTION
refresh(LCDVIEW_REDRAW_NOW);
#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;
else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM;
else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); }
@ -480,7 +480,6 @@ bool MarlinUI::get_blink() {
void MarlinUI::status_screen() {
#if HAS_LCD_MENU
encoder_direction_normal();
ENCODER_RATE_MULTIPLY(false);
#endif

View file

@ -424,6 +424,11 @@ public:
static int16_t preheat_hotend_temp[2], preheat_bed_temp[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 bool lcd_clicked;