2022-03-21 17:02:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "drivers/st7789/st7789.hpp"
|
|
|
|
#include "libraries/pico_graphics/pico_graphics.hpp"
|
2022-05-28 01:00:56 +01:00
|
|
|
#include "common/pimoroni_bus.hpp"
|
2022-03-21 17:02:46 +00:00
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
class ST7789Generic : public PicoGraphics {
|
|
|
|
private:
|
|
|
|
ST7789 st7789;
|
|
|
|
|
|
|
|
public:
|
2022-05-28 01:00:56 +01:00
|
|
|
ST7789Generic(uint16_t width, uint16_t height, Rotation rotation, bool round=false, void *frame_buffer=nullptr) :
|
2022-05-12 18:40:37 +01:00
|
|
|
PicoGraphics(width, height, frame_buffer),
|
2022-05-28 01:00:56 +01:00
|
|
|
st7789(width, height, rotation, round, frame_buffer, get_spi_pins(BG_SPI_FRONT)) {
|
|
|
|
common_init();
|
2022-05-12 18:40:37 +01:00
|
|
|
};
|
|
|
|
|
2022-05-28 01:00:56 +01:00
|
|
|
ST7789Generic(uint16_t width, uint16_t height, Rotation rotation, bool round, void *frame_buffer, SPIPins bus_pins) :
|
2022-05-12 18:40:37 +01:00
|
|
|
PicoGraphics(width, height, frame_buffer),
|
2022-05-28 01:00:56 +01:00
|
|
|
st7789(width, height, rotation, round, frame_buffer, bus_pins) {
|
|
|
|
common_init();
|
2022-05-12 18:40:37 +01:00
|
|
|
};
|
|
|
|
|
2022-05-28 01:00:56 +01:00
|
|
|
ST7789Generic(uint16_t width, uint16_t height, Rotation rotation, void *frame_buffer, ParallelPins bus_pins) :
|
2022-05-12 18:40:37 +01:00
|
|
|
PicoGraphics(width, height, frame_buffer),
|
2022-05-28 01:00:56 +01:00
|
|
|
st7789(width, height, rotation, frame_buffer, bus_pins) {
|
|
|
|
common_init();
|
2022-05-12 18:40:37 +01:00
|
|
|
};
|
2022-03-21 17:02:46 +00:00
|
|
|
|
2022-05-28 01:00:56 +01:00
|
|
|
void common_init() {
|
|
|
|
this->frame_buffer = (Pen *)st7789.frame_buffer;
|
|
|
|
this->st7789.init();
|
|
|
|
this->set_dimensions(this->st7789.width, this->st7789.height);
|
|
|
|
this->st7789.update(palette);
|
|
|
|
}
|
2022-03-21 17:02:46 +00:00
|
|
|
|
|
|
|
void update();
|
|
|
|
void set_backlight(uint8_t brightness);
|
2022-05-12 12:04:55 +01:00
|
|
|
void configure_display(bool rotate180);
|
2022-05-27 16:52:43 +01:00
|
|
|
void set_framebuffer(void* frame_buffer) {
|
|
|
|
this->frame_buffer = (Pen *)frame_buffer;
|
|
|
|
st7789.frame_buffer = frame_buffer;
|
|
|
|
}
|
2022-03-21 17:02:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|