mirror of
https://github.com/stasenso/rp_pico_test.git
synced 2026-06-26 21:42:44 +03:00
decomposition
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
|
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} main.c Thread.c DrawBezier.c font_data.c)
|
add_executable(${PROJECT_NAME} main.c Thread.c DrawBezier.c font_data.c Reverse.c SineWave.c SetPixel.c)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
|
|||||||
+1
-7
@@ -1,11 +1,5 @@
|
|||||||
#include "DrawBezier.h"
|
#include "DrawBezier.h"
|
||||||
// Установка пикселя в буфере (с проверкой границ)
|
#include "SetPixel.h"
|
||||||
void set_pixel(uint16_t x, uint16_t y, uint16_t color) {
|
|
||||||
if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) {
|
|
||||||
frame_buffer[y * WIDTH + x] = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Функция для вычисления базисного полинома Бернштейна
|
// Функция для вычисления базисного полинома Бернштейна
|
||||||
float bernstein(int i, int n, float t) {
|
float bernstein(int i, int n, float t) {
|
||||||
// Вычисление биномиального коэффициента C(n, i)
|
// Вычисление биномиального коэффициента C(n, i)
|
||||||
|
|||||||
+1
-2
@@ -1,9 +1,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
|
||||||
void set_pixel(uint16_t x, uint16_t y, uint16_t color);
|
|
||||||
float bernstein(int i, int n, float t);
|
float bernstein(int i, int n, float t);
|
||||||
void draw_bezier(const int *points_x, const int *points_y, size_t num_points, uint16_t color);
|
void draw_bezier(const int *points_x, const int *points_y, size_t num_points, uint16_t color);
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
unsigned short reverse(unsigned short x)
|
||||||
|
{
|
||||||
|
x = (x & 0xFF) << 8 | (x & 0xFF00) >> 8;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#ifndef REVERSE_H
|
||||||
|
#define REVERSE_H
|
||||||
|
unsigned short reverse(unsigned short x);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#include "SetPixel.h"
|
||||||
|
#include "Thread.h"
|
||||||
|
// Установка пикселя в буфере (с проверкой границ)
|
||||||
|
void set_pixel(uint16_t x, uint16_t y, uint16_t color) {
|
||||||
|
if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) {
|
||||||
|
frame_buffer[y * WIDTH + x] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#ifndef SET_PIXEL_H
|
||||||
|
#define SET_PIXEL_H
|
||||||
|
#include <stdint.h>
|
||||||
|
void set_pixel(uint16_t x, uint16_t y, uint16_t color);
|
||||||
|
#endif
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#include "SineWave.h"
|
||||||
|
#include "font_data.h"
|
||||||
|
#include "Thread.h"
|
||||||
|
#include "Reverse.h"
|
||||||
|
#include "SetPixel.h"
|
||||||
|
#include <math.h>
|
||||||
|
void generate_sine_wave_points(size_t num_points, int amplitude, float frequency, int offset_x, int offset_y, float phase_shift) {
|
||||||
|
if (num_points == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float step = (2.0f * M_PI * frequency) / (num_points - 1);
|
||||||
|
float x_step = (float)WIDTH / (num_points - 1);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_points; i++) {
|
||||||
|
int x = offset_x + (int)(i * x_step);
|
||||||
|
int y = offset_y + (int)(amplitude * sinf(i * step + phase_shift)); // Добавлен сдвиг фазы
|
||||||
|
set_pixel(x, y, reverse(0b0000011111100000));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#ifdef SINE_WAVE_H
|
||||||
|
#define SINE_WAVE_H
|
||||||
|
void generate_sine_wave_points(size_t num_points, int amplitude, float frequency, int offset_x, int offset_y, float phase_shift);
|
||||||
|
#endif
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
// Шрифт, сгенерированный из /home/smikhai/Repo/rp_pico_test/Font/font_grid_with_cyrillic.bmp
|
// Шрифт, сгенерированный из /home/smikhai/Repo/rp_pico_test/Font/font_grid_with_cyrillic.bmp
|
||||||
#include "font_data.h"
|
#include "font_data.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "DrawBezier.h"
|
#include "SetPixel.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
const uint16_t image_linear_width = 704;
|
const uint16_t image_linear_width = 704;
|
||||||
const uint8_t char_width = 22;
|
const uint8_t char_width = 22;
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
// Изображение, сгенерированное из Font/font_grid_with_cyrillic.bmp
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
const uint16_t image_linear_width = 7744;
|
|
||||||
const uint8_t char_width = 22;
|
|
||||||
const uint8_t char_height = 22;
|
|
||||||
const uint16_t total_chars = 352;
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef IMAGE_DATA_H
|
|
||||||
#define IMAGE_DATA_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
extern const uint16_t image_linear_width;
|
|
||||||
extern const uint8_t char_width;
|
|
||||||
extern const uint8_t char_height;
|
|
||||||
extern const uint16_t total_chars;
|
|
||||||
extern const uint8_t image_data[];
|
|
||||||
|
|
||||||
#endif // IMAGE_DATA_H
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
#include "DrawBezier.h"
|
#include "DrawBezier.h"
|
||||||
#include "font_data.h"
|
#include "font_data.h"
|
||||||
|
#include "Reverse.h"
|
||||||
int main() {
|
int main() {
|
||||||
uint16_t red = 0;
|
uint16_t red = 0;
|
||||||
uint16_t green = 0;
|
uint16_t green = 0;
|
||||||
@@ -65,23 +65,3 @@ void fillBufer (uint16_t* buffer,uint16_t color){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short reverse(unsigned short x)
|
|
||||||
{
|
|
||||||
x = (x & 0xFF) << 8 | (x & 0xFF00) >> 8;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
void generate_sine_wave_points(size_t num_points, int amplitude, float frequency, int offset_x, int offset_y, float phase_shift) {
|
|
||||||
if (num_points == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float step = (2.0f * M_PI * frequency) / (num_points - 1);
|
|
||||||
float x_step = (float)WIDTH / (num_points - 1);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < num_points; i++) {
|
|
||||||
int x = offset_x + (int)(i * x_step);
|
|
||||||
int y = offset_y + (int)(amplitude * sinf(i * step + phase_shift)); // Добавлен сдвиг фазы
|
|
||||||
set_pixel(x, y, reverse(0b0000011111100000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user