Skip to content

Instantly share code, notes, and snippets.

@XanCraft21
Created September 26, 2022 05:47
Show Gist options
  • Save XanCraft21/3c64c0bb37d35460a6035fd3ab29e6cd to your computer and use it in GitHub Desktop.
Save XanCraft21/3c64c0bb37d35460a6035fd3ab29e6cd to your computer and use it in GitHub Desktop.
Arduino LovyanGFX Sprite Buffer Test
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
int screenWidth = 128;
int screenHeight = 128;
int textSize = 2;
bool psram = false;
class LGFX : public lgfx::LGFX_Device {
//lgfx::Panel_GC9A01 _panel_instance;
//lgfx::Panel_HX8357B _panel_instance;
//lgfx::Panel_HX8357D _panel_instance;
//lgfx::Panel_ILI9163 _panel_instance;
//lgfx::Panel_ILI9225 _panel_instance;
//lgfx::Panel_ILI9341 _panel_instance;
//lgfx::Panel_ILI9342 _panel_instance;
//lgfx::Panel_ILI9481 _panel_instance;
//lgfx::Panel_ILI9486 _panel_instance;
//lgfx::Panel_ILI9488 _panel_instance;
//lgfx::Panel_SSD1331 _panel_instance;
lgfx::Panel_SSD1351 _panel_instance;
//lgfx::Panel_SSD1963 _panel_instance;
//lgfx::Panel_ST7735S _panel_instance;
//lgfx::Panel_ST7789 _panel_instance;
//lgfx::Panel_ST7796 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
public:
LGFX(void) {
{
auto cfg = _bus_instance.config();
cfg.spi_host = VSPI_HOST;
cfg.spi_mode = 2;
cfg.freq_write = 25000000;
cfg.freq_read = 16000000;
cfg.spi_3wire = false;
cfg.use_lock = false;
cfg.dma_channel = SPI_DMA_CH_AUTO;
cfg.pin_sclk = 18;
cfg.pin_mosi = 23;
cfg.pin_miso = 19;
cfg.pin_dc = 26;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = 25;
cfg.pin_rst = 27;
cfg.pin_busy = -1;
cfg.panel_width = 128;
cfg.panel_height = 128;
cfg.memory_width = 128;
cfg.memory_height = 128;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = false;
cfg.invert = false;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = false;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 32;
cfg.invert = false;
cfg.freq = 44100;
cfg.pwm_channel = 7;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
setPanel(&_panel_instance);
}
};
LGFX display;
LGFX_Sprite sprite(&display);
void setup() {
display.setColorDepth(16);
display.init();
display.setBrightness(110);
sprite.setColorDepth(16);
sprite.setTextSize(textSize);
sprite.setTextColor(0xffff);
sprite.setTextWrap(true);
sprite.setPsram(psram);
sprite.createSprite(screenWidth, screenHeight);
}
void loop() {
sprite.fillSprite(0b1111100000000000);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b0000011111100000);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b0000000000011111);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b1111111111100000);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b0000011111111111);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b1111100000011111);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b1111111111111111);
sprite.pushSprite(0, 0);
delay(1000);
sprite.fillSprite(0b0000000000000000);
sprite.pushSprite(0, 0);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment