-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixled_esp.hpp
57 lines (45 loc) · 1.16 KB
/
pixled_esp.hpp
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
53
54
55
56
57
#ifndef PIXLED_ESP_HPP
#define PIXLED_ESP_HPP
#include <driver/timer.h>
#include "pixled_driver.hpp"
#include "pixled.h"
#include <freertos/task.h>
#define PIXLED_TIMER_DIVIDER 16
#define PIXLED_TIMER_SCALE (TIMER_BASE_CLK / PIXLED_TIMER_DIVIDER) // convert counter value to seconds
namespace pixled {
class EspOutput : public api::Output {
private:
Strip& strip;
public:
EspOutput(Strip& strip) : strip(strip) {}
void write(const api::Color& color, std::size_t i) override;
};
void IRAM_ATTR frame_interrupt_handler(void* param);
void esp_runtime_main_task(void* param);
class EspRuntime {
friend void IRAM_ATTR frame_interrupt_handler(void*);
friend void esp_runtime_main_task(void*);
public:
Runtime runtime;
private:
Strip& strip;
uint8_t fps;
timer_group_t timer_group;
timer_idx_t timer_idx;
xQueueHandle timer_queue;
TaskHandle_t task_handle;
public:
EspRuntime(
api::Mapping& map,
api::Output& output,
api::Function<Color>& animation,
Strip& strip,
uint8_t fps,
timer_group_t timer_group = TIMER_GROUP_0,
timer_idx_t timer_idx = TIMER_0
);
void start();
void stop();
};
}
#endif