Skip to content

Commit 4f902ac

Browse files
authored
🐛 Fix Simulator TFT compile (MarlinFirmware#25279)
1 parent cf02107 commit 4f902ac

File tree

4 files changed

+96
-84
lines changed

4 files changed

+96
-84
lines changed

Marlin/src/HAL/NATIVE_SIM/tft/tft_spi.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
#endif
3232

3333
#define DATASIZE_8BIT 8
34-
#define DATASIZE_16BIT 16
35-
#define TFT_IO_DRIVER TFT_SPI
34+
#define DATASIZE_16BIT 16
35+
#define TFT_IO_DRIVER TFT_SPI
36+
#define DMA_MAX_SIZE 0xFFFF
3637

37-
#define DMA_MINC_ENABLE 1
38+
#define DMA_MINC_ENABLE 1
3839
#define DMA_MINC_DISABLE 0
3940

4041
class TFT_SPI {
@@ -58,7 +59,9 @@ class TFT_SPI {
5859
static void WriteData(uint16_t Data);
5960
static void WriteReg(uint16_t Reg);
6061

62+
static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { WriteSequence(Data, Count); }
63+
static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { WriteMultiple(Color, Count); }
64+
6165
static void WriteSequence(uint16_t *Data, uint16_t Count);
62-
// static void WriteMultiple(uint16_t Color, uint16_t Count);
6366
static void WriteMultiple(uint16_t Color, uint32_t Count);
6467
};

Marlin/src/inc/Conditionals_LCD.h

+2-23
Original file line numberDiff line numberDiff line change
@@ -1549,29 +1549,8 @@
15491549
#endif
15501550
#endif
15511551

1552-
// Set TFT_COLOR_UI_PORTRAIT flag, if needed
1553-
#if defined(TFT_ROTATION) && (HAS_SPI_TFT || HAS_FSMC_TFT || HAS_LTDC_TFT)
1554-
#define _CMP_TFT_ROTATE_90 90
1555-
#define _CMP_TFT_ROTATE_270 270
1556-
#define _CMP_TFT_ROTATE_90_MIRROR_X 90
1557-
#define _CMP_TFT_ROTATE_90_MIRROR_Y 90
1558-
#define _CMP_TFT_ROTATE_270_MIRROR_X 270
1559-
#define _CMP_TFT_ROTATE_270_MIRROR_Y 270
1560-
#define _ISROT(N) || (_CAT(_CMP_, TFT_ROTATION) == N)
1561-
#define ISROT(V...) (0 MAP(_ISROT, V))
1562-
1563-
#if ISROT(90, 270)
1564-
#define TFT_COLOR_UI_PORTRAIT 1
1565-
#endif
1566-
1567-
#undef _CMP_TFT_ROTATE_90
1568-
#undef _CMP_TFT_ROTATE_270
1569-
#undef _CMP_TFT_ROTATE_90_MIRROR_X
1570-
#undef _CMP_TFT_ROTATE_90_MIRROR_Y
1571-
#undef _CMP_TFT_ROTATE_270_MIRROR_X
1572-
#undef _CMP_TFT_ROTATE_270_MIRROR_Y
1573-
#undef _ISROT
1574-
#undef ISROT
1552+
#if ANY(HAS_SPI_TFT, HAS_FSMC_TFT, HAS_LTDC_TFT)
1553+
#include "../lcd/tft_io/tft_orientation.h"
15751554
#endif
15761555

15771556
#if ENABLED(TFT_RES_320x240)

Marlin/src/lcd/tft_io/tft_io.h

+2-57
Original file line numberDiff line numberDiff line change
@@ -34,65 +34,10 @@
3434
#endif
3535

3636
#ifndef DMA_MAX_SIZE
37-
#error "MAX_DMA_SIZE is not configured for this platform."
37+
#error "DMA_MAX_SIZE is not configured for this platform."
3838
#endif
3939

40-
#define TFT_EXCHANGE_XY _BV32(1)
41-
#define TFT_INVERT_X _BV32(2)
42-
#define TFT_INVERT_Y _BV32(3)
43-
44-
#define TFT_NO_ROTATION (0x00)
45-
#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
46-
#define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y)
47-
#define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y)
48-
49-
#define TFT_MIRROR_X (TFT_INVERT_Y)
50-
#define TFT_MIRROR_Y (TFT_INVERT_X)
51-
52-
#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_MIRROR_X)
53-
#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_MIRROR_Y)
54-
55-
#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_MIRROR_X)
56-
#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_MIRROR_Y)
57-
58-
#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_MIRROR_X)
59-
#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_MIRROR_Y)
60-
61-
// TFT_ROTATION is user configurable
62-
#ifndef TFT_ROTATION
63-
#define TFT_ROTATION TFT_NO_ROTATION
64-
#endif
65-
66-
// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
67-
#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
68-
69-
#define TFT_COLOR_RGB _BV32(3)
70-
#define TFT_COLOR_BGR _BV32(4)
71-
72-
// Each TFT Driver is responsible for its default color mode.
73-
// #ifndef TFT_COLOR
74-
// #define TFT_COLOR TFT_COLOR_RGB
75-
// #endif
76-
77-
#define TOUCH_ORIENTATION_NONE 0
78-
#define TOUCH_LANDSCAPE 1
79-
#define TOUCH_PORTRAIT 2
80-
81-
#ifndef TOUCH_CALIBRATION_X
82-
#define TOUCH_CALIBRATION_X 0
83-
#endif
84-
#ifndef TOUCH_CALIBRATION_Y
85-
#define TOUCH_CALIBRATION_Y 0
86-
#endif
87-
#ifndef TOUCH_OFFSET_X
88-
#define TOUCH_OFFSET_X 0
89-
#endif
90-
#ifndef TOUCH_OFFSET_Y
91-
#define TOUCH_OFFSET_Y 0
92-
#endif
93-
#ifndef TOUCH_ORIENTATION
94-
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
95-
#endif
40+
#include "tft_orientation.h"
9641

9742
#ifndef TFT_DRIVER
9843
#define TFT_DRIVER AUTO
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#define TFT_EXCHANGE_XY _BV32(1)
25+
#define TFT_INVERT_X _BV32(2)
26+
#define TFT_INVERT_Y _BV32(3)
27+
28+
#define TFT_NO_ROTATION (0x00)
29+
#define TFT_ROTATE_90 (TFT_EXCHANGE_XY | TFT_INVERT_X)
30+
#define TFT_ROTATE_180 (TFT_INVERT_X | TFT_INVERT_Y)
31+
#define TFT_ROTATE_270 (TFT_EXCHANGE_XY | TFT_INVERT_Y)
32+
33+
#define TFT_MIRROR_X (TFT_INVERT_Y)
34+
#define TFT_MIRROR_Y (TFT_INVERT_X)
35+
36+
#define TFT_ROTATE_90_MIRROR_X (TFT_ROTATE_90 ^ TFT_MIRROR_X)
37+
#define TFT_ROTATE_90_MIRROR_Y (TFT_ROTATE_90 ^ TFT_MIRROR_Y)
38+
39+
#define TFT_ROTATE_180_MIRROR_X (TFT_ROTATE_180 ^ TFT_MIRROR_X)
40+
#define TFT_ROTATE_180_MIRROR_Y (TFT_ROTATE_180 ^ TFT_MIRROR_Y)
41+
42+
#define TFT_ROTATE_270_MIRROR_X (TFT_ROTATE_270 ^ TFT_MIRROR_X)
43+
#define TFT_ROTATE_270_MIRROR_Y (TFT_ROTATE_270 ^ TFT_MIRROR_Y)
44+
45+
// TFT_ROTATION is user configurable
46+
#ifndef TFT_ROTATION
47+
#define TFT_ROTATION TFT_NO_ROTATION
48+
#endif
49+
50+
// TFT_ORIENTATION is the "sum" of TFT_DEFAULT_ORIENTATION plus user TFT_ROTATION
51+
#define TFT_ORIENTATION ((TFT_DEFAULT_ORIENTATION) ^ (TFT_ROTATION))
52+
53+
// Set TFT_COLOR_UI_PORTRAIT flag, if needed
54+
#if ((TFT_ORIENTATION) & TFT_EXCHANGE_XY) == 0
55+
#define TFT_COLOR_UI_PORTRAIT 1
56+
#endif
57+
58+
#define TFT_COLOR_RGB _BV32(3)
59+
#define TFT_COLOR_BGR _BV32(4)
60+
61+
// Each TFT Driver is responsible for its default color mode.
62+
// #ifndef TFT_COLOR
63+
// #define TFT_COLOR TFT_COLOR_RGB
64+
// #endif
65+
66+
#define TOUCH_ORIENTATION_NONE 0
67+
#define TOUCH_LANDSCAPE 1
68+
#define TOUCH_PORTRAIT 2
69+
70+
#ifndef TOUCH_CALIBRATION_X
71+
#define TOUCH_CALIBRATION_X 0
72+
#endif
73+
#ifndef TOUCH_CALIBRATION_Y
74+
#define TOUCH_CALIBRATION_Y 0
75+
#endif
76+
#ifndef TOUCH_OFFSET_X
77+
#define TOUCH_OFFSET_X 0
78+
#endif
79+
#ifndef TOUCH_OFFSET_Y
80+
#define TOUCH_OFFSET_Y 0
81+
#endif
82+
#ifndef TOUCH_ORIENTATION
83+
#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
84+
#endif
85+

0 commit comments

Comments
 (0)