Browse Source

thermostat: fix thermostat build and files format

pull/2601/head
Dmitry Blinov 5 months ago
parent
commit
7822b56cac
4 changed files with 1154 additions and 1304 deletions
  1. +1119
    -1263
      code/espurna/button.cpp
  2. +5
    -5
      code/espurna/thermostat.cpp
  3. +29
    -35
      code/espurna/thermostat.h
  4. +1
    -1
      code/platformio.ini

+ 1119
- 1263
code/espurna/button.cpp
File diff suppressed because it is too large
View File


+ 5
- 5
code/espurna/thermostat.cpp View File

@ -520,28 +520,28 @@ void resetBurnCounters() {
#define wifi_on_width 16
#define wifi_on_height 16
const char wifi_on_bits[] PROGMEM = {
const uint8_t wifi_on_bits[] PROGMEM = {
0x00, 0x00, 0x0E, 0x00, 0x7E, 0x00, 0xFE, 0x01, 0xE0, 0x03, 0x80, 0x07,
0x02, 0x0F, 0x1E, 0x1E, 0x3E, 0x1C, 0x78, 0x38, 0xE0, 0x38, 0xC0, 0x31,
0xC6, 0x71, 0x8E, 0x71, 0x8E, 0x73, 0x00, 0x00, };
#define mqtt_width 16
#define mqtt_height 16
const char mqtt_bits[] PROGMEM = {
const uint8_t mqtt_bits[] PROGMEM = {
0x00, 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0xEA, 0x7F, 0xEA, 0x7F,
0x00, 0x38, 0x10, 0x18, 0x18, 0x08, 0x1C, 0x00, 0xFE, 0x57, 0xFE, 0x57,
0x1C, 0x00, 0x18, 0x00, 0x10, 0x00, 0x00, 0x00, };
#define remote_temp_width 16
#define remote_temp_height 16
const char remote_temp_bits[] PROGMEM = {
const uint8_t remote_temp_bits[] PROGMEM = {
0x00, 0x00, 0xE0, 0x18, 0x10, 0x25, 0x10, 0x25, 0x90, 0x19, 0x50, 0x01,
0x50, 0x01, 0xD0, 0x01, 0x50, 0x01, 0x50, 0x01, 0xD0, 0x01, 0x50, 0x01,
0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0x00, 0x00, };
#define server_width 16
#define server_height 16
const char server_bits[] PROGMEM = {
const uint8_t server_bits[] PROGMEM = {
0x00, 0x00, 0xF8, 0x1F, 0xFC, 0x3F, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30,
0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30, 0xF8, 0x1F, 0xFC, 0x3F, 0xFE, 0x7F,
0x1E, 0x78, 0xFE, 0x7F, 0xFC, 0x3F, 0x00, 0x00, };
@ -564,7 +564,7 @@ bool _display_need_refresh = true;
bool _temp_range_need_update = true;
//------------------------------------------------------------------------------
void drawIco(int16_t x, int16_t y, const char *ico, bool on = true) {
void drawIco(int16_t x, int16_t y, const uint8_t *ico, bool on = true) {
display.drawIco16x16(x, y, ico, !on);
_display_need_refresh = true;
}


+ 29
- 35
code/espurna/thermostat.h View File

@ -11,55 +11,53 @@ Copyright (C) 2017 by Dmitry Blinov <dblinov76 at gmail dot com>
#include <Arduino.h>
#include <functional>
#define ASK_TEMP_RANGE_INTERVAL_INITIAL 15000 // ask initially once per every 15 seconds
#define ASK_TEMP_RANGE_INTERVAL_REGULAR 60000 // ask every minute to be sure
#define MILLIS_IN_SEC 1000
#define MILLIS_IN_MIN 60000
#define THERMOSTAT_STATE_UPDATE_INTERVAL 60000 // 1 min
#define THERMOSTAT_RELAY 0 // use relay 0
#define THERMOSTAT_TEMP_RANGE_MIN 10 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MIN_MIN 3 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MIN_MAX 30 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX 20 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX_MIN 8 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX_MAX 35 // grad. Celsius
#define THERMOSTAT_ALONE_ON_TIME 5 // 5 min
#define THERMOSTAT_ALONE_OFF_TIME 55 // 55 min
#define THERMOSTAT_MAX_ON_TIME 30 // 30 min
#define THERMOSTAT_MIN_OFF_TIME 10 // 10 min
#define THERMOSTAT_ENABLED_BY_DEFAULT true
#define THERMOSTAT_MODE_COOLER_BY_DEFAULT false
#define MQTT_TOPIC_HOLD_TEMP "hold_temp"
#define MQTT_TOPIC_HOLD_TEMP_MIN "min"
#define MQTT_TOPIC_HOLD_TEMP_MAX "max"
#define MQTT_TOPIC_REMOTE_TEMP "remote_temp"
#define MQTT_TOPIC_ASK_TEMP_RANGE "ask_temp_range"
#define ASK_TEMP_RANGE_INTERVAL_INITIAL 15000 // ask initially once per every 15 seconds
#define ASK_TEMP_RANGE_INTERVAL_REGULAR 60000 // ask every minute to be sure
#define MILLIS_IN_SEC 1000
#define MILLIS_IN_MIN 60000
#define THERMOSTAT_STATE_UPDATE_INTERVAL 60000 // 1 min
#define THERMOSTAT_RELAY 0 // use relay 0
#define THERMOSTAT_TEMP_RANGE_MIN 10 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MIN_MIN 3 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MIN_MAX 30 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX 20 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX_MIN 8 // grad. Celsius
#define THERMOSTAT_TEMP_RANGE_MAX_MAX 35 // grad. Celsius
#define THERMOSTAT_ALONE_ON_TIME 5 // 5 min
#define THERMOSTAT_ALONE_OFF_TIME 55 // 55 min
#define THERMOSTAT_MAX_ON_TIME 30 // 30 min
#define THERMOSTAT_MIN_OFF_TIME 10 // 10 min
#define THERMOSTAT_ENABLED_BY_DEFAULT true
#define THERMOSTAT_MODE_COOLER_BY_DEFAULT false
#define MQTT_TOPIC_HOLD_TEMP "hold_temp"
#define MQTT_TOPIC_HOLD_TEMP_MIN "min"
#define MQTT_TOPIC_HOLD_TEMP_MAX "max"
#define MQTT_TOPIC_REMOTE_TEMP "remote_temp"
#define MQTT_TOPIC_ASK_TEMP_RANGE "ask_temp_range"
#define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MIN "notify_temp_range_min"
#define MQTT_TOPIC_NOTIFY_TEMP_RANGE_MAX "notify_temp_range_max"
struct temp_t
{
struct temp_t {
float temp;
unsigned long last_update = 0;
bool need_display_update = false;
};
struct temp_range_t
{
struct temp_range_t {
int min = THERMOSTAT_TEMP_RANGE_MIN;
int max = THERMOSTAT_TEMP_RANGE_MAX;
unsigned long last_update = 0;
unsigned long ask_time = 0;
unsigned long ask_interval = ASK_TEMP_RANGE_INTERVAL_INITIAL;
unsigned long ask_interval = ASK_TEMP_RANGE_INTERVAL_INITIAL;
bool need_display_update = true;
};
using thermostat_callback_f = std::function<void(bool state)>;
void thermostatRegister(thermostat_callback_f callback);
const temp_t &thermostatRemoteTemp();
const temp_range_t &thermostatRange();
const temp_t& thermostatRemoteTemp();
const temp_range_t& thermostatRange();
void thermostatEnabled(bool enabled);
bool thermostatEnabled();
@ -69,10 +67,6 @@ bool thermostatModeCooler();
void thermostatSetup();
#if THERMOSTAT_DISPLAY_SUPPORT
void displayOn();
void displaySetup();
void displayLoop();
#endif
#endif

+ 1
- 1
code/platformio.ini View File

@ -159,7 +159,7 @@ shared_lib_deps =
sparkfun/SparkFun VEML6075 Arduino Library@^1.1.4
pololu/VL53L1X@^1.0.1
https://github.com/mcleng/MAX6675-Library#2.0.1
https://github.com/ThingPulse/esp8266-oled-ssd1306#3398c97
https://github.com/ThingPulse/esp8266-oled-ssd1306#9be7b01
adafruit/Adafruit BusIO@^1.11.5
adafruit/Adafruit SI1145 Library@^1.2.0
https://github.com/BoschSensortec/BSEC-Arduino-library.git#v1.6.1480


Loading…
Cancel
Save