kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Example/test for ST7789 displays
rodzic
f812e23d8e
commit
67b11826b7
|
@ -6,3 +6,4 @@ add_subdirectory(pico_explorer)
|
|||
add_subdirectory(pico_rgb_keypad)
|
||||
add_subdirectory(pico_rtc_display)
|
||||
add_subdirectory(pico_tof_display)
|
||||
add_subdirectory(st7789)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
add_executable(
|
||||
st7789_demo
|
||||
demo.cpp
|
||||
)
|
||||
|
||||
# Pull in pico libraries that we need
|
||||
target_link_libraries(st7789_demo pico_stdlib hardware_spi st7789 pico_graphics)
|
||||
|
||||
# create map/bin/hex file etc.
|
||||
pico_add_extra_outputs(st7789_demo)
|
|
@ -0,0 +1,59 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "st7789.hpp"
|
||||
#include "pico_graphics.hpp"
|
||||
|
||||
#define CS 17
|
||||
#define DC 16
|
||||
#define SCK 18
|
||||
#define MOSI 19
|
||||
#define MISO -1
|
||||
|
||||
using namespace pimoroni;
|
||||
|
||||
class PicoDisplay : public PicoGraphics {
|
||||
public:
|
||||
static const int WIDTH = 240;
|
||||
static const int HEIGHT = 240;
|
||||
|
||||
uint16_t *__fb;
|
||||
private:
|
||||
ST7789 screen;
|
||||
|
||||
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, true);
|
||||
//screen.flip();
|
||||
};
|
||||
void update() {
|
||||
screen.update();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
uint16_t buffer[PicoDisplay::WIDTH * PicoDisplay::HEIGHT];
|
||||
PicoDisplay display(buffer);
|
||||
|
||||
int main() {
|
||||
display.init();
|
||||
|
||||
while(1) {
|
||||
display.set_pen(0, 0, 0);
|
||||
display.clear();
|
||||
display.set_pen(255, 0, 0);
|
||||
display.circle(Point(60, 120), 60);
|
||||
display.set_pen(255, 255, 255);
|
||||
display.text("Hello", Point(10, 10), 220, 4);
|
||||
display.update();
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
add_library(pico_graphics types.cpp font_data.cpp pico_graphics.cpp)
|
||||
include(pico_graphics.cmake)
|
|
@ -1,4 +1,6 @@
|
|||
add_library(pico_graphics
|
||||
${CMAKE_CURRENT_LIST_DIR}/types.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/font_data.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/pico_graphics.cpp)
|
||||
${CMAKE_CURRENT_LIST_DIR}/pico_graphics.cpp)
|
||||
|
||||
target_include_directories(pico_graphics INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
Ładowanie…
Reference in New Issue