Advertisement
honey_the_codewitch

async batching on a wrover dev kit

Apr 24th, 2022 (edited)
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <Arduino.h>
  2. #include <tft_io.hpp>
  3. #include <ili9341.hpp>
  4. #include <gfx_cpp14.hpp>
  5. using namespace arduino;
  6. using namespace gfx;
  7.  
  8. #define LCD_HOST    VSPI
  9. #define PIN_NUM_MISO 25
  10. #define PIN_NUM_MOSI 23
  11. #define PIN_NUM_CLK  19
  12. #define PIN_NUM_CS   22
  13.  
  14. #define PIN_NUM_DC   21
  15. #define PIN_NUM_RST  18
  16. #define PIN_NUM_BCKL 5
  17.  
  18. using bus_t = tft_spi_ex<VSPI,PIN_NUM_CS,PIN_NUM_MOSI,PIN_NUM_MISO,PIN_NUM_CLK,SPI_MODE0,false,320*240*2+8,2>;
  19. using lcd_t = ili9341<PIN_NUM_DC,PIN_NUM_RST,PIN_NUM_BCKL,bus_t,1,false,400,200>;
  20.  
  21. lcd_t lcd;
  22. float hue;
  23. void setup() {
  24.   Serial.begin(115200);
  25.   hue = 0.0;
  26. }
  27.  
  28. void loop() {
  29.   hsv_pixel<24> px(true,hue,1,1);
  30.   auto px2 = px;
  31.   // batching is the fastest way
  32.   auto ba = draw::batch_async(lcd,lcd.bounds());
  33.   for(int y = 0;y<lcd.dimensions().height;++y) {
  34.     px2.template channelr<channel_name::S>(((double)y)/lcd.bounds().y2);
  35.     for(int x = 0;x<lcd.dimensions().width;++x) {
  36.       px2.template channelr<channel_name::V>(((double)x)/lcd.bounds().x2);
  37.       ba.write(px2);
  38.     }
  39.   }
  40.   // commit what we wrote
  41.   ba.commit();
  42.   hue+=.1;
  43.   if(hue>1.0) {
  44.     hue = 0.0;
  45.   }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement