mirror of
https://github.com/stasenso/rp_pico_display_engine.git
synced 2026-06-26 21:32:41 +03:00
refactor: move display.h to include/display and add CMake build for Thermometr example
This commit is contained in:
+11
-1
@@ -1,3 +1,13 @@
|
||||
build/*
|
||||
.vscode/*
|
||||
**/build/
|
||||
|
||||
# CMake
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
compile_commands.json
|
||||
Makefile
|
||||
CTestTestfile.cmake
|
||||
Testing/
|
||||
.cmake/
|
||||
.vscode/*
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.18.4)
|
||||
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
|
||||
|
||||
project(thermometr_example C CXX ASM)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile_commands.json" FORCE)
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.c
|
||||
../../src/core/display.c
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
../../include
|
||||
../../include/display
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
pico_stdlib
|
||||
hardware_spi
|
||||
hardware_dma
|
||||
hardware_timer
|
||||
pico_multicore
|
||||
)
|
||||
|
||||
pico_add_extra_outputs(${PROJECT_NAME})
|
||||
@@ -0,0 +1,61 @@
|
||||
#include "pico/stdlib.h"
|
||||
#include "display/display.h"
|
||||
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 240
|
||||
|
||||
|
||||
static void on_frame_done(void)
|
||||
{
|
||||
// В SAFE режиме swap выполняется внутри submit()
|
||||
display_submit();
|
||||
}
|
||||
|
||||
|
||||
static void render_test_pattern(uint16_t* buf)
|
||||
{
|
||||
for (uint16_t y = 0; y < HEIGHT; y++)
|
||||
{
|
||||
for (uint16_t x = 0; x < WIDTH; x++)
|
||||
{
|
||||
uint16_t r = (x & 0x1F) << 11;
|
||||
uint16_t g = (y & 0x3F) << 5;
|
||||
uint16_t b = (x & 0x1F);
|
||||
|
||||
buf[y * WIDTH + x] = r | g | b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
stdio_init_all();
|
||||
|
||||
display_config_t cfg = {
|
||||
.width = WIDTH,
|
||||
.height = HEIGHT,
|
||||
.buffer_count = 1,
|
||||
.mode = DISPLAY_MODE_SAFE,
|
||||
.frame_done_cb = on_frame_done
|
||||
};
|
||||
|
||||
display_init(&cfg);
|
||||
|
||||
// Рисуем первый кадр
|
||||
uint16_t* buf = display_get_draw_buffer();
|
||||
render_test_pattern(buf);
|
||||
|
||||
display_submit();
|
||||
|
||||
while (1)
|
||||
{
|
||||
display_poll();
|
||||
|
||||
// Здесь можно обновлять содержимое буфера
|
||||
// SAFE + 1 buffer будет ждать окончания DMA
|
||||
buf = display_get_draw_buffer();
|
||||
render_test_pattern(buf);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user