18 {
19 aht_ = aht;
20 bmp_ = bmp;
21 gui_ = gui;
22
23
25 constexpr float VCC = 3.3f;
26 constexpr float R_REF = 100000.0f;
27 float r_ntc =
28 R_REF * voltage / (VCC - voltage);
29
30
31 constexpr float B = 3950.0f;
32 constexpr float T0 = 298.15f;
33 constexpr float R0 = 10000.0f;
34
35
36 float temp = 1.0f / (1.0f / T0 + (1.0f / B) * log(r_ntc / R0)) - 273.15f;
37 temperature_ = temp;
38 });
39
40
42 constexpr float VCC = 3.3f;
43 constexpr float R_REF = 100000.0f;
44 float r_photo =
45 R_REF * voltage / (VCC - voltage);
46
47
48 constexpr float K = 1500000.0f;
49 constexpr float GAMMA = 1.5f;
50 float lux = K / pow(r_photo, GAMMA);
51
52
53 light_queue_.push_front(lux);
54 if (light_queue_.size() > 50) {
55 float avg = 0.0f;
56 for (auto l : light_queue_) avg += l;
57 avg /= light_queue_.size();
58 light_ = avg;
59
60
61 static int counter = 0;
62 if (++counter > 5) {
63 if (gui_) gui_->
SetLight(
static_cast<uint8_t
>(light_ / 20 + 1));
64 counter = 0;
65 }
66
67
68 light_queue_.pop_back();
69 }
70 });
71 }
void RegisterChannelCallback(int channel, std::function< void(float)> cb)
Registers a callback function for a specific channel.
void SetLight(uint8_t light)
Set display brightness (0-15)