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.

pictureEmbed.ino 1.9KB

3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Simple example to embed pictures in your sketch
  2. // and draw on the ILI9341 display with writeRect()
  3. //
  4. // By Frank Bösing
  5. //
  6. // https://forum.pjrc.com/threads/32601-SPI-Library-Issue-w-ILI9341-TFT-amp-PN532-NFC-Module-on-Teensy-3-2?p=94534&viewfull=1#post94534
  7. #include "SPI.h"
  8. #include "ILI9488_t3.h"
  9. // Converted to code with:
  10. // http://www.rinkydinkelectronics.com/t_imageconverter565.php
  11. //
  12. #include "picture.c" //the picture
  13. /* GIMP (https://www.gimp.org/) can also be used to export the image using the following steps:
  14. 1. File -> Export As
  15. 2. In the Export Image dialog, use 'C source code (*.c)' as filetype.
  16. 3. Press export to get the export options dialog.
  17. 4. Type the desired variable name into the 'prefixed name' box.
  18. 5. Uncheck 'GLIB types (guint8*)'
  19. 6. Check 'Save as RGB565 (16-bit)'
  20. 7. Press export to save your image.
  21. Assuming 'image_name' was typed in the 'prefixed name' box of step 4, you can have to include the c file as above,
  22. using the image can be done with:
  23. tft.writeRect(0, 0, image_name.width, image_name.height, (uint16_t*)(image_name.pixel_data));
  24. See also https://forum.pjrc.com/threads/35575-Export-for-ILI9488_t3-with-GIMP
  25. */
  26. // Normal Connections
  27. #define TFT_DC 9
  28. #define TFT_CS 10
  29. #define TFT_RST 8 // 255 = unused, connect to 3.3V
  30. #define TFT_MOSI 11
  31. #define TFT_SCLK 13
  32. #define TFT_MISO 12
  33. // Alternate Connections with Teensy Audio Shield
  34. //#define TFT_DC 20
  35. //#define TFT_CS 21
  36. //#define TFT_RST 255 // 255 = unused, connect to 3.3V
  37. //#define TFT_MOSI 7
  38. //#define TFT_SCLK 14
  39. //#define TFT_MISO 12
  40. ILI9488_t3 tft = ILI9488_t3(&SPI, TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
  41. void setup() {
  42. tft.begin();
  43. tft.setRotation(3);
  44. tft.fillScreen(ILI9488_BLACK);
  45. tft.writeRect(32, 33, 256, 174, (uint16_t*)picture);
  46. }
  47. void loop(void) {
  48. }