PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extFontRom.ino 2.2KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /******************************************************************
  2. An example of how use an external ROM chip with RA8875, this time
  3. the ER3303_1 (same as GT23L24T3Y or GT30H24T3Y), an unified chinese
  4. font rom.
  5. In short:
  6. 1) use setExternalFontRom to set ROM and it's correct encoding
  7. 2) use setFont(EXTFONT) to use the external font
  8. 3) to switch back to internal font ROM, use setFont(INTFONT)
  9. Library can handle the following Font ROM:
  10. GT21L16T1W, GT21H16T1W, GT23L16U2W, GT30H24T3Y, GT23L24T3Y, GT23L24M1Z,
  11. GT23L32S4W, GT30H32S4W, ER3303_1
  12. Each font ROM has it's encoding so follow font rom datasheet!
  13. Not working? You don't have the correct font rom installed!
  14. Choose yours!
  15. ******************************************************************/
  16. #include <SPI.h>
  17. #include <RA8875.h>
  18. #define RA8875_CS 10
  19. #define RA8875_RESET 9//any pin or nothing!
  20. RA8875 tft = RA8875(RA8875_CS,RA8875_RESET);
  21. uint16_t tx, ty;
  22. void setup()
  23. {
  24. tft.begin(RA8875_800x480);
  25. //tft.changeMode(TEXT);
  26. tft.setTextColor(RA8875_WHITE);
  27. //now set the external rom font ER3303_1 an unified chinese font chip,
  28. //it contains also some ASCII char and use GB12345 encoding.
  29. //It's important to read your font chip datasheet or you will
  30. //get from nothing ti garbage on screen!
  31. tft.setExternalFontRom(ER3303_1,GB12345);
  32. //switch to external rom
  33. tft.setFont(EXTFONT);
  34. //now write some chinese....
  35. //note that when using ext font chip the size will be X24
  36. //since most of font maps are 24x24.
  37. tft.print("ÉîÛÚÐñÈÕ¶«·½¿Æ¼¼ÓÐÏÞ¹«Ë¾"); //
  38. //the X16 sixe of ROM ER3303_1 can also use ASCII...
  39. tft.setFontSize(X16);//switch to X16
  40. tft.setTextColor(RA8875_RED);
  41. tft.setCursor(0,50);
  42. tft.println("ABCD 1234567890"); //I will use println this time!
  43. //switch to internal rom
  44. tft.setFont(INTFONT);
  45. tft.setTextColor(RA8875_GREEN);
  46. tft.println("ABCD 1234567890");
  47. //not bad neh? you can use different encodings without use
  48. //any MCU memory, just add an hardware font chip and istruct library.
  49. tft.setFont(EXTFONT);
  50. //you can switching back on the fly to EXTFONT
  51. tft.print("ÉîÛÚÐñÈÕ¶«·½¿Æ¼¼ÓÐÏÞ¹«Ë¾");
  52. //voilà
  53. }
  54. void loop()
  55. {
  56. }