Skip to content

Commit 9cf5658

Browse files
committed
touch fix + ui improvements
1 parent 4ebac68 commit 9cf5658

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

Diff for: Marlin/Configuration.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@
104104
*
105105
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
106106
*/
107-
#define SERIAL_PORT 0
108107

109108
#if MOTHERBOARD == BOARD_MKS_ROBIN_NANO_V3
110109
#define SERIAL_PORT -1
110+
#else
111+
#define SERIAL_PORT 0
111112
#endif
112113

113114

@@ -3196,7 +3197,9 @@
31963197
//#define DISABLE_ENCODER // Disable the click encoder, if any
31973198
//#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S.
31983199

3199-
//#define TOUCH_SCREEN_CALIBRATION
3200+
#if MOTHERBOARD == BOARD_LINUX_RAMPS
3201+
#define TOUCH_SCREEN_CALIBRATION
3202+
#endif
32003203

32013204
//#define TOUCH_CALIBRATION_X 12316
32023205
//#define TOUCH_CALIBRATION_Y -8981

Diff for: Marlin/src/inc/Conditionals_LCD.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,12 @@
14901490
#define TFT_INTERFACE_SPI
14911491
#elif ENABLED(MKS_TS35_V2_0_VERTICAL)
14921492
#define TFT_DEFAULT_DRIVER ST7796
1493-
#define TFT_DEFAULT_ORIENTATION TFT_INVERT_Y
1493+
#define TFT_DEFAULT_ORIENTATION TFT_INVERT_Y
1494+
#define TOUCH_ORIENTATION TOUCH_PORTRAIT
1495+
#define TOUCH_CALIBRATION_X 11579
1496+
#define TOUCH_CALIBRATION_Y 17253
1497+
#define TOUCH_OFFSET_X -24
1498+
#define TOUCH_OFFSET_Y -42
14941499
#define TFT_RES_320x480
14951500
#define TFT_INTERFACE_SPI
14961501
#elif EITHER(LERDGE_TFT35, ANET_ET5_TFT35) // ST7796

Diff for: Marlin/src/lcd/tft/touch.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,8 @@ void Touch::init() {
6363
enable();
6464
}
6565

66-
//void Touch::add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, intptr_t data) { // TEST !!!!!!!!!!!!!!
67-
void Touch::add_control(TouchControlType type, uint16_t y, uint16_t x, uint16_t height, uint16_t width, intptr_t data) {
68-
//y = 320 - x;
69-
//y = y;
70-
x = 480 - x - width;
66+
void Touch::add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, intptr_t data) { // TEST !!!!!!!!!!!!!!
67+
7168
if (controls_count == MAX_CONTROLS) return;
7269

7370
controls[controls_count].type = type;
@@ -115,6 +112,11 @@ void Touch::idle() {
115112
if (PENDING(last_touch_ms, time_to_hold)) return;
116113

117114
if (x != 0 && y != 0) {
115+
// char msg[20];
116+
// sprintf_P(msg, "(%d, %d)", x, y);
117+
// ui.set_status(msg);
118+
// return;
119+
118120
if (current_control) {
119121
if (WITHIN(x, current_control->x - FREE_MOVE_RANGE, current_control->x + current_control->width + FREE_MOVE_RANGE) && WITHIN(y, current_control->y - FREE_MOVE_RANGE, current_control->y + current_control->height + FREE_MOVE_RANGE)) {
120122
NOLESS(x, current_control->x);

Diff for: Marlin/src/lcd/tft/ui_320x480.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include "../../inc/MarlinConfigPre.h"
24+
#include "../../HAL/shared/Marduino.h"
2425

2526
#if HAS_UI_320x480
2627

@@ -323,29 +324,29 @@ void MarlinUI::draw_status_screen() {
323324
TERN_(SDSUPPORT, add_control(20, 190, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
324325
#endif //SD !!!!!!!!!!!!!!!!
325326

326-
y += TERN(HAS_UI_480x272, 36, 44);
327327
// print duration
328-
char buffer[14];
328+
const uint8_t progress = ui.get_progress_percent();
329+
char buffer[30];
329330
duration_t elapsed = print_job_timer.duration();
330331
elapsed.toDigital(buffer);
331332

332-
tft.canvas(96, 325, 128, 30);
333+
sprintf_P(buffer, PSTR("%s %d %%"), buffer, progress);
334+
335+
tft.canvas(96, 400, 128, 30);
333336
tft.set_background(COLOR_BACKGROUND);
334337
tft_string.set(buffer);
335338
tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
336339

337-
y += TERN(HAS_UI_480x272, 28, 36);
338340
// progress bar
339-
const uint8_t progress = ui.get_progress_percent();
340-
tft.canvas(4, 380, 312, 9);
341+
//const uint8_t progress = ui.get_progress_percent();
342+
tft.canvas(4, 433, 312, 9);
341343
tft.set_background(COLOR_PROGRESS_BG);
342344
tft.add_rectangle(0, 0, 312, 9, COLOR_PROGRESS_FRAME);
343345
if (progress)
344346
tft.add_bar(1, 1, (310 * progress) / 100, 7, COLOR_PROGRESS_BAR);
345347

346-
y += 20;
347348
// status message
348-
tft.canvas(0, 400, 320, 30);
349+
tft.canvas(0, 445, 320, 30);
349350
tft.set_background(COLOR_BACKGROUND);
350351
tft_string.set(status_message);
351352
tft_string.trim();

0 commit comments

Comments
 (0)