honey_the_codewitch

st7789 boilerplate

Mar 14th, 2022 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. // change these to your settings
  2. #define LCD_HOST VSPI
  3. #define PIN_NUM_CS 5
  4. #define PIN_NUM_MOSI 23
  5. #define PIN_NUM_MISO -1
  6. #define PIN_NUM_CLK 18
  7. #define PIN_NUM_DC 2
  8. #define PIN_NUM_RST 4
  9. #define PIN_NUM_BKL 15
  10. #define LCD_WRITE_SPEED_PERCENT 200 // 20Mhz - try 400!
  11. #define LCD_READ_SPEED_PERCENT 200 // 20Mhz - try 400!
  12.  
  13. #define LCD_ROTATION 1
  14. #define LCD_WIDTH 240 // is this right? should be portrait, not landscape either way.
  15. #define LCD_HEIGHT 320
  16.  
  17. #include <Arduino.h>
  18. #include <tft_io.hpp>
  19. #include <st7789.hpp>
  20. #include <gfx_cpp14.hpp>
  21.  
  22. using namespace arduino;
  23. using namespace gfx;
  24.  
  25. using bus_type = tft_spi_ex<LCD_HOST,
  26.                             PIN_NUM_CS,
  27.                             PIN_NUM_MOSI,
  28.                             PIN_NUM_MISO,
  29.                             PIN_NUM_CLK,
  30.                             SPI_MODE0,
  31.                             false
  32. #ifdef OPTIMIZE_DMA
  33.                             ,(LCD_WIDTH*LCD_HEIGHT)/8+8
  34. #endif
  35.                             >;
  36.  
  37.  
  38. using lcd_type = st7789<LCD_WIDTH,
  39.                         LCD_HEIGHT,
  40.                         PIN_NUM_DC,
  41.                         PIN_NUM_RST,
  42.                         PIN_NUM_BKL,
  43.                         bus_type,
  44.                         LCD_ROTATION,
  45.                         LCD_WRITE_SPEED_PERCENT,
  46.                         LCD_READ_SPEED_PERCENT>;
  47.  
  48. lcd_type lcd;
  49.  
  50. void setup() {}
  51.  
  52. void loop() {}
Add Comment
Please, Sign In to add comment