Skip to content

Commit

Permalink
Fix Menu Mixer for Color UI (#20566)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhapsodyv authored and thinkyhead committed Apr 29, 2021
1 parent 910908f commit 427a2fc
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Marlin/src/lcd/menu/menu_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include "../../feature/mixing.h"

#if HAS_GRAPHICAL_TFT
#include "../tft/tft.h"
#endif

#define CHANNEL_MIX_EDITING !HAS_DUAL_MIXING

#if ENABLED(GRADIENT_MIX)
Expand Down Expand Up @@ -67,6 +71,9 @@
mixer.refresh_gradient();
ui.goto_previous_screen();
}
else {
TERN_(HAS_GRAPHICAL_TFT, tft.draw_edit_screen_buttons());
}
}

void lcd_mixer_edit_gradient_menu() {
Expand Down Expand Up @@ -155,6 +162,8 @@ void lcd_mixer_mix_edit() {
ui.goto_previous_screen();
}

TERN_(HAS_GRAPHICAL_TFT, tft.draw_edit_screen_buttons());

#else

START_MENU();
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/tft/tft.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class TFT {
static inline 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 inline 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 inline 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();
};

extern TFT tft;
21 changes: 21 additions & 0 deletions Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
#endif
}

tft.draw_edit_screen_buttons();
}

void TFT::draw_edit_screen_buttons() {
#if ENABLED(TOUCH_SCREEN)
add_control(32, 176, DECREASE, imgDecrease);
add_control(224, 176, INCREASE, imgIncrease);
Expand Down Expand Up @@ -658,6 +662,23 @@ void menu_item(const uint8_t row, bool sel ) {
#endif
}

void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) {
#define TFT_COL_WIDTH ((TFT_WIDTH) / (LCD_WIDTH))
tft.canvas(col * TFT_COL_WIDTH, 4 + 45 * row, TFT_WIDTH - (col * TFT_COL_WIDTH), 43);
tft.set_background(COLOR_BACKGROUND);
}

int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
tft_string.set(utf8_str_P);
tft_string.trim();
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
return tft_string.width();
}

int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return lcd_put_u8str_max_P(utf8_str, max_length);
}

void MarlinUI::move_axis_screen() {
}

Expand Down
21 changes: 21 additions & 0 deletions Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
#endif
}

tft.draw_edit_screen_buttons();
}

void TFT::draw_edit_screen_buttons() {
#if ENABLED(TOUCH_SCREEN)
add_control(64, 256, DECREASE, imgDecrease);
add_control(352, 256, INCREASE, imgIncrease);
Expand Down Expand Up @@ -661,6 +665,23 @@ void menu_item(const uint8_t row, bool sel ) {
#endif
}

void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) {
#define TFT_COL_WIDTH ((TFT_WIDTH) / (LCD_WIDTH))
tft.canvas(col * TFT_COL_WIDTH, 4 + 45 * row, TFT_WIDTH - (col * TFT_COL_WIDTH), 43);
tft.set_background(COLOR_BACKGROUND);
}

int lcd_put_u8str_max_P(PGM_P utf8_str_P, pixel_len_t max_length) {
tft_string.set(utf8_str_P);
tft_string.trim();
tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
return tft_string.width();
}

int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) {
return lcd_put_u8str_max_P(utf8_str, max_length);
}

#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
#include "../../feature/babystep.h"
#endif
Expand Down

0 comments on commit 427a2fc

Please sign in to comment.