Procházet zdrojové kódy

Anet ET4 / ET4P and Anet TFT28 / TFT35 (#20280)

Keith Bennett před 3 roky
rodič
revize
a0c8d348a0
No account linked to committer's email address

+ 10
- 0
Marlin/Configuration.h Zobrazit soubor

@@ -2369,6 +2369,16 @@
2369 2369
 //#define LONGER_LK_TFT28
2370 2370
 
2371 2371
 //
2372
+// 320x240, 2.8", FSMC Stock Display from ET4
2373
+//
2374
+//#define ANET_ET4_TFT28
2375
+
2376
+//
2377
+// 480x320, 3.5", FSMC Stock Display from ET5
2378
+//
2379
+//#define ANET_ET5_TFT35
2380
+
2381
+//
2372 2382
 // Generic TFT with detailed options
2373 2383
 //
2374 2384
 //#define TFT_GENERIC

+ 18
- 17
Marlin/src/HAL/STM32/tft/tft_fsmc.cpp Zobrazit soubor

@@ -48,13 +48,14 @@ void TFT_FSMC::Init() {
48 48
 
49 49
   uint32_t NSBank = (uint32_t)pinmap_peripheral(digitalPinToPinName(TFT_CS_PIN), PinMap_FSMC_CS);
50 50
 
51
+  // Perform the SRAM1 memory initialization sequence
51 52
   SRAMx.Instance = FSMC_NORSRAM_DEVICE;
52 53
   SRAMx.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
53
-  /* SRAMx.Init */
54
+  // SRAMx.Init
54 55
   SRAMx.Init.NSBank = NSBank;
55 56
   SRAMx.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
56 57
   SRAMx.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
57
-  SRAMx.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
58
+  SRAMx.Init.MemoryDataWidth = TERN(TFT_INTERFACE_FSMC_8BIT, FSMC_NORSRAM_MEM_BUS_WIDTH_8, FSMC_NORSRAM_MEM_BUS_WIDTH_16);
58 59
   SRAMx.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
59 60
   SRAMx.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
60 61
   SRAMx.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
@@ -67,8 +68,8 @@ void TFT_FSMC::Init() {
67 68
   #ifdef STM32F4xx
68 69
     SRAMx.Init.PageSize = FSMC_PAGE_SIZE_NONE;
69 70
   #endif
70
-  /* Read Timing - relatively slow to ensure ID information is correctly read from TFT controller */
71
-  /* Can be decreases from 15-15-24 to 4-4-8 with risk of stability loss */
71
+  // Read Timing - relatively slow to ensure ID information is correctly read from TFT controller
72
+  // Can be decreases from 15-15-24 to 4-4-8 with risk of stability loss
72 73
   Timing.AddressSetupTime = 15;
73 74
   Timing.AddressHoldTime = 15;
74 75
   Timing.DataSetupTime = 24;
@@ -76,8 +77,8 @@ void TFT_FSMC::Init() {
76 77
   Timing.CLKDivision = 16;
77 78
   Timing.DataLatency = 17;
78 79
   Timing.AccessMode = FSMC_ACCESS_MODE_A;
79
-  /* Write Timing */
80
-  /* Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss */
80
+  // Write Timing
81
+  // Can be decreases from 8-15-8 to 0-0-1 with risk of stability loss
81 82
   ExtTiming.AddressSetupTime = 8;
82 83
   ExtTiming.AddressHoldTime = 15;
83 84
   ExtTiming.DataSetupTime = 8;
@@ -131,7 +132,7 @@ void TFT_FSMC::Init() {
131 132
 
132 133
 uint32_t TFT_FSMC::GetID() {
133 134
   uint32_t id;
134
-  WriteReg(0x0000);
135
+  WriteReg(0);
135 136
   id = LCD->RAM;
136 137
 
137 138
   if (id == 0)
@@ -141,16 +142,16 @@ uint32_t TFT_FSMC::GetID() {
141 142
   return id;
142 143
 }
143 144
 
144
- uint32_t TFT_FSMC::ReadID(uint16_t Reg) {
145
-   uint32_t id;
146
-   WriteReg(Reg);
147
-   id = LCD->RAM; // dummy read
148
-   id = Reg << 24;
149
-   id |= (LCD->RAM & 0x00FF) << 16;
150
-   id |= (LCD->RAM & 0x00FF) << 8;
151
-   id |= LCD->RAM & 0x00FF;
152
-   return id;
153
- }
145
+uint32_t TFT_FSMC::ReadID(tft_data_t Reg) {
146
+  uint32_t id;
147
+  WriteReg(Reg);
148
+  id = LCD->RAM; // dummy read
149
+  id = Reg << 24;
150
+  id |= (LCD->RAM & 0x00FF) << 16;
151
+  id |= (LCD->RAM & 0x00FF) << 8;
152
+  id |= LCD->RAM & 0x00FF;
153
+  return id;
154
+}
154 155
 
155 156
 bool TFT_FSMC::isBusy() {
156 157
   if (__IS_DMA_ENABLED(&DMAtx))

+ 25
- 16
Marlin/src/HAL/STM32/tft/tft_fsmc.h Zobrazit soubor

@@ -44,9 +44,12 @@
44 44
 #define DATASIZE_16BIT SPI_DATASIZE_16BIT
45 45
 #define TFT_IO_DRIVER  TFT_FSMC
46 46
 
47
+#define TFT_DATASIZE TERN(TFT_INTERFACE_FSMC_8BIT, DATASIZE_8BIT, DATASIZE_16BIT)
48
+typedef TERN(TFT_INTERFACE_FSMC_8BIT, uint8_t, uint16_t) tft_data_t;
49
+
47 50
 typedef struct {
48
-  __IO uint16_t REG;
49
-  __IO uint16_t RAM;
51
+  __IO tft_data_t REG;
52
+  __IO tft_data_t RAM;
50 53
 } LCD_CONTROLLER_TypeDef;
51 54
 
52 55
 class TFT_FSMC {
@@ -56,8 +59,8 @@ class TFT_FSMC {
56 59
 
57 60
     static LCD_CONTROLLER_TypeDef *LCD;
58 61
 
59
-    static uint32_t ReadID(uint16_t Reg);
60
-    static void Transmit(uint16_t Data) { LCD->RAM = Data; __DSB(); }
62
+    static uint32_t ReadID(tft_data_t Reg);
63
+    static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); }
61 64
     static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
62 65
 
63 66
   public:
@@ -66,11 +69,11 @@ class TFT_FSMC {
66 69
     static bool isBusy();
67 70
     static void Abort() { __HAL_DMA_DISABLE(&DMAtx); }
68 71
 
69
-    static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) {}
72
+    static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {}
70 73
     static void DataTransferEnd() {};
71 74
 
72
-    static void WriteData(uint16_t Data) { Transmit(Data); }
73
-    static void WriteReg(uint16_t Reg) { LCD->REG = Reg; __DSB(); }
75
+    static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); }
76
+    static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); }
74 77
 
75 78
     static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); }
76 79
     static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); }
@@ -98,14 +101,16 @@ const PinMap PinMap_FSMC[] = {
98 101
   {PE_8,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D05
99 102
   {PE_9,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D06
100 103
   {PE_10,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D07
101
-  {PE_11,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D08
102
-  {PE_12,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D09
103
-  {PE_13,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D10
104
-  {PE_14,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D11
105
-  {PE_15,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D12
106
-  {PD_8,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D13
107
-  {PD_9,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D14
108
-  {PD_10,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D15
104
+  #if DISABLED(TFT_INTERFACE_FSMC_8BIT)
105
+    {PE_11,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D08
106
+    {PE_12,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D09
107
+    {PE_13,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D10
108
+    {PE_14,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D11
109
+    {PE_15,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D12
110
+    {PD_8,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D13
111
+    {PD_9,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D14
112
+    {PD_10,  FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_D15
113
+  #endif
109 114
   {PD_4,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NOE
110 115
   {PD_5,   FSMC_NORSRAM_DEVICE, FSMC_PIN_DATA}, // FSMC_NWE
111 116
   {NC,    NP,    0}
@@ -121,7 +126,11 @@ const PinMap PinMap_FSMC_CS[] = {
121 126
   {NC,    NP,    0}
122 127
 };
123 128
 
124
-#define FSMC_RS(A)  (void *)((2 << A) - 2)
129
+#if ENABLED(TFT_INTERFACE_FSMC_8BIT)
130
+  #define FSMC_RS(A)  (void *)((2 << (A-1)) - 1)
131
+#else
132
+  #define FSMC_RS(A)  (void *)((2 << A) - 2)
133
+#endif
125 134
 
126 135
 const PinMap PinMap_FSMC_RS[] = {
127 136
   #ifdef PF0

+ 2
- 7
Marlin/src/HAL/STM32/tft/xpt2046.h Zobrazit soubor

@@ -23,8 +23,10 @@
23 23
 
24 24
 #ifdef STM32F1xx
25 25
   #include <stm32f1xx_hal.h>
26
+  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
26 27
 #elif defined(STM32F4xx)
27 28
   #include <stm32f4xx_hal.h>
29
+  #define __IS_DMA_ENABLED(__HANDLE__)  ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
28 30
 #endif
29 31
 
30 32
 #include "../../../inc/MarlinConfig.h"
@@ -60,13 +62,6 @@ enum XPTCoordinate : uint8_t {
60 62
   #define XPT2046_Z1_THRESHOLD 10
61 63
 #endif
62 64
 
63
-#ifdef STM32F1xx
64
-  #define __IS_DMA_ENABLED(__HANDLE__)      ((__HANDLE__)->Instance->CCR & DMA_CCR_EN)
65
-#elif defined(STM32F4xx)
66
-  #define __IS_DMA_ENABLED(__HANDLE__)      ((__HANDLE__)->Instance->CR & DMA_SxCR_EN)
67
-#endif
68
-
69
-
70 65
 class XPT2046 {
71 66
 private:
72 67
   static SPI_HandleTypeDef SPIx;

+ 2
- 0
Marlin/src/core/boards.h Zobrazit soubor

@@ -370,6 +370,8 @@
370 370
 #define BOARD_MKS_ROBIN2              4218  // MKS_ROBIN2 (STM32F407ZE)
371 371
 #define BOARD_MKS_ROBIN_PRO_V2        4219  // MKS Robin Pro V2 (STM32F407VE)
372 372
 #define BOARD_MKS_ROBIN_NANO_V3       4220  // MKS Robin Nano V3 (STM32F407VG)
373
+#define BOARD_ANET_ET4                4221  // ANET ET4 V1.x (STM32F407VGT6)
374
+#define BOARD_ANET_ET4P               4222  // ANET ET4P V1.x (STM32F407VGT6)
373 375
 
374 376
 //
375 377
 // ARM Cortex M7

+ 3
- 1
Marlin/src/core/macros.h Zobrazit soubor

@@ -151,7 +151,7 @@
151 151
 
152 152
 #endif
153 153
 
154
-// Macros to chain up to 12 conditions
154
+// Macros to chain up to 14 conditions
155 155
 #define _DO_1(W,C,A)       (_##W##_1(A))
156 156
 #define _DO_2(W,C,A,B)     (_##W##_1(A) C _##W##_1(B))
157 157
 #define _DO_3(W,C,A,V...)  (_##W##_1(A) C _DO_2(W,C,V))
@@ -164,6 +164,8 @@
164 164
 #define _DO_10(W,C,A,V...) (_##W##_1(A) C _DO_9(W,C,V))
165 165
 #define _DO_11(W,C,A,V...) (_##W##_1(A) C _DO_10(W,C,V))
166 166
 #define _DO_12(W,C,A,V...) (_##W##_1(A) C _DO_11(W,C,V))
167
+#define _DO_13(W,C,A,V...) (_##W##_1(A) C _DO_12(W,C,V))
168
+#define _DO_14(W,C,A,V...) (_##W##_1(A) C _DO_13(W,C,V))
167 169
 #define __DO_N(W,C,N,V...) _DO_##N(W,C,V)
168 170
 #define _DO_N(W,C,N,V...)  __DO_N(W,C,N,V)
169 171
 #define DO(W,C,V...)       (_DO_N(W,C,NUM_ARGS(V),V))

+ 19
- 19
Marlin/src/inc/Conditionals_LCD.h Zobrazit soubor

@@ -1073,28 +1073,23 @@
1073 1073
  *  - TFT_COLOR
1074 1074
  *  - GRAPHICAL_TFT_UPSCALE
1075 1075
  */
1076
-#if ENABLED(MKS_TS35_V2_0)
1077
-  // Most common: ST7796
1076
+#if ENABLED(MKS_TS35_V2_0)          // Most common: ST7796
1078 1077
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
1079 1078
   #define TFT_RES_480x320
1080 1079
   #define TFT_INTERFACE_SPI
1081
-#elif ENABLED(MKS_ROBIN_TFT24)
1082
-  // Most common: ST7789
1080
+#elif ENABLED(MKS_ROBIN_TFT24)      // Most common: ST7789
1083 1081
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
1084 1082
   #define TFT_RES_320x240
1085 1083
   #define TFT_INTERFACE_FSMC
1086
-#elif ENABLED(MKS_ROBIN_TFT28)
1087
-  // Most common: ST7789
1084
+#elif ENABLED(MKS_ROBIN_TFT28)      // Most common: ST7789
1088 1085
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
1089 1086
   #define TFT_RES_320x240
1090 1087
   #define TFT_INTERFACE_FSMC
1091
-#elif ENABLED(MKS_ROBIN_TFT32)
1092
-  // Most common: ST7789
1088
+#elif ENABLED(MKS_ROBIN_TFT32)      // Most common: ST7789
1093 1089
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
1094 1090
   #define TFT_RES_320x240
1095 1091
   #define TFT_INTERFACE_FSMC
1096
-#elif ENABLED(MKS_ROBIN_TFT35)
1097
-  // Most common: ILI9488
1092
+#elif ENABLED(MKS_ROBIN_TFT35)      // Most common: ILI9488
1098 1093
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
1099 1094
   #define TFT_RES_480x320
1100 1095
   #define TFT_INTERFACE_FSMC
@@ -1103,12 +1098,11 @@
1103 1098
   #define TFT_DRIVER SSD1963
1104 1099
   #define TFT_RES_480x272
1105 1100
   #define TFT_INTERFACE_FSMC
1106
-#elif ENABLED(MKS_ROBIN_TFT_V1_1R)
1107
-  // ILI9328 or R61505
1101
+#elif ENABLED(MKS_ROBIN_TFT_V1_1R)  // ILI9328 or R61505
1108 1102
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
1109 1103
   #define TFT_RES_320x240
1110 1104
   #define TFT_INTERFACE_FSMC
1111
-#elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35)
1105
+#elif EITHER(TFT_TRONXY_X5SA, ANYCUBIC_TFT35) // ILI9488
1112 1106
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
1113 1107
   #define TFT_DRIVER ILI9488
1114 1108
   #define TFT_RES_480x320
@@ -1117,6 +1111,14 @@
1117 1111
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
1118 1112
   #define TFT_RES_320x240
1119 1113
   #define TFT_INTERFACE_FSMC
1114
+#elif ENABLED(ANET_ET4_TFT28)       // ST7789
1115
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_Y)
1116
+  #define TFT_RES_320x240
1117
+  #define TFT_INTERFACE_FSMC
1118
+#elif ENABLED(ANET_ET5_TFT35)       // ST7796
1119
+  #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY)
1120
+  #define TFT_RES_480x320
1121
+  #define TFT_INTERFACE_FSMC
1120 1122
 #elif ENABLED(TFT_GENERIC)
1121 1123
   #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y)
1122 1124
   #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320)
@@ -1197,11 +1199,9 @@
1197 1199
     #define TOUCH_OFFSET_X       XPT2046_X_OFFSET
1198 1200
     #define TOUCH_OFFSET_Y       XPT2046_Y_OFFSET
1199 1201
     #define TOUCH_ORIENTATION    TOUCH_LANDSCAPE
1200
-  #else
1201
-    #define TOUCH_CALIBRATION_X  0
1202
-    #define TOUCH_CALIBRATION_Y  0
1203
-    #define TOUCH_OFFSET_X       0
1204
-    #define TOUCH_OFFSET_Y       0
1205
-    #define TOUCH_ORIENTATION    TOUCH_ORIENTATION_NONE
1206 1202
   #endif
1207 1203
 #endif
1204
+
1205
+#if MB(ANET_ET4, ANET_ET4P)
1206
+  #define IS_ANET_ET 1
1207
+#endif

+ 2
- 2
Marlin/src/inc/SanityCheck.h Zobrazit soubor

@@ -2303,7 +2303,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
2303 2303
   + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) \
2304 2304
   + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \
2305 2305
   + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \
2306
-  + COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R) \
2306
+  + COUNT_ENABLED(MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, ANET_ET4_TFT28, ANET_ET5_TFT35) \
2307 2307
   + COUNT_ENABLED(TFTGLCD_PANEL_SPI, TFTGLCD_PANEL_I2C) \
2308 2308
   + COUNT_ENABLED(VIKI2, miniVIKI) \
2309 2309
   + COUNT_ENABLED(ZONESTAR_12864LCD, ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) \
@@ -2347,7 +2347,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
2347 2347
 #undef IS_EXTUI
2348 2348
 #undef IS_LEGACY_TFT
2349 2349
 
2350
-#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28)
2350
+#if ANY(TFT_GENERIC, MKS_TS35_V2_0, MKS_ROBIN_TFT24, MKS_ROBIN_TFT28, MKS_ROBIN_TFT32, MKS_ROBIN_TFT35, MKS_ROBIN_TFT43, MKS_ROBIN_TFT_V1_1R, TFT_TRONXY_X5SA, ANYCUBIC_TFT35, ANYCUBIC_TFT35, LONGER_LK_TFT28, ANET_ET4_TFT28, ANET_ET5_TFT35)
2351 2351
   #if NONE(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI)
2352 2352
     #error "TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI is required for your TFT. Please enable one."
2353 2353
   #elif 1 < ENABLED(TFT_COLOR_UI) + ENABLED(TFT_CLASSIC_UI) + ENABLED(TFT_LVGL_UI)

+ 1
- 1
Marlin/src/lcd/tft/canvas.cpp Zobrazit soubor

@@ -95,7 +95,7 @@ void CANVAS::AddImage(int16_t x, int16_t y, MarlinImage image, uint16_t *colors)
95 95
     if (line >= startLine && line < endLine) {
96 96
       uint16_t *pixel = buffer + x + (line - startLine) * width;
97 97
       for (int16_t j = 0; j < image_width; j++) {
98
-        if ((x + j >= 0) && (x + j < width)) *pixel = *data;
98
+        if ((x + j >= 0) && (x + j < width)) *pixel = ENDIAN_COLOR(*data);
99 99
         pixel++;
100 100
         data++;
101 101
       }

+ 7
- 0
Marlin/src/lcd/tft/tft.h Zobrazit soubor

@@ -30,6 +30,13 @@
30 30
 
31 31
 #include "../../inc/MarlinConfig.h"
32 32
 
33
+#if TFT_INTERFACE_FSMC_8BIT
34
+  // When we have a 8 bit interface, we need to invert the bytes of the color
35
+  #define ENDIAN_COLOR(C) (((C) >> 8) | ((C) << 8))
36
+#else
37
+  #define ENDIAN_COLOR(C) (C)
38
+#endif
39
+
33 40
 #if HAS_UI_320x240
34 41
   #define TFT_WIDTH         320
35 42
   #define TFT_HEIGHT        240

+ 14
- 13
Marlin/src/lcd/tft/tft_queue.cpp Zobrazit soubor

@@ -158,7 +158,7 @@ void TFT_Queue::fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui
158 158
   task_parameters->y = y;
159 159
   task_parameters->width = width;
160 160
   task_parameters->height = height;
161
-  task_parameters->color = color;
161
+  task_parameters->color = ENDIAN_COLOR(color);
162 162
   task_parameters->count = width * height;
163 163
 
164 164
   *end_of_queue = TASK_END_OF_QUEUE;
@@ -200,7 +200,7 @@ void TFT_Queue::set_background(uint16_t color) {
200 200
   last_parameter = end_of_queue;
201 201
 
202 202
   parameters->type = CANVAS_SET_BACKGROUND;
203
-  parameters->color = color;
203
+  parameters->color = ENDIAN_COLOR(color);
204 204
 
205 205
   end_of_queue += sizeof(parametersCanvasBackground_t);
206 206
   task_parameters->count++;
@@ -227,7 +227,7 @@ void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string
227 227
   parameters->type = CANVAS_ADD_TEXT;
228 228
   parameters->x = x;
229 229
   parameters->y = y;
230
-  parameters->color = color;
230
+  parameters->color = ENDIAN_COLOR(color);
231 231
   parameters->stringLength = 0;
232 232
   parameters->maxWidth = maxWidth;
233 233
 
@@ -261,18 +261,19 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *col
261 261
   if (color_mode == HIGHCOLOR) return;
262 262
 
263 263
   uint16_t *color = (uint16_t *)end_of_queue;
264
-  uint8_t number_of_color = 0;
264
+  uint8_t color_count = 0;
265 265
 
266 266
   switch (color_mode) {
267
-    case GREYSCALE1:  number_of_color =  1; break;
268
-    case GREYSCALE2:  number_of_color =  3; break;
269
-    case GREYSCALE4:  number_of_color = 15; break;
270
-    default:
271
-      break;
267
+    case GREYSCALE1: color_count =  1; break;
268
+    case GREYSCALE2: color_count =  3; break;
269
+    case GREYSCALE4: color_count = 15; break;
270
+    default: break;
272 271
   }
273 272
 
274
-  while (number_of_color--) {
275
-    *color++ = *colors++;
273
+  uint16_t tmp;
274
+  while (color_count--) {
275
+    tmp = *colors++;
276
+    *color++ = ENDIAN_COLOR(tmp);
276 277
   }
277 278
 
278 279
   end_of_queue = (uint8_t *)color;
@@ -326,7 +327,7 @@ void TFT_Queue::add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
326 327
   parameters->y = y;
327 328
   parameters->width = width;
328 329
   parameters->height = height;
329
-  parameters->color = color;
330
+  parameters->color = ENDIAN_COLOR(color);
330 331
 
331 332
   end_of_queue += sizeof(parametersCanvasBar_t);
332 333
   task_parameters->count++;
@@ -344,7 +345,7 @@ void TFT_Queue::add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t h
344 345
   parameters->y = y;
345 346
   parameters->width = width;
346 347
   parameters->height = height;
347
-  parameters->color = color;
348
+  parameters->color = ENDIAN_COLOR(color);
348 349
 
349 350
   end_of_queue += sizeof(parametersCanvasRectangle_t);
350 351
   task_parameters->count++;

+ 7
- 7
Marlin/src/lcd/tft/ui_320x240.cpp Zobrazit soubor

@@ -414,21 +414,21 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
414 414
   extern screenFunc_t _manual_move_func_ptr;
415 415
   if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) {
416 416
 
417
-    #define SLIDER_LENGHT 224
417
+    #define SLIDER_LENGTH 224
418 418
     #define SLIDER_Y_POSITION 140
419 419
 
420
-    tft.canvas((TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION, SLIDER_LENGHT, 16);
420
+    tft.canvas((TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION, SLIDER_LENGTH, 16);
421 421
     tft.set_background(COLOR_BACKGROUND);
422 422
 
423
-    int16_t position = (SLIDER_LENGHT - 2) * ui.encoderPosition / maxEditValue;
423
+    int16_t position = (SLIDER_LENGTH - 2) * ui.encoderPosition / maxEditValue;
424 424
     tft.add_bar(0, 7, 1, 2, ui.encoderPosition == 0 ? COLOR_SLIDER_INACTIVE : COLOR_SLIDER);
425 425
     tft.add_bar(1, 6, position, 4, COLOR_SLIDER);
426
-    tft.add_bar(position + 1, 6, SLIDER_LENGHT - 2 - position, 4, COLOR_SLIDER_INACTIVE);
427
-    tft.add_bar(SLIDER_LENGHT - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
426
+    tft.add_bar(position + 1, 6, SLIDER_LENGTH - 2 - position, 4, COLOR_SLIDER_INACTIVE);
427
+    tft.add_bar(SLIDER_LENGTH - 1, 7, 1, 2, int32_t(ui.encoderPosition) == maxEditValue ? COLOR_SLIDER : COLOR_SLIDER_INACTIVE);
428 428
 
429 429
     #if ENABLED(TOUCH_SCREEN)
430
-      tft.add_image((SLIDER_LENGHT - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
431
-      touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGHT) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGHT, 32, maxEditValue);
430
+      tft.add_image((SLIDER_LENGTH - 8) * ui.encoderPosition / maxEditValue, 0, imgSlider, COLOR_SLIDER);
431
+      touch.add_control(SLIDER, (TFT_WIDTH - SLIDER_LENGTH) / 2, SLIDER_Y_POSITION - 8, SLIDER_LENGTH, 32, maxEditValue);
432 432
     #endif
433 433
   }
434 434
 

+ 13
- 1
Marlin/src/lcd/tft_io/tft_io.h Zobrazit soubor

@@ -75,8 +75,20 @@
75 75
 #define TOUCH_LANDSCAPE         1
76 76
 #define TOUCH_PORTRAIT          2
77 77
 
78
+#ifndef TOUCH_CALIBRATION_X
79
+  #define TOUCH_CALIBRATION_X   0
80
+#endif
81
+#ifndef TOUCH_CALIBRATION_Y
82
+  #define TOUCH_CALIBRATION_Y   0
83
+#endif
84
+#ifndef TOUCH_OFFSET_X
85
+  #define TOUCH_OFFSET_X        0
86
+#endif
87
+#ifndef TOUCH_OFFSET_Y
88
+  #define TOUCH_OFFSET_Y        0
89
+#endif
78 90
 #ifndef TOUCH_ORIENTATION
79
-  #define TOUCH_ORIENTATION    TOUCH_LANDSCAPE
91
+  #define TOUCH_ORIENTATION     TOUCH_LANDSCAPE
80 92
 #endif
81 93
 
82 94
 #define SSD1963         0x5761

+ 4
- 0
Marlin/src/pins/pins.h Zobrazit soubor

@@ -598,6 +598,10 @@
598 598
   #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h"    // STM32F4                                env:mks_robin_pro2
599 599
 #elif MB(MKS_ROBIN_NANO_V3)
600 600
   #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h"   // STM32F4                                env:mks_robin_nano_v3
601
+#elif MB(ANET_ET4)
602
+  #include "stm32f4/pins_ANET_ET4.h"            // STM32F4                                env:Anet_ET4_OpenBLT
603
+#elif MB(ANET_ET4P)
604
+  #include "stm32f4/pins_ANET_ET4P.h"           // STM32F4                                env:Anet_ET4_OpenBLT
601 605
 
602 606
 //
603 607
 // ARM Cortex M7

+ 223
- 0
Marlin/src/pins/stm32f4/pins_ANET_ET4.h Zobrazit soubor

@@ -0,0 +1,223 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+#if NOT_TARGET(STM32F4)
26
+  #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
27
+#elif HOTENDS > 1 || E_STEPPERS > 1
28
+  #error "Anet ET4 only supports one hotend / E-stepper. Comment out this line to continue."
29
+#endif
30
+
31
+#ifndef BOARD_INFO_NAME
32
+  #define BOARD_INFO_NAME "Anet ET4 1.x"
33
+#endif
34
+
35
+//
36
+// EEPROM
37
+//
38
+
39
+// Use one of these or SDCard-based Emulation will be used
40
+#if NO_EEPROM_SELECTED
41
+  //#define SRAM_EEPROM_EMULATION                 // Use BackSRAM-based EEPROM emulation
42
+  #define FLASH_EEPROM_EMULATION                  // Use Flash-based EEPROM emulation
43
+  //#define IIC_BL24CXX_EEPROM                    // Use I2C EEPROM onboard IC (AT24C04C, Size 4KB, PageSize 16B)
44
+#endif
45
+
46
+#if ENABLED(FLASH_EEPROM_EMULATION)
47
+  // Decrease delays and flash wear by spreading writes across the
48
+  // 128 kB sector allocated for EEPROM emulation.
49
+  #define FLASH_EEPROM_LEVELING
50
+#elif ENABLED(IIC_BL24CXX_EEPROM)
51
+  #define IIC_EEPROM_SDA                    PB11
52
+  #define IIC_EEPROM_SCL                    PB10
53
+  #define EEPROM_DEVICE_ADDRESS             0xA0
54
+  #define MARLIN_EEPROM_SIZE              0x1000  // 4KB
55
+#endif
56
+
57
+//
58
+// Limit Switches
59
+//
60
+#define X_STOP_PIN                          PC13
61
+#define Y_STOP_PIN                          PE12
62
+#define Z_STOP_PIN                          PE11
63
+
64
+//
65
+// Z Probe
66
+//
67
+#if ENABLED(BLTOUCH)
68
+  #error "You will need to use 24V to 5V converter and remove one resistor and capacitor from the motherboard. See https://github.com/davidtgbe/Marlin/blob/bugfix-2.0.x/docs/Tutorials/bltouch-en.md for more information. Comment out this line to proceed at your own risk."
69
+  #define SERVO0_PIN                        PC3
70
+#elif !defined(Z_MIN_PROBE_PIN)
71
+  #define Z_MIN_PROBE_PIN                   PC3
72
+#endif
73
+
74
+//
75
+// Filament Runout Sensor
76
+//
77
+#ifndef FIL_RUNOUT_PIN
78
+  #define FIL_RUNOUT_PIN                    PA2
79
+#endif
80
+
81
+//
82
+// Power Loss Detection
83
+//
84
+#ifndef POWER_LOSS_PIN
85
+  #define POWER_LOSS_PIN                    PA8
86
+#endif
87
+
88
+//
89
+// LED PIN
90
+//
91
+#define LED_PIN                             PD12
92
+
93
+//
94
+// Steppers
95
+//
96
+#define X_STEP_PIN                          PB6
97
+#define X_DIR_PIN                           PB5
98
+#define X_ENABLE_PIN                        PB7
99
+
100
+#define Y_STEP_PIN                          PB3
101
+#define Y_DIR_PIN                           PD6
102
+#define Y_ENABLE_PIN                        PB4
103
+
104
+#define Z_STEP_PIN                          PA12
105
+#define Z_DIR_PIN                           PA11
106
+#define Z_ENABLE_PIN                        PA15
107
+
108
+#define E0_STEP_PIN                         PB9
109
+#define E0_DIR_PIN                          PB8
110
+#define E0_ENABLE_PIN                       PE0
111
+
112
+//
113
+// Temperature Sensors
114
+//
115
+#define TEMP_0_PIN                          PA1
116
+#define TEMP_BED_PIN                        PA4
117
+
118
+//
119
+// Heaters
120
+//
121
+#define HEATER_0_PIN                        PA0
122
+#define HEATER_BED_PIN                      PE2
123
+
124
+//
125
+// Fans
126
+//
127
+#define FAN_PIN                             PE3   // Layer fan
128
+#define FAN1_PIN                            PE1   // Hotend fan
129
+
130
+#ifndef E0_AUTO_FAN_PIN
131
+  #define E0_AUTO_FAN_PIN               FAN1_PIN
132
+#endif
133
+
134
+//
135
+// LCD / Controller
136
+//
137
+#define TFT_RESET_PIN                       PE6
138
+#define TFT_CS_PIN                          PD7
139
+#define TFT_RS_PIN                          PD13
140
+#define TFT_INTERFACE_FSMC_8BIT
141
+
142
+//
143
+// Touch Screen
144
+// https://ldm-systems.ru/f/doc/catalog/HY-TFT-2,8/XPT2046.pdf
145
+//
146
+#if ENABLED(TOUCH_SCREEN)
147
+  #define TOUCH_CS_PIN                      PB2
148
+  #define TOUCH_SCK_PIN                     PB0
149
+  #define TOUCH_MOSI_PIN                    PE5
150
+  #define TOUCH_MISO_PIN                    PE4
151
+  #define TOUCH_INT_PIN                     PB1
152
+#endif
153
+
154
+// Touchscreen calibration does not work correctly with ANET_ET5_TFT35 or ANET_ET4_TFT28
155
+#if ENABLED(TOUCH_SCREEN_CALIBRATION)
156
+  #undef TOUCH_SCREEN_CALIBRATION
157
+#endif
158
+
159
+#if ENABLED(ANET_ET5_TFT35)
160
+  #ifndef TOUCH_CALIBRATION_X
161
+    #define TOUCH_CALIBRATION_X            17125
162
+  #endif
163
+  #ifndef TOUCH_CALIBRATION_Y
164
+    #define TOUCH_CALIBRATION_Y           -11307
165
+  #endif
166
+  #ifndef TOUCH_OFFSET_X
167
+    #define TOUCH_OFFSET_X                   -26
168
+  #endif
169
+  #ifndef TOUCH_OFFSET_Y
170
+    #define TOUCH_OFFSET_Y                   337
171
+  #endif
172
+  #ifndef TOUCH_ORIENTATION
173
+    #define TOUCH_ORIENTATION     TOUCH_PORTRAIT
174
+  #endif
175
+#elif ENABLED(ANET_ET4_TFT28)
176
+  #ifndef TOUCH_CALIBRATION_X
177
+    #define TOUCH_CALIBRATION_X           -11838
178
+  #endif
179
+  #ifndef TOUCH_CALIBRATION_Y
180
+    #define TOUCH_CALIBRATION_Y             8776
181
+  #endif
182
+  #ifndef TOUCH_OFFSET_X
183
+    #define TOUCH_OFFSET_X                   333
184
+  #endif
185
+  #ifndef TOUCH_OFFSET_Y
186
+    #define TOUCH_OFFSET_Y                   -17
187
+  #endif
188
+  #ifndef TOUCH_ORIENTATION
189
+    #define TOUCH_ORIENTATION     TOUCH_PORTRAIT
190
+  #endif
191
+#endif
192
+
193
+//
194
+// SD Card
195
+//
196
+//#define SDIO_SUPPORT
197
+
198
+#ifndef SDCARD_CONNECTION
199
+  #define SDCARD_CONNECTION         CUSTOM_CABLE
200
+#endif
201
+
202
+#if ENABLED(SDSUPPORT)
203
+
204
+  #define SDIO_D0_PIN                       PC8
205
+  #define SDIO_D1_PIN                       PC9
206
+  #define SDIO_D2_PIN                       PC10
207
+  #define SDIO_D3_PIN                       PC11
208
+  #define SDIO_CK_PIN                       PC12
209
+  #define SDIO_CMD_PIN                      PD2
210
+
211
+  #if DISABLED(SDIO_SUPPORT)
212
+    #define SOFTWARE_SPI
213
+    #define SDSS                     SDIO_D3_PIN
214
+    #define SCK_PIN                  SDIO_CK_PIN
215
+    #define MISO_PIN                 SDIO_D0_PIN
216
+    #define MOSI_PIN                SDIO_CMD_PIN
217
+  #endif
218
+
219
+  #ifndef SD_DETECT_PIN
220
+    #define SD_DETECT_PIN                   PD3
221
+  #endif
222
+
223
+#endif

+ 34
- 0
Marlin/src/pins/stm32f4/pins_ANET_ET4P.h Zobrazit soubor

@@ -0,0 +1,34 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 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 <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#pragma once
24
+
25
+#define BOARD_INFO_NAME "Anet ET4P 1.x"
26
+
27
+//
28
+// TMC2208 Configuration_adv defaults for Anet ET4P-MB_V1.x
29
+//
30
+#if !AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_Z(TMC2208_STANDALONE) || !AXIS_DRIVER_TYPE_E0(TMC2208_STANDALONE)
31
+  #error "ANET_ET4P requires ([XYZ]|E0)_DRIVER_TYPE set to TMC2208_STANDALONE."
32
+#endif
33
+
34
+#include "pins_ANET_ET4.h"

+ 23
- 0
platformio.ini Zobrazit soubor

@@ -1242,6 +1242,29 @@ extra_scripts     = ${common.extra_scripts}
1242 1242
   pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1243 1243
 
1244 1244
 #
1245
+# Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4)
1246
+# For use with with davidtgbe's OpenBLT bootloader https://github.com/davidtgbe/openblt/releases
1247
+# Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000.
1248
+#
1249
+[env:Anet_ET4_OpenBLT]
1250
+platform             = ${common_stm32.platform}
1251
+extends              = common_stm32
1252
+build_flags          = ${common_stm32.build_flags} -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED
1253
+board                = genericSTM32F407VGT6
1254
+board_build.core     = stm32
1255
+board_build.variant  = MARLIN_F4x7Vx
1256
+board_build.ldscript = ldscript.ld
1257
+board_build.firmware = firmware.srec
1258
+board_build.offset   = 0x10000
1259
+board_upload.offset_address = 0x08010000
1260
+build_unflags        = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC -DUSBD_VID=0x0483
1261
+debug_tool           = jlink
1262
+upload_protocol      = jlink
1263
+extra_scripts        = ${common.extra_scripts}
1264
+  pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
1265
+  buildroot/share/PlatformIO/scripts/stm32_bootloader.py
1266
+
1267
+#
1245 1268
 # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4)
1246 1269
 #
1247 1270
 [env:BIGTREE_SKR_PRO]

Loading…
Zrušit
Uložit