-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoutineSpin.h
48 lines (38 loc) · 1.18 KB
/
RoutineSpin.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
#pragma once
#include <cmath>
#include "Routine.h"
#include "FastLED.h"
class CRoutineSpin : public CRoutine
{
public:
static constexpr size_t c_alloc_qty = 32;
static constexpr size_t c_period_ms = 40000;
static constexpr float c_max_theta = 2 * M_PI;
static constexpr float c_theta_delta = c_max_theta / c_period_ms;
static constexpr float c_q = 60;
static constexpr size_t c_num_spokes = 6;
public:
CRoutineSpin(CPixelArray* pixels, CRGB rgb);
~CRoutineSpin();
public:
virtual void Continue() override;
virtual const char* GetName() override { return "Spin"; }
private:
void RecalculateThetas();
CHSV RecalculateColor(size_t index);
private:
CHSV m_color;
float m_theta[c_num_spokes] = {};
size_t m_last_run = 0;
private:
static CMemoryPool<CRoutineSpin, 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<CRoutineSpin*>(ptr));
}
};