F439_CPP_SPI_RA8875_TFT_LCD_03 1.0
STM32F439 SPI RA8875 7-inch TFT display demo built on the STM32_GFX and STM32_RA8875 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
112void Adafruit_RA8875::csLow(void) {
113 HAL_GPIO_WritePin(_csPort, _csPin, GPIO_PIN_RESET);
114}
116void Adafruit_RA8875::csHigh(void) {
117 HAL_GPIO_WritePin(_csPort, _csPin, GPIO_PIN_SET);
118}
122void Adafruit_RA8875::waitForReady(void) {
123 if (_waitPort == nullptr)
124 return;
125 while (!HAL_GPIO_ReadPin(_waitPort, _waitPin)) {
126 delay(1);
127 }
128}
130uint8_t Adafruit_RA8875::spiTransfer(uint8_t d) {
131 uint8_t r = 0;
132 HAL_SPI_TransmitReceive(_spi, &d, &r, 1, RA8875_SPI_TIMEOUT_MS);
133 return r;
134}
136void Adafruit_RA8875::spiWrite(const uint8_t* data, uint16_t len) {
137 HAL_SPI_Transmit(_spi, (uint8_t*)data, len, RA8875_SPI_TIMEOUT_MS);
138}
140bool Adafruit_RA8875::spiConfigOk(void) {
141 return _spi != nullptr && _spi->Init.Mode == SPI_MODE_MASTER &&
142 _spi->Init.Direction == SPI_DIRECTION_2LINES &&
143 _spi->Init.DataSize == SPI_DATASIZE_8BIT &&
144 _spi->Init.CLKPolarity == SPI_POLARITY_LOW &&
145 _spi->Init.CLKPhase == SPI_PHASE_1EDGE &&
146 _spi->Init.FirstBit == SPI_FIRSTBIT_MSB &&
147 _spi->Init.NSS == SPI_NSS_SOFT;
148}
155void Adafruit_RA8875::spiSetSpeed(uint32_t hz) {
156 static const struct {
157 uint32_t div;
158 uint32_t reg;
159 } table[] = {
160 {2, SPI_BAUDRATEPRESCALER_2}, {4, SPI_BAUDRATEPRESCALER_4},
161 {8, SPI_BAUDRATEPRESCALER_8}, {16, SPI_BAUDRATEPRESCALER_16},
162 {32, SPI_BAUDRATEPRESCALER_32}, {64, SPI_BAUDRATEPRESCALER_64},
163 {128, SPI_BAUDRATEPRESCALER_128}, {256, SPI_BAUDRATEPRESCALER_256}};
164 uint32_t clk = Adafruit_RA8875_GetSpiClockHz(_spi);
165 if (clk == 0)
166 return;
167 uint32_t reg = SPI_BAUDRATEPRESCALER_256;
168 for (unsigned i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
169 if (clk / table[i].div <= hz) {
170 reg = table[i].reg;
171 break;
172 }
173 }
174 if (_spi->Init.BaudRatePrescaler != reg) {
175 _spi->Init.BaudRatePrescaler = reg;
176 HAL_SPI_Init(_spi);
177 }
178}
179
180/**************************************************************************/
192/**************************************************************************/
194 _size = s;
195
196 if (_size == RA8875_480x80) {
197 _width = 480;
198 _height = 80;
199 } else if (_size == RA8875_480x128) {
200 _width = 480;
201 _height = 128;
202 } else if (_size == RA8875_480x272) {
203 _width = 480;
204 _height = 272;
205 } else if (_size == RA8875_800x480) {
206 _width = 800;
207 _height = 480;
208 } else {
209 return false;
210 }
211 _rotation = 0;
212 if (!spiConfigOk()) {
213 RA8875_DEBUG_PRINTF("RA8875: SPI must be master, 8-bit, mode 0, MSB, soft NSS\r\n");
214 return false;
215 }
216 csHigh();
217
218 HAL_GPIO_WritePin(_rstPort, _rstPin, GPIO_PIN_RESET);
219 delay(100);
220 HAL_GPIO_WritePin(_rstPort, _rstPin, GPIO_PIN_SET);
221 delay(100);
222
223 spiSetSpeed(125000); // slow until the chip's PLL is running
224
225 uint8_t x = readReg(0);
226 if (x != 0x75) {
227 RA8875_DEBUG_PRINTF("RA8875: unexpected chip ID 0x%02X (expected 0x75)\r\n", x);
228 return false;
229 }
230
231 initialize();
232
233 spiSetSpeed(4000000); // full speed
234
235 return true;
236}
237
238/************************* Initialization *********************************/
239
240/**************************************************************************/
244/**************************************************************************/
251
252/**************************************************************************/
256/**************************************************************************/
257void Adafruit_RA8875::PLLinit(void) {
258 if (_size == RA8875_480x80 || _size == RA8875_480x128 ||
259 _size == RA8875_480x272) {
261 delay(1);
263 delay(1);
264 } else /* (_size == RA8875_800x480) */ {
266 delay(1);
268 delay(1);
269 }
270}
271
272/**************************************************************************/
276/**************************************************************************/
277void Adafruit_RA8875::initialize(void) {
278 PLLinit();
280
281 /* Timing values */
282 uint8_t pixclk;
283 uint8_t hsync_start;
284 uint8_t hsync_pw;
285 uint8_t hsync_finetune;
286 uint8_t hsync_nondisp;
287 uint8_t vsync_pw;
288 uint16_t vsync_nondisp;
289 uint16_t vsync_start;
290
291 /* Set the correct values for the display being used */
292 if (_size == RA8875_480x80) {
294 hsync_nondisp = 10;
295 hsync_start = 8;
296 hsync_pw = 48;
297 hsync_finetune = 0;
298 vsync_nondisp = 3;
299 vsync_start = 8;
300 vsync_pw = 10;
301 _voffset = 192; // This uses the bottom 80 pixels of a 272 pixel controller
302 } else if (_size == RA8875_480x128 || _size == RA8875_480x272) {
304 hsync_nondisp = 10;
305 hsync_start = 8;
306 hsync_pw = 48;
307 hsync_finetune = 0;
308 vsync_nondisp = 3;
309 vsync_start = 8;
310 vsync_pw = 10;
311 _voffset = 0;
312 } else // (_size == RA8875_800x480)
313 {
315 hsync_nondisp = 26;
316 hsync_start = 32;
317 hsync_pw = 96;
318 hsync_finetune = 0;
319 vsync_nondisp = 32;
320 vsync_start = 23;
321 vsync_pw = 2;
322 _voffset = 0;
323 }
324
325 writeReg(RA8875_PCSR, pixclk);
326 delay(1);
327
328 /* Horizontal settings registers */
329 writeReg(RA8875_HDWR, (_width / 8) - 1); // H width: (HDWR + 1) * 8 = 480
331 writeReg(RA8875_HNDR, (hsync_nondisp - hsync_finetune - 2) /
332 8); // H non-display: HNDR * 8 + HNDFTR + 2 = 10
333 writeReg(RA8875_HSTR, hsync_start / 8 - 1); // Hsync start: (HSTR + 1)*8
334 writeReg(
336 RA8875_HPWR_LOW + (hsync_pw / 8 - 1)); // HSync pulse width = (HPWR+1) * 8
337
338 /* Vertical settings registers */
339 writeReg(RA8875_VDHR0, (uint16_t)(_height - 1 + _voffset) & 0xFF);
340 writeReg(RA8875_VDHR1, (uint16_t)(_height - 1 + _voffset) >> 8);
341 writeReg(RA8875_VNDR0, vsync_nondisp - 1); // V non-display period = VNDR + 1
342 writeReg(RA8875_VNDR1, vsync_nondisp >> 8);
343 writeReg(RA8875_VSTR0, vsync_start - 1); // Vsync start position = VSTR + 1
344 writeReg(RA8875_VSTR1, vsync_start >> 8);
346 RA8875_VPWR_LOW + vsync_pw - 1); // Vsync pulse width = VPWR + 1
347
348 /* Set active window X */
349 writeReg(RA8875_HSAW0, 0); // horizontal start point
351 writeReg(RA8875_HEAW0, (uint16_t)(_width - 1) & 0xFF); // horizontal end point
352 writeReg(RA8875_HEAW1, (uint16_t)(_width - 1) >> 8);
353
354 /* Set active window Y */
355 writeReg(RA8875_VSAW0, 0 + _voffset); // vertical start point
356 writeReg(RA8875_VSAW1, 0 + _voffset);
358 (uint16_t)(_height - 1 + _voffset) & 0xFF); // vertical end point
359 writeReg(RA8875_VEAW1, (uint16_t)(_height - 1 + _voffset) >> 8);
360
361 /* ToDo: Setup touch panel? */
362
363 /* Clear the entire window */
365 delay(500);
366}
367
368/**************************************************************************/
374/**************************************************************************/
376 return _width;
377}
378
379/**************************************************************************/
385/**************************************************************************/
387 return _height;
388}
389
390/**************************************************************************/
396/**************************************************************************/
398 return _rotation;
399}
400
401/**************************************************************************/
407/**************************************************************************/
408void Adafruit_RA8875::setRotation(int8_t rotation) {
409 switch (rotation) {
410 case 2:
411 _rotation = rotation;
412 break;
413 default:
414 _rotation = 0;
415 break;
416 }
417}
418
419/************************* Text Mode ***********************************/
420
421/**************************************************************************/
425/**************************************************************************/
427 /* Set text mode */
429 uint8_t temp = readData();
430 temp |= RA8875_MWCR0_TXTMODE; // Set bit 7
431 writeData(temp);
432
433 /* Select the internal (ROM) font */
434 writeCommand(0x21);
435 temp = readData();
436 temp &= ~((1 << 7) | (1 << 5)); // Clear bits 7 and 5
437 writeData(temp);
438}
439
440/**************************************************************************/
447/**************************************************************************/
448void Adafruit_RA8875::textSetCursor(uint16_t x, uint16_t y) {
449 x = applyRotationX(x);
450 y = applyRotationY(y);
451
452 /* Set cursor location */
453 writeCommand(0x2A);
454 writeData(x & 0xFF);
455 writeCommand(0x2B);
456 writeData(x >> 8);
457 writeCommand(0x2C);
458 writeData(y & 0xFF);
459 writeCommand(0x2D);
460 writeData(y >> 8);
461}
462
463/**************************************************************************/
470/**************************************************************************/
471void Adafruit_RA8875::textColor(uint16_t foreColor, uint16_t bgColor) {
472 /* Set Fore Color */
473 writeCommand(0x63);
474 writeData((foreColor & 0xf800) >> 11);
475 writeCommand(0x64);
476 writeData((foreColor & 0x07e0) >> 5);
477 writeCommand(0x65);
478 writeData((foreColor & 0x001f));
479
480 /* Set Background Color */
481 writeCommand(0x60);
482 writeData((bgColor & 0xf800) >> 11);
483 writeCommand(0x61);
484 writeData((bgColor & 0x07e0) >> 5);
485 writeCommand(0x62);
486 writeData((bgColor & 0x001f));
487
488 /* Clear transparency flag */
489 writeCommand(0x22);
490 uint8_t temp = readData();
491 temp &= ~(1 << 6); // Clear bit 6
492 writeData(temp);
493}
494
495/**************************************************************************/
501/**************************************************************************/
502void Adafruit_RA8875::textTransparent(uint16_t foreColor) {
503 /* Set Fore Color */
504 writeCommand(0x63);
505 writeData((foreColor & 0xf800) >> 11);
506 writeCommand(0x64);
507 writeData((foreColor & 0x07e0) >> 5);
508 writeCommand(0x65);
509 writeData((foreColor & 0x001f));
510
511 /* Set transparency flag */
512 writeCommand(0x22);
513 uint8_t temp = readData();
514 temp |= (1 << 6); // Set bit 6
515 writeData(temp);
516}
517
518/**************************************************************************/
529/**************************************************************************/
530void Adafruit_RA8875::textEnlarge(uint8_t scale) {
531 if (scale > 3)
532 scale = 3; // highest setting is 3
533
534 /* Set font size flags */
535 writeCommand(0x22);
536 uint8_t temp = readData();
537 temp &= ~(0xF); // Clears bits 0..3
538 temp |= scale << 2;
539 temp |= scale;
540
541 writeData(temp);
542
543 _textScale = scale;
544}
545
546/**************************************************************************/
558/**************************************************************************/
559
562 uint8_t temp = readData();
563 temp |= RA8875_MWCR0_CURSOR;
564 writeData(temp);
565
567 temp = readData();
568 temp |= RA8875_MWCR0_BLINK;
569 writeData(temp);
570
571 if (rate > 255)
572 rate = 255;
574 writeData(rate);
575}
576
577/**************************************************************************/
584/**************************************************************************/
585void Adafruit_RA8875::textWrite(const char* buffer, uint16_t len) {
586 if (len == 0)
587 len = strlen(buffer);
589 for (uint16_t i = 0; i < len; i++) {
590 writeData(buffer[i]);
592#if defined(__arm__)
594 // This delay is needed with textEnlarge(1) because
595 // Teensy 3.X is much faster than Arduino Uno
596 if (_textScale > 0)
597 delay(1);
599#else
601 // For others, delay starting with textEnlarge(2)
602 if (_textScale > 1)
603 delay(1);
605#endif
607 }
608}
609
610/************************* Graphics ***********************************/
611
612/**************************************************************************/
616/**************************************************************************/
619 uint8_t temp = readData();
620 temp &= ~RA8875_MWCR0_TXTMODE; // bit #7
621 writeData(temp);
622}
623
624/**************************************************************************/
633/**************************************************************************/
634boolean Adafruit_RA8875::waitPoll(uint8_t regname, uint8_t waitflag) {
635 /* Wait for the command to finish */
636 while (1) {
637 uint8_t temp = readReg(regname);
638 if (!(temp & waitflag))
639 return true;
640 }
641 return false; // MEMEFIX: yeah i know, unreached! - add timeout?
642}
643
644/**************************************************************************/
651/**************************************************************************/
652void Adafruit_RA8875::setXY(uint16_t x, uint16_t y) {
654 writeReg(RA8875_CURH1, x >> 8);
656 writeReg(RA8875_CURV1, y >> 8);
657}
658
659/**************************************************************************/
666/**************************************************************************/
667void Adafruit_RA8875::pushPixels(uint32_t num, uint16_t p) {
668 uint8_t buf[128]; // 64 pixels per SPI burst
669 csLow();
670 spiTransfer(RA8875_DATAWRITE);
671 while (num) {
672 uint32_t n = (num > sizeof(buf) / 2) ? sizeof(buf) / 2 : num;
673 for (uint32_t i = 0; i < n; i++) {
674 buf[2 * i] = (uint8_t)(p >> 8);
675 buf[2 * i + 1] = (uint8_t)p;
676 }
677 spiWrite(buf, (uint16_t)(n * 2));
678 num -= n;
679 }
680 csHigh();
681}
682
683/**************************************************************************/
687/**************************************************************************/
694
695/**************************************************************************/
701/**************************************************************************/
702int16_t Adafruit_RA8875::applyRotationX(int16_t x) {
703 switch (_rotation) {
704 case 2:
705 x = _width - 1 - x;
706 break;
707 }
708
709 return x;
710}
711
712/**************************************************************************/
718/**************************************************************************/
719int16_t Adafruit_RA8875::applyRotationY(int16_t y) {
720 switch (_rotation) {
721 case 2:
722 y = _height - 1 - y;
723 break;
724 }
725
726 return y + _voffset;
727}
728
729/**************************************************************************/
737/**************************************************************************/
738void Adafruit_RA8875::drawPixel(int16_t x, int16_t y, uint16_t color) {
739 x = applyRotationX(x);
740 y = applyRotationY(y);
741
743 writeReg(RA8875_CURH1, x >> 8);
745 writeReg(RA8875_CURV1, y >> 8);
747 uint8_t px[3] = {RA8875_DATAWRITE, (uint8_t)(color >> 8), (uint8_t)color};
748 csLow();
749 spiWrite(px, sizeof(px));
750 csHigh();
751}
752
753/**************************************************************************/
762/**************************************************************************/
763void Adafruit_RA8875::drawPixels(uint16_t* p, uint32_t num, int16_t x,
764 int16_t y) {
765 x = applyRotationX(x);
766 y = applyRotationY(y);
767
769 writeReg(RA8875_CURH1, x >> 8);
771 writeReg(RA8875_CURV1, y >> 8);
772
773 uint8_t dir = RA8875_MWCR0_LRTD;
774 if (_rotation == 2) {
775 dir = RA8875_MWCR0_RLTD;
776 }
778
780 uint8_t buf[128]; // 64 pixels per SPI burst
781 csLow();
782 spiTransfer(RA8875_DATAWRITE);
783 while (num) {
784 uint32_t n = (num > sizeof(buf) / 2) ? sizeof(buf) / 2 : num;
785 for (uint32_t i = 0; i < n; i++) {
786 buf[2 * i] = (uint8_t)(p[i] >> 8);
787 buf[2 * i + 1] = (uint8_t)p[i];
788 }
789 spiWrite(buf, (uint16_t)(n * 2));
790 p += n;
791 num -= n;
792 }
793 csHigh();
794}
795
796/**************************************************************************/
806/**************************************************************************/
807void Adafruit_RA8875::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
808 uint16_t color) {
809 x0 = applyRotationX(x0);
810 y0 = applyRotationY(y0);
811 x1 = applyRotationX(x1);
812 y1 = applyRotationY(y1);
813
814 /* Set X */
815 writeCommand(0x91);
816 writeData(x0);
817 writeCommand(0x92);
818 writeData(x0 >> 8);
819
820 /* Set Y */
821 writeCommand(0x93);
822 writeData(y0);
823 writeCommand(0x94);
824 writeData(y0 >> 8);
825
826 /* Set X1 */
827 writeCommand(0x95);
828 writeData(x1);
829 writeCommand(0x96);
830 writeData((x1) >> 8);
831
832 /* Set Y1 */
833 writeCommand(0x97);
834 writeData(y1);
835 writeCommand(0x98);
836 writeData((y1) >> 8);
837
838 /* Set Color */
839 writeCommand(0x63);
840 writeData((color & 0xf800) >> 11);
841 writeCommand(0x64);
842 writeData((color & 0x07e0) >> 5);
843 writeCommand(0x65);
844 writeData((color & 0x001f));
845
846 /* Draw! */
848 writeData(0x80);
849
850 /* Wait for the command to finish */
852}
853
854/**************************************************************************/
863/**************************************************************************/
864void Adafruit_RA8875::drawFastVLine(int16_t x, int16_t y, int16_t h,
865 uint16_t color) {
866 drawLine(x, y, x, y + h, color);
867}
868
869/**************************************************************************/
878/**************************************************************************/
879void Adafruit_RA8875::drawFastHLine(int16_t x, int16_t y, int16_t w,
880 uint16_t color) {
881 drawLine(x, y, x + w, y, color);
882}
883
884/**************************************************************************/
894/**************************************************************************/
895void Adafruit_RA8875::drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
896 uint16_t color) {
897 rectHelper(x, y, x + w - 1, y + h - 1, color, false);
898}
899
900/**************************************************************************/
910/**************************************************************************/
911void Adafruit_RA8875::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
912 uint16_t color) {
913 rectHelper(x, y, x + w - 1, y + h - 1, color, true);
914}
915
916/**************************************************************************/
922/**************************************************************************/
923void Adafruit_RA8875::fillScreen(uint16_t color) {
924 rectHelper(0, 0, _width - 1, _height - 1, color, true);
925}
926
927/**************************************************************************/
936/**************************************************************************/
937void Adafruit_RA8875::drawCircle(int16_t x, int16_t y, int16_t r,
938 uint16_t color) {
939 circleHelper(x, y, r, color, false);
940}
941
942/**************************************************************************/
951/**************************************************************************/
952void Adafruit_RA8875::fillCircle(int16_t x, int16_t y, int16_t r,
953 uint16_t color) {
954 circleHelper(x, y, r, color, true);
955}
956
957/**************************************************************************/
969/**************************************************************************/
970void Adafruit_RA8875::drawTriangle(int16_t x0, int16_t y0, int16_t x1,
971 int16_t y1, int16_t x2, int16_t y2,
972 uint16_t color) {
973 triangleHelper(x0, y0, x1, y1, x2, y2, color, false);
974}
975
976/**************************************************************************/
988/**************************************************************************/
989void Adafruit_RA8875::fillTriangle(int16_t x0, int16_t y0, int16_t x1,
990 int16_t y1, int16_t x2, int16_t y2,
991 uint16_t color) {
992 triangleHelper(x0, y0, x1, y1, x2, y2, color, true);
993}
994
995/**************************************************************************/
1005/**************************************************************************/
1006void Adafruit_RA8875::drawEllipse(int16_t xCenter, int16_t yCenter,
1007 int16_t longAxis, int16_t shortAxis,
1008 uint16_t color) {
1009 ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, false);
1010}
1011
1012/**************************************************************************/
1022/**************************************************************************/
1023void Adafruit_RA8875::fillEllipse(int16_t xCenter, int16_t yCenter,
1024 int16_t longAxis, int16_t shortAxis,
1025 uint16_t color) {
1026 ellipseHelper(xCenter, yCenter, longAxis, shortAxis, color, true);
1027}
1028
1029/**************************************************************************/
1044/**************************************************************************/
1045void Adafruit_RA8875::drawCurve(int16_t xCenter, int16_t yCenter,
1046 int16_t longAxis, int16_t shortAxis,
1047 uint8_t curvePart, uint16_t color) {
1048 curveHelper(xCenter, yCenter, longAxis, shortAxis, curvePart, color, false);
1049}
1050
1051/**************************************************************************/
1066/**************************************************************************/
1067void Adafruit_RA8875::fillCurve(int16_t xCenter, int16_t yCenter,
1068 int16_t longAxis, int16_t shortAxis,
1069 uint8_t curvePart, uint16_t color) {
1070 curveHelper(xCenter, yCenter, longAxis, shortAxis, curvePart, color, true);
1071}
1072
1073/**************************************************************************/
1084/**************************************************************************/
1085void Adafruit_RA8875::drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,
1086 int16_t r, uint16_t color) {
1087 roundRectHelper(x, y, x + w, y + h, r, color, false);
1088}
1089
1090/**************************************************************************/
1101/**************************************************************************/
1102void Adafruit_RA8875::fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,
1103 int16_t r, uint16_t color) {
1104 roundRectHelper(x, y, x + w, y + h, r, color, true);
1105}
1106
1107/**************************************************************************/
1111/**************************************************************************/
1112void Adafruit_RA8875::circleHelper(int16_t x, int16_t y, int16_t r,
1113 uint16_t color, bool filled) {
1114 x = applyRotationX(x);
1115 y = applyRotationY(y);
1116
1117 /* Set X */
1118 writeCommand(0x99);
1119 writeData(x);
1120 writeCommand(0x9a);
1121 writeData(x >> 8);
1122
1123 /* Set Y */
1124 writeCommand(0x9b);
1125 writeData(y);
1126 writeCommand(0x9c);
1127 writeData(y >> 8);
1128
1129 /* Set Radius */
1130 writeCommand(0x9d);
1131 writeData(r);
1132
1133 /* Set Color */
1134 writeCommand(0x63);
1135 writeData((color & 0xf800) >> 11);
1136 writeCommand(0x64);
1137 writeData((color & 0x07e0) >> 5);
1138 writeCommand(0x65);
1139 writeData((color & 0x001f));
1140
1141 /* Draw! */
1143 if (filled) {
1145 } else {
1147 }
1148
1149 /* Wait for the command to finish */
1151}
1152
1153/**************************************************************************/
1157/**************************************************************************/
1158void Adafruit_RA8875::rectHelper(int16_t x, int16_t y, int16_t w, int16_t h,
1159 uint16_t color, bool filled) {
1160 x = applyRotationX(x);
1161 y = applyRotationY(y);
1162 w = applyRotationX(w);
1163 h = applyRotationY(h);
1164
1165 /* Set X */
1166 writeCommand(0x91);
1167 writeData(x);
1168 writeCommand(0x92);
1169 writeData(x >> 8);
1170
1171 /* Set Y */
1172 writeCommand(0x93);
1173 writeData(y);
1174 writeCommand(0x94);
1175 writeData(y >> 8);
1176
1177 /* Set X1 */
1178 writeCommand(0x95);
1179 writeData(w);
1180 writeCommand(0x96);
1181 writeData((w) >> 8);
1182
1183 /* Set Y1 */
1184 writeCommand(0x97);
1185 writeData(h);
1186 writeCommand(0x98);
1187 writeData((h) >> 8);
1188
1189 /* Set Color */
1190 writeCommand(0x63);
1191 writeData((color & 0xf800) >> 11);
1192 writeCommand(0x64);
1193 writeData((color & 0x07e0) >> 5);
1194 writeCommand(0x65);
1195 writeData((color & 0x001f));
1196
1197 /* Draw! */
1199 if (filled) {
1200 writeData(0xB0);
1201 } else {
1202 writeData(0x90);
1203 }
1204
1205 /* Wait for the command to finish */
1207}
1208
1209/**************************************************************************/
1213/**************************************************************************/
1214void Adafruit_RA8875::triangleHelper(int16_t x0, int16_t y0, int16_t x1,
1215 int16_t y1, int16_t x2, int16_t y2,
1216 uint16_t color, bool filled) {
1217 x0 = applyRotationX(x0);
1218 y0 = applyRotationY(y0);
1219 x1 = applyRotationX(x1);
1220 y1 = applyRotationY(y1);
1221 x2 = applyRotationX(x2);
1222 y2 = applyRotationY(y2);
1223
1224 /* Set Point 0 */
1225 writeCommand(0x91);
1226 writeData(x0);
1227 writeCommand(0x92);
1228 writeData(x0 >> 8);
1229 writeCommand(0x93);
1230 writeData(y0);
1231 writeCommand(0x94);
1232 writeData(y0 >> 8);
1233
1234 /* Set Point 1 */
1235 writeCommand(0x95);
1236 writeData(x1);
1237 writeCommand(0x96);
1238 writeData(x1 >> 8);
1239 writeCommand(0x97);
1240 writeData(y1);
1241 writeCommand(0x98);
1242 writeData(y1 >> 8);
1243
1244 /* Set Point 2 */
1245 writeCommand(0xA9);
1246 writeData(x2);
1247 writeCommand(0xAA);
1248 writeData(x2 >> 8);
1249 writeCommand(0xAB);
1250 writeData(y2);
1251 writeCommand(0xAC);
1252 writeData(y2 >> 8);
1253
1254 /* Set Color */
1255 writeCommand(0x63);
1256 writeData((color & 0xf800) >> 11);
1257 writeCommand(0x64);
1258 writeData((color & 0x07e0) >> 5);
1259 writeCommand(0x65);
1260 writeData((color & 0x001f));
1261
1262 /* Draw! */
1264 if (filled) {
1265 writeData(0xA1);
1266 } else {
1267 writeData(0x81);
1268 }
1269
1270 /* Wait for the command to finish */
1272}
1273
1274/**************************************************************************/
1278/**************************************************************************/
1279void Adafruit_RA8875::ellipseHelper(int16_t xCenter, int16_t yCenter,
1280 int16_t longAxis, int16_t shortAxis,
1281 uint16_t color, bool filled) {
1282 xCenter = applyRotationX(xCenter);
1283 yCenter = applyRotationY(yCenter);
1284
1285 /* Set Center Point */
1286 writeCommand(0xA5);
1287 writeData(xCenter);
1288 writeCommand(0xA6);
1289 writeData(xCenter >> 8);
1290 writeCommand(0xA7);
1291 writeData(yCenter);
1292 writeCommand(0xA8);
1293 writeData(yCenter >> 8);
1294
1295 /* Set Long and Short Axis */
1296 writeCommand(0xA1);
1297 writeData(longAxis);
1298 writeCommand(0xA2);
1299 writeData(longAxis >> 8);
1300 writeCommand(0xA3);
1301 writeData(shortAxis);
1302 writeCommand(0xA4);
1303 writeData(shortAxis >> 8);
1304
1305 /* Set Color */
1306 writeCommand(0x63);
1307 writeData((color & 0xf800) >> 11);
1308 writeCommand(0x64);
1309 writeData((color & 0x07e0) >> 5);
1310 writeCommand(0x65);
1311 writeData((color & 0x001f));
1312
1313 /* Draw! */
1314 writeCommand(0xA0);
1315 if (filled) {
1316 writeData(0xC0);
1317 } else {
1318 writeData(0x80);
1319 }
1320
1321 /* Wait for the command to finish */
1323}
1324
1325/**************************************************************************/
1329/**************************************************************************/
1330void Adafruit_RA8875::curveHelper(int16_t xCenter, int16_t yCenter,
1331 int16_t longAxis, int16_t shortAxis,
1332 uint8_t curvePart, uint16_t color,
1333 bool filled) {
1334 xCenter = applyRotationX(xCenter);
1335 yCenter = applyRotationY(yCenter);
1336 curvePart = (curvePart + _rotation) % 4;
1337
1338 /* Set Center Point */
1339 writeCommand(0xA5);
1340 writeData(xCenter);
1341 writeCommand(0xA6);
1342 writeData(xCenter >> 8);
1343 writeCommand(0xA7);
1344 writeData(yCenter);
1345 writeCommand(0xA8);
1346 writeData(yCenter >> 8);
1347
1348 /* Set Long and Short Axis */
1349 writeCommand(0xA1);
1350 writeData(longAxis);
1351 writeCommand(0xA2);
1352 writeData(longAxis >> 8);
1353 writeCommand(0xA3);
1354 writeData(shortAxis);
1355 writeCommand(0xA4);
1356 writeData(shortAxis >> 8);
1357
1358 /* Set Color */
1359 writeCommand(0x63);
1360 writeData((color & 0xf800) >> 11);
1361 writeCommand(0x64);
1362 writeData((color & 0x07e0) >> 5);
1363 writeCommand(0x65);
1364 writeData((color & 0x001f));
1365
1366 /* Draw! */
1367 writeCommand(0xA0);
1368 if (filled) {
1369 writeData(0xD0 | (curvePart & 0x03));
1370 } else {
1371 writeData(0x90 | (curvePart & 0x03));
1372 }
1373
1374 /* Wait for the command to finish */
1376}
1377
1378/**************************************************************************/
1382/**************************************************************************/
1383void Adafruit_RA8875::roundRectHelper(int16_t x, int16_t y, int16_t w,
1384 int16_t h, int16_t r, uint16_t color,
1385 bool filled) {
1386 x = applyRotationX(x);
1387 y = applyRotationY(y);
1388 w = applyRotationX(w);
1389 h = applyRotationY(h);
1390 if (x > w)
1391 swap(x, w);
1392 if (y > h)
1393 swap(y, h);
1394
1395 /* Set X */
1396 writeCommand(0x91);
1397 writeData(x);
1398 writeCommand(0x92);
1399 writeData(x >> 8);
1400
1401 /* Set Y */
1402 writeCommand(0x93);
1403 writeData(y);
1404 writeCommand(0x94);
1405 writeData(y >> 8);
1406
1407 /* Set X1 */
1408 writeCommand(0x95);
1409 writeData(w);
1410 writeCommand(0x96);
1411 writeData((w) >> 8);
1412
1413 /* Set Y1 */
1414 writeCommand(0x97);
1415 writeData(h);
1416 writeCommand(0x98);
1417 writeData((h) >> 8);
1418
1419 writeCommand(0xA1);
1420 writeData(r);
1421 writeCommand(0xA2);
1422 writeData((r) >> 8);
1423
1424 writeCommand(0xA3);
1425 writeData(r);
1426 writeCommand(0xA4);
1427 writeData((r) >> 8);
1428
1429 /* Set Color */
1430 writeCommand(0x63);
1431 writeData((color & 0xf800) >> 11);
1432 writeCommand(0x64);
1433 writeData((color & 0x07e0) >> 5);
1434 writeCommand(0x65);
1435 writeData((color & 0x001f));
1436
1437 /* Draw! */
1439 if (filled) {
1440 writeData(0xE0);
1441 } else {
1442 writeData(0xA0);
1443 }
1444
1445 /* Wait for the command to finish */
1447}
1448/**************************************************************************/
1459/**************************************************************************/
1460void Adafruit_RA8875::setScrollWindow(int16_t x, int16_t y, int16_t w,
1461 int16_t h, uint8_t mode) {
1462 // Horizontal Start point of Scroll Window
1463 writeCommand(0x38);
1464 writeData(x);
1465 writeCommand(0x39);
1466 writeData(x >> 8);
1467
1468 // Vertical Start Point of Scroll Window
1469 writeCommand(0x3a);
1470 writeData(y);
1471 writeCommand(0x3b);
1472 writeData(y >> 8);
1473
1474 // Horizontal End Point of Scroll Window
1475 writeCommand(0x3c);
1476 writeData(x + w);
1477 writeCommand(0x3d);
1478 writeData((x + w) >> 8);
1479
1480 // Vertical End Point of Scroll Window
1481 writeCommand(0x3e);
1482 writeData(y + h);
1483 writeCommand(0x3f);
1484 writeData((y + h) >> 8);
1485
1486 // Scroll function setting
1487 writeCommand(0x52);
1488 writeData(mode);
1489}
1490
1491/**************************************************************************/
1498/**************************************************************************/
1499void Adafruit_RA8875::scrollX(int16_t dist) {
1500 writeCommand(0x24);
1501 writeData(dist);
1502 writeCommand(0x25);
1503 writeData(dist >> 8);
1504}
1505
1506/**************************************************************************/
1513/**************************************************************************/
1514void Adafruit_RA8875::scrollY(int16_t dist) {
1515 writeCommand(0x26);
1516 writeData(dist);
1517 writeCommand(0x27);
1518 writeData(dist >> 8);
1519}
1520
1521/************************* Mid Level ***********************************/
1522
1523/**************************************************************************/
1530/**************************************************************************/
1531void Adafruit_RA8875::GPIOX(boolean on) {
1532 if (on)
1534 else
1536}
1537
1538/**************************************************************************/
1544/**************************************************************************/
1547}
1548
1549/**************************************************************************/
1555/**************************************************************************/
1558}
1559
1560/**************************************************************************/
1567/**************************************************************************/
1568void Adafruit_RA8875::PWM1config(boolean on, uint8_t clock) {
1569 if (on) {
1570 writeReg(RA8875_P1CR, RA8875_P1CR_ENABLE | (clock & 0xF));
1571 } else {
1572 writeReg(RA8875_P1CR, RA8875_P1CR_DISABLE | (clock & 0xF));
1573 }
1574}
1575
1576/**************************************************************************/
1583/**************************************************************************/
1584void Adafruit_RA8875::PWM2config(boolean on, uint8_t clock) {
1585 if (on) {
1586 writeReg(RA8875_P2CR, RA8875_P2CR_ENABLE | (clock & 0xF));
1587 } else {
1588 writeReg(RA8875_P2CR, RA8875_P2CR_DISABLE | (clock & 0xF));
1589 }
1590}
1591
1592/**************************************************************************/
1598/**************************************************************************/
1600 uint8_t adcClk = (uint8_t)RA8875_TPCR0_ADCCLK_DIV4;
1601
1602 if (_size == RA8875_800x480) // match up touch size with LCD size
1603 adcClk = (uint8_t)RA8875_TPCR0_ADCCLK_DIV16;
1604
1605 if (on) {
1606 /* Enable Touch Panel (Reg 0x70) */
1608 RA8875_TPCR0_WAKEENABLE | adcClk); // 10mhz max!
1609 /* Set Auto Mode (Reg 0x71) */
1611 // RA8875_TPCR1_VREFEXT |
1613 /* Enable TP INT */
1615 } else {
1616 /* Disable TP INT */
1618 /* Disable Touch Panel (Reg 0x70) */
1620 }
1621}
1622
1623/**************************************************************************/
1630/**************************************************************************/
1633 return true;
1634 return false;
1635}
1636
1637/**************************************************************************/
1649/**************************************************************************/
1650boolean Adafruit_RA8875::touchRead(uint16_t* x, uint16_t* y) {
1651 uint16_t tx, ty;
1652 uint8_t temp;
1653
1654 tx = readReg(RA8875_TPXH);
1655 ty = readReg(RA8875_TPYH);
1656 temp = readReg(RA8875_TPXYL);
1657 tx <<= 2;
1658 ty <<= 2;
1659 tx |= temp & 0x03; // get the bottom x bits
1660 ty |= (temp >> 2) & 0x03; // get the bottom y bits
1661
1662 *x = tx;
1663 *y = ty;
1664
1665 /* Clear TP INT Status */
1667
1668 return true;
1669}
1670
1671/**************************************************************************/
1677/**************************************************************************/
1684
1685/**************************************************************************/
1691/**************************************************************************/
1698
1699/************************* Low Level ***********************************/
1700
1701/**************************************************************************/
1708/**************************************************************************/
1709void Adafruit_RA8875::writeReg(uint8_t reg, uint8_t val) {
1710 writeCommand(reg);
1711 writeData(val);
1712}
1713
1714/**************************************************************************/
1722/**************************************************************************/
1723uint8_t Adafruit_RA8875::readReg(uint8_t reg) {
1724 writeCommand(reg);
1725 return readData();
1726}
1727
1728/**************************************************************************/
1734/**************************************************************************/
1736 waitForReady();
1737 csLow();
1738 spi_begin();
1739 spiTransfer(RA8875_DATAWRITE);
1740 waitForReady();
1741 spiTransfer(d);
1742 spi_end();
1743 csHigh();
1744}
1745
1746/**************************************************************************/
1752/**************************************************************************/
1754 waitForReady();
1755 csLow();
1756 spi_begin();
1757
1758 spiTransfer(RA8875_DATAREAD);
1759 waitForReady();
1760 uint8_t x = spiTransfer(0x0);
1761 spi_end();
1762
1763 csHigh();
1764 return x;
1765}
1766
1767/**************************************************************************/
1773/**************************************************************************/
1775 waitForReady();
1776 csLow();
1777 spi_begin();
1778
1779 spiTransfer(RA8875_CMDWRITE);
1780 waitForReady();
1781 spiTransfer(d);
1782 spi_end();
1783
1784 csHigh();
1785}
1786
1787/**************************************************************************/
1793/**************************************************************************/
1795 waitForReady();
1796 csLow();
1797 spi_begin();
1798 spiTransfer(RA8875_CMDREAD);
1799 waitForReady();
1800 uint8_t x = spiTransfer(0x0);
1801 spi_end();
1802
1803 csHigh();
1804 return x;
1805}
1806
1807/**************************************************************************/
1819/**************************************************************************/
1821 StorageWriteFn write, void* ctx,
1822 uint32_t sizeBytes) {
1823 _storageRead = read;
1824 _storageWrite = write;
1825 _storageCtx = ctx;
1826 _storageSize = sizeBytes;
1827}
1828
1829bool Adafruit_RA8875::storageReadBytes(uint32_t address, uint8_t* data,
1830 uint32_t length) {
1831 return _storageRead && _storageRead(_storageCtx, address, data, length);
1832}
1833
1834bool Adafruit_RA8875::storageWriteBytes(uint32_t address, const uint8_t* data,
1835 uint32_t length) {
1836 return _storageWrite && _storageWrite(_storageCtx, address, data, length);
1837}
1838
1839/**************************************************************************/
1847/**************************************************************************/
1848uint32_t Adafruit_RA8875::eepromReadS32(int location) {
1849 uint8_t b[4] = {0, 0, 0, 0};
1850 if (!storageReadBytes((uint32_t)location, b, 4))
1851 return 0;
1852 return ((uint32_t)b[0] << 24) | ((uint32_t)b[1] << 16) |
1853 ((uint32_t)b[2] << 8) | (uint32_t)b[3];
1854}
1855
1856/**************************************************************************/
1863/**************************************************************************/
1864void Adafruit_RA8875::eepromWriteS32(int location, int32_t value) {
1865 uint8_t b[4] = {(uint8_t)((value >> 24) & 0xff), (uint8_t)((value >> 16) & 0xff),
1866 (uint8_t)((value >> 8) & 0xff), (uint8_t)(value & 0xff)};
1867 storageWriteBytes((uint32_t)location, b, 4);
1868}
1869
1870/**************************************************************************/
1879/**************************************************************************/
1880bool Adafruit_RA8875::readCalibration(int location, tsMatrix_t* matrixPtr) {
1881 if (location + sizeof(tsMatrix_t) > _storageSize) {
1882 return false; // Calibration location outside of the storage bounds
1883 }
1884 uint8_t calibrated = 0;
1885 if (!storageReadBytes((uint32_t)location + CFG_EEPROM_TOUCHSCREEN_CALIBRATED,
1886 &calibrated, 1))
1887 return false;
1888 if (calibrated == 1) {
1889 matrixPtr->An = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_AN);
1890 matrixPtr->Bn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_BN);
1891 matrixPtr->Cn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_CN);
1892 matrixPtr->Dn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_DN);
1893 matrixPtr->En = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_EN);
1894 matrixPtr->Fn = eepromReadS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_FN);
1895 matrixPtr->Divider =
1897 return true;
1898 }
1899 return false;
1900}
1901
1902/**************************************************************************/
1909/**************************************************************************/
1910void Adafruit_RA8875::writeCalibration(int location, tsMatrix_t* matrixPtr) {
1911 // Note: upstream uses '<' here and '>' in readCalibration(); kept as is.
1912 if (location + sizeof(tsMatrix_t) < _storageSize) {
1913 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_AN, matrixPtr->An);
1914 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_BN, matrixPtr->Bn);
1915 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_CN, matrixPtr->Cn);
1916 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_DN, matrixPtr->Dn);
1917 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_EN, matrixPtr->En);
1918 eepromWriteS32(location + CFG_EEPROM_TOUCHSCREEN_CAL_FN, matrixPtr->Fn);
1920 matrixPtr->Divider);
1921 const uint8_t one = 1;
1922 storageWriteBytes((uint32_t)location + CFG_EEPROM_TOUCHSCREEN_CALIBRATED,
1923 &one, 1);
1924 }
1925}
#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