Bladeren bron

Fixes for TFTGLCD Panel, FastIO (#19614)

Serhiy-K 3 jaren geleden
bovenliggende
commit
887e2637c0

+ 4
- 4
Marlin/src/HAL/STM32/fastio.h Bestand weergeven

63
 
63
 
64
 #define _GET_MODE(IO)
64
 #define _GET_MODE(IO)
65
 #define _SET_MODE(IO,M)         pinMode(IO, M)
65
 #define _SET_MODE(IO,M)         pinMode(IO, M)
66
-#define _SET_OUTPUT(IO)         pinMode(IO, OUTPUT)                               /*!< Output Push Pull Mode & GPIO_NOPULL   */
66
+#define _SET_OUTPUT(IO)         pinMode(IO, OUTPUT)                               //!< Output Push Pull Mode & GPIO_NOPULL
67
 #define _SET_OUTPUT_OD(IO)      pinMode(IO, OUTPUT_OPEN_DRAIN)
67
 #define _SET_OUTPUT_OD(IO)      pinMode(IO, OUTPUT_OPEN_DRAIN)
68
 
68
 
69
 #define WRITE(IO,V)             _WRITE(IO,V)
69
 #define WRITE(IO,V)             _WRITE(IO,V)
73
 #define OUT_WRITE(IO,V)         do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
73
 #define OUT_WRITE(IO,V)         do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
74
 #define OUT_WRITE_OD(IO,V)      do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
74
 #define OUT_WRITE_OD(IO,V)      do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)
75
 
75
 
76
-#define SET_INPUT(IO)           _SET_MODE(IO, INPUT)                              /*!< Input Floating Mode                   */
77
-#define SET_INPUT_PULLUP(IO)    _SET_MODE(IO, INPUT_PULLUP)                       /*!< Input with Pull-up activation         */
78
-#define SET_INPUT_PULLDOWN(IO)  _SET_MODE(IO, INPUT_PULLDOWN)                     /*!< Input with Pull-down activation       */
76
+#define SET_INPUT(IO)           _SET_MODE(IO, INPUT)                              //!< Input Floating Mode
77
+#define SET_INPUT_PULLUP(IO)    _SET_MODE(IO, INPUT_PULLUP)                       //!< Input with Pull-up activation
78
+#define SET_INPUT_PULLDOWN(IO)  _SET_MODE(IO, INPUT_PULLDOWN)                     //!< Input with Pull-down activation
79
 #define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
79
 #define SET_OUTPUT(IO)          OUT_WRITE(IO, LOW)
80
 #define SET_PWM(IO)             _SET_MODE(IO, PWM)
80
 #define SET_PWM(IO)             _SET_MODE(IO, PWM)
81
 
81
 

+ 1
- 1
Marlin/src/core/language.h Bestand weergeven

303
 #define LCD_STR_C STR_C
303
 #define LCD_STR_C STR_C
304
 #define LCD_STR_E STR_E
304
 #define LCD_STR_E STR_E
305
 
305
 
306
-#if HAS_MARLINUI_HD44780
306
+#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
307
 
307
 
308
   // Custom characters defined in the first 8 characters of the LCD
308
   // Custom characters defined in the first 8 characters of the LCD
309
   #define LCD_STR_BEDTEMP     "\x00" // Print only as a char. This will have 'unexpected' results when used in a string!
309
   #define LCD_STR_BEDTEMP     "\x00" // Print only as a char. This will have 'unexpected' results when used in a string!

+ 1
- 1
Marlin/src/core/utility.h Bestand weergeven

71
   inline void restore() { ref_ = val_; }
71
   inline void restore() { ref_ = val_; }
72
 };
72
 };
73
 
73
 
74
-#define REMEMBER(N,X,V...) restorer<typeof(X)> restorer_##N(X, ##V)
74
+#define REMEMBER(N,X,V...) restorer<__typeof__(X)> restorer_##N(X, ##V)
75
 #define RESTORE(N) restorer_##N.restore()
75
 #define RESTORE(N) restorer_##N.restore()
76
 
76
 
77
 // Converts from an uint8_t in the range of 0-255 to an uint8_t
77
 // Converts from an uint8_t in the range of 0-255 to an uint8_t

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h Bestand weergeven

226
     #define LCD_PROGRESS_BAR
226
     #define LCD_PROGRESS_BAR
227
   #endif
227
   #endif
228
   #if ENABLED(TFTGLCD_PANEL_I2C)
228
   #if ENABLED(TFTGLCD_PANEL_I2C)
229
-    #define LCD_USE_I2C_BUZZER              // Enable buzzer on LCD for I2C and SPI buses (LiquidTWI2 not required)
230
     #define LCD_I2C_ADDRESS           0x27  // Must be equal to panel's I2C slave addres
229
     #define LCD_I2C_ADDRESS           0x27  // Must be equal to panel's I2C slave addres
231
   #endif
230
   #endif
231
+  #define LCD_USE_I2C_BUZZER                // Enable buzzer on LCD, used for both I2C and SPI buses (LiquidTWI2 not required)
232
   #define STD_ENCODER_PULSES_PER_STEP 2
232
   #define STD_ENCODER_PULSES_PER_STEP 2
233
   #define STD_ENCODER_STEPS_PER_MENU_ITEM 1
233
   #define STD_ENCODER_STEPS_PER_MENU_ITEM 1
234
   #define LCD_WIDTH                   20    // 20 or 24 chars in line
234
   #define LCD_WIDTH                   20    // 20 or 24 chars in line

+ 1
- 1
Marlin/src/inc/Conditionals_post.h Bestand weergeven

2457
 /**
2457
 /**
2458
  * Buzzer/Speaker
2458
  * Buzzer/Speaker
2459
  */
2459
  */
2460
-#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER, IS_TFTGLCD_PANEL)
2460
+#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
2461
   #define HAS_BUZZER 1
2461
   #define HAS_BUZZER 1
2462
   #if PIN_EXISTS(BEEPER)
2462
   #if PIN_EXISTS(BEEPER)
2463
     #define USE_BEEPER 1
2463
     #define USE_BEEPER 1

+ 84
- 139
Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp Bestand weergeven

32
  * and supports color output.
32
  * and supports color output.
33
  */
33
  */
34
 
34
 
35
-#if NONE(__AVR__, MCU_LPC1768, __STM32F1__, STM32F4xx)
35
+#if NONE(__AVR__, TARGET_LPC1768, __STM32F1__, STM32F4xx)
36
   #warning "Selected platform not yet tested. Please contribute your good pin mappings."
36
   #warning "Selected platform not yet tested. Please contribute your good pin mappings."
37
 #endif
37
 #endif
38
 
38
 
72
 #define ICON_HOT        B01000000    //when any T > 50deg
72
 #define ICON_HOT        B01000000    //when any T > 50deg
73
 #define PIC_MASK        0x7F
73
 #define PIC_MASK        0x7F
74
 
74
 
75
-//LEDs not used, for compatibility with Smoothieware
75
+// LEDs not used, for compatibility with Smoothieware
76
 #define LED_HOTEND_ON   B00000001
76
 #define LED_HOTEND_ON   B00000001
77
 #define LED_BED_ON      B00000010
77
 #define LED_BED_ON      B00000010
78
 #define LED_FAN_ON      B00000100
78
 #define LED_FAN_ON      B00000100
79
 #define LED_HOT         B00001000
79
 #define LED_HOT         B00001000
80
 #define LED_MASK        0x0F
80
 #define LED_MASK        0x0F
81
 
81
 
82
-#define FBSIZE      (LCD_WIDTH * LCD_HEIGHT + 2)
82
+#define FBSIZE          (LCD_WIDTH * LCD_HEIGHT + 2)
83
+#define MIDDLE_Y        ((LCD_HEIGHT - 1) / 2)
83
 
84
 
84
-//markers for change line color
85
+// Markers for change line colors
85
 #define COLOR_EDIT      '#'
86
 #define COLOR_EDIT      '#'
86
 #define COLOR_ERROR     '!'
87
 #define COLOR_ERROR     '!'
87
 
88
 
114
   GET_LCD_ROW = 0xE0,   // for detect panel
115
   GET_LCD_ROW = 0xE0,   // for detect panel
115
   GET_LCD_COL,          // reserved for compatibility with Smoothieware, not used
116
   GET_LCD_COL,          // reserved for compatibility with Smoothieware, not used
116
   LCD_PUT,              // write one line to LCD
117
   LCD_PUT,              // write one line to LCD
117
-  INIT_SCREEN = 0xFE,   // clear panel buffer
118
+  CLR_SCREEN,
119
+  INIT_SCREEN = 0xFE    // clear panel buffer
118
 };
120
 };
119
 
121
 
120
 static unsigned char framebuffer[FBSIZE];
122
 static unsigned char framebuffer[FBSIZE];
123
 static uint8_t picBits, ledBits, hotBits;
125
 static uint8_t picBits, ledBits, hotBits;
124
 static uint8_t PanelDetected = 0;
126
 static uint8_t PanelDetected = 0;
125
 
127
 
128
+// Different platforms use different SPI methods
129
+#if ANY(__AVR__, TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
130
+  #define SPI_SEND_ONE(V) SPI.transfer(V);
131
+  #define SPI_SEND_TWO(V) SPI.transfer16(V);
132
+#elif defined(STM32F4xx)
133
+  #define SPI_SEND_ONE(V) SPI.transfer(V, SPI_CONTINUE);
134
+  #define SPI_SEND_TWO(V) SPI.transfer16(V, SPI_CONTINUE);
135
+#elif defined(ARDUINO_ARCH_ESP32)
136
+  #define SPI_SEND_ONE(V) SPI.write(V);
137
+  #define SPI_SEND_TWO(V) SPI.write16(V);
138
+#endif
139
+
140
+#if ANY(__AVR__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
141
+  #define SPI_SEND_SOME(V,L,Z)  SPI.transfer(&V[Z], L);
142
+#elif defined(STM32F4xx)
143
+  #define SPI_SEND_SOME(V,L,Z)  SPI.transfer(&V[Z], L, SPI_CONTINUE);
144
+#elif ANY(TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_ESP32)
145
+  #define SPI_SEND_SOME(V,L,Z)  do{ for (uint16_t i = 0; i < L; i++) SPI_SEND_ONE(V[(Z)+i]); }while(0)
146
+#endif
147
+
126
 // Constructor
148
 // Constructor
127
 TFTGLCD::TFTGLCD() {}
149
 TFTGLCD::TFTGLCD() {}
128
 
150
 
129
-//clearing local buffer
151
+// Clear local buffer
130
 void TFTGLCD::clear_buffer() {
152
 void TFTGLCD::clear_buffer() {
131
   memset(&framebuffer[0], ' ', FBSIZE - 2);
153
   memset(&framebuffer[0], ' ', FBSIZE - 2);
132
   framebuffer[FBSIZE - 1] = framebuffer[FBSIZE - 2] = 0;
154
   framebuffer[FBSIZE - 1] = framebuffer[FBSIZE - 2] = 0;
133
   picBits = ledBits = 0;
155
   picBits = ledBits = 0;
134
 }
156
 }
135
 
157
 
136
-//set new text cursor position
158
+// Clear panel's screen
159
+void TFTGLCD::clr_screen() {
160
+  if (!PanelDetected) return;
161
+  #if ENABLED(TFTGLCD_PANEL_SPI)
162
+    WRITE(TFTGLCD_CS, LOW);
163
+    SPI_SEND_ONE(CLR_SCREEN);
164
+    WRITE(TFTGLCD_CS, HIGH);
165
+  #else
166
+    Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);  //set I2C device address
167
+    Wire.write(CLR_SCREEN);
168
+    Wire.endTransmission(); //transmit data
169
+  #endif
170
+}
171
+
172
+// Set new text cursor position
137
 void TFTGLCD::setCursor(uint8_t col, uint8_t row) {
173
 void TFTGLCD::setCursor(uint8_t col, uint8_t row) {
138
   fb = &framebuffer[0] + col + row * LCD_WIDTH;
174
   fb = &framebuffer[0] + col + row * LCD_WIDTH;
139
   cour_line = row;
175
   cour_line = row;
140
 }
176
 }
141
 
177
 
142
-//send char to buffer
178
+// Send char to buffer
143
 void TFTGLCD::write(char c) {
179
 void TFTGLCD::write(char c) {
144
   *fb++ = c;
180
   *fb++ = c;
145
 }
181
 }
146
 
182
 
147
-//send text line to buffer
183
+// Send text line to buffer
148
 void TFTGLCD::print(const char *line) {
184
 void TFTGLCD::print(const char *line) {
149
   while (*line) *fb++ = *line++;
185
   while (*line) *fb++ = *line++;
150
 }
186
 }
154
   if (!PanelDetected) return;
190
   if (!PanelDetected) return;
155
   #if ENABLED(TFTGLCD_PANEL_SPI)
191
   #if ENABLED(TFTGLCD_PANEL_SPI)
156
     WRITE(TFTGLCD_CS, LOW);
192
     WRITE(TFTGLCD_CS, LOW);
157
-    #ifdef __AVR__
158
-      SPI.transfer(LCD_PUT);
159
-      SPI.transfer(cour_line);
160
-      SPI.transfer(&framebuffer[cour_line * LCD_WIDTH], LCD_WIDTH);
161
-    #elif EITHER(MCU_LPC1768, __STM32F1__)
162
-      SPI.transfer(LCD_PUT);
163
-      SPI.transfer(cour_line);
164
-      for (uint16_t i = 0; i < LCD_WIDTH; i++)  SPI.transfer(framebuffer[cour_line * LCD_WIDTH + i]);
165
-    #elif defined(STM32F4xx)
166
-      SPI.transfer(LCD_PUT, SPI_CONTINUE);
167
-      SPI.transfer(cour_line, SPI_CONTINUE);
168
-      SPI.transfer(&framebuffer[cour_line * LCD_WIDTH], LCD_WIDTH, SPI_CONTINUE);
169
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
170
-      SPI.transfer(LCD_PUT);
171
-      SPI.transfer(cour_line);
172
-      SPI.transfer(&framebuffer[cour_line * LCD_WIDTH], LCD_WIDTH);
173
-    #elif defined(ARDUINO_ARCH_ESP32)
174
-      SPI.write(LCD_PUT);
175
-      SPI.write(cour_line);
176
-      for (uint16_t i = 0; i < LCD_WIDTH; i++) SPI.write(framebuffer[cour_line * LCD_WIDTH + i]);
177
-    #endif
193
+    SPI_SEND_ONE(LCD_PUT);
194
+    SPI_SEND_ONE(cour_line);
195
+    SPI_SEND_SOME(framebuffer, LCD_WIDTH, cour_line * LCD_WIDTH);
178
     WRITE(TFTGLCD_CS, HIGH);
196
     WRITE(TFTGLCD_CS, HIGH);
179
   #else
197
   #else
180
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);  //set I2C device address
198
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);  //set I2C device address
193
   #if ENABLED(TFTGLCD_PANEL_SPI)
211
   #if ENABLED(TFTGLCD_PANEL_SPI)
194
     // Send all framebuffer to panel
212
     // Send all framebuffer to panel
195
     WRITE(TFTGLCD_CS, LOW);
213
     WRITE(TFTGLCD_CS, LOW);
196
-    #ifdef __AVR__
197
-      SPI.transfer(LCD_WRITE);
198
-      SPI.transfer(&framebuffer[0], FBSIZE);
199
-    #elif EITHER(MCU_LPC1768, __STM32F1__)
200
-      SPI.transfer(LCD_WRITE);
201
-      for (uint16_t i = 0; i < FBSIZE; i++) SPI.transfer(framebuffer[i]);
202
-    #elif defined(STM32F4xx)
203
-      SPI.transfer(LCD_WRITE, SPI_CONTINUE);
204
-      SPI.transfer(&framebuffer[0], FBSIZE, SPI_CONTINUE);
205
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
206
-      SPI.transfer(LCD_WRITE);
207
-      SPI.transfer(&framebuffer[0], FBSIZE);
208
-    #elif defined(ARDUINO_ARCH_ESP32)
209
-      SPI.write(LCD_WRITE);
210
-      for (uint16_t i = 0; i < FBSIZE; i++) SPI.write(framebuffer[i]);
211
-    #endif
214
+    SPI_SEND_ONE(LCD_WRITE);
215
+    SPI_SEND_SOME(framebuffer, FBSIZE, 0);
212
     WRITE(TFTGLCD_CS, HIGH);
216
     WRITE(TFTGLCD_CS, HIGH);
213
   #else
217
   #else
214
     uint8_t r;
218
     uint8_t r;
235
   if (!PanelDetected) return;
239
   if (!PanelDetected) return;
236
   #if ENABLED(TFTGLCD_PANEL_SPI)
240
   #if ENABLED(TFTGLCD_PANEL_SPI)
237
     WRITE(TFTGLCD_CS, LOW);
241
     WRITE(TFTGLCD_CS, LOW);
238
-    #if ANY(__AVR__, MCU_LPC1768, __STM32F1__)
239
-      SPI.transfer(CONTRAST);
240
-      SPI.transfer((uint8_t)contrast);
241
-    #elif defined(STM32F4xx)
242
-      SPI.transfer(CONTRAST, SPI_CONTINUE);
243
-      SPI.transfer((uint8_t)contrast, SPI_CONTINUE);
244
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
245
-      SPI.transfer(CONTRAST);
246
-      SPI.transfer((uint8_t)contrast);
247
-    #elif defined(ARDUINO_ARCH_ESP32)
248
-      SPI.write(CONTRAST);
249
-      SPI.write((uint8_t)contrast);
250
-    #endif
242
+    SPI_SEND_ONE(CONTRAST);
243
+    SPI_SEND_ONE((uint8_t)contrast);
251
     WRITE(TFTGLCD_CS, HIGH);
244
     WRITE(TFTGLCD_CS, HIGH);
252
   #else
245
   #else
253
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
246
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
257
   #endif
250
   #endif
258
 }
251
 }
259
 
252
 
260
-//reading buttons and encoder states
261
 extern volatile int8_t encoderDiff;
253
 extern volatile int8_t encoderDiff;
262
 
254
 
255
+// Read buttons and encoder states
263
 uint8_t MarlinUI::read_slow_buttons(void) {
256
 uint8_t MarlinUI::read_slow_buttons(void) {
264
   if (!PanelDetected)    return 0;
257
   if (!PanelDetected)    return 0;
265
   #if ENABLED(TFTGLCD_PANEL_SPI)
258
   #if ENABLED(TFTGLCD_PANEL_SPI)
266
     uint8_t b = 0;
259
     uint8_t b = 0;
267
     WRITE(TFTGLCD_CS, LOW);
260
     WRITE(TFTGLCD_CS, LOW);
268
-    #if ANY(__AVR__, MCU_LPC1768, __STM32F1__)
269
-      SPI.transfer(READ_ENCODER);
270
-      WRITE(TFTGLCD_CS, LOW); //for delay
271
-      encoderDiff += SPI.transfer(READ_BUTTONS);
272
-      WRITE(TFTGLCD_CS, LOW); //for delay
273
-      b = SPI.transfer(GET_SPI_DATA);
274
-    #elif defined(STM32F4xx)
275
-      SPI.transfer(READ_ENCODER, SPI_CONTINUE);
276
-      encoderDiff += SPI.transfer(READ_BUTTONS, SPI_CONTINUE);
277
-      b = SPI.transfer(GET_SPI_DATA, SPI_CONTINUE);
278
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
279
-      SPI.transfer(READ_ENCODER);
280
-      WRITE(TFTGLCD_CS, LOW); //for delay ????
281
-      encoderDiff += SPI.transfer(READ_BUTTONS);
282
-      WRITE(TFTGLCD_CS, LOW); //for delay ????
283
-      b = SPI.transfer(GET_SPI_DATA);
284
-    #elif defined(ARDUINO_ARCH_ESP32)
285
-      SPI.transfer(READ_ENCODER);
286
-      WRITE(TFTGLCD_CS, LOW); //for delay ????
287
-      encoderDiff += SPI.transfer(READ_BUTTONS);
288
-      WRITE(TFTGLCD_CS, LOW); //for delay ????
289
-      b = SPI.transfer(GET_SPI_DATA);
261
+    SPI_SEND_ONE(READ_ENCODER);
262
+    #ifndef STM32F4xx
263
+      WRITE(TFTGLCD_CS, LOW); // for delay
290
     #endif
264
     #endif
265
+    encoderDiff += SPI_SEND_ONE(READ_BUTTONS);
266
+    #ifndef STM32F4xx
267
+      WRITE(TFTGLCD_CS, LOW); // for delay
268
+      WRITE(TFTGLCD_CS, LOW);
269
+    #endif
270
+    b = SPI_SEND_ONE(GET_SPI_DATA);
291
     WRITE(TFTGLCD_CS, HIGH);
271
     WRITE(TFTGLCD_CS, HIGH);
292
     return b;
272
     return b;
293
   #else
273
   #else
298
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 2, 0, 0, 1);
278
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 2, 0, 0, 1);
299
     #elif defined(__STM32F1__)
279
     #elif defined(__STM32F1__)
300
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, (uint8_t)2);
280
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, (uint8_t)2);
301
-    #elif EITHER(STM32F4xx, MCU_LPC1768)
281
+    #elif EITHER(STM32F4xx, TARGET_LPC1768)
302
       Wire.requestFrom(LCD_I2C_ADDRESS, 2);
282
       Wire.requestFrom(LCD_I2C_ADDRESS, 2);
303
     #endif
283
     #endif
304
     encoderDiff += Wire.read();
284
     encoderDiff += Wire.read();
306
   #endif
286
   #endif
307
 }
287
 }
308
 
288
 
309
-// duration in ms, freq in Hz
289
+// Duration in ms, freq in Hz
310
 void MarlinUI::buzz(const long duration, const uint16_t freq) {
290
 void MarlinUI::buzz(const long duration, const uint16_t freq) {
311
   if (!PanelDetected) return;
291
   if (!PanelDetected) return;
312
   #if ENABLED(TFTGLCD_PANEL_SPI)
292
   #if ENABLED(TFTGLCD_PANEL_SPI)
313
     WRITE(TFTGLCD_CS, LOW);
293
     WRITE(TFTGLCD_CS, LOW);
314
-    #if ANY(__AVR__, MCU_LPC1768, __STM32F1__)
315
-      SPI.transfer(BUZZER);
316
-      SPI.transfer16((uint16_t)duration);
317
-      SPI.transfer16(freq);
318
-    #elif defined(STM32F4xx)
319
-      SPI.transfer(BUZZER, SPI_CONTINUE);
320
-      SPI.transfer16((uint16_t)duration, SPI_CONTINUE);
321
-      SPI.transfer16(freq, SPI_CONTINUE);
322
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
323
-      SPI.transfer(BUZZER);
324
-      SPI.transfer16((uint16_t)duration);
325
-      SPI.transfer16(freq);
326
-    #elif defined(ARDUINO_ARCH_ESP32)
327
-      SPI.write(BUZZER);
328
-      SPI.write16((uint16_t)duration);
329
-      SPI.write16(freq);
330
-    #endif
294
+    SPI_SEND_ONE(BUZZER);
295
+    SPI_SEND_TWO((uint16_t)duration);
296
+    SPI_SEND_TWO(freq);
331
     WRITE(TFTGLCD_CS, HIGH);
297
     WRITE(TFTGLCD_CS, HIGH);
332
   #else
298
   #else
333
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
299
     Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
346
   t = 0;
312
   t = 0;
347
   #if ENABLED(TFTGLCD_PANEL_SPI)
313
   #if ENABLED(TFTGLCD_PANEL_SPI)
348
     // SPI speed must be less 10MHz
314
     // SPI speed must be less 10MHz
349
-    OUT_WRITE(TFTGLCD_CS, HIGH);
315
+    _SET_OUTPUT(TFTGLCD_CS);
316
+    WRITE(TFTGLCD_CS, HIGH);
350
     spiInit(TERN(__STM32F1__, SPI_QUARTER_SPEED, SPI_FULL_SPEED));
317
     spiInit(TERN(__STM32F1__, SPI_QUARTER_SPEED, SPI_FULL_SPEED));
351
     WRITE(TFTGLCD_CS, LOW);
318
     WRITE(TFTGLCD_CS, LOW);
352
-    #if ANY(__AVR__, MCU_LPC1768, __STM32F1__)
353
-      SPI.transfer(GET_LCD_ROW);
354
-      t = SPI.transfer(GET_SPI_DATA);
355
-    #elif defined(STM32F4xx)
356
-      SPI.transfer(GET_LCD_ROW, SPI_CONTINUE);
357
-      t = SPI.transfer(GET_SPI_DATA, SPI_CONTINUE);
358
-    #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
359
-      SPI.transfer(GET_LCD_ROW);
360
-      t = SPI.transfer(GET_SPI_DATA);
361
-    #elif defined(ARDUINO_ARCH_ESP32)
362
-      SPI.write(GET_LCD_ROW);
363
-      t = SPI.transfer(GET_SPI_DATA);
364
-    #endif
319
+    SPI_SEND_ONE(GET_LCD_ROW);
320
+    t = SPI_SEND_ONE(GET_SPI_DATA);
365
   #else
321
   #else
366
-    #ifdef MCU_LPC1768
322
+    #ifdef TARGET_LPC1768
367
       Wire.begin();   //init twi/I2C
323
       Wire.begin();   //init twi/I2C
368
     #else
324
     #else
369
       Wire.begin((uint8_t)LCD_I2C_ADDRESS); //init twi/I2C
325
       Wire.begin((uint8_t)LCD_I2C_ADDRESS); //init twi/I2C
373
     Wire.endTransmission(); // send buffer
329
     Wire.endTransmission(); // send buffer
374
     #ifdef __AVR__
330
     #ifdef __AVR__
375
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 1, 0, 0, 1);
331
       Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 1, 0, 0, 1);
376
-    #elif ANY(__STM32F1__, STM32F4xx, MCU_LPC1768)
332
+    #elif ANY(__STM32F1__, STM32F4xx, TARGET_LPC1768)
377
       Wire.requestFrom(LCD_I2C_ADDRESS, 1);
333
       Wire.requestFrom(LCD_I2C_ADDRESS, 1);
378
     #endif
334
     #endif
379
     t = (uint8_t)Wire.read();
335
     t = (uint8_t)Wire.read();
382
   if (t == LCD_HEIGHT) {
338
   if (t == LCD_HEIGHT) {
383
     PanelDetected = 1;
339
     PanelDetected = 1;
384
     #if ENABLED(TFTGLCD_PANEL_SPI)
340
     #if ENABLED(TFTGLCD_PANEL_SPI)
385
-      PanelDetected = 1;
386
-      #if ANY(__AVR__, MCU_LPC1768, __STM32F1__)
387
-        SPI.transfer(INIT_SCREEN);
388
-        SPI.transfer(Marlin);
389
-      #elif defined(STM32F4xx)
390
-        SPI.transfer(INIT_SCREEN, SPI_CONTINUE);
391
-        SPI.transfer(Marlin, SPI_CONTINUE);
392
-      #elif ANY(ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
393
-        SPI.transfer(INIT_SCREEN);
394
-        SPI.transfer(Marlin);
395
-      #elif defined(ARDUINO_ARCH_ESP32)
396
-        SPI.write(INIT_SCREEN);
397
-        SPI.write(Marlin);
398
-      #endif
341
+      SPI_SEND_ONE(INIT_SCREEN);
342
+      SPI_SEND_ONE(Marlin);
399
       WRITE(TFTGLCD_CS, HIGH);
343
       WRITE(TFTGLCD_CS, HIGH);
400
     #else
344
     #else
401
       Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
345
       Wire.beginTransmission((uint8_t)LCD_I2C_ADDRESS);
415
 
359
 
416
 void MarlinUI::clear_lcd() {
360
 void MarlinUI::clear_lcd() {
417
   if (!PanelDetected) return;
361
   if (!PanelDetected) return;
362
+  lcd.clr_screen();
418
   lcd.clear_buffer();
363
   lcd.clear_buffer();
419
-  lcd.print_screen();
420
 }
364
 }
421
 
365
 
422
 int16_t MarlinUI::contrast; // Initialized by settings.load()
366
 int16_t MarlinUI::contrast; // Initialized by settings.load()
583
       lcd.write('%'); lcd.write(percent);
527
       lcd.write('%'); lcd.write(percent);
584
     }
528
     }
585
     else { // For progress bar test
529
     else { // For progress bar test
586
-      lcd.setCursor(LCD_WIDTH / 2 - 2, LCD_HEIGHT / 2 - 2);
530
+      lcd.setCursor(LCD_WIDTH / 2 - 2, MIDDLE_Y);
587
       lcd.print(i16tostr3rj(percent));  lcd.write('%');
531
       lcd.print(i16tostr3rj(percent));  lcd.write('%');
588
       lcd.print_line();
532
       lcd.print_line();
589
-      lcd.setCursor(0, LCD_HEIGHT / 2 - 1);
533
+      lcd.setCursor(0, MIDDLE_Y + 1);
590
       lcd.write('%'); lcd.write(percent);
534
       lcd.write('%'); lcd.write(percent);
591
       lcd.print_line();
535
       lcd.print_line();
592
     }
536
     }
912
   }
856
   }
913
 
857
 
914
   // Low-level draw_edit_screen can be used to draw an edit screen from anyplace
858
   // Low-level draw_edit_screen can be used to draw an edit screen from anyplace
859
+  // This line moves to the last line of the screen for UBL plot screen on the panel side
915
   void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
860
   void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
916
     if (!PanelDetected) return;
861
     if (!PanelDetected) return;
917
     ui.encoder_direction_normal();
862
     ui.encoder_direction_normal();
918
-    lcd.setCursor(0, LCD_HEIGHT - 1);  //last line is free most time
863
+    lcd.setCursor(0, MIDDLE_Y);
919
     lcd.write(COLOR_EDIT);
864
     lcd.write(COLOR_EDIT);
920
     lcd_put_u8str_P(pstr);
865
     lcd_put_u8str_P(pstr);
921
     if (value != nullptr) {
866
     if (value != nullptr) {
922
       lcd.write(':');
867
       lcd.write(':');
923
-      lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), LCD_HEIGHT - 1);  // Right-justified, padded by spaces
924
-      lcd.write(' ');                                                // Overwrite char if value gets shorter
868
+      lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), MIDDLE_Y);  // Right-justified, padded by spaces
869
+      lcd.write(' ');     // Overwrite char if value gets shorter
925
       lcd.print(value);
870
       lcd.print(value);
926
       lcd.write(' ');
871
       lcd.write(' ');
927
       lcd.print_line();
872
       lcd.print_line();
932
   void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff) {
877
   void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff) {
933
     if (!PanelDetected) return;
878
     if (!PanelDetected) return;
934
     ui.draw_select_screen_prompt(pref, string, suff);
879
     ui.draw_select_screen_prompt(pref, string, suff);
935
-    lcd.setCursor(0, LCD_HEIGHT - 1);
880
+    lcd.setCursor(0, MIDDLE_Y);
936
     lcd.write(COLOR_EDIT);
881
     lcd.write(COLOR_EDIT);
937
     lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']');
882
     lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']');
938
-    lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, LCD_HEIGHT - 1);
883
+    lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, MIDDLE_Y);
939
     lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' ');
884
     lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' ');
940
     lcd.print_line();
885
     lcd.print_line();
941
   }
886
   }

+ 1
- 0
Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.h Bestand weergeven

45
   public:
45
   public:
46
     TFTGLCD();
46
     TFTGLCD();
47
     void clear_buffer();
47
     void clear_buffer();
48
+    void clr_screen();
48
     void setCursor(uint8_t col, uint8_t row);
49
     void setCursor(uint8_t col, uint8_t row);
49
     void write(char c);
50
     void write(char c);
50
     void print(const char *line);
51
     void print(const char *line);

+ 1
- 1
Marlin/src/lcd/menu/menu_advanced.cpp Bestand weergeven

490
       #if ENABLED(PROBE_OFFSET_WIZARD)
490
       #if ENABLED(PROBE_OFFSET_WIZARD)
491
         SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
491
         SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
492
       #endif
492
       #endif
493
-      
493
+
494
       END_MENU();
494
       END_MENU();
495
     }
495
     }
496
   #endif
496
   #endif

+ 8
- 8
Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h Bestand weergeven

223
 #endif
223
 #endif
224
 
224
 
225
 /**
225
 /**
226
- *              _____                                             _____
227
- *          NC | · · | GND                                    5V | · · | GND
228
- *       RESET | · · | 1.31(SD_DETECT)             (LCD_D7) 1.23 | · · | 1.22 (LCD_D6)
229
- *  (MOSI)0.18 | · · | 3.25(BTN_EN2)               (LCD_D5) 1.21 | · · | 1.20 (LCD_D4)
230
- * (SD_SS)0.16 | · · | 3.26(BTN_EN1)               (LCD_RS) 1.19 | · · | 1.18 (LCD_EN)
231
- *   (SCK)0.15 | · · | 0.17(MISO)                 (BTN_ENC) 0.28 | · · | 1.30 (BEEPER)
232
- *              -----                                             -----
233
- *              EXP2                                              EXP1
226
+ *               _____                                             _____
227
+ *           NC | · · | GND                                    5V | · · | GND
228
+ *        RESET | · · | 1.31 (SD_DETECT)            (LCD_D7) 1.23 | · · | 1.22 (LCD_D6)
229
+ *  (MOSI) 0.18 | · · | 3.25 (BTN_EN2)              (LCD_D5) 1.21 | · · | 1.20 (LCD_D4)
230
+ * (SD_SS) 0.16 | · · | 3.26 (BTN_EN1)              (LCD_RS) 1.19 | · · | 1.18 (LCD_EN)
231
+ *   (SCK) 0.15 | · · | 0.17 (MISO)                (BTN_ENC) 0.28 | · · | 1.30 (BEEPER)
232
+ *               -----                                             -----
233
+ *               EXP2                                              EXP1
234
  */
234
  */
235
 #if HAS_WIRED_LCD
235
 #if HAS_WIRED_LCD
236
   #if ENABLED(ANET_FULL_GRAPHICS_LCD)
236
   #if ENABLED(ANET_FULL_GRAPHICS_LCD)

+ 1
- 1
Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h Bestand weergeven

92
 //
92
 //
93
 // LCD / Controller
93
 // LCD / Controller
94
 //
94
 //
95
-#if HAS_WIRED_LCD
95
+#if HAS_WIRED_LCD && DISABLED(LCD_USE_I2C_BUZZER)
96
   #define BEEPER_PIN                       P1_30  // (37) not 5V tolerant
96
   #define BEEPER_PIN                       P1_30  // (37) not 5V tolerant
97
 #endif
97
 #endif
98
 
98
 

+ 3
- 0
Marlin/src/pins/stm32f0/pins_MALYAN_M300.h Bestand weergeven

33
 //
33
 //
34
 #if NO_EEPROM_SELECTED
34
 #if NO_EEPROM_SELECTED
35
   #define FLASH_EEPROM_EMULATION
35
   #define FLASH_EEPROM_EMULATION
36
+  #ifndef MARLIN_EEPROM_SIZE
37
+    #define MARLIN_EEPROM_SIZE 0x800U             // 2KB
38
+  #endif
36
 #endif
39
 #endif
37
 
40
 
38
 //
41
 //

+ 1
- 0
Marlin/src/pins/stm32f1/pins_MORPHEUS.h Bestand weergeven

89
 //
89
 //
90
 #define LED_PIN                             PC13
90
 #define LED_PIN                             PC13
91
 #define SDSS                                PA3
91
 #define SDSS                                PA3
92
+#define TFTGLCD_CS                          PA4

Laden…
Annuleren
Opslaan