PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

284 行
13KB

  1. /*
  2. Part of RA8875 library from https://github.com/sumotoy/RA8875
  3. License:GNU General Public License v3.0
  4. RA8875 fast SPI library for RAiO SPI RA8875 drived TFT
  5. Copyright (C) 2014 egidio massimo costa sumotoy (a t) gmail.com
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _RA8875USERSETTINGS_H_
  18. #define _RA8875USERSETTINGS_H_
  19. /* ---------------------------- USER SETTINGS --------------------------------------*/
  20. /* [RENDER TEXT OPTIMIZATIONS] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  21. From 0.70b11 the Font Rendering Engine has some optimizations for render font faster but this require much more code.
  22. Not all users need this so you can select if include Render Text Optimizations or not by comment the following line. */
  23. #define _RA8875_TXTRNDOPTIMIZER // [default uncommented]
  24. /* [VISUALIZE RENDER TEXT OPTIMIZATIONS - >>> ONLY FOR DEBUG <<<] +++++++++++++++++++++++++++++++++++++++
  25. The Text Render optimizations introduced in b11 it's the result of testing several algorithms so it's in continue evolution.
  26. RA8875_VISPIXDEBUG force the rendering engine to show how the font it's rendered (Only for debug!!!).
  27. RA8875_TXTBENCH enable the font rendering engine to measure the time (Only for debug!!!), this
  28. option works ONLY when RA8875_VISPIXDEBUG it's uncommented or values are falsed*/
  29. //#define RA8875_VISPIXDEBUG // [default commented]
  30. //#define RA8875_TXTBENCH // [default commented]
  31. /* [USE_RA8875_SEPARATE_TEXT_COLOR] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  32. RA8875 chip set color globally, this mean that if you set text color white and after you create
  33. a red circle, every text after that will result red text.
  34. Enabling this feature your text will always maintain the choosed color. */
  35. #define USE_RA8875_SEPARATE_TEXT_COLOR // [default uncommented]
  36. /* [RENDERED FONTS FOLLOWS INTERNAL FONTS CURSORS] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  37. The library internal tracking the x,y position of the text cursors but not the rendered fonts, by
  38. enabling this option you will force library to inform RA8875 to keep track of the x,y text cursor.
  39. This option will slow down a bit the text rendering (just a bit) */
  40. #define FORCE_RA8875_TXTREND_FOLLOW_CURS // [default uncommented]
  41. /* [DISABLE ALL TOUCH SCREEN LIBRARY CAPABILITIES AND RELATIVE CODE] +++++++++++++++++++++++++++++++++++++++
  42. If your project don't need Touch Screen or you choosed to use an external library you can comment out
  43. the following line and ALL resources related will not loaded at all.
  44. If this is uncommented the CHOOSE YOUR TOUCH SCREEN TYPE has no effect. */
  45. //#define _AVOID_TOUCHSCREEN // [default commented]
  46. /* [CHOOSE YOUR TOUCH SCREEN TYPE] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47. This library supports the RA8875 internal resistive touch screen driver or a FT5206
  48. based capacitive touch screen driver. Below, you have to choose one of them.
  49. The Resistive Touch screen it's drived directly by RA8875.
  50. The Capacitive Touch Screen use a I2C chip called FT5206 (hardwired to address 0x38).
  51. Please choose at list one (NOT both), if you comment both it's the same as _AVOID_TOUCHSCREEN*/
  52. //#define USE_RA8875_TOUCH//resistive touch screen
  53. //#define USE_FT5206_TOUCH//capacitive touch screen
  54. /* [ONLY ADAFRUIT USERS - Weird rotation issue on some 800x480 adafruit display] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  55. An user had a strange rotation problem with an Adafruit 800x480 display. If this happen to you
  56. (only if this happen!) please try to uncomment the following line.
  57. Default:commented
  58. */
  59. //#define USE_ADAFRUIT_PHASE_FIXUP
  60. /* [USE ALTERNATIVE I2C/WIRE ON ARDUINO DUE] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  61. Arduino DUE has 2 I2C interfaces, default use Wire but you can force library to use Wire1.
  62. Just uncomment the line below, this option works only for Arduino DUE and has NO effects
  63. on other CPU!
  64. */
  65. //#define USE_DUE_WIRE1_INTERFACE//force use Wire1 (only for DUE, no effects on other CPU)
  66. /* [Default Interrupt Number for Touchscreen] [RA8875 & FT5206] ++++++++++++++++++++++++++++++++++
  67. Some microcontroller like Teensy 3,3.1 and LC automatically assign ISR number (since they
  68. can virtually assign ISR to any pin) but some old one like Arduino UNO have ISR hardcoded */
  69. #if !defined(_AVOID_TOUCHSCREEN)
  70. #define __RA8875ISRINT 0// // [default 0, pin 2 on Arduino UNO]
  71. #endif
  72. /* [INTERNAL KEY MATRIX] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  73. RA8875 has a 5x6 Key Matrix controller onboard, if you are not plan to use it
  74. better leave commented the following define since it will share some registers
  75. with several functions, otherwise de-comment it! */
  76. //#define USE_RA8875_KEYMATRIX // [default commented]
  77. /* [DEFAULT CURSOR BLINK RATE] +++++++++++++++++++++++++++++++++++++++++++++++++++++++
  78. Nothing special here, you can set the default blink rate */
  79. #define DEFAULTCURSORBLINKRATE 10 // [default 10]
  80. /* [DEFAULT INTERNAL FONT ENCODING] ++++++++++++++++++++++++++++++++++++++++++++++++++
  81. RA8875 has 4 different font set, same shape but suitable for most languages
  82. please look at RA8875 datasheet and choose the correct one for your language!
  83. ISO_IEC_8859_1 (default),
  84. ISO_IEC_8859_2,
  85. ISO_IEC_8859_3,
  86. ISO_IEC_8859_4
  87. The default one it's the most common one and should work in most situations */
  88. #define DEFAULTINTENCODING ISO_IEC_8859_1 // [default ISO_IEC_8859_1]
  89. /* [STARTUP SETTINGS] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  90. #define _DFT_RA8875_TEXTWRAP true // [default true]
  91. /* [DEFAULT EXTERNAL FONT-ROM TYPE] ++++++++++++++++++++++++++++++++++++++++++++
  92. If your card has a FONT-ROM installed, here you have to write wich one!
  93. I support both Genicomp and Eastrising since they are the same chip named differently!
  94. Possible solutions:
  95. GT21L16T1W (Genicomp)
  96. GT21H16T1W (Genicomp)
  97. GT23L16U2W (Genicomp)
  98. GT30H24T3Y (Genicomp)
  99. GT23L24T3Y (Genicomp)
  100. GT23L24M1Z (Genicomp)
  101. GT23L32S4W (Genicomp)
  102. GT30H32S4W (Genicomp)
  103. GT30L32S4W (Genicomp)
  104. ER3303_1 (Eastrising) *tested
  105. ER3304_1 (Eastrising) *tested
  106. */
  107. #define _DFT_RA8875_EXTFONTROMTYPE GT21L16T1W // [default GT21L16T1W]
  108. /* [DEFAULT EXTERNAL FONT-ROM ENCODING] ++++++++++++++++++++++++++++++++++++++++++++
  109. Having an external FONT-ROM mean choose the desidered encoding (supported by ROM-CHIP!)
  110. Possible solutions:
  111. GB2312,
  112. GB12345,
  113. BIG5,
  114. UNICODE,
  115. ASCII,
  116. UNIJIS,
  117. JIS0208,
  118. LATIN/GREEK/ARABIC */
  119. #define _DFT_RA8875_EXTFONTROMCODING GB2312 // [default GB2312]
  120. /* [Default Screen Rotation] ++++++++++++++++++++++++++++++++++++++++++++
  121. */
  122. #define _RA8875_DEFAULTSCRROT 0 // [default 0]
  123. /* [Default Backlight Color] ++++++++++++++++++++++++++++++++++++++++++++
  124. */
  125. #define _RA8875_DEFAULTBACKLIGHT RA8875_BLACK // [default RA8875_BLACK]
  126. /* [Default foreground Text Color] ++++++++++++++++++++++++++++++++++++++++++++
  127. */
  128. #define _RA8875_DEFAULTTXTFRGRND RA8875_WHITE // [default RA8875_WHITE]
  129. /* [Default background Text Color] ++++++++++++++++++++++++++++++++++++++++++++
  130. */
  131. #define _RA8875_DEFAULTTXTBKGRND RA8875_BLACK // [default RA8875_BLACK]
  132. /* [ARDUINO DUE SPI MODE] ++++++++++++++++++++++++++++++++++++++++++++
  133. This library support DUE SPI Extended mode, by decommenting the line below
  134. you have to choose from pin 4,10,52 for CS pin in DUE or you will get an error!
  135. */
  136. //#define SPI_DUE_MODE_EXTENDED
  137. /*----------------------------------------------------------------------------------
  138. SPI SPEED
  139. ----------------------------------------------------------------------------------*/
  140. /*
  141. From here it's better don't touch anithing, everithing has been tuned for maximum speed.
  142. Only DUE or any AVR 8bit (like uno) can have some troubles with particular old libraries
  143. because the use of fast port handle, in that case....
  144. On Arduino DUE and other 8 bit Arduino MCU you can disable the fast CS port
  145. by commenting #define _FASTSSPORT, this will force to use the classic digitalWrite.
  146. */
  147. /* Accordly RA8875 datasheet the READ cycles and WRITE cycles have different speed:
  148. System clock/3(only write cycle), System clock/6(with read cycle)
  149. MAXSPISPEED parameters it's also related to MCU features so it probably need to be tuned.
  150. Not all MCU are capable to work at those speeds. Following parameters worked with both board I have.
  151. After som mail exchange with RAiO I solved the dilemma behind SPI speed limit:
  152. The RA8875 has limitation of 12Mhz SPI but this has been set because not all internal macros
  153. can run over that speed, the library automatically deal with this so I was able to go over 20Mhz!
  154. At that speed you need to short cables as much you can, provide clean supply and good decoupling!
  155. DO NOT Exceed 23Mhz for RA8875! It will result in garbage on screen or run very slow.
  156. */
  157. #if defined(SPI_HAS_TRANSACTION)
  158. //SPI transaction enabled library----------------------
  159. const static uint32_t MAXSPIREADSPEED = 6000000UL; //Read don't go higher than 22000000!;
  160. #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
  161. const static uint32_t MAXSPISPEED = 18000000UL; //don't go higher than 22000000!;
  162. #elif defined(__MKL26Z64__) //[Teensy LC] (12 or 24 Mhz max)
  163. const static uint32_t MAXSPISPEED = 12000000UL; //default SPI main speed TeensyLC
  164. const static uint32_t MAXSPISPEED2 = 22000000UL; //don't go higher than 22000000!;
  165. #elif defined(___DUESTUFF) //[DUE]
  166. const static uint32_t MAXSPISPEED = 15000000UL; // try experiment higher values but NOT over 22000000!
  167. //#define _FASTSSPORT
  168. #elif defined(ESP8266)
  169. const static uint32_t MAXSPISPEED = 8000000UL; //don't go higher than 22000000!;
  170. //#define _FASTSSPORT
  171. #elif defined(SPARK)
  172. const static uint32_t MAXSPISPEED = 8000000UL; //don't go higher than 22000000!;
  173. // TODO: add more CPU here!
  174. #else //rest of the world (UNO, etc)
  175. const static uint32_t MAXSPISPEED = 10000000UL; //be careful, higher values result in extremely slow rendering!
  176. #define _FASTSSPORT
  177. #endif
  178. #else
  179. // legacy SPI library-------------------------------------------------------------
  180. #if defined(ENERGIA)
  181. // LaunchPad, FraunchPad and StellarPad specific
  182. #if defined(__TM4C129XNCZAD__) || defined(__TM4C1294NCPDT__)//tiva???
  183. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4
  184. #define SPI_SPEED_READ SPI_CLOCK_DIV8
  185. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8
  186. #elif defined(__LM4F120H5QR__) || defined(__TM4C123GH6PM__)//stellaris first version
  187. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4
  188. #define SPI_SPEED_READ SPI_CLOCK_DIV8
  189. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8
  190. #elif defined(__MSP430MCU__)//MSP430???
  191. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4
  192. #define SPI_SPEED_READ SPI_CLOCK_DIV4
  193. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8
  194. #elif defined(TMS320F28069)//C2000???
  195. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4
  196. #define SPI_SPEED_READ SPI_CLOCK_DIV4
  197. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8
  198. #elif defined(__CC3200R1M1RGC__)//CC3200???
  199. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4
  200. #define SPI_SPEED_READ SPI_CLOCK_DIV4
  201. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8
  202. #endif
  203. #else
  204. // DUE
  205. #if defined(___DUESTUFF)
  206. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4 //84 divided by 4 = 21Mhz
  207. #define SPI_SPEED_READ SPI_CLOCK_DIV8
  208. #define SPI_SPEED_SAFE SPI_CLOCK_DIV6 //10.5Mhz
  209. //#define _FASTSSPORT
  210. #elif defined(ESP8266)//legacy
  211. #define SPI_SPEED_WRITE SPI_CLOCK_DIV4 //8mhz
  212. #define SPI_SPEED_READ SPI_CLOCK_DIV8
  213. #define SPI_SPEED_SAFE SPI_CLOCK_DIV4 //8
  214. #elif defined(SPARK)//Really early development (72MHz )
  215. #define SPI_SPEED_WRITE SPI_CLOCK_DIV8 //9mhz
  216. #define SPI_SPEED_READ SPI_CLOCK_DIV4 //18Mhz
  217. #define SPI_SPEED_SAFE SPI_CLOCK_DIV8 //9
  218. #else
  219. // TODO: Add more CPU here!
  220. //rest of the world included UNO, etc.
  221. #define SPI_SPEED_WRITE SPI_CLOCK_DIV2 //UNO = 4Mhz
  222. #define SPI_SPEED_READ SPI_CLOCK_DIV4
  223. #define SPI_SPEED_SAFE SPI_CLOCK_DIV2
  224. #define _FASTSSPORT
  225. #endif
  226. #endif
  227. #endif
  228. //Touch Screen stuff (do not touch)
  229. #if defined(_AVOID_TOUCHSCREEN)
  230. #undef USE_RA8875_TOUCH
  231. #undef USE_FT5206_TOUCH
  232. #else
  233. #if defined(USE_RA8875_TOUCH) && defined(USE_FT5206_TOUCH)
  234. #error you have to choose between USE_RA8875_TOUCH & USE_FT5206_TOUCH!
  235. #elif !defined(USE_RA8875_TOUCH) && !defined(USE_FT5206_TOUCH)
  236. #define _AVOID_TOUCHSCREEN
  237. #elif defined(USE_FT5206_TOUCH) && !defined(USE_RA8875_TOUCH)
  238. //#include "Wire.h"//include the support for FT5206
  239. static const uint8_t _FT5206REgisters[9] = {
  240. 0x16,0x3C,0xE9,0x01,0x01,0xA0,0x0A,0x06,0x28
  241. };
  242. #elif !defined(USE_FT5206_TOUCH) && defined(USE_RA8875_TOUCH)
  243. #include "_settings/RA8875Calibration.h"
  244. #endif
  245. #endif
  246. //was here
  247. // Different displays may need/want different _waitPoll timeouts. Example on 800x480 display found drawing large circle took about 57ms which was a lot > 10 default fefore...
  248. #define _RA8875_WAITPOLL_TIMEOUT_DCR_LINESQUTRI_STATUS 20 // Have seen 12 or so
  249. #define _RA8875_WAITPOLL_TIMEOUT_DCR_CIRCLE_STATUS 75
  250. #define _RA8875_WAITPOLL_TIMEOUT_ELLIPSE_STATUS 75
  251. #endif