-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.h
44 lines (38 loc) · 1.18 KB
/
temp.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
#ifdef RF_RX_PIN
#include <Arduino.h>
#include <ErriezOregonTHN128Receive.h>
#endif
struct LocalTemp {
char temp[10];
};
#ifdef RF_RX_PIN
void printReceivedData(OregonTHN128Data_t *data) {
bool negativeTemperature = false;
static uint32_t rxCount = 0;
int16_t tempAbs;
char msg[80];
// Convert to absolute temperature
tempAbs = data->temperature;
if (tempAbs < 0) {
negativeTemperature = true;
tempAbs *= -1;
}
snprintf_P(msg, sizeof(msg),
PSTR("RX %lu: Rol: %d, Channel %d, Temp: %s%d.%d, Low batt: %d (0x%08lx)"),
rxCount++,
data->rollingAddress, data->channel,
(negativeTemperature ? "-" : ""), (tempAbs / 10), (tempAbs % 10), data->lowBattery,
data->rawData);
Serial.println(msg);
}
void fillLocalTempFromJson(OregonTHN128Data_t *oregonData, LocalTemp* localTemp) {
bool negativeTemperature = false;
int16_t tempAbs = oregonData->temperature;
// Convert to absolute temperature
if (tempAbs < 0) {
negativeTemperature = true;
tempAbs *= -1;
}
sprintf(localTemp->temp, "%s%d\xb0", (negativeTemperature ? "-" : ""), (tempAbs / 10));
}
#endif