Skip to content

Instantly share code, notes, and snippets.

@mhama
Created January 28, 2023 12:31
Show Gist options
  • Save mhama/fb0f5630f2e1309798f61589ae26706c to your computer and use it in GitHub Desktop.
Save mhama/fb0f5630f2e1309798f61589ae26706c to your computer and use it in GitHub Desktop.
LovyanGFX definition for Waveshare RP2040-LCD-1.28 (round LCD with RP2040 microcontroller)
#pragma once
#define LGFX_USE_V1
#include <LovyanGFX.hpp>
// LGFX for Waveshare RP2040-LCD-1.28
// https://www.waveshare.com/wiki/RP2040-LCD-1.28
// ref: https://github.com/lovyan03/LovyanGFX/blob/master/src/lgfx_user/LGFX_RP2040_096_Waveshare_sample.hpp
class LGFX : public lgfx::LGFX_Device
{
lgfx::Panel_GC9A01 _panel_instance;
lgfx::Bus_SPI _bus_instance;
lgfx::Light_PWM _light_instance;
public:
LGFX(void)
{
{
auto cfg = _bus_instance.config();
cfg.spi_host = 1;
cfg.spi_mode = 0;
cfg.freq_write = 80000000;
cfg.pin_sclk = 10;
cfg.pin_miso = -1;
cfg.pin_mosi = 11;
cfg.pin_dc = 8;
_bus_instance.config(cfg);
_panel_instance.setBus(&_bus_instance);
}
{
auto cfg = _panel_instance.config();
cfg.pin_cs = 9;
cfg.pin_rst = 12;
cfg.panel_width = 240;
cfg.panel_height = 240;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.invert = true;
cfg.rgb_order = false;
//cfg.offset_rotation = 0;
_panel_instance.config(cfg);
}
{
auto cfg = _light_instance.config();
cfg.pin_bl = 25;
cfg.pwm_channel = 1;
_light_instance.config(cfg);
_panel_instance.setLight(&_light_instance);
}
setPanel(&_panel_instance);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment