Skip to content

Commit

Permalink
docs: added XY-plot examples
Browse files Browse the repository at this point in the history
  • Loading branch information
klonyyy committed Dec 8, 2024
1 parent 206679a commit fa17bda
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 125 deletions.
23 changes: 23 additions & 0 deletions example/MCUViewer_test/Core/App/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
#include "stm32g4xx_ll_gpio.h"
#include "testClass.hpp"
#include "testClass2.hpp"
#include <cmath>

TestClass test;
TemplateTest<uint32_t, bool> templateTest;
volatile float sinTest = 0.0f;
volatile float cosTest = 0.0f;
volatile float LissajousX = 0.0f;
volatile float LissajousY1 = 0.0f;
volatile float LissajousY2 = 0.0f;
volatile float LissajousY3 = 0.0f;

volatile float roseX = 0.0f;
volatile float roseY = 0.0f;

volatile float smallRoseX = 0.0f;
volatile float smallRoseY = 0.0f;

volatile float petalsNumber = 8.0f;

void maincpp()
{
Expand All @@ -35,6 +48,16 @@ void maincpp()
{
sinTest = test.getSin(x);
cosTest = test.getCos(x);
LissajousX = test.getLissajousX(x);
LissajousY1 = test.getLissajousY1(x);
LissajousY2 = test.getLissajousY2(x);
LissajousY3 = test.getLissajousY3(x);

float r = cosf(petalsNumber / 2.0f * x);
roseX = r * cosf(x);
roseY = r * sinf(x);
smallRoseY = 0.4f * r * sinf(x);

x += 0.01f;

if (x > 6.28f)
Expand Down
20 changes: 20 additions & 0 deletions example/MCUViewer_test/Core/App/testClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ float TestClass::getCos(float x)
return cosf(x);
}

float TestClass::getLissajousX(float x)
{
return sinf(x);
}

float TestClass::getLissajousY1(float x)
{
return sinf(4.0f * x);
}

float TestClass::getLissajousY2(float x)
{
return sinf(7.0f * x);
}

float TestClass::getLissajousY3(float x)
{
return sinf(15.0f * x);
}

void TestClass::spin()
{
x += 0.02f;
Expand Down
6 changes: 5 additions & 1 deletion example/MCUViewer_test/Core/App/testClass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class TestClass

float getSin(float x);
float getCos(float x);
float getLissajousX(float x);
float getLissajousY1(float x);
float getLissajousY2(float x);
float getLissajousY3(float x);
void spin();

struct __attribute__((packed, aligned(1))) StructA
Expand All @@ -34,7 +38,7 @@ class TestClass

private:
volatile float triangle = 0.0f;
volatile float triangleFrequency = 1.0f;
volatile float triangleFrequency = 0.01f;
volatile float a,b,c;
volatile float x, dir = 1.0f;
volatile int8_t tri = 0;
Expand Down
Loading

0 comments on commit fa17bda

Please sign in to comment.