From fb8649860222a1a30c62a688340e13dbd4849d2f Mon Sep 17 00:00:00 2001 From: Stanislav N Mikhailov Date: Sat, 2 May 2026 15:44:14 +0300 Subject: [PATCH] Init --- .gitignore | 33 +++++++++++++++++++++ .gitmodules | 3 ++ CMakeLists.txt | 51 +++++++++++++++++++++++++++++++++ external/rp_pico_display_engine | 1 + src/main.c | 40 ++++++++++++++++++++++++++ 5 files changed, 128 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 external/rp_pico_display_engine create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09ab11e --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Build directories +/build/ +**/build/ +/cmake-build-*/ + +# CMake +/CMakeCache.txt +**/CMakeCache.txt +/CMakeFiles/ +**/CMakeFiles/ +/cmake_install.cmake +**/cmake_install.cmake +/compile_commands.json +**/compile_commands.json +/Makefile +**/Makefile +/CTestTestfile.cmake +**/CTestTestfile.cmake +/Testing/ +**/Testing/ + +# Pico SDK and linker/generated files +*.bin +*.dis +*.elf +*.hex +*.map +*.uf2 +*.ld + +# IDE/editor +.vscode/ +.idea/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4299cc8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/rp_pico_display_engine"] + path = external/rp_pico_display_engine + url = https://github.com/stasenso/rp_pico_display_engine.git diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..dd8e106 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.18.4) +include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) + +project(my_app C CXX ASM) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) + +pico_sdk_init() + +set(DISPLAY_ENGINE_DIR ${CMAKE_CURRENT_LIST_DIR}/external/rp_pico_display_engine) + +add_library(display_engine STATIC + ${DISPLAY_ENGINE_DIR}/src/Font/font_data.c + ${DISPLAY_ENGINE_DIR}/src/core/display.c + ${DISPLAY_ENGINE_DIR}/src/core/display_transport.c + ${DISPLAY_ENGINE_DIR}/src/core/display_driver.c + ${DISPLAY_ENGINE_DIR}/src/render/context.c + ${DISPLAY_ENGINE_DIR}/src/render/line.c + # Uncomment if/when you need these primitives: + # ${DISPLAY_ENGINE_DIR}/src/render/grid.c + # ${DISPLAY_ENGINE_DIR}/src/render/sine_wave.c + # ${DISPLAY_ENGINE_DIR}/src/render/bezier.c +) + +target_include_directories(display_engine PUBLIC + ${DISPLAY_ENGINE_DIR}/include + ${DISPLAY_ENGINE_DIR}/include/display +) + +target_link_libraries(display_engine PUBLIC + pico_stdlib + hardware_spi + hardware_dma + hardware_timer + pico_multicore +) + +target_compile_definitions(display_engine PUBLIC + DISPLAY_TYPE=DISPLAY_TYPE_ST7789 + DISPLAY_SPI_PORT=spi1 + DISPLAY_PIN_MOSI=15 + DISPLAY_PIN_SCK=14 + DISPLAY_PIN_CS=13 + DISPLAY_PIN_DC=12 + DISPLAY_PIN_RST=11 + DISPLAY_PIN_BL=10 +) + +add_executable(my_app src/main.c) +target_link_libraries(my_app PRIVATE display_engine) +pico_add_extra_outputs(my_app) diff --git a/external/rp_pico_display_engine b/external/rp_pico_display_engine new file mode 160000 index 0000000..bbde040 --- /dev/null +++ b/external/rp_pico_display_engine @@ -0,0 +1 @@ +Subproject commit bbde0402afb3a9d1e71aa8ea610022bf3d4b7c41 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..c0fc811 --- /dev/null +++ b/src/main.c @@ -0,0 +1,40 @@ +#include "pico/stdlib.h" +#include "display/display.h" +#include "display/render/context.h" + +int main(void) { + stdio_init_all(); + + display_config_t cfg = { + .width = 320, + .height = 240, + .buffer_count = 1, + .mode = DISPLAY_MODE_SAFE + }; + display_init(&cfg); + + render_ctx_t rc; + uint32_t frame = 0; + + while (1) { + uint16_t *buf = display_begin_paint_blocking(); + render_begin(&rc, buf, 320, 240); + switch ((frame / 30u) % 4u) { + case 0: + render_clear(&rc, RGB16(255, 0, 0)); + break; + case 1: + render_clear(&rc, RGB16(0, 255, 0)); + break; + case 2: + render_clear(&rc, RGB16(0, 0, 255)); + break; + default: + render_clear(&rc, RGB16(255, 255, 255)); + break; + } + display_end_paint(); + frame++; + sleep_ms(16); + } +}