F439_CPP_SPI_RA8875_TFT_LCD_04 1.0
STM32F439 SPI RA8875 7-inch TFT display with FRAM-backed touch calibration, built on the STM32_GFX, STM32_RA8875 and STM32_MB85RS64V libraries
Loading...
Searching...
No Matches
Adafruit_RA8875.cpp
Go to the documentation of this file.
1
34#include "Adafruit_RA8875.h"
35
36#ifdef ADAFRUIT_RA8875_DEBUG
37#include <stdio.h>
39#define RA8875_DEBUG_PRINTF(...) printf(__VA_ARGS__)
40#else
41#define RA8875_DEBUG_PRINTF(...) ((void)0)
42#endif
43
45#define RA8875_SPI_TIMEOUT_MS 100
46
47// The SPI peripheral is fully configured by CubeMX and the bus speed is
48// applied by spiSetSpeed(), so Arduino's SPI transactions are not needed.
49#define spi_begin()
50#define spi_end()
51
59__attribute__((weak)) uint32_t Adafruit_RA8875_GetSpiClockHz(SPI_HandleTypeDef* hspi) {
60#if defined(STM32H7)
61 uint32_t periph = RCC_PERIPHCLK_SPI123;
62#if defined(SPI4)
63 if (hspi->Instance == SPI4 || hspi->Instance == SPI5)
64 periph = RCC_PERIPHCLK_SPI45;
65#endif
66#if defined(SPI6)
67 if (hspi->Instance == SPI6)
68 periph = RCC_PERIPHCLK_SPI6;
69#endif
70 return HAL_RCCEx_GetPeriphCLKFreq(periph);
71#else
72 bool apb2 = false;
73#if defined(SPI1)
74 apb2 = apb2 || (hspi->Instance == SPI1);
75#endif
76#if defined(SPI4)
77 apb2 = apb2 || (hspi->Instance == SPI4);
78#endif
79#if defined(SPI5)
80 apb2 = apb2 || (hspi->Instance == SPI5);
81#endif
82#if defined(SPI6)
83 apb2 = apb2 || (hspi->Instance == SPI6);
84#endif
85 return apb2 ? HAL_RCC_GetPCLK2Freq() : HAL_RCC_GetPCLK1Freq();
86#endif
87}
88
89/**************************************************************************/
101/**************************************************************************/
102Adafruit_RA8875::Adafruit_RA8875(SPI_HandleTypeDef* spi, GPIO_TypeDef* csPort,
103 uint16_t csPin, GPIO_TypeDef* rstPort,
104 uint16_t rstPin, GPIO_TypeDef* waitPort,
105 uint16_t waitPin)
106 : Adafruit_GFX(800, 480), _spi(spi), _csPort(csPort), _rstPort(rstPort),
107 _waitPort(waitPort), _csPin(csPin), _rstPin(rstPin), _waitPin(waitPin),
108 _storageRead(nullptr), _storageWrite(nullptr), _storageCtx(nullptr),
109 _storageSize(0) {}
110
114void Adafruit_RA8875::csLow(void) {
115 HAL_GPIO_WritePin(_csPort, _csPin, GPIO_PIN_RESET);
116}
120void Adafruit_RA8875::csHigh(void) {
121 HAL_GPIO_WritePin(_csPort, _csPin, GPIO_PIN_SET);
122}
129void Adafruit_RA8875::waitForReady(void) {
130 if (_waitPort == nullptr)
131 return;
132 while (!HAL_GPIO_ReadPin(_waitPort, _waitPin)) {
133 delay(1);
134 }
135}
144uint8_t Adafruit_RA8875::spiTransfer(uint8_t d) {
145 uint8_t r = 0;
146 HAL_SPI_TransmitReceive(_spi, &d, &r, 1, RA8875_SPI_TIMEOUT_MS);
147 return r;
148}
156void Adafruit_RA8875::spiWrite(const uint8_t* data, uint16_t len) {
157 HAL_SPI_Transmit(_spi, (uint8_t*)data, len, RA8875_SPI_TIMEOUT_MS);
158}
164bool Adafruit_RA8875::spiConfigOk(void) {
165 return _spi != nullptr && _spi->Init.Mode == SPI_MODE_MASTER &&
166 _spi->Init.Direction == SPI_DIRECTION_2LINES &&
167 _spi->Init.DataSize == SPI_DATASIZE_8BIT &&
168 _spi->Init.CLKPolarity == SPI_POLARITY_LOW &&
169 _spi->Init.CLKPhase == SPI_PHASE_1EDGE &&
170 _spi->Init.FirstBit == SPI_FIRSTBIT_MSB &&
171 _spi->Init.NSS == SPI_NSS_SOFT;
172}
179void Adafruit_RA8875::spiSetSpeed(uint32_t hz) {
180 static const struct {
181 uint32_t div;
182 uint32_t reg;
183 } table[] = {
184 {2, SPI_BAUDRATEPRESCALER_2}, {4, SPI_BAUDRATEPRESCALER_4},
185 {8, SPI_BAUDRATEPRESCALER_8}, {16, SPI_BAUDRATEPRESCALER_16},
186 {32, SPI_BAUDRATEPRESCALER_32}, {64, SPI_BAUDRATEPRESCALER_64},
187 {128, SPI_BAUDRATEPRESCALER_128}, {256, SPI_BAUDRATEPRESCALER_256}};
188 uint32_t clk = Adafruit_RA8875_GetSpiClockHz(_spi);
189 if (clk == 0)
190 return;
191 uint32_t reg = SPI_BAUDRATEPRESCALER_256;
192 for (unsigned i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
193 if (clk / table[i].div <= hz) {
194 reg = table[i].reg;
195 break;
196 }
197 }
198 if (_spi->Init.BaudRatePrescaler != reg) {
199 _spi->Init.BaudRatePrescaler = reg;
200 HAL_SPI_Init(_spi);
201 }
202}
203
204/**************************************************************************/
216/**************************************************************************/
218 _size = s;
219
220 if (_size == RA8875_480x80) {
221 _width = 480;
222 _height = 80;
223 } else if (_size == RA8875_480x128) {
224 _width = 480;
225 _height = 128;
226 } else if (_size == RA8875_480x272) {
227 _width = 480;
228 _height = 272;
229 } else if (_size == RA8875_800x480) {
230 _width = 800;
231 _height = 480;
232 } else {
233 return false;
234 }
235 _rotation = 0;
236 if (!spiConfigOk()) {
237 RA8875_DEBUG_PRINTF("RA8875: SPI must be master, 8-bit, mode 0, MSB, soft NSS\r\n");
238 return false;
239 }
240 csHigh();
241
242 HAL_GPIO_WritePin(_rstPort, _rstPin, GPIO_PIN_RESET);
243 delay(100);
244 HAL_GPIO_WritePin(_rstPort, _rstPin, GPIO_PIN_SET);
245 delay(100);
246
247 spiSetSpeed(125000); // slow until the chip's PLL is running
248
249 uint8_t x = readReg(0);
250 if (x != 0x75) {
251 RA8875_DEBUG_PRINTF("RA8875: unexpected chip ID 0x%02X (expected 0x75)\r\n", x);
252 return false;
253 }
254
255 initialize();
256
257 spiSetSpeed(4000000); // full speed
258
259 return true;
260}
261
262/************************* Initialization *********************************/
263
264/**************************************************************************/
268/**************************************************************************/
275
276/**************************************************************************/
280/**************************************************************************/
281void Adafruit_RA8875::PLLinit(void) {
282 if (_size == RA8875_480x80 || _size == RA8875_480x128 ||
283 _size == RA8875_480x272) {
285 delay(1);
287 delay(1);
288 } else /* (_size == RA8875_800x480) */ {
290 delay(1);
292 delay(1);
293 }
294}
295
296/**************************************************************************/
300/**************************************************************************/
301void Adafruit_RA8875::initialize(void) {
302 PLLinit();
304
305 /* Timing values */
306 uint8_t pixclk;
307 uint8_t hsync_start;
308 uint8_t hsync_pw;
309 uint8_t hsync_finetune;
310 uint8_t hsync_nondisp;
311 uint8_t vsync_pw;
312 uint16_t vsync_nondisp;
313 uint16_t vsync_start;
314
315 /* Set the correct values for the display being used */
316 if (_size == RA8875_480x80) {
318 hsync_nondisp = 10;
319 hsync_start = 8;
320 hsync_pw = 48;
321 hsync_finetune = 0;
322 vsync_nondisp = 3;
323 vsync_start = 8;
324 vsync_pw = 10;
325 _voffset = 192; // This uses the bottom 80 pixels of a 272 pixel controller
326 } else if (_size == RA8875_480x128 || _size == RA8875_480x272) {
328 hsync_nondisp = 10;
329 hsync_start = 8;
330 hsync_pw = 48;
331 hsync_finetune = 0;
332 vsync_nondisp = 3;
333 vsync_start = 8;
334 vsync_pw = 10;
335 _voffset = 0;
336 } else // (_size == RA8875_800x480)
337 {
339 hsync_nondisp = 26;
340 hsync_start = 32;
341 hsync_pw = 96;
342 hsync_finetune = 0;
343 vsync_nondisp = 32;
344 vsync_start = 23;
345 vsync_pw = 2;
346 _voffset = 0;
347 }
348
349 writeReg(RA8875_PCSR, pixclk);
350 delay(1);
351
352 /* Horizontal settings registers */
353 writeReg(RA8875_HDWR, (_width / 8) - 1); // H width: (HDWR + 1) * 8 = 480
355 writeReg(RA8875_HNDR, (hsync_nondisp - hsync_finetune - 2) /
356 8); // H non-display: HNDR * 8 + HNDFTR + 2 = 10
357 writeReg(RA8875_HSTR, hsync_start / 8 - 1); // Hsync start: (HSTR + 1)*8
358 writeReg(
360 RA8875_HPWR_LOW + (hsync_pw / 8 - 1)); // HSync pulse width = (HPWR+1) * 8
361
362 /* Vertical settings registers */
363 writeReg(RA8875_VDHR0, (uint16_t)(_height - 1 + _voffset) & 0xFF);
364 writeReg(RA8875_VDHR1, (uint16_t)(_height - 1 + _voffset) >> 8);
365 writeReg(RA8875_VNDR0, vsync_nondisp - 1); // V non-display period = VNDR + 1
366 writeReg(RA8875_VNDR1, vsync_nondisp >> 8);
367 writeReg(RA8875_VSTR0, vsync_start - 1); // Vsync start position = VSTR + 1
368 writeReg(RA8875_VSTR1, vsync_start >> 8);
370 RA8875_VPWR_LOW + vsync_pw - 1); // Vsync pulse width = VPWR + 1
371
372 /* Set active window X */
373 writeReg(RA8875_HSAW0, 0); // horizontal start point
375 writeReg(RA8875_HEAW0, (uint16_t)(_width - 1) & 0xFF); // horizontal end point
376 writeReg(RA8875_HEAW1, (uint16_t)(_width - 1) >> 8);
377
378 /* Set active window Y */
379 writeReg(RA8875_VSAW0, 0 + _voffset); // vertical start point
380 writeReg(RA8875_VSAW1, 0 + _voffset);
382 (uint16_t)(_height - 1 + _voffset) & 0xFF); // vertical end point
383 writeReg(RA8875_VEAW1, (uint16_t)(_height - 1 + _voffset) >> 8);
384
385 /* ToDo: Setup touch panel? */
386
387 /* Clear the entire window */
389 delay(500);
390}
391
392/**************************************************************************/
398/**************************************************************************/
400 return _width;
401}
402
403/**************************************************************************/
409/**************************************************************************/
411 return _height;
412}
413
414/**************************************************************************/
420/**************************************************************************/
422 return _rotation;
423}
424
425/**************************************************************************/
431/**************************************************************************/
432void Adafruit_RA8875::setRotation(int8_t rotation) {
433 switch (rotation) {
434 case 2:
435 _rotation = rotation;
436 break;
437 default:
438 _rotation = 0;
439 break;
440 }
441}
442
443/************************* Text Mode ***********************************/
444
445/**************************************************************************/
449/**************************************************************************/
451 /* Set text mode */
453 uint8_t temp = readData();
454 temp |= RA8875_MWCR0_TXTMODE; // Set bit 7
455 writeData(temp);
456
457 /* Select the internal (ROM) font */
458 writeCommand(0x21);
459 temp = readData();
460 temp &= ~((1 << 7) | (1 << 5)); // Clear bits 7 and 5
461 writeData(temp);
462}
463
464/**************************************************************************/
471/**************************************************************************/
472void Adafruit_RA8875::textSetCursor(uint16_t x, uint16_t y) {
473 x = applyRotationX(x);
474 y = applyRotationY(y);
475
476 /* Set cursor location */
477 writeCommand(0x2A);
478 writeData(x & 0xFF);
479 writeCommand(0x2B);
480 writeData(x >> 8);
481 writeCommand(0x2C);
482 writeData(y & 0xFF);
483 writeCommand(0x2D);
484 writeData(y >> 8);
485}
486
487/**************************************************************************/
494/**************************************************************************/
495void Adafruit_RA8875::textColor(uint16_t foreColor, uint16_t bgColor) {
496 /* Set Fore Color */
497 writeCommand(0x63);
498 writeData((foreColor & 0xf800) >> 11);
499 writeCommand(0x64);
500 writeData((foreColor & 0x07e0) >> 5);
501 writeCommand(0x65);
502 writeData((foreColor & 0x001f));
503
504 /* Set Background Color */
505 writeCommand(0x60);
506 writeData((bgColor & 0xf800) >> 11);
507 writeCommand(0x61);
508 writeData((bgColor & 0x07e0) >> 5);
509 writeCommand(0x62);
510 writeData((bgColor & 0x001f));
511
512 /* Clear transparency flag */
513 writeCommand(0x22);
514 uint8_t temp = readData();
515 temp &= ~(1 << 6); // Clear bit 6
516 writeData(temp);
517}
518
519/**************************************************************************/
525/**************************************************************************/
526void Adafruit_RA8875::textTransparent(uint16_t foreColor) {
527 /* Set Fore Color */
528 writeCommand(0x63);
529 writeData((foreColor & 0xf800) >> 11);
530 writeCommand(0x64);
531 writeData((foreColor & 0x07e0) >> 5);
532 writeCommand(0x65);
533 writeData((foreColor & 0x001f));
534
535 /* Set transparency flag */
536 writeCommand(0x22);
537 uint8_t temp = readData();
538 temp |= (1 << 6); // Set bit 6
539 writeData(temp);
540}
541
542/**************************************************************************/
553/**************************************************************************/
554void Adafruit_RA8875::textEnlarge(uint8_t scale) {
555 if (scale > 3)
556 scale = 3; // highest setting is 3
557
558 /* Set font size flags */
559 writeCommand(0x22);
560 uint8_t temp = readData();
561 temp &= ~(0xF); // Clears bits 0..3
562 temp |= scale << 2;
563 temp |= scale;
564
565 writeData(temp);
566
567 _textScale = scale;
568}
569
570/**************************************************************************/
582/**************************************************************************/
583
586 uint8_t temp = readData();
587 temp |= RA8875_MWCR0_CURSOR;
588 writeData(temp);
589
591 temp = readData();
592 temp |= RA8875_MWCR0_BLINK;
593 writeData(temp);
594
595 if (rate > 255)
596 rate = 255;
598 writeData(rate);
599}
600
601/**************************************************************************/
608/**************************************************************************/
609void Adafruit_RA8875::textWrite(const char* buffer, uint16_t len) {
610 if (len == 0)
611 len = strlen(buffer);
613 for (uint16_t i = 0; i < len; i++) {
614 writeData(buffer[i]);
616#if defined(__arm__)
618 // This delay is needed with textEnlarge(1) because
619 // Teensy 3.X is much faster than Arduino Uno
620 if (_textScale > 0)
621 delay(1);
623#else
625 // For others, delay starting with textEnlarge(2)
626 if (_textScale > 1)
627 delay(1);
629#endif
631 }
632}
633
634/************************* Graphics ***********************************/
635
636/**************************************************************************/
640/**************************************************************************/
643 uint8_t temp = readData();
644 temp &= ~RA8875_MWCR0_TXTMODE; // bit #7
645 writeData(temp);
646}
647
648/**************************************************************************/
657/**************************************************************************/
658boolean Adafruit_RA8875::waitPoll(uint8_t regname, uint8_t waitflag) {
659 /* Wait for the command to finish */
660 while (1) {
661 uint8_t temp = readReg(regname);
662 if (!(temp & waitflag))
663 return true;
664 }
665 return false; // MEMEFIX: yeah i know, unreached! - add timeout?
666}
667
668/**************************************************************************/
675/**************************************************************************/
676void Adafruit_RA8875::setXY(uint16_t x, uint16_t y) {
678 writeReg(RA8875_CURH1, x >> 8);
680 writeReg(RA8875_CURV1, y >> 8);
681}
682
683/**************************************************************************/
690/**************************************************************************/
691void Adafruit_RA8875::pushPixels(uint32_t num, uint16_t p) {
692 uint8_t buf[128]; // 64 pixels per SPI burst
693 csLow();
694 spiTransfer(RA8875_DATAWRITE);
695 while (num) {
696 uint32_t n = (num > sizeof(buf) / 2) ? sizeof(buf) / 2 : num;
697 for (uint32_t i = 0; i < n; i++) {
698 buf[2 * i] = (uint8_t)(p >> 8);
699 buf[2 * i + 1] = (uint8_t)p;
700 }
701 spiWrite(buf, (uint16_t)(n * 2));
702 num -= n;
703 }
704 csHigh();
705}
706
707/**************************************************************************/
711/**************************************************************************/
718
719/**************************************************************************/
725/**************************************************************************/
726int16_t Adafruit_RA8875::applyRotationX(int16_t x) {
727 switch (_rotation) {
728 case 2:
729 x = _width - 1 - x;
730 break;
731 }
732
733 return x;
734}
735
736/**************************************************************************/
742/**************************************************************************/
743int16_t Adafruit_RA8875::applyRotationY(int16_t y) {
744 switch (_rotation) {
745 case 2:
746 y = _height - 1 - y;
747 break;
748 }
749
750 return y + _voffset;
751}
752
753/**************************************************************************/
761/**************************************************************************/
762void Adafruit_RA8875::drawPixel(int16_t x, int16_t y, uint16_t color) {
763 x = applyRotationX(x);
764 y = applyRotationY(y);
765
767 writeReg(RA8875_CURH1, x >> 8);
769 writeReg(RA8875_CURV1, y >> 8);
771 uint8_t px[3] = {RA8875_DATAWRITE, (uint8_t)(color >> 8), (uint8_t)color};
772 csLow();
773 spiWrite(px, sizeof(px));
774 csHigh();
775}
776
777/**************************************************************************/
786/**************************************************************************/
787void Adafruit_RA8875::drawPixels(uint16_t* p, uint32_t num, int16_t x,
788 int16_t y) {
789 x = applyRotationX(x);
790 y = applyRotationY(y);
791
793 writeReg(RA8875_CURH1, x >> 8);
795 writeReg(RA8875_CURV1, y >> 8);
796
797 uint8_t dir = RA8875_MWCR0_LRTD;
798 if (_rotation == 2) {
799 dir = RA8875_MWCR0_RLTD;
800 }
802
804 uint8_t buf[128]; // 64 pixels per SPI burst
805 csLow();
806 spiTransfer(RA8875_DATAWRITE);
807 while (num) {
808 uint32_t n = (num > sizeof(buf) / 2) ? sizeof(buf) / 2 : num;
809 for (uint32_t i = 0; i < n; i++) {
810 buf[2 * i] = (uint8_t)(p[i] >> 8);
811 buf[2 * i + 1] = (uint8_t)p[i];
812 }
813 spiWrite(buf, (uint16_t)(n * 2));
814 p += n;
815 num -= n;
816 }
817 csHigh();
818}
819
820/**************************************************************************/
830/**************************************************************************/
831void Adafruit_RA8875::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
832 uint16_t color) {
833 x0 = applyRotationX(x0);
834 y0 = applyRotationY(y0);
835 x1 = applyRotationX(x1);
836 y1 = applyRotationY(y1);
837
838 /* Set X */
839 writeCommand(0x91);
840 writeData(x0);
841 writeCommand(0x92);
842 writeData(x0 >> 8);
843
844 /* Set Y */
845 writeCommand(0x93);
846 writeData(y0);
847 writeCommand(0x94);
848 writeData(y0 >> 8);
849
850 /* Set X1 */
851 writeCommand(0x95);
852 writeData(x1);
853 writeCommand(0x96);
854 writeData((x1) >> 8);
855
856 /* Set Y1 */
857 writeCommand(0x97);
858 writeData(y1);
859 writeCommand(0x98);
860 writeData((y1) >> 8);
861
862 /* Set Color */
863 writeCommand(0x63);
864 writeData((color & 0xf800) >> 11);
865 writeCommand(0x64);
866 writeData((color & 0x07e0) >> 5);
867 writeCommand(0x65);
868 writeData((color & 0x001f));
869
870 /* Draw! */
872 writeData(0x80);
873
874 /* Wait for the command to finish */
876}
877
878/**************************************************************************/
887/**************************************************************************/
888void Adafruit_RA8875::drawFastVLine(int16_t x, int16_t y, int16_t h,
889 uint16_t color) {
890 drawLine(x, y, x, y + h, color);
891}
892
893/**************************************************************************/
902/**************************************************************************/
903void Adafruit_RA8875::drawFastHLine(int16_t x, int16_t y, int16_t w,
904 uint16_t color) {
905 drawLine(x, y, x + w, y, color);
906}
907
908/**************************************************************************/
918/**************************************************************************/
919void Adafruit_RA8875::drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
920 uint16_t color) {
921 rectHelper(x, y, x + w - 1, y + h - 1, color, false);
922}
923
924/**************************************************************************/
934/**************************************************************************/
935void Adafruit_RA8875::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
936 uint16_t color) {
937 rectHelper(x, y, x + w - 1, y + h - 1, color, true);
938}
939
940/**************************************************************************/
946/**************************************************************************/
947void Adafruit_RA8875::fillScreen(uint16_t color) {
948 rectHelper(0, 0, _width - 1, _height - 1, color, true);
949}
950
951/**************************************************************************/
960/**************************************************************************/
961void Adafruit_RA8875::drawCircle(int16_t x, int16_t y, int16_t r,
962 uint16_t color) {
963 circleHelper(x, y, r, color, false);
964}
965
966/**************************************************************************/
975/**************************************************************************/
976void Adafruit_RA8875::fillCircle(int16_t x, int16_t y, int16_t r,
977 uint16_t color) {
978 circleHelper(x, y, r, color, true);
979}
980
981/**************************************************************************/
993/**************************************************************************/
994void Adafruit_RA8875::drawTriangle(int16_t x0, int16_t y0, int16_t x1,
995 int16_t y1, int16_t x2, int16_t y2,
996 uint16_t color) {
997 triangleHelper(x0, y0, x1, y1, x2, y2, color, false);
998}
999
1000/**************************************************************************/
1012/**************************************************************************/
1013void Adafruit_RA8875::fillTriangle(int16_t x0, int16_t y0, int16_t x1,
1014 int16_t y1, int16_t x2, int16_t y2,
1015 uint16_t color) {
1016 triangleHelper(x0, y0, x1, y1, x2, y2, color, true);
1017}
1018
1019/**************************************************************************/
1029/**************************************************************************/
1030void Adafruit_RA8875::drawEllipse(int16_t xCenter, int16_t yCenter,
1031 int16_t longAxis, int16_t shortAxis,
1032 uint16_t color) {
1033 ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, false);
1034}
1035
1036/**************************************************************************/
1046/**************************************************************************/
1047void Adafruit_RA8875::fillEllipse(int16_t xCenter, int16_t yCenter,
1048 int16_t longAxis, int16_t shortAxis,
1049 uint16_t color) {
1050 ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, true);
1051}
1052
1053/**************************************************************************/
1068/**************************************************************************/
1069void Adafruit_RA8875::drawCurve(int16_t xCenter, int16_t yCenter,
1070 int16_t longAxis, int16_t shortAxis,
1071 uint8_t curvePart, uint16_t color) {
1072 curveHelper(xCenter, yCenter, longAxis, shortAxis, curvePart, color, false);
1073}
1074
1075/**************************************************************************/
1090/**************************************************************************/
1091void Adafruit_RA8875::fillCurve(int16_t xCenter, int16_t yCenter,
1092 int16_t longAxis, int16_t shortAxis,
1093 uint8_t curvePart, uint16_t color) {
1094 curveHelper(xCenter, yCenter, longAxis, shortAxis, curvePart, color, true);
1095}
1096
1097/**************************************************************************/
1108/**************************************************************************/
1109void Adafruit_RA8875::drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,
1110 int16_t r, uint16_t color) {
1111 roundRectHelper(x, y, x + w, y + h, r, color, false);
1112}
1113
1114/**************************************************************************/
1125/**************************************************************************/
1126void Adafruit_RA8875::fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,
1127 int16_t r, uint16_t color) {
1128 roundRectHelper(x, y, x + w, y + h, r, color, true);
1129}
1130
1131/**************************************************************************/
1135/**************************************************************************/
1136void Adafruit_RA8875::circleHelper(int16_t x, int16_t y, int16_t r,
1137 uint16_t color, bool filled) {
1138 x = applyRotationX(x);
1139 y = applyRotationY(y);
1140
1141 /* Set X */
1142 writeCommand(0x99);
1143 writeData(x);
1144 writeCommand(0x9a);
1145 writeData(x >> 8);
1146
1147 /* Set Y */
1148 writeCommand(0x9b);
1149 writeData(y);
1150 writeCommand(0x9c);
1151 writeData(y >> 8);
1152
1153 /* Set Radius */
1154 writeCommand(0x9d);
1155 writeData(r);
1156
1157 /* Set Color */
1158 writeCommand(0x63);
1159 writeData((color & 0xf800) >> 11);
1160 writeCommand(0x64);
1161 writeData((color & 0x07e0) >> 5);
1162 writeCommand(0x65);
1163 writeData((color & 0x001f));
1164
1165 /* Draw! */
1167 if (filled) {
1169 } else {
1171 }
1172
1173 /* Wait for the command to finish */
1175}
1176
1177/**************************************************************************/
1181/**************************************************************************/
1182void Adafruit_RA8875::rectHelper(int16_t x, int16_t y, int16_t w, int16_t h,
1183 uint16_t color, bool filled) {
1184 x = applyRotationX(x);
1185 y = applyRotationY(y);
1186 w = applyRotationX(w);
1187 h = applyRotationY(h);
1188
1189 /* Set X */
1190 writeCommand(0x91);
1191 writeData(x);
1192 writeCommand(0x92);
1193 writeData(x >> 8);
1194
1195 /* Set Y */
1196 writeCommand(0x93);
1197 writeData(y);
1198 writeCommand(0x94);
1199 writeData(y >> 8);
1200
1201 /* Set X1 */
1202 writeCommand(0x95);
1203 writeData(w);
1204 writeCommand(0x96);
1205 writeData((w) >> 8);
1206
1207 /* Set Y1 */
1208 writeCommand(0x97);
1209 writeData(h);
1210 writeCommand(0x98);
1211 writeData((h) >> 8);
1212
1213 /* Set Color */
1214 writeCommand(0x63);
1215 writeData((color & 0xf800) >> 11);
1216 writeCommand(0x64);
1217 writeData((color & 0x07e0) >> 5);
1218 writeCommand(0x65);
1219 writeData((color & 0x001f));
1220
1221 /* Draw! */
1223 if (filled) {
1224 writeData(0xB0);
1225 } else {
1226 writeData(0x90);
1227 }
1228
1229 /* Wait for the command to finish */
1231}
1232
1233/**************************************************************************/
1237/**************************************************************************/
1238void Adafruit_RA8875::triangleHelper(int16_t x0, int16_t y0, int16_t x1,
1239 int16_t y1, int16_t x2, int16_t y2,
1240 uint16_t color, bool filled) {
1241 x0 = applyRotationX(x0);
1242 y0 = applyRotationY(y0);
1243 x1 = applyRotationX(x1);
1244 y1 = applyRotationY(y1);
1245 x2 = applyRotationX(x2);
1246 y2 = applyRotationY(y2);
1247
1248 /* Set Point 0 */
1249 writeCommand(0x91);
1250 writeData(x0);
1251 writeCommand(0x92);
1252 writeData(x0 >> 8);
1253 writeCommand(0x93);
1254 writeData(y0);
1255 writeCommand(0x94);
1256 writeData(y0 >> 8);
1257
1258 /* Set Point 1 */
1259 writeCommand(0x95);
1260 writeData(x1);
1261 writeCommand(0x96);
1262 writeData(x1 >> 8);
1263 writeCommand(0x97);
1264 writeData(y1);
1265 writeCommand(0x98);
1266 writeData(y1 >> 8);
1267
1268 /* Set Point 2 */
1269 writeCommand(0xA9);
1270 writeData(x2);
1271 writeCommand(0xAA);
1272 writeData(x2 >> 8);
1273 writeCommand(0xAB);
1274 writeData(y2);
1275 writeCommand(0xAC);
1276 writeData(y2 >> 8);
1277
1278 /* Set Color */
1279 writeCommand(0x63);
1280 writeData((color & 0xf800) >> 11);
1281 writeCommand(0x64);
1282 writeData((color & 0x07e0) >> 5);
1283 writeCommand(0x65);
1284 writeData((color & 0x001f));
1285
1286 /* Draw! */
1288 if (filled) {
1289 writeData(0xA1);
1290 } else {
1291 writeData(0x81);
1292 }
1293
1294 /* Wait for the command to finish */
1296}
1297
1298/**************************************************************************/
1302/**************************************************************************/
1303void Adafruit_RA8875::ellipseHelper(int16_t xCenter, int16_t yCenter,
1304 int16_t longAxis, int16_t shortAxis,
1305 uint16_t color, bool filled) {
1306 xCenter = applyRotationX(xCenter);
1307 yCenter = applyRotationY(yCenter);
1308
1309 /* Set Center Point */
1310 writeCommand(0xA5);
1311 writeData(xCenter);
1312 writeCommand(0xA6);
1313 writeData(xCenter >> 8);
1314 writeCommand(0xA7);
1315 writeData(yCenter);
1316 writeCommand(0xA8);
1317 writeData(yCenter >> 8);
1318
1319 /* Set Long and Short Axis */
1320 writeCommand(0xA1);
1321 writeData(longAxis);
1322 writeCommand(0xA2);
1323 writeData(longAxis >> 8);
1324 writeCommand(0xA3);
1325 writeData(shortAxis);
1326 writeCommand(0xA4);
1327 writeData(shortAxis >> 8);
1328
1329 /* Set Color */
1330 writeCommand(0x63);
1331 writeData((color & 0xf800) >> 11);
1332 writeCommand(0x64);
1333 writeData((color & 0x07e0) >> 5);
1334 writeCommand(0x65);
1335 writeData((color & 0x001f));
1336
1337 /* Draw! */
1338 writeCommand(0xA0);
1339 if (filled) {
1340 writeData(0xC0);
1341 } else {
1342 writeData(0x80);
1343 }
1344
1345 /* Wait for the command to finish */
1347}
1348
1349/**************************************************************************/
1353/**************************************************************************/
1354void Adafruit_RA8875::curveHelper(int16_t xCenter, int16_t yCenter,
1355 int16_t longAxis, int16_t shortAxis,
1356 uint8_t curvePart, uint16_t color,
1357 bool filled) {
1358 xCenter = applyRotationX(xCenter);
1359 yCenter = applyRotationY(yCenter);
1360 curvePart = (curvePart + _rotation) % 4;
1361
1362 /* Set Center Point */
1363 writeCommand(0xA5);
1364 writeData(xCenter);
1365 writeCommand(0xA6);
1366 writeData(xCenter >> 8);
1367 writeCommand(0xA7);
1368 writeData(yCenter);
1369 writeCommand(0xA8);
1370 writeData(yCenter >> 8);
1371
1372 /* Set Long and Short Axis */
1373 writeCommand(0xA1);
1374 writeData(longAxis);
1375 writeCommand(0xA2);
1376 writeData(longAxis >> 8);
1377 writeCommand(0xA3);
1378 writeData(shortAxis);
1379 writeCommand(0xA4);
1380 writeData(shortAxis >> 8);
1381
1382 /* Set Color */
1383 writeCommand(0x63);
1384 writeData((color & 0xf800) >> 11);
1385 writeCommand(0x64);
1386 writeData((color & 0x07e0) >> 5);
1387 writeCommand(0x65);
1388 writeData((color & 0x001f));
1389
1390 /* Draw! */
1391 writeCommand(0xA0);
1392 if (filled) {
1393 writeData(0xD0 | (curvePart & 0x03));
1394 } else {
1395 writeData(0x90 | (curvePart & 0x03));
1396 }
1397
1398 /* Wait for the command to finish */
1400}
1401
1402/**************************************************************************/
1406/**************************************************************************/
1407void Adafruit_RA8875::roundRectHelper(int16_t x, int16_t y, int16_t w,
1408 int16_t h, int16_t r, uint16_t color,
1409 bool filled) {
1410 x = applyRotationX(x);
1411 y = applyRotationY(y);
1412 w = applyRotationX(w);
1413 h = applyRotationY(h);
1414 if (x > w)
1415 swap(x, w);
1416 if (y > h)
1417 swap(y, h);
1418
1419 /* Set X */
1420 writeCommand(0x91);
1421 writeData(x);
1422 writeCommand(0x92);
1423 writeData(x >> 8);
1424
1425 /* Set Y */
1426 writeCommand(0x93);
1427 writeData(y);
1428 writeCommand(0x94);
1429 writeData(y >> 8);
1430
1431 /* Set X1 */
1432 writeCommand(0x95);
1433 writeData(w);
1434 writeCommand(0x96);
1435 writeData((w) >> 8);
1436
1437 /* Set Y1 */
1438 writeCommand(0x97);
1439 writeData(h);
1440 writeCommand(0x98);
1441 writeData((h) >> 8);
1442
1443 writeCommand(0xA1);
1444 writeData(r);
1445 writeCommand(0xA2);
1446 writeData((r) >> 8);
1447
1448 writeCommand(0xA3);
1449 writeData(r);
1450 writeCommand(0xA4);
1451 writeData((r) >> 8);
1452
1453 /* Set Color */
1454 writeCommand(0x63);
1455 writeData((color & 0xf800) >> 11);
1456 writeCommand(0x64);
1457 writeData((color & 0x07e0) >> 5);
1458 writeCommand(0x65);
1459 writeData((color & 0x001f));
1460
1461 /* Draw! */
1463 if (filled) {
1464 writeData(0xE0);
1465 } else {
1466 writeData(0xA0);
1467 }
1468
1469 /* Wait for the command to finish */
1471}
1472/**************************************************************************/
1483/**************************************************************************/
1484void Adafruit_RA8875::setScrollWindow(int16_t x, int16_t y, int16_t w,
1485 int16_t h, uint8_t mode) {
1486 // Horizontal Start point of Scroll Window
1487 writeCommand(0x38);
1488 writeData(x);
1489 writeCommand(0x39);
1490 writeData(x >> 8);
1491
1492 // Vertical Start Point of Scroll Window
1493 writeCommand(0x3a);
1494 writeData(y);
1495 writeCommand(0x3b);
1496 writeData(y >> 8);
1497
1498 // Horizontal End Point of Scroll Window
1499 writeCommand(0x3c);
1500 writeData(x + w);
1501 writeCommand(0x3d);
1502 writeData((x + w) >> 8);
1503
1504 // Vertical End Point of Scroll Window
1505 writeCommand(0x3e);
1506 writeData(y + h);
1507 writeCommand(0x3f);
1508 writeData((y + h) >> 8);
1509
1510 // Scroll function setting
1511 writeCommand(0x52);
1512 writeData(mode);
1513}
1514
1515/**************************************************************************/
1522/**************************************************************************/
1523void Adafruit_RA8875::scrollX(int16_t dist) {
1524 writeCommand(0x24);
1525 writeData(dist);
1526 writeCommand(0x25);
1527 writeData(dist >> 8);
1528}
1529
1530/**************************************************************************/
1537/**************************************************************************/
1538void Adafruit_RA8875::scrollY(int16_t dist) {
1539 writeCommand(0x26);
1540 writeData(dist);
1541 writeCommand(0x27);
1542 writeData(dist >> 8);
1543}
1544
1545/************************* Mid Level ***********************************/
1546
1547/**************************************************************************/
1554/**************************************************************************/
1555void Adafruit_RA8875::GPIOX(boolean on) {
1556 if (on)
1558 else
1560}
1561
1562/**************************************************************************/
1568/**************************************************************************/
1571}
1572
1573/**************************************************************************/
1579/**************************************************************************/
1582}
1583
1584/**************************************************************************/
1591/**************************************************************************/
1592void Adafruit_RA8875::PWM1config(boolean on, uint8_t clock) {
1593 if (on) {
1594 writeReg(RA8875_P1CR, RA8875_P1CR_ENABLE | (clock & 0xF));
1595 } else {
1596 writeReg(RA8875_P1CR, RA8875_P1CR_DISABLE | (clock & 0xF));
1597 }
1598}
1599
1600/**************************************************************************/
1607/**************************************************************************/
1608void Adafruit_RA8875::PWM2config(boolean on, uint8_t clock) {
1609 if (on) {
1610 writeReg(RA8875_P2CR, RA8875_P2CR_ENABLE | (clock & 0xF));
1611 } else {
1612 writeReg(RA8875_P2CR, RA8875_P2CR_DISABLE | (clock & 0xF));
1613 }
1614}
1615
1616/**************************************************************************/
1622/**************************************************************************/
1624 uint8_t adcClk = (uint8_t)RA8875_TPCR0_ADCCLK_DIV4;
1625
1626 if (_size == RA8875_800x480) // match up touch size with LCD size
1627 adcClk = (uint8_t)RA8875_TPCR0_ADCCLK_DIV16;
1628
1629 if (on) {
1630 /* Enable Touch Panel (Reg 0x70) */
1632 RA8875_TPCR0_WAKEENABLE | adcClk); // 10mhz max!
1633 /* Set Auto Mode (Reg 0x71) */
1635 // RA8875_TPCR1_VREFEXT |
1637 /* Enable TP INT */
1639 } else {
1640 /* Disable TP INT */
1642 /* Disable Touch Panel (Reg 0x70) */
1644 }
1645}
1646
1647/**************************************************************************/
1654/**************************************************************************/
1657 return true;
1658 return false;
1659}
1660
1661/**************************************************************************/
1673/**************************************************************************/
1674boolean Adafruit_RA8875::touchRead(uint16_t* x, uint16_t* y) {
1675 uint16_t tx, ty;
1676 uint8_t temp;
1677
1678 tx = readReg(RA8875_TPXH);
1679 ty = readReg(RA8875_TPYH);
1680 temp = readReg(RA8875_TPXYL);
1681 tx <<= 2;
1682 ty <<= 2;
1683 tx |= temp & 0x03; // get the bottom x bits
1684 ty |= (temp >> 2) & 0x03; // get the bottom y bits
1685
1686 *x = tx;
1687 *y = ty;
1688
1689 /* Clear TP INT Status */
1691
1692 return true;
1693}
1694
1695/**************************************************************************/
1701/**************************************************************************/
1708
1709/**************************************************************************/
1715/**************************************************************************/
1722
1723/************************* Low Level ***********************************/
1724
1725/**************************************************************************/
1732/**************************************************************************/
1733void Adafruit_RA8875::writeReg(uint8_t reg, uint8_t val) {
1734 writeCommand(reg);
1735 writeData(val);
1736}
1737
1738/**************************************************************************/
1746/**************************************************************************/
1747uint8_t Adafruit_RA8875::readReg(uint8_t reg) {
1748 writeCommand(reg);
1749 return readData();
1750}
1751
1752/**************************************************************************/
1758/**************************************************************************/
1760 waitForReady();
1761 csLow();
1762 spi_begin();
1763 spiTransfer(RA8875_DATAWRITE);
1764 waitForReady();
1765 spiTransfer(d);
1766 spi_end();
1767 csHigh();
1768}
1769
1770/**************************************************************************/
1776/**************************************************************************/
1778 waitForReady();
1779 csLow();
1780 spi_begin();
1781
1782 spiTransfer(RA8875_DATAREAD);
1783 waitForReady();
1784 uint8_t x = spiTransfer(0x0);
1785 spi_end();
1786
1787 csHigh();
1788 return x;
1789}
1790
1791/**************************************************************************/
1797/**************************************************************************/
1799 waitForReady();
1800 csLow();
1801 spi_begin();
1802
1803 spiTransfer(RA8875_CMDWRITE);
1804 waitForReady();
1805 spiTransfer(d);
1806 spi_end();
1807
1808 csHigh();
1809}
1810
1811/**************************************************************************/
1817/**************************************************************************/
1819 waitForReady();
1820 csLow();
1821 spi_begin();
1822 spiTransfer(RA8875_CMDREAD);
1823 waitForReady();
1824 uint8_t x = spiTransfer(0x0);
1825 spi_end();
1826
1827 csHigh();
1828 return x;
1829}
1830
1831/**************************************************************************/
1843/**************************************************************************/
1845 StorageWriteFn write, void* ctx,
1846 uint32_t sizeBytes) {
1847 _storageRead = read;
1848 _storageWrite = write;
1849 _storageCtx = ctx;
1850 _storageSize = sizeBytes;
1851}
1852
1860bool Adafruit_RA8875::storageReadBytes(uint32_t address, uint8_t* data,
1861 uint32_t length) {
1862 return _storageRead && _storageRead(_storageCtx, address, data, length);
1863}
1864
1872bool Adafruit_RA8875::storageWriteBytes(uint32_t address, const uint8_t* data,
1873 uint32_t length) {
1874 return _storageWrite && _storageWrite(_storageCtx, address, data, length);
1875}
1876
1877/**************************************************************************/
1885/**************************************************************************/
1886uint32_t Adafruit_RA8875::eepromReadS32(int location) {
1887 uint8_t b[4] = {0, 0, 0, 0};
1888 if (!storageReadBytes((uint32_t)location, b, 4))
1889 return 0;
1890 return ((uint32_t)b[0] << 24) | ((uint32_t)b[1] << 16) |
1891 ((uint32_t)b[2] << 8) | (uint32_t)b[3];
1892}
1893
1894/**************************************************************************/
1901/**************************************************************************/
1902void Adafruit_RA8875::eepromWriteS32(int location, int32_t value) {
1903 uint8_t b[4] = {(uint8_t)((value >> 24) & 0xff), (uint8_t)((value >> 16) & 0xff),
1904 (uint8_t)((value >> 8) & 0xff), (uint8_t)(value & 0xff)};
1905 storageWriteBytes((uint32_t)location, b, 4);
1906}
1907
1908/**************************************************************************/
1917/**************************************************************************/
1918bool Adafruit_RA8875::readCalibration(int location, tsMatrix_t* matrixPtr) {
1919 if (location + sizeof(tsMatrix_t) > _storageSize) {
1920 return false; // Calibration location outside of the storage bounds
1921 }
1922 uint8_t calibrated = 0;
1923 if (!storageReadBytes((uint32_t)location + CFG_EEPROM_TOUCHSCREEN_CALIBRATED,
1924 &calibrated, 1))
1925 return false;
1926 if (calibrated == 1) {
1927 matrixPtr->An = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_AN);
1928 matrixPtr->Bn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_BN);
1929 matrixPtr->Cn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_CN);
1930 matrixPtr->Dn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_DN);
1931 matrixPtr->En = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_EN);
1932 matrixPtr->Fn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_FN);
1933 matrixPtr->Divider =
1935 return true;
1936 }
1937 return false;
1938}
1939
1940/**************************************************************************/
1947/**************************************************************************/
1948void Adafruit_RA8875::writeCalibration(int location, tsMatrix_t* matrixPtr) {
1949 // Note: upstream uses '<' here and '>' in readCalibration(); kept as is.
1950 if (location + sizeof(tsMatrix_t) < _storageSize) {
1951 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_AN, matrixPtr->An);
1952 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_BN, matrixPtr->Bn);
1953 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_CN, matrixPtr->Cn);
1954 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_DN, matrixPtr->Dn);
1955 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_EN, matrixPtr->En);
1956 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_FN, matrixPtr->Fn);
1958 matrixPtr->Divider);
1959 const uint8_t one = 1;
1960 storageWriteBytes((uint32_t)location + CFG_EEPROM_TOUCHSCREEN_CALIBRATED,
1961 &one, 1);
1962 }
1963}
#define RA8875_DEBUG_PRINTF(...)
Diagnostics compiled out.
__attribute__((weak)) uint32_t Adafruit_RA8875_GetSpiClockHz(SPI_HandleTypeDef *hspi)
Frequency of the clock feeding an SPI peripheral (before the baud prescaler). Weak: override it in yo...
#define RA8875_SPI_TIMEOUT_MS
SPI transfer timeout in milliseconds.
#define spi_end()
Not needed on STM32.
#define spi_begin()
Not needed on STM32.
#define RA8875_VSTR0
See datasheet.
#define RA8875_VSAW1
See datasheet.
#define RA8875_HDWR
See datasheet.
#define RA8875_INTC2_TP
See datasheet.
#define RA8875_TPCR1_DEBOUNCE
See datasheet.
#define RA8875_SYSR_MCU8
See datasheet.
#define RA8875_VNDR1
See datasheet.
#define RA8875_HEAW1
See datasheet.
#define RA8875_HNDFTR_DE_HIGH
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_FN
EEPROM Storage Location.
#define RA8875_DCR_DRAWSQUARE
See datasheet.
#define RA8875_HPWR
See datasheet.
#define RA8875_CURV0
See datasheet.
#define RA8875_TPCR0_ENABLE
See datasheet.
#define RA8875_TPCR0_ADCCLK_DIV4
See datasheet.
#define RA8875_VEAW1
See datasheet.
#define RA8875_MRWC
See datasheet.
#define RA8875_MWCR0_CURSOR
See datasheet.
#define RA8875_MWCR0_LRTD
Left->Right then Top->Down.
#define RA8875_DCR_FILL
See datasheet.
#define RA8875_DCR_CIRCLE_STATUS
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_BN
EEPROM Storage Location.
#define RA8875_P1CR_ENABLE
See datasheet.
#define RA8875_DATAREAD
See datasheet.
#define RA8875_TPYH
See datasheet.
#define RA8875_PWRR_SOFTRESET
See datasheet.
#define RA8875_GPIOX
See datasheet.
#define RA8875_MWCR0_RLTD
Right->Left then Top->Down.
#define RA8875_VNDR0
See datasheet.
#define RA8875_PCSR_4CLK
See datasheet.
#define RA8875_CURV1
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CALIBRATED
EEPROM Storage Location.
#define RA8875_VSAW0
See datasheet.
#define RA8875_DCR_CIRCLE_START
See datasheet.
#define RA8875_DCR_NOFILL
See datasheet.
#define RA8875_VEAW0
See datasheet.
#define RA8875_HSAW1
See datasheet.
#define RA8875_INTC1
See datasheet.
#define RA8875_P1CR_DISABLE
See datasheet.
#define RA8875_PWRR_NORMAL
See datasheet.
#define RA8875_SYSR_16BPP
See datasheet.
#define RA8875_PWRR_SLEEP
See datasheet.
#define RA8875_VDHR0
See datasheet.
#define RA8875_DCR_LINESQUTRI_STATUS
See datasheet.
#define RA8875_PLLC1
See datasheet.
#define RA8875_ELLIPSE_STATUS
See datasheet.
#define RA8875_PWRR
See datasheet.
#define RA8875_ELLIPSE
See datasheet.
#define RA8875_MWCR0_DIRMASK
Bitmask for Write Direction.
#define RA8875_VSTR1
See datasheet.
#define RA8875_HSTR
See datasheet.
#define RA8875_P2CR
See datasheet.
#define RA8875_HEAW0
See datasheet.
#define RA8875_PLLC2
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_DN
EEPROM Storage Location.
#define RA8875_PCSR
See datasheet.
#define RA8875_PCSR_2CLK
See datasheet.
#define RA8875_HPWR_LOW
See datasheet.
#define RA8875_PLLC2_DIV4
See datasheet.
#define RA8875_CMDWRITE
See datasheet.
#define RA8875_DCR_LINESQUTRI_STOP
See datasheet.
#define RA8875_TPCR0_WAIT_4096CLK
See datasheet.
#define RA8875_TPCR0
See datasheet.
#define RA8875_CMDREAD
See datasheet.
#define RA8875_MWCR0_BLINK
See datasheet.
#define RA8875_PWRR_DISPOFF
See datasheet.
#define RA8875_P2CR_ENABLE
See datasheet.
#define RA8875_MWCR0_TXTMODE
See datasheet.
#define RA8875_PLLC1_PLLDIV1
See datasheet.
#define RA8875_MWCR0
See datasheet.
#define RA8875_DCR_LINESQUTRI_START
See datasheet.
#define RA8875_PCSR_PDATL
See datasheet.
#define RA8875_DCR
See datasheet.
#define RA8875_DATAWRITE
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_CN
EEPROM Storage Location.
RA8875sizes
@ RA8875_480x272
@ RA8875_800x480
@ RA8875_480x80
@ RA8875_480x128
#define RA8875_CURH0
See datasheet.
#define RA8875_TPCR1
See datasheet.
#define RA8875_P1CR
See datasheet.
#define RA8875_PWRR_DISPON
See datasheet.
#define RA8875_P2CR_DISABLE
See datasheet.
#define RA8875_HNDR
See datasheet.
#define RA8875_P1DCR
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_EN
EEPROM Storage Location.
#define RA8875_P2DCR
See datasheet.
#define RA8875_TPCR0_DISABLE
See datasheet.
#define RA8875_INTC1_TP
See datasheet.
#define RA8875_MCLR
See datasheet.
#define RA8875_TPCR0_WAKEENABLE
See datasheet.
#define RA8875_TPCR1_AUTO
See datasheet.
#define RA8875_SYSR
See datasheet.
#define RA8875_BTCR
See datasheet.
#define RA8875_INTC2
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_DIVIDER
EEPROM Storage Location.
#define RA8875_VDHR1
See datasheet.
#define RA8875_MCLR_FULL
See datasheet.
#define RA8875_VPWR_LOW
See datasheet.
#define RA8875_TPCR0_ADCCLK_DIV16
See datasheet.
#define RA8875_VPWR
See datasheet.
#define RA8875_TPXH
See datasheet.
#define RA8875_HNDFTR
See datasheet.
#define RA8875_HSAW0
See datasheet.
#define RA8875_TPXYL
See datasheet.
#define RA8875_MCLR_START
See datasheet.
#define RA8875_CURH1
See datasheet.
#define CFG_EEPROM_TOUCHSCREEN_CAL_AN
EEPROM Storage Location.
uint8_t rotation
Display rotation (0 thru 3)
void GPIOX(boolean on)
void fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
bool readCalibration(int location, tsMatrix_t *matrixPtr)
boolean touchRead(uint16_t *x, uint16_t *y)
void drawPixel(int16_t x, int16_t y, uint16_t color)
void touchEnable(boolean on)
void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
void sleep(boolean sleep)
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
void fillCircle(int16_t x, int16_t y, int16_t r, uint16_t color)
void fillScreen(uint16_t color)
void writeReg(uint8_t reg, uint8_t val)
void fillCurve(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color)
Adafruit_RA8875(SPI_HandleTypeDef *spi, GPIO_TypeDef *csPort, uint16_t csPin, GPIO_TypeDef *rstPort, uint16_t rstPin, GPIO_TypeDef *waitPort=nullptr, uint16_t waitPin=0)
void PWM2config(boolean on, uint8_t clock)
void writeCalibration(int location, tsMatrix_t *matrixPtr)
void pushPixels(uint32_t num, uint16_t p)
void writeCommand(uint8_t d)
virtual size_t write(uint8_t b)
void setScrollWindow(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t mode)
uint8_t readStatus(void)
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
void fillEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
void drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h, int16_t r, uint16_t color)
uint32_t eepromReadS32(int location)
uint8_t readData(void)
void cursorBlink(uint8_t rate)
boolean begin(enum RA8875sizes s)
void setXY(uint16_t x, uint16_t y)
void drawCircle(int16_t x, int16_t y, int16_t r, uint16_t color)
void textEnlarge(uint8_t scale)
void textSetCursor(uint16_t x, uint16_t y)
uint16_t height(void)
void PWM1out(uint8_t p)
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
void PWM2out(uint8_t p)
int8_t getRotation(void)
void drawCurve(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint8_t curvePart, uint16_t color)
void scrollY(int16_t dist)
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
void setCalibrationStorage(StorageReadFn read, StorageWriteFn write, void *ctx, uint32_t sizeBytes)
void textColor(uint16_t foreColor, uint16_t bgColor)
boolean touched(void)
void drawPixels(uint16_t *p, uint32_t count, int16_t x, int16_t y)
void displayOn(boolean on)
uint8_t readReg(uint8_t reg)
uint16_t width(void)
boolean waitPoll(uint8_t r, uint8_t f)
void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
void writeData(uint8_t d)
void textTransparent(uint16_t foreColor)
void PWM1config(boolean on, uint8_t clock)
void setRotation(int8_t rotation)
void textWrite(const char *buffer, uint16_t len=0)
void scrollX(int16_t dist)
void drawEllipse(int16_t xCenter, int16_t yCenter, int16_t longAxis, int16_t shortAxis, uint16_t color)
void eepromWriteS32(int location, int32_t value)
int32_t Divider