diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 71dc7e38..55313720 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/examples/breakout_roundlcd/CMakeLists.txt b/examples/breakout_roundlcd/CMakeLists.txt new file mode 100644 index 00000000..dd287353 --- /dev/null +++ b/examples/breakout_roundlcd/CMakeLists.txt @@ -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}) \ No newline at end of file diff --git a/examples/st7789/round_demo.cpp b/examples/breakout_roundlcd/demo.cpp similarity index 65% rename from examples/st7789/round_demo.cpp rename to examples/breakout_roundlcd/demo.cpp index 4d5beb4b..63b17203 100644 --- a/examples/st7789/round_demo.cpp +++ b/examples/breakout_roundlcd/demo.cpp @@ -3,54 +3,18 @@ #include #include -#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; diff --git a/examples/st7789/CMakeLists.txt b/examples/st7789/CMakeLists.txt deleted file mode 100644 index ad10cd39..00000000 --- a/examples/st7789/CMakeLists.txt +++ /dev/null @@ -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) - diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 1ba5ce81..283f3501 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(breakout_roundlcd) add_subdirectory(pico_graphics) add_subdirectory(pico_display) add_subdirectory(pico_unicorn) diff --git a/libraries/breakout_roundlcd/CMakeLists.txt b/libraries/breakout_roundlcd/CMakeLists.txt new file mode 100644 index 00000000..46e19eb2 --- /dev/null +++ b/libraries/breakout_roundlcd/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/libraries/breakout_roundlcd/breakout_roundlcd.cmake b/libraries/breakout_roundlcd/breakout_roundlcd.cmake new file mode 100644 index 00000000..aa0d5718 --- /dev/null +++ b/libraries/breakout_roundlcd/breakout_roundlcd.cmake @@ -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) \ No newline at end of file diff --git a/libraries/breakout_roundlcd/breakout_roundlcd.cpp b/libraries/breakout_roundlcd/breakout_roundlcd.cpp new file mode 100644 index 00000000..2e9fa620 --- /dev/null +++ b/libraries/breakout_roundlcd/breakout_roundlcd.cpp @@ -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); + } + +} \ No newline at end of file diff --git a/libraries/breakout_roundlcd/breakout_roundlcd.hpp b/libraries/breakout_roundlcd/breakout_roundlcd.hpp new file mode 100644 index 00000000..a03a6bdd --- /dev/null +++ b/libraries/breakout_roundlcd/breakout_roundlcd.hpp @@ -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); + }; + +}