-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkw11-l.h
59 lines (42 loc) · 1.35 KB
/
kw11-l.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
53
54
55
56
57
58
59
// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license
#include "gen.h"
#include <ArduinoJson.h>
#include <atomic>
#include <thread>
#include "bus.h"
#include "console.h"
#include "device.h"
class kw11_l: public device
{
private:
bus *const b { nullptr };
console *cnsl { nullptr };
#if defined(BUILD_FOR_RP2040)
SemaphoreHandle_t lf_csr_lock { xSemaphoreCreateBinary() };
#else
std::thread *th { nullptr };
std::mutex lf_csr_lock;
#endif
int int_frequency { 50 };
uint16_t lf_csr { 0 };
int64_t t_diff_sum { 0 };
uint64_t n_t_diff { 0 };
std::atomic_bool stop_flag { false };
uint8_t get_lf_crs();
void set_lf_crs_b7();
void do_interrupt();
public:
kw11_l(bus *const b);
virtual ~kw11_l();
void reset() override;
void show_state(console *const cnsl) const override;
void set_interrupt_frequency(const int Hz);
JsonDocument serialize();
static kw11_l *deserialize(const JsonVariantConst j, bus *const b, console *const cnsl);
void begin(console *const cnsl);
void operator()();
uint16_t read_word(const uint16_t a) override;
void write_byte(const uint16_t addr, const uint8_t v) override;
void write_word(const uint16_t addr, const uint16_t v) override;
};