remove reference to CUD
This commit is contained in:
parent
e5ecd5f3a0
commit
70f6ae0092
3 changed files with 30 additions and 79 deletions
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
|
|
@ -284,5 +284,9 @@
|
||||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||||
"C_Cpp_Runner.showCompilationTime": false,
|
"C_Cpp_Runner.showCompilationTime": false,
|
||||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
"C_Cpp_Runner.msvcSecureNoWarnings": false,
|
||||||
|
"files.associations": {
|
||||||
|
"random": "cpp",
|
||||||
|
"*.tcc": "cpp"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
85
src/main.cpp
85
src/main.cpp
|
|
@ -1,25 +1,5 @@
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
#include <cud_display.hpp>
|
|
||||||
#include <ise_display.hpp>
|
|
||||||
|
|
||||||
/***********************************************
|
|
||||||
* Begin Configuration *
|
|
||||||
************************************************/
|
|
||||||
|
|
||||||
// Display Configuration
|
|
||||||
#define cudDisplayAdapter Serial2
|
|
||||||
#define CUD_DISPLAY_BAUD_RATE 115200
|
|
||||||
#define CUD_DISPLAY_TX_PIN 4
|
|
||||||
#define CUD_DISPLAY_RX_PIN 17
|
|
||||||
|
|
||||||
// Air Conditioner Configuration
|
|
||||||
#define AIR_CONDITIONER_LOCK_FRAM_ADDRESS 4900
|
|
||||||
#define AIR_CONDITIONER_LOCK_RELATIVE_TOPIC "ac_lock"
|
|
||||||
#define AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC "ac_lock/set"
|
|
||||||
#define AIR_CONDITIONER_SENSOR_TYPE AC_SENSOR_TYPE_DHT22
|
|
||||||
#define AIR_CONDITIONER_SENSOR_PIN 32
|
|
||||||
#define AIR_CONDITIONER_IR_PIN 5
|
|
||||||
#define AIR_CONDITIONER_RMT_CHANNEL RMT_CHANNEL_0
|
|
||||||
|
|
||||||
const char *mode_names[] = {"off", "fan_only", "cool"};
|
const char *mode_names[] = {"off", "fan_only", "cool"};
|
||||||
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
||||||
|
|
@ -32,14 +12,12 @@ AirConditioner ac = {
|
||||||
.fan_speeds = 4,
|
.fan_speeds = 4,
|
||||||
.fan_speed_names = fan_speed_names,
|
.fan_speed_names = fan_speed_names,
|
||||||
.getInfraredCode = &getInfraredCode};
|
.getInfraredCode = &getInfraredCode};
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* End Configuration *
|
* End Configuration *
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
ESPMegaPRO espmega = ESPMegaPRO();
|
ESPMegaPRO espmega = ESPMegaPRO();
|
||||||
CUDDisplay cudDisplay = CUDDisplay(&cudDisplayAdapter);
|
ISEDisplay iseDisplay = ISEDisplay(&iseDisplayAdapter);
|
||||||
ISEDisplay iseDisplay = ISEDisplay(&cudDisplayAdapter);
|
|
||||||
|
|
||||||
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
||||||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||||
|
|
@ -47,38 +25,7 @@ ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
||||||
|
|
||||||
void handleMqttMessage(char *topic, char *payload)
|
void handleMqttMessage(char *topic, char *payload)
|
||||||
{
|
{
|
||||||
char *temperature = (char*)calloc(16,sizeof(char));
|
|
||||||
strcpy(temperature, payload);
|
|
||||||
int temp_int;
|
|
||||||
temp_int = atoi(temperature);
|
|
||||||
|
|
||||||
Serial.printf("MQTT Message: %s %s\n", topic, payload);
|
|
||||||
if (!strcmp(topic, AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC))
|
|
||||||
{
|
|
||||||
if (!strcmp(payload, "lock"))
|
|
||||||
{
|
|
||||||
lockAC();
|
|
||||||
espmega.iot->publishRelative(AIR_CONDITIONER_LOCK_RELATIVE_TOPIC, "lock");
|
|
||||||
}
|
|
||||||
else if (!strcmp(payload, "unlock"))
|
|
||||||
{
|
|
||||||
unlockAC();
|
|
||||||
espmega.iot->publishRelative(AIR_CONDITIONER_LOCK_RELATIVE_TOPIC, "unlock");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(temperature);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lockAC()
|
|
||||||
{
|
|
||||||
espmega.fram.write8(AIR_CONDITIONER_LOCK_FRAM_ADDRESS, 0);
|
|
||||||
cudDisplay.setACControlEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void unlockAC()
|
|
||||||
{
|
|
||||||
espmega.fram.write8(AIR_CONDITIONER_LOCK_FRAM_ADDRESS, 1);
|
|
||||||
cudDisplay.setACControlEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendStopBytes()
|
void sendStopBytes()
|
||||||
|
|
@ -90,9 +37,9 @@ void sendStopBytes()
|
||||||
|
|
||||||
void sendExtStopBytes()
|
void sendExtStopBytes()
|
||||||
{
|
{
|
||||||
cudDisplayAdapter.write(0xFF);
|
iseDisplayAdapter.write(0xFF);
|
||||||
cudDisplayAdapter.write(0xFF);
|
iseDisplayAdapter.write(0xFF);
|
||||||
cudDisplayAdapter.write(0xFF);
|
iseDisplayAdapter.write(0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
|
@ -105,9 +52,9 @@ void setup()
|
||||||
// If GPIO 2 is pulled low, clear the FRAM then reboot (Reset the device to factory defaults)
|
// If GPIO 2 is pulled low, clear the FRAM then reboot (Reset the device to factory defaults)
|
||||||
bool clear_fram = !gpio_get_level(GPIO_NUM_2);
|
bool clear_fram = !gpio_get_level(GPIO_NUM_2);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
cudDisplayAdapter.begin(CUD_DISPLAY_BAUD_RATE, SERIAL_8N1, CUD_DISPLAY_RX_PIN, CUD_DISPLAY_TX_PIN);
|
iseDisplayAdapter.begin(ISE_DISPLAY_BAUD_RATE, SERIAL_8N1, ISE_DISPLAY_RX_PIN, ISE_DISPLAY_TX_PIN);
|
||||||
sendExtStopBytes();
|
sendExtStopBytes();
|
||||||
cudDisplayAdapter.print("rest");
|
iseDisplayAdapter.print("rest");
|
||||||
sendExtStopBytes();
|
sendExtStopBytes();
|
||||||
sendStopBytes();
|
sendStopBytes();
|
||||||
Serial.print("rest");
|
Serial.print("rest");
|
||||||
|
|
@ -152,24 +99,13 @@ void setup()
|
||||||
espmega.iot->registerCard(1); // Register the Output Card
|
espmega.iot->registerCard(1); // Register the Output Card
|
||||||
espmega.iot->registerCard(2); // Register the Climate Card
|
espmega.iot->registerCard(2); // Register the Climate Card
|
||||||
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
||||||
cudDisplay.begin(bindedGetTime, &espmega.inputs, &espmega.outputs, &climateCard);
|
iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard);
|
||||||
if (espmega.fram.read8(AIR_CONDITIONER_LOCK_FRAM_ADDRESS))
|
|
||||||
{
|
|
||||||
lockAC();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// AC is unlocked
|
|
||||||
unlockAC();
|
|
||||||
}
|
|
||||||
espmega.iot->subscribeRelative(AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC);
|
|
||||||
espmega.iot->registerRelativeMqttCallback(&handleMqttMessage);
|
espmega.iot->registerRelativeMqttCallback(&handleMqttMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
espmega.loop();
|
espmega.loop();
|
||||||
cudDisplay.loop();
|
|
||||||
iseDisplay.loop();
|
iseDisplay.loop();
|
||||||
|
|
||||||
// Update the time every 15 seconds
|
// Update the time every 15 seconds
|
||||||
|
|
@ -184,10 +120,5 @@ void loop()
|
||||||
|
|
||||||
void on_pin_change(uint8_t pin, uint8_t value)
|
void on_pin_change(uint8_t pin, uint8_t value)
|
||||||
{
|
{
|
||||||
// For pin 0-6, when the pin value changes, toggle the corresponding PWM pin
|
|
||||||
if (pin < 7)
|
|
||||||
{
|
|
||||||
bool new_value = !espmega.outputs.getState(pin);
|
|
||||||
espmega.outputs.digitalWrite(pin, new_value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
18
src/main.hpp
18
src/main.hpp
|
|
@ -1,8 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <ESPMegaProOS.hpp>
|
#include <ESPMegaProOS.hpp>
|
||||||
#include <cud_display.hpp>
|
#include <ise_display.hpp>
|
||||||
#include <ir_codes.hpp>
|
#include <ir_codes.hpp>
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* Begin Configuration *
|
||||||
|
************************************************/
|
||||||
|
|
||||||
|
// Display Configuration
|
||||||
|
#define iseDisplayAdapter Serial2
|
||||||
|
#define ISE_DISPLAY_BAUD_RATE 115200
|
||||||
|
#define ISE_DISPLAY_TX_PIN 4
|
||||||
|
#define ISE_DISPLAY_RX_PIN 17
|
||||||
|
|
||||||
|
// Air Conditioner Configuration
|
||||||
|
#define AIR_CONDITIONER_SENSOR_TYPE AC_SENSOR_TYPE_DHT22
|
||||||
|
#define AIR_CONDITIONER_SENSOR_PIN 32
|
||||||
|
#define AIR_CONDITIONER_IR_PIN 5
|
||||||
|
#define AIR_CONDITIONER_RMT_CHANNEL RMT_CHANNEL_0
|
||||||
|
|
||||||
void handleMqttMessage(char *topic, char *payload);
|
void handleMqttMessage(char *topic, char *payload);
|
||||||
void lockAC();
|
void lockAC();
|
||||||
void unlockAC();
|
void unlockAC();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue