prototype without display
This commit is contained in:
parent
c176a6ce3e
commit
202e49f6cf
27
src/main.cpp
27
src/main.cpp
|
@ -3,6 +3,7 @@
|
||||||
/************************************************
|
/************************************************
|
||||||
* Global Variables *
|
* Global Variables *
|
||||||
************************************************/
|
************************************************/
|
||||||
|
RemoteVariable aqi = RemoteVariable();
|
||||||
ESPMegaPRO espmega = ESPMegaPRO();
|
ESPMegaPRO espmega = ESPMegaPRO();
|
||||||
const char *mode_names[] = AC_MODE_NAMES;
|
const char *mode_names[] = AC_MODE_NAMES;
|
||||||
const char *fan_speed_names[] = AC_FAN_SPEED_NAMES;
|
const char *fan_speed_names[] = AC_FAN_SPEED_NAMES;
|
||||||
|
@ -50,8 +51,23 @@ void setup()
|
||||||
espmega.iot->connectToMqtt();
|
espmega.iot->connectToMqtt();
|
||||||
// Initialize Internal Display
|
// Initialize Internal Display
|
||||||
espmega.enableInternalDisplay(&INTERNAL_DISPLAY_UART);
|
espmega.enableInternalDisplay(&INTERNAL_DISPLAY_UART);
|
||||||
|
// Initialize Air Conditioner
|
||||||
|
espmega.installCard(2, &ac);
|
||||||
|
ac.bindFRAM(&espmega.fram, AC_FRAM_ADDR);
|
||||||
|
espmega.display->bindClimateCard(&ac); // Show our climate card on the display
|
||||||
|
// Register all cards with iot
|
||||||
|
espmega.iot->registerCard(0);
|
||||||
|
espmega.iot->registerCard(1);
|
||||||
|
espmega.iot->registerCard(2);
|
||||||
|
// Initialize Remote Variables
|
||||||
|
aqi.begin(10, AQI_STATE_TOPIC, espmega.iot, true, AQI_REQUEST_TOPIC);
|
||||||
|
// Input callbacks
|
||||||
|
// This pre-load the input buffers
|
||||||
|
// We need to do this to prevent switches that are left on the "on" position from triggering the callback
|
||||||
|
espmega.inputs.loop();
|
||||||
|
espmega.inputs.registerCallback(handle_input_change);
|
||||||
|
// Start the display routine
|
||||||
|
// TODO - Write CUDDisplay class
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
@ -65,3 +81,10 @@ void send_stop_bytes(HardwareSerial &uart)
|
||||||
uart.write(0xFF);
|
uart.write(0xFF);
|
||||||
uart.write(0xFF);
|
uart.write(0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handle_input_change(uint8_t pin, bool state) {
|
||||||
|
// When input pin 0 - 6 changes, toggle the corresponding output pin
|
||||||
|
if (pin >= 0 && pin <= 6) {
|
||||||
|
espmega.outputs.setState(pin, !espmega.outputs.getState(pin));
|
||||||
|
}
|
||||||
|
}
|
15
src/main.hpp
15
src/main.hpp
|
@ -3,6 +3,7 @@
|
||||||
#include <ir_codes.hpp>
|
#include <ir_codes.hpp>
|
||||||
#include <ClimateCard.hpp>
|
#include <ClimateCard.hpp>
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
|
#include <RemoteVariable.hpp>
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* Pin Definitions *
|
* Pin Definitions *
|
||||||
|
@ -54,3 +55,17 @@
|
||||||
#define AC_FRAM_ADDR 5000 // 2 bytes
|
#define AC_FRAM_ADDR 5000 // 2 bytes
|
||||||
#define AC_LOCK_FRAM_ADDR 5002 // 1 byte
|
#define AC_LOCK_FRAM_ADDR 5002 // 1 byte
|
||||||
#define AC_DISPLAY_MODE_FRAM_ADDR 5003 // 1 byte
|
#define AC_DISPLAY_MODE_FRAM_ADDR 5003 // 1 byte
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* Remote Variables *
|
||||||
|
***********************************************/
|
||||||
|
#define AQI_STATE_TOPIC "/iqair/usaqi"
|
||||||
|
#define AQI_REQUEST_TOPIC "/iqair/request"
|
||||||
|
|
||||||
|
/***********************************************
|
||||||
|
* Function Prototypes *
|
||||||
|
***********************************************/
|
||||||
|
void setup();
|
||||||
|
void loop();
|
||||||
|
void send_stop_bytes(HardwareSerial &uart);
|
||||||
|
void handle_input_change(uint8_t pin, bool state);
|
Loading…
Reference in New Issue