- Added watchdog to ensure 1.5 minutes evaluation of temperatur - added boot time output to MQTT ti track reboots - keep chosen set temp during resets (only power loss will result in reading the default temp from flash) - Add smaller case to fit concrete wall housings - added command to upload firmware to all targets as comment in platformio.ini
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
#include <Arduino.h>
|
|
#include "ui.h"
|
|
#include "vars.h"
|
|
|
|
bool history_initialized = false;
|
|
|
|
dataset_t glblData = {.temp = NAN, .hum = NAN, .pres = NAN, .seaLevelPress = NAN, .settemp= NAN, .heating=false, .enBuff =false, .relPowerSave=true, .presAlarm=false, .myIP={0}, .wifiStrength = WIFISTRENGTH_OFF, .wifiMode= WIFIMODE_OFF, .override = OVR_NONE, .bootTime = {0}};
|
|
hist_t history = {{0},{0},{0}};
|
|
|
|
int32_t* history_getPressPt(void){
|
|
return history.press;
|
|
}
|
|
int32_t* history_getHumPt(void){
|
|
return history.hum;
|
|
}
|
|
int32_t* history_getTempPt(void){
|
|
return history.temp;
|
|
}
|
|
|
|
void history_setPress(const uint16_t index, const float _press){
|
|
history.press[index] = (uint8_t) _press;
|
|
}
|
|
void history_setHum(uint16_t index, float _hum){
|
|
history.hum[index] = (int32_t) _hum;
|
|
}
|
|
void history_setTemp(const uint16_t index, const float _temp){
|
|
history.temp[index] = (int32_t) (_temp*10);
|
|
}
|
|
bool history_isInitialized(void){
|
|
return history_initialized;
|
|
}
|
|
void history_append(const float _press, const float _temp, const float _hum){
|
|
|
|
if(history_initialized){
|
|
for(uint16_t i=1; i<HISTLEN; i++){
|
|
history.temp[i-1] = history.temp[i];
|
|
history.hum[i-1] = history.hum[i];
|
|
history.press[i-1] = history.press[i];
|
|
}
|
|
}else{
|
|
history_initialized=true;
|
|
for(uint16_t i=1; i<HISTLEN; i++){
|
|
history.temp[i-1] = (int32_t) (_temp * 10);
|
|
history.hum[i-1] = (int32_t) _hum;
|
|
history.press[i-1] = (int32_t) (_press);
|
|
}
|
|
}
|
|
if(_press != NAN)
|
|
history.press[HISTLEN-1] = (int32_t) (_press);
|
|
else
|
|
history.press[HISTLEN-1] = INT32_MIN;
|
|
if(_hum != NAN)
|
|
history.hum[HISTLEN-1] = (int32_t) _hum;
|
|
else
|
|
history.hum[HISTLEN-1] = INT32_MIN;
|
|
if(_temp != NAN)
|
|
history.temp[HISTLEN-1] = (int32_t) (_temp * 10);
|
|
else
|
|
history.temp[HISTLEN-1] = INT32_MIN;
|
|
}
|
|
|
|
|