-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoutineRings.h
52 lines (42 loc) · 1.49 KB
/
RoutineRings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <cmath>
#include "Routine.h"
#include "FastLED.h"
class CRoutineRings : public CRoutine
{
public:
static constexpr size_t c_alloc_qty = 32;
static constexpr size_t c_period_ms = 20000;
static constexpr float c_max_radius = sqrt(2);
static constexpr float c_radius_delta = c_max_radius / c_period_ms;
static constexpr float c_thickness = 0.15;
static constexpr size_t c_num_circles = 3;
static constexpr float c_max_midpoint_x = 0.50;
static constexpr float c_max_midpoint_y = 0.50;
public:
CRoutineRings(CPixelArray* pixels);
CRoutineRings(CPixelArray* pixels, CPixelArray::Coordinate midpoint);
~CRoutineRings();
public:
virtual void Continue() override;
virtual const char* GetName() override { return "Rings"; }
private:
void RecalculateRadius();
CRGB RecalculateColor(size_t index);
private:
CPixelArray::Coordinate m_midpoint;
CRGB m_color[c_num_circles];
float m_radius[c_num_circles] = {};
size_t m_last_run = 0;
private:
static CMemoryPool<CRoutineRings, c_alloc_qty> s_pool;
public:
void* operator new(size_t)
{
return s_pool.alloc();
}
void operator delete(void* ptr)
{
s_pool.free(reinterpret_cast<CRoutineRings*>(ptr));
}
};