Created dedicated library class for round LCD breakout
This commit is contained in:
parent
500581d679
commit
0866ade054
|
@ -1,3 +1,4 @@
|
|||
add_subdirectory(breakout_roundlcd)
|
||||
add_subdirectory(pico_display)
|
||||
add_subdirectory(pico_unicorn)
|
||||
add_subdirectory(pico_unicorn_plasma)
|
||||
|
@ -5,5 +6,4 @@ add_subdirectory(pico_scroll)
|
|||
add_subdirectory(pico_explorer)
|
||||
add_subdirectory(pico_rgb_keypad)
|
||||
add_subdirectory(pico_rtc_display)
|
||||
add_subdirectory(pico_tof_display)
|
||||
add_subdirectory(st7789)
|
||||
add_subdirectory(pico_tof_display)
|
|
@ -0,0 +1,12 @@
|
|||
set(OUTPUT_NAME roundlcd_demo)
|
||||
|
||||
add_executable(
|
||||
${OUTPUT_NAME}
|
||||
demo.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(${OUTPUT_NAME} pico_stdlib breakout_roundlcd)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(${OUTPUT_NAME})
|
|
@ -3,54 +3,18 @@
|
|||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "st7789.hpp"
|
||||
#include "pico_graphics.hpp"
|
||||
#include "breakout_roundlcd.hpp"
|
||||
#include "time.h"
|
||||
|
||||
// Place a 1.3 Round SPI LCD in the *front* slot of breakout garden.
|
||||
|
||||
#define CS 17
|
||||
#define DC 16
|
||||
#define SCK 18
|
||||
#define MOSI 19
|
||||
#define MISO -1
|
||||
|
||||
// "true" to init the screen in "round" mode
|
||||
#define ROUND true
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
// Create a PicoDisplay to bind PicoGraphics with our ST7789 display
|
||||
class PicoDisplay : public PicoGraphics {
|
||||
public:
|
||||
static const int WIDTH = 240;
|
||||
static const int HEIGHT = 240;
|
||||
|
||||
uint16_t *__fb;
|
||||
private:
|
||||
ST7789 screen;
|
||||
uint16_t buffer[BreakoutRoundLCD::WIDTH * BreakoutRoundLCD::HEIGHT];
|
||||
BreakoutRoundLCD display(buffer);
|
||||
|
||||
public:
|
||||
PicoDisplay(uint16_t *buf) : PicoGraphics(WIDTH, HEIGHT, buf),
|
||||
screen(WIDTH, HEIGHT, buf,
|
||||
spi0,
|
||||
CS, DC, SCK, MOSI, MISO) {
|
||||
__fb = buf;
|
||||
}
|
||||
|
||||
void init() {
|
||||
screen.init(true, ROUND);
|
||||
};
|
||||
void update() {
|
||||
screen.update();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
uint16_t buffer[PicoDisplay::WIDTH * PicoDisplay::HEIGHT];
|
||||
PicoDisplay display(buffer);
|
||||
|
||||
constexpr float RADIUS = PicoDisplay::WIDTH / 2;
|
||||
constexpr float RADIUS = BreakoutRoundLCD::WIDTH / 2;
|
||||
|
||||
Pen from_hsv(float h, float s, float v) {
|
||||
uint8_t r, g, b;
|
|
@ -1,11 +0,0 @@
|
|||
add_executable(
|
||||
st7789_round_demo
|
||||
round_demo.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(st7789_round_demo pico_stdlib hardware_spi st7789 pico_graphics)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(st7789_round_demo)
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
add_subdirectory(breakout_roundlcd)
|
||||
add_subdirectory(pico_graphics)
|
||||
add_subdirectory(pico_display)
|
||||
add_subdirectory(pico_unicorn)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
set(LIB_NAME breakout_roundlcd)
|
||||
add_library(${LIB_NAME} INTERFACE)
|
||||
|
||||
target_sources(${LIB_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(${LIB_NAME} INTERFACE pico_stdlib st7789 pico_graphics)
|
|
@ -0,0 +1,14 @@
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/../../drivers/st7789/st7789.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../pico_graphics/pico_graphics.cmake)
|
||||
|
||||
set(LIB_NAME breakout_roundlcd)
|
||||
add_library(${LIB_NAME} INTERFACE)
|
||||
|
||||
target_sources(${LIB_NAME} INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/${LIB_NAME}.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${LIB_NAME} INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(${LIB_NAME} INTERFACE pico_stdlib st7789 pico_graphics)
|
|
@ -0,0 +1,53 @@
|
|||
#include "breakout_roundlcd.hpp"
|
||||
|
||||
namespace pimoroni {
|
||||
|
||||
BreakoutRoundLCD::BreakoutRoundLCD(uint16_t *buf)
|
||||
: PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf) {
|
||||
__fb = buf;
|
||||
}
|
||||
|
||||
BreakoutRoundLCD::BreakoutRoundLCD(uint16_t *buf, spi_inst_t *spi,
|
||||
uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso)
|
||||
: PicoGraphics(WIDTH, HEIGHT, buf), screen(WIDTH, HEIGHT, buf, spi, cs, dc, sck, mosi, miso) {
|
||||
__fb = buf;
|
||||
}
|
||||
|
||||
void BreakoutRoundLCD::init() {
|
||||
// initialise the screen
|
||||
screen.init(true, true);
|
||||
}
|
||||
|
||||
// spi_inst_t* BreakoutRoundLCD::get_spi() const {
|
||||
// return screen.get_spi();
|
||||
// }
|
||||
|
||||
// int BreakoutRoundLCD::get_cs() const {
|
||||
// return screen.get_cs();
|
||||
// }
|
||||
|
||||
// int BreakoutRoundLCD::get_dc() const {
|
||||
// return screen.get_dc();
|
||||
// }
|
||||
|
||||
// int BreakoutRoundLCD::get_sck() const {
|
||||
// return screen.get_sck();
|
||||
// }
|
||||
|
||||
// int BreakoutRoundLCD::get_mosi() const {
|
||||
// return screen.get_mosi();
|
||||
// }
|
||||
|
||||
// int BreakoutRoundLCD::get_miso() const {
|
||||
// return screen.get_miso();
|
||||
// }
|
||||
|
||||
void BreakoutRoundLCD::update() {
|
||||
screen.update();
|
||||
}
|
||||
|
||||
void BreakoutRoundLCD::set_backlight(uint8_t brightness) {
|
||||
screen.set_backlight(brightness);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../drivers/st7789/st7789.hpp"
|
||||
#include "../../libraries/pico_graphics/pico_graphics.hpp"
|
||||
|
||||
namespace pimoroni {
|
||||
|
||||
class BreakoutRoundLCD : public PicoGraphics {
|
||||
//--------------------------------------------------
|
||||
// Constants
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
static const int WIDTH = 240;
|
||||
static const int HEIGHT = 240;
|
||||
static const uint8_t PIN_UNUSED = UINT8_MAX;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Variables
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
uint16_t *__fb;
|
||||
private:
|
||||
ST7789 screen;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
BreakoutRoundLCD(uint16_t *buf);
|
||||
BreakoutRoundLCD(uint16_t *buf, spi_inst_t *spi,
|
||||
uint8_t cs, uint8_t dc, uint8_t sck, uint8_t mosi, uint8_t miso = PIN_UNUSED);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
void init();
|
||||
|
||||
// spi_inst_t* get_spi() const;
|
||||
// int get_cs() const;
|
||||
// int get_dc() const;
|
||||
// int get_sck() const;
|
||||
// int get_mosi() const;
|
||||
// int get_miso() const;
|
||||
|
||||
void update();
|
||||
void set_backlight(uint8_t brightness);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue