From 25d4af7ab30ec6f564f81e5a12891bf0182b84ab Mon Sep 17 00:00:00 2001 From: Stanislav N Mikhailov Date: Wed, 25 Mar 2026 22:13:29 +0300 Subject: [PATCH] Migrate root app to display/render pipeline --- CMakeLists.txt | 8 +++- main.c | 107 ++++++++++++++++++------------------------------- 2 files changed, 46 insertions(+), 69 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f35a053..0243837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,14 +9,18 @@ pico_sdk_init() add_executable(${PROJECT_NAME} main.c - Thread.c src/Font/font_data.c + src/core/display.c src/render/context.c - BackBuffer.c + src/render/line.c + src/render/grid.c + src/render/sine_wave.c + src/render/bezier.c ) target_include_directories(${PROJECT_NAME} PRIVATE include + include/display ) target_link_libraries(${PROJECT_NAME} diff --git a/main.c b/main.c index 4e9bf62..31fcc6b 100644 --- a/main.c +++ b/main.c @@ -1,79 +1,52 @@ -#include "main.h" -#include "Thread.h" -#include "pico/multicore.h" #include "pico/stdlib.h" -#include "Font/font_data.h" +#include "display/display.h" #include "display/render/context.h" -#include "BackBuffer.h" +#include "display/render/grid.h" +#include "display/render/sine_wave.h" +#include "Font/font_data.h" -int main() { - uint16_t red = 0; - uint16_t green = 0; - uint16_t blue = 0; - uint16_t summcolor=0; - uint32_t data; - // Точки для кривой Безье - int points_x[60]; - int points_y[60]; - size_t num_points = 1600; - uint16_t color = reverse(0b0000011111100000); +#define WIDTH 320 +#define HEIGHT 240 + +static void on_frame_done(void) +{ + display_submit(); +} + +int main(void) +{ stdio_init_all(); - - // Настройка GPIO25 как выход - gpio_init(25); - gpio_set_dir(25, GPIO_OUT); - // Включение светодиода - gpio_put(25, 1); + display_config_t cfg = { + .width = WIDTH, + .height = HEIGHT, + .buffer_count = 1, + .mode = DISPLAY_MODE_SAFE, + .frame_done_cb = on_frame_done + }; - multicore_launch_core1(coreEntry); //Запускаю в ядре 1 процесс вывода на экран - float x=0.0; - float freq=1.0; - bool minmax=false; + display_init(&cfg); + display_submit(); + + float phase = 0.0f; render_ctx_t rc; - wchar_t buffer[100]; - while (x<500) + + while (1) { - data = multicore_fifo_pop_blocking(); - - fillBufer(frame_buffer,reverse(0x4A69));// - grid(20,20,40,0x634d); - generate_sine_wave_points(num_points, 50, freq, 0, HEIGHT / 2,x); - render_begin(&rc, frame_buffer, WIDTH, HEIGHT); - swprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), L"Value of pi: %.2f", temperature); - draw_string(&rc, 20,110,buffer,0b1111111111111111); // - multicore_fifo_push_blocking(0); //Экран 0 нарисован - x+=0.03; - if (minmax) - { - if (freq<=0.0){ - minmax=false;} - else freq-=0.05; - } - else - { - if (freq>=10.0){ - minmax=true;} - else freq+=0.05; - } + display_poll(); - + uint16_t* buf = display_get_draw_buffer(); + render_begin(&rc, buf, WIDTH, HEIGHT); - //sleep_ms(20); - } - - while (1) { - tight_loop_contents(); + render_clear(&rc, RGB16(9, 19, 9)); + render_grid(&rc, 20, 20, 40, RGB16(12, 26, 13)); + render_sine_wave(&rc, WIDTH, 50, 2.0f, 0, HEIGHT / 2, phase, RGB16(0, 255, 0)); + draw_string(&rc, 12, 12, L"rp_pico_display_engine", RGB565(255, 255, 255)); + + phase += 0.08f; + if (phase > 6.2831853f) + { + phase -= 6.2831853f; + } } } - -void fillBufer (uint16_t* buffer,uint16_t color){ - for (uint16_t y = 0; y < HEIGHT; y++) - { - for (uint16_t x = 0; x < WIDTH; x++) - { - buffer[y*WIDTH+x]=color; - } - } - -}