PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

UserCustomChars.ino 3.9KB

3 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. An example of how easy it's upload custom 8x16 symbols.
  3. RA8875 has 255 locations reserved for user custom designed symbols.
  4. */
  5. #include <SPI.h>
  6. #include <RA8875.h>
  7. #define RA8875_RESET 9//any pin or nothing!
  8. #if defined(NEEDS_SET_MODULE)//Energia, this case is for stellaris/tiva
  9. RA8875 tft = RA8875(3);//select SPI module 3
  10. /*
  11. for module 3 (stellaris)
  12. SCLK: PD_0
  13. MOSI: PD_3
  14. MISO: PD_2
  15. SS: PD_1
  16. */
  17. #endif
  18. //define some custom char (8x16)
  19. const uint8_t battery1[16] = {
  20. 0b00111000,
  21. 0b00111000,
  22. 0b11111111,
  23. 0b10000001,
  24. 0b10111101,
  25. 0b10111101,
  26. 0b10111101,
  27. 0b10111101,
  28. 0b10111101,
  29. 0b10111101,
  30. 0b10111101,
  31. 0b10111101,
  32. 0b10111101,
  33. 0b10111101,
  34. 0b10000001,
  35. 0b11111111
  36. };
  37. const uint8_t battery2[16] = {
  38. 0b00111000,
  39. 0b00111000,
  40. 0b11111111,
  41. 0b10000001,
  42. 0b10000001,
  43. 0b10000001,
  44. 0b10111101,
  45. 0b10111101,
  46. 0b10111101,
  47. 0b10111101,
  48. 0b10111101,
  49. 0b10111101,
  50. 0b10111101,
  51. 0b10111101,
  52. 0b10000001,
  53. 0b11111111
  54. };
  55. const uint8_t battery3[16] = {
  56. 0b00111000,
  57. 0b00111000,
  58. 0b11111111,
  59. 0b10000001,
  60. 0b10000001,
  61. 0b10000001,
  62. 0b10000001,
  63. 0b10000001,
  64. 0b10111101,
  65. 0b10111101,
  66. 0b10111101,
  67. 0b10111101,
  68. 0b10111101,
  69. 0b10111101,
  70. 0b10000001,
  71. 0b11111111
  72. };
  73. const uint8_t battery4[16] = {
  74. 0b00111000,
  75. 0b00111000,
  76. 0b11111111,
  77. 0b10000001,
  78. 0b10000001,
  79. 0b10000001,
  80. 0b10000001,
  81. 0b10000001,
  82. 0b10000001,
  83. 0b10000001,
  84. 0b10111101,
  85. 0b10111101,
  86. 0b10111101,
  87. 0b10111101,
  88. 0b10000001,
  89. 0b11111111
  90. };
  91. const uint8_t battery5[16] = {
  92. 0b00111000,
  93. 0b00111000,
  94. 0b11111111,
  95. 0b10000001,
  96. 0b10000001,
  97. 0b10000001,
  98. 0b10000001,
  99. 0b10000001,
  100. 0b10000001,
  101. 0b10000001,
  102. 0b10000001,
  103. 0b10000001,
  104. 0b10000001,
  105. 0b10000001,
  106. 0b10000001,
  107. 0b11111111
  108. };
  109. //next 3 are part of the same char
  110. const uint8_t battery6a[16] = {
  111. 0b00000111,
  112. 0b00000111,
  113. 0b11111111,
  114. 0b11000000,
  115. 0b11000000,
  116. 0b11000000,
  117. 0b11110000,
  118. 0b11111100,
  119. 0b11111111,
  120. 0b11111111,
  121. 0b11111111,
  122. 0b11111111,
  123. 0b11111111,
  124. 0b11111111,
  125. 0b00000000,
  126. 0b00000000
  127. };
  128. const uint8_t battery6b[16] = {
  129. 0b11100000,
  130. 0b11100000,
  131. 0b11111111,
  132. 0b00000011,
  133. 0b00000011,
  134. 0b00000011,
  135. 0b00000011,
  136. 0b00000011,
  137. 0b00000011,
  138. 0b11000011,
  139. 0b11110011,
  140. 0b11111111,
  141. 0b11111111,
  142. 0b11111111,
  143. 0b00000000,
  144. 0b00000000
  145. };
  146. const uint8_t battery6c[16] = {
  147. 0b00011111,
  148. 0b00000011,
  149. 0b00001111,
  150. 0b00000011,
  151. 0b00011111,
  152. 0b00000000,
  153. 0b00011111,
  154. 0b00000011,
  155. 0b00001111,
  156. 0b00000011,
  157. 0b00011111,
  158. 0b00000000,
  159. 0b00000000,
  160. 0b00000000,
  161. 0b00000000,
  162. 0b00000000
  163. };
  164. void setup()
  165. {
  166. uint8_t i;
  167. tft.begin(RA8875_800x480);
  168. //upload chars in address 0x00 to 0x04
  169. tft.uploadUserChar(battery1, 0); //0x00
  170. tft.uploadUserChar(battery2, 1);
  171. tft.uploadUserChar(battery3, 2);
  172. tft.uploadUserChar(battery4, 3);
  173. tft.uploadUserChar(battery5, 4); //0x04
  174. tft.uploadUserChar(battery6a, 5); //
  175. tft.uploadUserChar(battery6b, 6); //
  176. tft.uploadUserChar(battery6c, 7); //
  177. //now custom char are stored in CGRAM
  178. tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
  179. tft.setFontScale(0);
  180. for (i = 0; i < 5; i++) {
  181. tft.setCursor(tft.width() / 2, tft.height() / 2);
  182. tft.showUserChar(i);//retrieve from 0x00 to 0x04
  183. delay(200);
  184. }
  185. tft.setFontScale(0);
  186. }
  187. uint8_t rot;
  188. void loop()
  189. {
  190. uint8_t i;
  191. tft.clearScreen();//exact as tft.fillScreen();
  192. tft.setRotation(rot);
  193. tft.setTextColor(RA8875_WHITE, RA8875_BLACK);
  194. //custom char are managed as text but need to be called
  195. //by a special function
  196. //the only text parameter that is not accepted is setFontScale!
  197. for (i = 0; i < 5; i++) {
  198. tft.setCursor(10, 10);
  199. tft.showUserChar(i);//retrieve from 0x00 to 0x04
  200. delay(200);
  201. }
  202. //now another feature, you can design a char wider
  203. //by using many char slot combined.
  204. //below an example, 3 chars wider
  205. tft.setTextColor(RA8875_LIGHT_ORANGE);
  206. tft.setCursor(30, 11);
  207. tft.showUserChar(5, 2);
  208. delay(1000);
  209. if (rot > 3) rot = 0;
  210. rot++;
  211. }