Skip to content

Commit

Permalink
merge followup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 28, 2024
1 parent 8ada41b commit 5a1ca0c
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 55 deletions.
5 changes: 3 additions & 2 deletions Marlin/src/lcd/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class MenuEditItemBase : public MenuItemBase {
void * const ev, // Edit value pointer
const int32_t minv, // Encoder minimum
const int32_t maxv, // Encoder maximum
const float scale, // Smallest step
const float step, // Smallest step
intptr_t to_string, // Value-to-string conversion function
const uint32_t ep, // Initial encoder value
const screenFunc_t cs, // MenuItem_type::draw_edit_screen => MenuEditItemBase::edit()
Expand All @@ -196,7 +196,8 @@ class MenuEditItemBase : public MenuItemBase {

// This method is for the current menu item
static void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); }
static void put_new_value(float val); //todo fix this should not be here or preprocessor controlled, this is TFT_COLOR_UI with touch specific

static void put_new_value(float val); // TODO: Only include for TFT_COLOR_UI with touch
};

#if HAS_MEDIA
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/tft/tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TFT {
static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); }
static void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); }
static void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); }
static void draw_edit_screen_buttons(bool mode_keypad = false);
static void draw_edit_screen_buttons(const bool mode_keypad=false);
#if ENABLED(TOUCH_SCREEN)
static void drawSimpleBtn(const char *label, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color, uint16_t colorTxt, BTN_STYLE style, bool selected, TouchControlType touchType = BUTTON, intptr_t data = 0, int32_t index = 0);
#endif
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void Touch::touch(touch_control_t *control) {
break;
#endif

case MENU_SCREEN: ui.goto_screen((screenFunc_t)control->data); break;
case MENU_SCREEN: ui.goto_screen(screenFunc_t(control->data)); break;
case BACK: ui.goto_previous_screen(); break;
case MENU_CLICK:
TERN_(SINGLE_TOUCH_NAVIGATION, ui.encoderPosition = control->data);
Expand All @@ -180,7 +180,7 @@ void Touch::touch(touch_control_t *control) {
break;
case PAGE_DOWN:
encoderTopLine = (encoderTopLine + 2 * LCD_HEIGHT < screen_items) ? encoderTopLine + LCD_HEIGHT : screen_items - LCD_HEIGHT;
ui.encoderPosition = ui.encoderPosition + LCD_HEIGHT < (uint32_t)screen_items ? ui.encoderPosition + LCD_HEIGHT : screen_items;
ui.encoderPosition = ui.encoderPosition + LCD_HEIGHT < uint32_t(screen_items) ? ui.encoderPosition + LCD_HEIGHT : screen_items;
ui.refresh();
break;
case SLIDER: hold(control); ui.encoderPosition = (x - control->x) * control->data / control->width; break;
Expand Down Expand Up @@ -259,16 +259,16 @@ void Touch::touch(touch_control_t *control) {
#endif

case MOVE_AXIS:
ui.goto_screen((screenFunc_t)ui.move_axis_screen);
ui.goto_screen(screenFunc_t(ui.move_axis_screen));
break;

// TODO: TOUCH could receive data to pass to the callback
case BUTTON: ((screenFunc_t)control->data)(); break;
case BUTTON: (screenFunc_t(control->data))(); break;
case CALLBACK:
DEBUG_ECHOLNPGM("Previous event value: ", touch_event.index);
DEBUG_ECHOLNPGM("Previous event value: ", touch_event.index);
touch_event.index = control->index;
DEBUG_ECHOLNPGM("Create touch event: ", touch_event.index);
((touch_handler_t)control->data)(&touch_event);
(touch_handler_t(control->data))(&touch_event);
break;

default: break;
Expand Down
9 changes: 3 additions & 6 deletions Marlin/src/lcd/tft/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,14 @@ enum TouchControlType : uint16_t {

typedef struct __attribute__((__packed__)) {
TouchControlType type;
uint16_t x;
uint16_t y;
uint16_t width;
uint16_t height;
uint16_t x, y;
uint16_t width, height;
intptr_t data;
int32_t index;
} touch_control_t;

typedef struct {
uint16_t x;
uint16_t y;
uint16_t x, y;
int32_t index;
} touch_event_t;

Expand Down
Loading

0 comments on commit 5a1ca0c

Please sign in to comment.