air conditioner initial support
This commit is contained in:
parent
011710fe82
commit
5f0dedc7eb
|
@ -0,0 +1,56 @@
|
||||||
|
#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;
|
||||||
|
};
|
|
@ -1,4 +1,3 @@
|
||||||
#pragma once
|
|
||||||
#include <DigitalInputCard.hpp>
|
#include <DigitalInputCard.hpp>
|
||||||
|
|
||||||
// Instantiate the card with the specified address
|
// Instantiate the card with the specified address
|
||||||
|
|
|
@ -162,7 +162,7 @@ uint32_t ESPMegaDisplay::getNumber(const char* component) {
|
||||||
* @return The value of the string component.
|
* @return The value of the string component.
|
||||||
* @note The returned char array must be freed after use.
|
* @note The returned char array must be freed after use.
|
||||||
*/
|
*/
|
||||||
char* ESPMegaDisplay::getString(const char* component) {
|
const char* ESPMegaDisplay::getString(const char* component) {
|
||||||
uint32_t start = millis();
|
uint32_t start = millis();
|
||||||
// Send the get command
|
// Send the get command
|
||||||
this->displayAdapter->print("get ");
|
this->displayAdapter->print("get ");
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#pragma once
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ESPMegaPRO_OOP.hpp>
|
#include <ESPMegaPRO_OOP.hpp>
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@ class ESPMegaDisplay
|
||||||
void jumpToPage(int page);
|
void jumpToPage(int page);
|
||||||
void setString(const char* component, const char* value);
|
void setString(const char* component, const char* value);
|
||||||
void setNumber(const char* component, int value);
|
void setNumber(const char* component, int value);
|
||||||
char* getString(const char* component);
|
const char* getString(const char* component);
|
||||||
bool getStringToBuffer(const char* component, char* buffer, uint8_t buffer_size);
|
bool getStringToBuffer(const char* component, char* buffer, uint8_t buffer_size);
|
||||||
uint32_t getNumber(const char* component);
|
uint32_t getNumber(const char* component);
|
||||||
void handlePwmStateChange(uint8_t pin, uint16_t value);
|
void handlePwmStateChange(uint8_t pin, uint16_t value);
|
||||||
|
|
|
@ -25,5 +25,6 @@ lib_deps = adafruit/Adafruit PWM Servo Driver Library@^2.4.1
|
||||||
paulstoffregen/DS1307RTC@0.0.0-alpha+sha.c2590c0033
|
paulstoffregen/DS1307RTC@0.0.0-alpha+sha.c2590c0033
|
||||||
knolleary/pubsubclient@^2.8.0
|
knolleary/pubsubclient@^2.8.0
|
||||||
seithan/Easy Nextion Library@^1.0.6
|
seithan/Easy Nextion Library@^1.0.6
|
||||||
|
z3t0/IRremote@^4.2.0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue