Merge pull request #8897 from thinkyhead/bf1_lcd_click_redraw

[1.1.x] Clear lcd_clicked on use
This commit is contained in:
Scott Lahteine 2017-12-26 20:54:31 -06:00 committed by GitHub
commit ecba9b6738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -287,7 +287,8 @@ uint16_t max_display_update_time = 0;
*/ */
#define _MENU_ITEM_PART_1(TYPE, ...) \ #define _MENU_ITEM_PART_1(TYPE, ...) \
if (_menuLineNr == _thisItemNr) { \ if (_menuLineNr == _thisItemNr) { \
if (lcd_clicked && encoderLine == _thisItemNr) { if (encoderLine == _thisItemNr && lcd_clicked) { \
lcd_clicked = false
#define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \ #define _MENU_ITEM_PART_2(TYPE, LABEL, ...) \
menu_action_ ## TYPE(__VA_ARGS__); \ menu_action_ ## TYPE(__VA_ARGS__); \
@ -491,6 +492,12 @@ uint16_t max_display_update_time = 0;
float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
#endif #endif
inline bool use_click() {
const bool click = lcd_clicked;
lcd_clicked = false;
return click;
}
/** /**
* General function to go directly to a screen * General function to go directly to a screen
*/ */
@ -670,7 +677,7 @@ void lcd_status_screen() {
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
if (lcd_clicked) { if (use_click()) {
#if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT) #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
previous_lcd_status_ms = millis(); // get status message to show up for a while previous_lcd_status_ms = millis(); // get status message to show up for a while
#endif #endif
@ -855,7 +862,7 @@ void kill_screen(const char* lcd_msg) {
static void progress_bar_test() { static void progress_bar_test() {
static int8_t bar_percent = 0; static int8_t bar_percent = 0;
if (lcd_clicked) { if (use_click()) {
lcd_goto_previous_menu(); lcd_goto_previous_menu();
lcd_set_custom_characters(CHARSET_MENU); lcd_set_custom_characters(CHARSET_MENU);
return; return;
@ -1082,7 +1089,7 @@ void kill_screen(const char* lcd_msg) {
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
void _lcd_babystep(const AxisEnum axis, const char* msg) { void _lcd_babystep(const AxisEnum axis, const char* msg) {
if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); } if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR); const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
@ -1105,7 +1112,7 @@ void kill_screen(const char* lcd_msg) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
void lcd_babystep_zoffset() { void lcd_babystep_zoffset() {
if (lcd_clicked) { return lcd_goto_previous_menu_no_defer(); } if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
defer_return_to_status = true; defer_return_to_status = true;
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
@ -1787,7 +1794,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_level_bed_get_z() { void _lcd_level_bed_get_z() {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (lcd_clicked) { if (use_click()) {
// //
// Save the current Z position and move // Save the current Z position and move
@ -1849,7 +1856,6 @@ void kill_screen(const char* lcd_msg) {
* Step 5: Initiate a move to the next point * Step 5: Initiate a move to the next point
*/ */
void _lcd_level_goto_next_point() { void _lcd_level_goto_next_point() {
// Set the menu to display ahead of blocking call
lcd_goto_screen(_lcd_level_bed_moving); lcd_goto_screen(_lcd_level_bed_moving);
// G29 Records Z, moves, and signals when it pauses // G29 Records Z, moves, and signals when it pauses
@ -1867,7 +1873,7 @@ void kill_screen(const char* lcd_msg) {
*/ */
void _lcd_level_bed_homing_done() { void _lcd_level_bed_homing_done() {
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING)); if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
if (lcd_clicked) { if (use_click()) {
manual_probe_index = 0; manual_probe_index = 0;
_lcd_level_goto_next_point(); _lcd_level_goto_next_point();
} }
@ -2358,7 +2364,7 @@ void kill_screen(const char* lcd_msg) {
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
return lcd_goto_screen(_lcd_ubl_map_homing); return lcd_goto_screen(_lcd_ubl_map_homing);
if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd(); if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
@ -2827,7 +2833,7 @@ void kill_screen(const char* lcd_msg) {
*/ */
void _lcd_move_xyz(const char* name, AxisEnum axis) { void _lcd_move_xyz(const char* name, AxisEnum axis) {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition && !processing_manual_move) { if (encoderPosition && !processing_manual_move) {
refresh_cmd_timeout(); refresh_cmd_timeout();
@ -2889,12 +2895,10 @@ void kill_screen(const char* lcd_msg) {
if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max); if ((int32_t)encoderPosition > 0) NOMORE(current_position[axis], max);
#endif #endif
encoderPosition = 0;
manual_move_to_current(axis); manual_move_to_current(axis);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0;
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
const float pos = current_position[axis] const float pos = current_position[axis]
#if IS_KINEMATIC #if IS_KINEMATIC
@ -2912,7 +2916,7 @@ void kill_screen(const char* lcd_msg) {
int8_t eindex=-1 int8_t eindex=-1
#endif #endif
) { ) {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
if (!processing_manual_move) { if (!processing_manual_move) {
@ -2994,7 +2998,7 @@ void kill_screen(const char* lcd_msg) {
_manual_move_func_ptr = func; _manual_move_func_ptr = func;
START_MENU(); START_MENU();
if (LCD_HEIGHT >= 4) { if (LCD_HEIGHT >= 4) {
switch(axis) { switch (axis) {
case X_AXIS: case X_AXIS:
STATIC_ITEM(MSG_MOVE_X, true, true); break; STATIC_ITEM(MSG_MOVE_X, true, true); break;
case Y_AXIS: case Y_AXIS:
@ -3797,7 +3801,7 @@ void kill_screen(const char* lcd_msg) {
* *
*/ */
void lcd_info_stats_menu() { void lcd_info_stats_menu() {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
char buffer[21]; char buffer[21];
printStatistics stats = print_job_timer.getStats(); printStatistics stats = print_job_timer.getStats();
@ -3831,7 +3835,7 @@ void kill_screen(const char* lcd_msg) {
* *
*/ */
void lcd_info_thermistors_menu() { void lcd_info_thermistors_menu() {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
START_SCREEN(); START_SCREEN();
#define THERMISTOR_ID TEMP_SENSOR_0 #define THERMISTOR_ID TEMP_SENSOR_0
#include "thermistornames.h" #include "thermistornames.h"
@ -3892,7 +3896,7 @@ void kill_screen(const char* lcd_msg) {
* *
*/ */
void lcd_info_board_menu() { void lcd_info_board_menu() {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
START_SCREEN(); START_SCREEN();
STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController
STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000 STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@ -3913,7 +3917,7 @@ void kill_screen(const char* lcd_msg) {
* *
*/ */
void lcd_info_printer_menu() { void lcd_info_printer_menu() {
if (lcd_clicked) { return lcd_goto_previous_menu(); } if (use_click()) { return lcd_goto_previous_menu(); }
START_SCREEN(); START_SCREEN();
STATIC_ITEM(MSG_MARLIN, true, true); // Marlin STATIC_ITEM(MSG_MARLIN, true, true); // Marlin
STATIC_ITEM(SHORT_BUILD_VERSION, true); // x.x.x-Branch STATIC_ITEM(SHORT_BUILD_VERSION, true); // x.x.x-Branch
@ -4312,7 +4316,7 @@ void kill_screen(const char* lcd_msg) {
if (liveEdit) (*callbackFunc)(); \ if (liveEdit) (*callbackFunc)(); \
if (lcd_clicked) lcd_goto_previous_menu(); \ if (lcd_clicked) lcd_goto_previous_menu(); \
} \ } \
return lcd_clicked; \ return use_click(); \
} \ } \
void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \ void menu_edit_ ## _name() { _menu_edit_ ## _name(); } \
void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \ void menu_edit_callback_ ## _name() { if (_menu_edit_ ## _name()) (*callbackFunc)(); } \
@ -4669,7 +4673,7 @@ void lcd_update() {
#if ENABLED(DOGLCD) #if ENABLED(DOGLCD)
|| drawing_screen || drawing_screen
#endif #endif
) { ) {
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
@ -4773,12 +4777,13 @@ void lcd_update() {
if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) { if ((lcdDrawUpdate || IS_DRAWING) && (!bbr2 || bbr2 > max_display_update_time)) {
// Change state of drawing flag between screen updates
if (!IS_DRAWING) switch (lcdDrawUpdate) { if (!IS_DRAWING) switch (lcdDrawUpdate) {
case LCDVIEW_CALL_NO_REDRAW: case LCDVIEW_CALL_NO_REDRAW:
lcdDrawUpdate = LCDVIEW_NONE; lcdDrawUpdate = LCDVIEW_NONE;
break; break;
case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here) case LCDVIEW_CLEAR_CALL_REDRAW:
case LCDVIEW_CALL_REDRAW_NEXT: // set by handlers, then altered after (never occurs here?) case LCDVIEW_CALL_REDRAW_NEXT:
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
case LCDVIEW_NONE: case LCDVIEW_NONE:
@ -4790,7 +4795,7 @@ void lcd_update() {
#endif #endif
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
#define CURRENTSCREEN() (*currentScreen)(), lcd_clicked = false #define CURRENTSCREEN() (*currentScreen)()
#else #else
#define CURRENTSCREEN() lcd_status_screen() #define CURRENTSCREEN() lcd_status_screen()
#endif #endif
@ -4815,6 +4820,10 @@ void lcd_update() {
CURRENTSCREEN(); CURRENTSCREEN();
#endif #endif
#if ENABLED(ULTIPANEL)
lcd_clicked = false;
#endif
// Keeping track of the longest time for an individual LCD update. // Keeping track of the longest time for an individual LCD update.
// Used to do screen throttling when the planner starts to fill up. // Used to do screen throttling when the planner starts to fill up.
NOLESS(max_display_update_time, millis() - ms); NOLESS(max_display_update_time, millis() - ms);
@ -4830,17 +4839,16 @@ void lcd_update() {
#endif // ULTIPANEL #endif // ULTIPANEL
// Change state of drawing flag between screen updates
if (!IS_DRAWING) switch (lcdDrawUpdate) { if (!IS_DRAWING) switch (lcdDrawUpdate) {
case LCDVIEW_CLEAR_CALL_REDRAW: case LCDVIEW_CLEAR_CALL_REDRAW:
lcd_implementation_clear(); lcd_implementation_clear(); break;
case LCDVIEW_CALL_REDRAW_NEXT:
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
break;
case LCDVIEW_REDRAW_NOW: case LCDVIEW_REDRAW_NOW:
lcdDrawUpdate = LCDVIEW_NONE; lcdDrawUpdate = LCDVIEW_NONE;
break;
case LCDVIEW_NONE: case LCDVIEW_NONE:
break; case LCDVIEW_CALL_REDRAW_NEXT:
case LCDVIEW_CALL_NO_REDRAW:
default: break;
} // switch } // switch
} // ELAPSED(ms, next_lcd_update_ms) } // ELAPSED(ms, next_lcd_update_ms)