-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData.cpp
55 lines (46 loc) · 1.12 KB
/
Data.cpp
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
#include "Data.h"
#include "ChartData.h"
#include "Dimmer.h"
#include "Heure.h"
#include "Watts.h"
#include "WiFiSerial.h"
#include <Arduino.h>
#include <NTPClient.h>
namespace Data
{
unsigned long last_boot = 0;
void taskChart(void* p_chart)
{
auto& c = *reinterpret_cast<Chart*>(p_chart);
for (;;)
{
if (Dimmer::isHC())
{
c.at(Category::P1_HP).push_back(0);
c.at(Category::P2_HP).push_back(0);
c.at(Category::P1_HC).push_back(Watts::power1);
c.at(Category::P2_HC).push_back(Watts::power2);
}
else
{
c.at(Category::P1_HP).push_back(Watts::power1);
c.at(Category::P2_HP).push_back(Watts::power2);
c.at(Category::P1_HC).push_back(0);
c.at(Category::P2_HC).push_back(0);
}
// weblogf("%s, %d, %f\n", c.id, c.res, Watts::power2);
delay(c.res * 1000);
}
}
void begin()
{
while (!Heure::isTimeSet())
delay(100);
last_boot = Heure::getEpochTime();
for (const auto& c: charts)
{
xTaskCreate(taskChart, "task chart",
3000, (void*)&c, 3, nullptr);
}
}
}