ac lock not working

This commit is contained in:
Siwat Sirichai 2024-03-23 13:31:06 +07:00
parent 0a93b99021
commit b3fe91ac8e
9 changed files with 332 additions and 238 deletions

View File

@ -12,7 +12,7 @@
platform = espressif32
board = wt32-eth01
framework = arduino
lib_deps = siwats/ESPMegaPROR3@^2.3.8
lib_deps = siwats/ESPMegaPROR3@^2.4.3
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=5
monitor_port = COM36

65
src/config.hpp Normal file
View File

@ -0,0 +1,65 @@
#pragma once
#include "constants.hpp"
/***********************************************
* Pin Definitions *
***********************************************/
// There are 4 rows of lights
#define LIGHT_ROW_1_PIN 0
#define LIGHT_ROW_2_PIN 1
#define LIGHT_ROW_3_PIN 2
#define LIGHT_ROW_4_PIN 3
// There are 3 rows of fans
#define FAN_ROW_1_PIN 4
#define FAN_ROW_2_PIN 5
#define FAN_ROW_3_PIN 6
// There are one power relay for the air purifier
#define AIR_PURIFIER_PIN 7
// There are one power relay for the mosquito zapper
#define MOSQUITO_ZAPPER_PIN 8
/***********************************************
* Air Conditioner *
***********************************************/
// @note The infrared codes are defined in ir_codes.hpp and ir_codes.cpp
#define AC_MIN_TEMP 16
#define AC_MAX_TEMP 32
#define AC_MODES 3
#define AC_FAN_SPEEDS 4
#define AC_MODE_NAMES {"off", "cool", "fan_only"}
#define AC_FAN_SPEED_NAMES {"auto", "high", "medium", "low"}
#define AC_IR_TX_PIN 12 // GP Type
#define AC_IR_CHANNEL RMT_CHANNEL_0
#define AC_SENSOR_TYPE AC_SENSOR_TYPE_DHT22
#define AC_SENSOR_PIN 32 // GP Type
/***********************************************
* Display Configuration *
***********************************************/
// UART Configuration
#define INTERNAL_DISPLAY_UART Serial
#define INTERNAL_DISPLAY_BAUDRATE 115200
#define DISPLAY_UART Serial1
#define DISPLAY_TX 4
#define DISPLAY_RX 17
#define DISPLAY_COMMUNICATION_BAUDRATE 115200
#define DISPLAY_OTA_BAUDRATE 921600
/***********************************************
* Persistent Storage Configuration *
***********************************************/
#define AC_FRAM_ADDR 10000 // 3 bytes
#define AC_LOCK_FRAM_ADDR 10010 // 10 byte
#define AC_DISPLAY_MODE_FRAM_ADDR 10020 // 1 byte
#define AC_DISPLAY_TEMP_LOWER_BOUND_ADDR 10030 // 6 byte
#define AC_DISPLAY_TEMP_UPPER_BOUND_ADDR 10040 // 6 byte
/***********************************************
* Remote Variables & Smart Variables *
***********************************************/
#define AQI_STATE_TOPIC "/iqair/usaqi"
#define AQI_REQUEST_TOPIC "/iqair/request"
#define AC_LOCK_RELATIVE_TOPIC "/ac/lock"
#define AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC "/ac/temp_bound/lower"
#define AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC "/ac/temp_bound/upper"

4
src/constants.hpp Normal file
View File

@ -0,0 +1,4 @@
#pragma once
#define AC_TYPE_M1M2 0
#define AC_TYPE_M3M4M5M6 1

View File

@ -20,6 +20,46 @@ CUDDisplay::CUDDisplay(cud_display_conf_t *conf) : ESPMegaDisplay(conf->uart, co
.picture_off_pressed = {LCD_DASHBOARD_PIC_FAN_1_OFF_PRESSED, LCD_DASHBOARD_PIC_FAN_2_OFF_PRESSED, LCD_DASHBOARD_PIC_FAN_3_OFF_PRESSED}};
}
CUDDisplay::~CUDDisplay()
{
if (ac_lock_topic != nullptr)
{
free(ac_lock_topic);
}
if (ac_lock_set_topic != nullptr)
{
free(ac_lock_set_topic);
}
if (ac_lock_request_topic != nullptr)
{
free(ac_lock_request_topic);
}
if (ac_temp_upper_bound_topic != nullptr)
{
free(ac_temp_upper_bound_topic);
}
if (ac_temp_upper_bound_set_topic != nullptr)
{
free(ac_temp_upper_bound_set_topic);
}
if (ac_temp_upper_bound_request_topic != nullptr)
{
free(ac_temp_upper_bound_request_topic);
}
if (ac_temp_lower_bound_topic != nullptr)
{
free(ac_temp_lower_bound_topic);
}
if (ac_temp_lower_bound_set_topic != nullptr)
{
free(ac_temp_lower_bound_set_topic);
}
if (ac_temp_lower_bound_request_topic != nullptr)
{
free(ac_temp_lower_bound_request_topic);
}
}
void CUDDisplay::begin(cud_display_cards_t cards)
{
// Save Cards
@ -47,6 +87,51 @@ void CUDDisplay::begin(cud_display_cards_t cards)
this->cards.ac->registerChangeCallback(binded_ac_callback);
ESP_LOGV("CUD Display", "Registering AC Sensor Callbacks");
this->cards.ac->registerSensorCallback(binded_ac_sensor_callback);
// Initialize Smart Variables
ESP_LOGV("CUD Display", "Initializing Smart Variables");
// Get Base Topic
char *base_topic = this->cards.iot->getMqttConfig()->base_topic;
uint8_t base_topic_length = strlen(base_topic);
// Smart Variables
// AC Lock
this->ac_lock.begin(10);
this->ac_lock.bindFRAM(this->cards.fram, AC_LOCK_FRAM_ADDR);
ac_lock_topic = (char *)malloc(base_topic_length + strlen(AC_LOCK_RELATIVE_TOPIC) + 3);
sprintf(ac_lock_topic, "%s%s", base_topic, AC_LOCK_RELATIVE_TOPIC);
this->ac_lock.enableIoT(this->cards.iot, ac_lock_topic);
ac_lock_set_topic = (char *)malloc(base_topic_length + strlen(AC_LOCK_RELATIVE_TOPIC) + sizeof("/set") + 3);
sprintf(ac_lock_set_topic, "%s%s/set", base_topic, AC_LOCK_RELATIVE_TOPIC);
this->ac_lock.enableSetValue(ac_lock_set_topic);
ac_lock_request_topic = (char *)malloc(base_topic_length + strlen(AC_LOCK_RELATIVE_TOPIC) + sizeof("/request") + 3);
sprintf(ac_lock_request_topic, "%s%s/request", base_topic, AC_LOCK_RELATIVE_TOPIC);
this->ac_lock.enableValueRequest(ac_lock_request_topic);
auto binded_ac_lock_callback = std::bind(&CUDDisplay::handle_lock_change, this, std::placeholders::_1);
this->ac_lock.registerCallback(binded_ac_lock_callback);
// AC Temp Lower Bound
this->ac_temp_lower_bound.begin(6);
this->ac_temp_lower_bound.bindFRAM(this->cards.fram, AC_DISPLAY_TEMP_LOWER_BOUND_ADDR);
ac_temp_lower_bound_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC) + 3);
sprintf(ac_temp_lower_bound_topic, "%s%s", base_topic, AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC);
this->ac_temp_lower_bound.enableIoT(this->cards.iot, ac_temp_lower_bound_topic);
ac_temp_lower_bound_set_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC) + sizeof("/set") + 3);
sprintf(ac_temp_lower_bound_set_topic, "%s%s/set", base_topic, AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC);
this->ac_temp_lower_bound.enableSetValue(ac_temp_lower_bound_set_topic);
ac_temp_lower_bound_request_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC) + sizeof("/request") + 3);
sprintf(ac_temp_lower_bound_request_topic, "%s%s/request", base_topic, AC_TEMP_LOWER_BOUND_RELATIVE_TOPIC);
this->ac_temp_lower_bound.enableValueRequest(ac_temp_lower_bound_request_topic);
// AC Temp Upper Bound
this->ac_temp_upper_bound.begin(6);
this->ac_temp_upper_bound.bindFRAM(this->cards.fram, AC_DISPLAY_TEMP_UPPER_BOUND_ADDR);
ac_temp_upper_bound_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC) + 3);
sprintf(ac_temp_upper_bound_topic, "%s%s", base_topic, AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC);
this->ac_temp_upper_bound.enableIoT(this->cards.iot, ac_temp_upper_bound_topic);
ac_temp_upper_bound_set_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC) + sizeof("/set") + 3);
sprintf(ac_temp_upper_bound_set_topic, "%s%s/set", base_topic, AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC);
this->ac_temp_upper_bound.enableSetValue(ac_temp_upper_bound_set_topic);
ac_temp_upper_bound_request_topic = (char *)malloc(base_topic_length + strlen(AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC) + sizeof("/request") + 3);
sprintf(ac_temp_upper_bound_request_topic, "%s%s/request", base_topic, AC_TEMP_UPPER_BOUND_RELATIVE_TOPIC);
this->ac_temp_upper_bound.enableValueRequest(ac_temp_upper_bound_request_topic);
// Initialize the display
ESP_LOGV("CUD Display", "Initializing display");
this->display_init();
@ -198,7 +283,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_STATE)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Toggle the AC
// Is the AC on?
@ -218,7 +303,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_MODE_FAN)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC mode to fan
this->cards.ac->setMode(1);
@ -228,7 +313,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_MODE_COOL)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC mode to cool
this->cards.ac->setMode(2);
@ -238,7 +323,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_FAN_SPEED_AUTO)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC fan speed to auto
this->cards.ac->setFanSpeed(0);
@ -248,7 +333,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_FAN_SPEED_LOW)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC fan speed to low
this->cards.ac->setFanSpeed(1);
@ -258,7 +343,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_FAN_SPEED_MEDIUM)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC fan speed to medium
this->cards.ac->setFanSpeed(2);
@ -268,7 +353,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_FAN_SPEED_HIGH)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Set the AC fan speed to high
this->cards.ac->setFanSpeed(3);
@ -278,7 +363,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_TEMP_UP_BUTTON)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Increase the AC temperature
this->cards.ac->setTemperature(this->cards.ac->getTemperature() + 1);
@ -288,7 +373,7 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
if (element_id == LCD_DASHBOARD_ELEMENT_AC_TEMP_DOWN_BUTTON)
{
// Is the control locked? If it is, we can ignore the touch
if (this->ac_locked)
if (this->get_ac_lock())
return;
// Decrease the AC temperature
this->cards.ac->setTemperature(this->cards.ac->getTemperature() - 1);
@ -297,6 +382,11 @@ void CUDDisplay::handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch
// The element_id is not the one that our display is handling, so we can ignore it
}
void CUDDisplay::handle_lock_change(char *value)
{
set_ac_lock((bool)ac_lock.getIntValue());
}
void CUDDisplay::handle_aqi_change(char *value)
{
// Update the AQI value on the display
@ -469,7 +559,7 @@ void CUDDisplay::refresh_display_ac()
ESP_LOGV("CUD Display", "Previous Mode: %d, Drawn Mode: %d", previous_mode, drawn_mode);
// Draw the state picture set
// Is the AC locked?
if (this->ac_locked)
if (this->get_ac_lock())
{
// When the display is locked
// the state picture set we use is the locked state picture set
@ -534,7 +624,6 @@ void CUDDisplay::refresh_display_ac()
this->displayAdapter->printf("%s.txt=\"%d\"", LCD_DASHBOARD_ELEMENT_NAME_AC_TEMPERATURE, temperature);
this->sendStopBytes();
this->giveSerialMutex();
}
void CUDDisplay::system_toggle()
@ -542,14 +631,13 @@ void CUDDisplay::system_toggle()
// TODO: Implement this
}
void CUDDisplay::set_ac_lock(bool state)
{
this->ac_locked = state;
ac_lock.setIntValue((bool)state);
this->refresh_display_ac();
}
bool CUDDisplay::get_ac_lock()
{
return this->ac_locked;
return (bool)ac_lock.getIntValue();
}

View File

@ -15,6 +15,10 @@
#include <DigitalInputCard.hpp>
#include <DigitalOutputCard.hpp>
#include <RemoteVariable.hpp>
#include <SmartVariable.hpp>
#include <FRAM.h>
#include <ESPMegaIoT.hpp>
#include "config.hpp"
struct cud_display_conf_t
{
@ -35,6 +39,8 @@ struct cud_display_cards_t
DigitalInputCard *inputCard;
DigitalOutputCard *outputCard;
ClimateCard *ac;
FRAM *fram;
ESPMegaIoT *iot;
};
struct cud_display_light_group_t
@ -61,10 +67,12 @@ class CUDDisplay : public ESPMegaDisplay
{
public:
CUDDisplay(cud_display_conf_t *conf);
~CUDDisplay();
void begin(cud_display_cards_t cards);
void display_init();
void set_ac_lock(bool state);
bool get_ac_lock();
private:
// States Calculation
bool get_lights_state();
@ -77,6 +85,7 @@ class CUDDisplay : public ESPMegaDisplay
void handle_ac_change(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
void handle_ac_sensor(float temperature, float humidity);
void handle_touch(uint8_t page_id, uint8_t element_id, uint8_t touch_type);
void handle_lock_change(char* value);
// Change Display Elements
void set_display_light_state(uint8_t row, bool state);
void set_display_light_all_state();
@ -89,11 +98,22 @@ class CUDDisplay : public ESPMegaDisplay
// Helper Functions
void system_toggle();
// AC Functions and Variables
bool ac_locked;
uint8_t previous_mode; // Used to store mode prior to turning off
// Local Variables
cud_display_conf_t *conf;
cud_display_cards_t cards;
cud_display_light_group_t light_group;
cud_display_fan_group_t fan_group;
SmartVariable ac_lock;
SmartVariable ac_temp_lower_bound;
SmartVariable ac_temp_upper_bound;
char *ac_lock_topic;
char *ac_lock_set_topic;
char *ac_lock_request_topic;
char *ac_temp_lower_bound_topic;
char *ac_temp_lower_bound_set_topic;
char *ac_temp_lower_bound_request_topic;
char *ac_temp_upper_bound_topic;
char *ac_temp_upper_bound_set_topic;
char *ac_temp_upper_bound_request_topic;
};

View File

@ -1,37 +0,0 @@
#pragma once
/**
* @file display_iot.hpp
* @author Siwat Sirichai (siwat@siwatinc.com)
* @brief IoT Wrapper for the Display
* @version 0.1
* @date 2024-03-19
*
* @copyright Copyright (c) SIWAT SIRICHAI 2024
*
*/
#include "display.hpp"
#define AC_LOCK_STATE_TOPIC "ac/lock"
#define AC_LOCK_SET_TOPIC "ac/lock/set"
#define AC_LOCK_FRAM_ADDR 6000 // 1 byte
struct cud_display_iot_conf_t
{
CUDDisplay *display;
ESPMegaIoT *iot;
FRAM *fram;
};
class CUDDisplayIoTWrapper
{
public:
CUDDisplayIoTWrapper();
void begin(cud_display_conf_t);
void subscribe();
void publish_lock_state();
void set_lock_state(bool state);
void get_lock_state();
private:
void handle_mqtt_message(char *topic, char* payload);
cud_display_iot_conf_t conf;
};

View File

@ -92,8 +92,10 @@ const uint16_t ir_code_fan[4][407] = {
};
const uint16_t ir_code_off[407] = {5044, 2129, 408, 1744, 406, 670, 380, 697, 404, 671, 405, 1746, 380, 696, 405, 671, 406, 670, 405, 671, 405, 1746, 406, 670, 405, 1747, 406, 1745, 406, 670, 405, 1746, 405, 1746, 407, 1745, 405, 1746, 406, 1746, 380, 696, 380, 1771, 380, 696, 405, 671, 380, 695, 406, 670, 407, 670, 379, 696, 407, 1744, 380, 696, 380, 695, 407, 1746, 405, 670, 406, 670, 405, 671, 406, 1744, 381, 696, 406, 669, 405, 671, 380, 696, 405, 671, 406, 670, 405, 670, 380, 696, 407, 669, 405, 670, 407, 668, 381, 696, 406, 670, 405, 670, 406, 1746, 407, 1744, 406, 1745, 381, 696, 405, 670, 407, 1745, 406, 669, 407, 29355, 5069, 2104, 406, 1745, 380, 696, 380, 696, 380, 696, 380, 1771, 406, 670, 379, 697, 406, 669, 405, 671, 406, 1745, 381, 695, 380, 1772, 405, 1746, 407, 669, 380, 1771, 407, 1745, 406, 1745, 434, 1718, 406, 1745, 381, 695, 380, 1771, 381, 695, 406, 670, 406, 670, 406, 670, 405, 671, 379, 696, 403, 1749, 406, 670, 406, 669, 407, 1745, 405, 671, 410, 664, 406, 671, 407, 669, 405, 670, 380, 696, 406, 670, 406, 670, 406, 669, 407, 1745, 380, 1772, 405, 670, 380, 696, 380, 1771, 380, 1772, 380, 1772, 405, 670, 407, 669, 406, 670, 380, 695, 380, 696, 405, 671, 406, 670, 379, 696, 407, 669, 406, 671, 405, 669, 380, 696, 380, 696, 406, 669, 408, 1744, 381, 695, 406, 670, 406, 669, 381, 695, 381, 695, 380, 696, 380, 696, 405, 671, 405, 672, 378, 696, 406, 670, 380, 696, 379, 696, 406, 670, 406, 669, 389, 687, 380, 696, 380, 696, 380, 695, 406, 1746, 407, 669, 380, 1771, 406, 670, 380, 1772, 405, 670, 407, 669, 406, 1745, 407, 1745, 380, 1771, 380, 1771, 381, 1771, 381, 1771, 380, 696, 406, 669, 407, 669, 405, 671, 380, 695, 406, 670, 380, 696, 405, 670, 381, 696, 380, 696, 379, 696, 405, 671, 380, 695, 381, 695, 381, 695, 380, 1772, 379, 697, 379, 696, 406, 670, 380, 695, 406, 671, 405, 670, 382, 693, 408, 668, 406, 670, 380, 696, 406, 670, 380, 695, 382, 695, 404, 671, 406, 670, 406, 669, 380, 699, 377, 696, 380, 695, 407, 669, 380, 696, 380, 696, 380, 696, 406, 670, 380, 695, 380, 696, 380, 696, 406, 1744, 381, 1771, 407, 669, 380, 696, 380, 1771, 381, 1771, 381, 694, 406};
size_t getInfraredCode(uint8_t mode, uint8_t fan_speed, uint8_t temperature_index, const uint16_t **codePtr) {
switch (mode) {
size_t getInfraredCode(uint8_t mode, uint8_t fan_speed, uint8_t temperature_index, const uint16_t **codePtr)
{
switch (mode)
{
case 0: // Off
*codePtr = &(ir_code_off[0]);
return 407;

View File

@ -104,8 +104,11 @@ void setup()
cud_display_cards_t cards = {
.inputCard = &espmega.inputs,
.outputCard = &espmega.outputs,
.ac = &ac};
.ac = &ac,
.fram = &espmega.fram,
.iot = espmega.iot,};
cudDisplay.begin(cards);
espmega.iot->registerMqttCallback(handle_mqtt_message);
ESP_LOGI("CUD IoT OS", "Initialization Complete");
}
@ -128,3 +131,7 @@ void handle_input_change(uint8_t pin, bool state) {
espmega.outputs.setState(pin, !espmega.outputs.getState(pin));
}
}
void handle_mqtt_message(char *topic, char *payload) {
ESP_LOGD("CUD IoT OS", "MQTT Message Received: %s, %s", topic, payload);
}

View File

@ -16,63 +16,7 @@
#include "lcd_elements.hpp"
#include "ir_codes.hpp"
#include "display.hpp"
/***********************************************
* Pin Definitions *
***********************************************/
// There are 4 rows of lights
#define LIGHT_ROW_1_PIN 0
#define LIGHT_ROW_2_PIN 1
#define LIGHT_ROW_3_PIN 2
#define LIGHT_ROW_4_PIN 3
// There are 3 rows of fans
#define FAN_ROW_1_PIN 4
#define FAN_ROW_2_PIN 5
#define FAN_ROW_3_PIN 6
// There are one power relay for the air purifier
#define AIR_PURIFIER_PIN 7
// There are one power relay for the mosquito zapper
#define MOSQUITO_ZAPPER_PIN 8
/***********************************************
* Air Conditioner *
***********************************************/
// @note The infrared codes are defined in ir_codes.hpp and ir_codes.cpp
#define AC_MIN_TEMP 16
#define AC_MAX_TEMP 32
#define AC_MODES 3
#define AC_FAN_SPEEDS 4
#define AC_MODE_NAMES {"off", "cool", "fan_only"}
#define AC_FAN_SPEED_NAMES {"auto", "high", "medium", "low"}
#define AC_IR_TX_PIN 12 // GP Type
#define AC_IR_CHANNEL RMT_CHANNEL_0
#define AC_SENSOR_TYPE AC_SENSOR_TYPE_DHT22
#define AC_SENSOR_PIN 32 // GP Type
/***********************************************
* Display Configuration *
***********************************************/
// UART Configuration
#define INTERNAL_DISPLAY_UART Serial
#define INTERNAL_DISPLAY_BAUDRATE 115200
#define DISPLAY_UART Serial1
#define DISPLAY_TX 4
#define DISPLAY_RX 17
#define DISPLAY_COMMUNICATION_BAUDRATE 115200
#define DISPLAY_OTA_BAUDRATE 921600
/***********************************************
* Persistent Storage Configuration *
***********************************************/
#define AC_FRAM_ADDR 10000 // 3 bytes
#define AC_LOCK_FRAM_ADDR 10005 // 1 byte
#define AC_DISPLAY_MODE_FRAM_ADDR 10010 // 1 byte
/***********************************************
* Remote Variables *
***********************************************/
#define AQI_STATE_TOPIC "/iqair/usaqi"
#define AQI_REQUEST_TOPIC "/iqair/request"
#include "config.hpp"
/***********************************************
* Function Prototypes *
@ -81,3 +25,4 @@ void setup();
void loop();
void send_stop_bytes(HardwareSerial &uart);
void handle_input_change(uint8_t pin, bool state);
void handle_mqtt_message(char *topic, char *payload);