Last active
March 27, 2021 02:14
-
-
Save yamamaya/0ce59c3bcc2a04495ef7eca0ae9530dc to your computer and use it in GitHub Desktop.
WT32-SC01 with Arduino core and LovyanGFX / large sprite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LovyanGFX.hpp> | |
struct LGFX_Config { | |
static constexpr spi_host_device_t spi_host = HSPI_HOST; | |
static constexpr int dma_channel = 1; | |
static constexpr int spi_sclk = 14; | |
static constexpr int spi_mosi = 13; | |
static constexpr int spi_miso = -1; | |
static constexpr int spi_dlen = 8; | |
}; | |
static lgfx::LGFX_SPI<LGFX_Config> lcd; | |
static LGFX_Sprite sprite(&lcd); | |
static lgfx::Panel_ST7796 panel; | |
void setup() { | |
Serial.begin( 9600 ); | |
panel.freq_write = 40000000L; | |
panel.freq_fill = 40000000L; | |
panel.freq_read = 40000000L; | |
panel.spi_mode = 0; | |
panel.spi_mode_read = 0; | |
panel.len_dummy_read_pixel = 8; | |
panel.spi_read = false; | |
panel.spi_3wire = false; | |
panel.spi_cs = 15; | |
panel.spi_dc = 21; | |
panel.gpio_rst = 22; | |
panel.gpio_bl = 23; | |
panel.backlight_level = true; | |
panel.memory_width = 320; | |
panel.memory_height = 480; | |
panel.panel_width = 320; | |
panel.panel_height = 480; | |
panel.offset_x = 0; | |
panel.offset_y = 0; | |
panel.rotation = 1; | |
panel.offset_rotation = 0; | |
lcd.setPanel(&panel); | |
lcd.init(); | |
sprite.setPsram( true ); | |
sprite.setColorDepth( 16 ); | |
sprite.createSprite( 480, 320 ); | |
sprite.clear( TFT_BLUE ); | |
sprite.pushSprite( 0, 0 ); | |
} | |
unsigned long t1 = 0; | |
int frame_count = 0; | |
void loop() { | |
if ( t1 == 0 ) { | |
t1 = millis(); | |
} | |
frame_count ++; | |
unsigned long t2 = millis(); | |
if ( t2 - t1 > 1000 ) { | |
Serial.println( ( (float)frame_count / ( t2 - t1 ) ) * 1000 ); | |
t1 = t2; | |
frame_count = 0; | |
} | |
int x = random( 480 ); | |
int y = random( 320 ); | |
int r = random( 10, 50 ); | |
uint16_t col = random( 0x10000 ); | |
sprite.fillCircle( x, y, r, col ); | |
sprite.pushSprite( 0, 0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment