mirror of
https://github.com/stasenso/rp_pico_test.git
synced 2026-06-26 21:42:44 +03:00
Sine wave added
This commit is contained in:
@@ -10,21 +10,23 @@ int main() {
|
||||
uint16_t blue = 0;
|
||||
uint16_t summcolor=0;
|
||||
uint32_t data;
|
||||
int points_x[] = {0,50, 150, 250, 300,320};
|
||||
int points_y[] = {0,200, 50, 50, 200,240};
|
||||
size_t num_points = sizeof(points_x) / sizeof(points_x[0]);
|
||||
// Точки для кривой Безье
|
||||
int points_x[30];
|
||||
int points_y[30];
|
||||
size_t num_points = 30;
|
||||
uint16_t color = reverse(0b0000011111100000);
|
||||
stdio_init_all();
|
||||
multicore_launch_core1(coreEntry); //Запускаю в ядре 1 процесс вывода на экран
|
||||
|
||||
int x=0;
|
||||
while (x<50)
|
||||
{
|
||||
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));//
|
||||
draw_bezier(points_x, points_y, num_points, color);
|
||||
multicore_fifo_push_blocking(0); //Экран 0 нарисован
|
||||
red+=1;
|
||||
sleep_ms(40);
|
||||
|
||||
multicore_fifo_push_blocking(0); //Экран 0 нарисован
|
||||
x+=5;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
tight_loop_contents();
|
||||
@@ -48,3 +50,15 @@ unsigned short reverse(unsigned short 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>
|
||||
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