57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#pragma once
|
|
#include <ExpansionCard.hpp>
|
|
#include <IRremote.hpp>
|
|
#include <FRAM.h>
|
|
#include <vector>
|
|
|
|
#define CARD_TYPE_CLIMATE 0x03
|
|
|
|
#define AC_SENSOR_TYPE_NONE 0x00
|
|
#define AC_SENSOR_TYPE_DHT22 0x01
|
|
#define AC_SENSOR_TYPE_DS18B20 0x02
|
|
|
|
struct ClimateCardData {
|
|
uint8_t ac_temperature;
|
|
uint8_t ac_mode;
|
|
uint8_t ac_fan_speed;
|
|
};
|
|
// This requires 3 bytes of FRAM
|
|
|
|
class ClimateCard : public ExpansionCard {
|
|
public:
|
|
bool begin(uint16_t *infraredCodes, uint8_t sensor_type, uint8_t sensor_pin);
|
|
bool begin(uint16_t *infraredCodes);
|
|
void loop();
|
|
void bindFRAM(FRAM *fram, uint16_t fram_address);
|
|
void setFRAMAutoSave(bool autoSave);
|
|
void saveStateToFRAM();
|
|
void loadStateFromFRAM();
|
|
void setTemperature(uint8_t temperature);
|
|
void setMode(uint8_t mode);
|
|
void setFanSpeed(uint8_t fan_speed);
|
|
void registerCallback(std::function<void(uint8_t, uint8_t, uint8_t)> callback);
|
|
uint8_t getType();
|
|
private:
|
|
// Callbacks
|
|
std::vector<std::function<void(uint8_t, uint8_t, uint8_t)>> callbacks;
|
|
// Update functions
|
|
void updateSensor();
|
|
void updateAirConditioner();
|
|
void updateAirConditioner(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
|
|
// IR variables
|
|
IRsend irsender;
|
|
uint16_t *infraredCodes;
|
|
// Air conditioner variables
|
|
int ac_temperature;
|
|
int ac_mode;
|
|
int ac_fan_speed;
|
|
// Sensor variables
|
|
uint8_t sensor_type;
|
|
uint8_t sensor_pin;
|
|
float humidity;
|
|
float room_temperature;
|
|
// FRAM variables
|
|
FRAM *fram;
|
|
uint8_t fram_address;
|
|
};
|