mirror of
https://github.com/stasenso/rp_pico_display_engine.git
synced 2026-06-26 21:32:41 +03:00
Sine wave added
This commit is contained in:
@@ -10,21 +10,23 @@ int main() {
|
|||||||
uint16_t blue = 0;
|
uint16_t blue = 0;
|
||||||
uint16_t summcolor=0;
|
uint16_t summcolor=0;
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
int points_x[] = {0,50, 150, 250, 300,320};
|
// Точки для кривой Безье
|
||||||
int points_y[] = {0,200, 50, 50, 200,240};
|
int points_x[30];
|
||||||
size_t num_points = sizeof(points_x) / sizeof(points_x[0]);
|
int points_y[30];
|
||||||
|
size_t num_points = 30;
|
||||||
uint16_t color = reverse(0b0000011111100000);
|
uint16_t color = reverse(0b0000011111100000);
|
||||||
stdio_init_all();
|
stdio_init_all();
|
||||||
multicore_launch_core1(coreEntry); //Запускаю в ядре 1 процесс вывода на экран
|
multicore_launch_core1(coreEntry); //Запускаю в ядре 1 процесс вывода на экран
|
||||||
|
int x=0;
|
||||||
|
while (x<50)
|
||||||
|
{
|
||||||
data = multicore_fifo_pop_blocking();
|
data = multicore_fifo_pop_blocking();
|
||||||
|
generate_sine_wave_points(points_x, points_y, num_points, 50, 1, x, HEIGHT / 2);
|
||||||
fillBufer(frame_buffer,reverse(0x4A69));//
|
fillBufer(frame_buffer,reverse(0x4A69));//
|
||||||
draw_bezier(points_x, points_y, num_points, color);
|
draw_bezier(points_x, points_y, num_points, color);
|
||||||
multicore_fifo_push_blocking(0); //Экран 0 нарисован
|
multicore_fifo_push_blocking(0); //Экран 0 нарисован
|
||||||
red+=1;
|
x+=5;
|
||||||
sleep_ms(40);
|
}
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tight_loop_contents();
|
tight_loop_contents();
|
||||||
@@ -48,3 +50,15 @@ unsigned short reverse(unsigned short x)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generate_sine_wave_points(int *points_x, int *points_y, size_t num_points, int amplitude, int frequency, int offset_x, int offset_y) {
|
||||||
|
if (num_points == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float step = (2.0f * M_PI * frequency) / (num_points - 1);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_points; i++) {
|
||||||
|
points_x[i] = offset_x + i * (WIDTH / num_points);
|
||||||
|
points_y[i] = offset_y + (int)(amplitude * sinf(i * step));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
void fillBufer (uint16_t* buffer,uint16_t color);
|
void fillBufer (uint16_t* buffer,uint16_t color);
|
||||||
unsigned short reverse(unsigned short x);
|
unsigned short reverse(unsigned short x);
|
||||||
|
void generate_sine_wave_points(int *points_x, int *points_y, size_t num_points, int amplitude, int frequency, int offset_x, int offset_y);
|
||||||
Reference in New Issue
Block a user