change constructor
This commit is contained in:
parent
c718750c45
commit
b4db37a8d6
3 changed files with 12 additions and 10 deletions
|
|
@ -1,15 +1,14 @@
|
|||
#include <cud_display.hpp>
|
||||
|
||||
CUDDisplay::CUDDisplay() : ESPMegaDisplay(&Serial2)
|
||||
CUDDisplay::CUDDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CUDDisplay::begin(std::function<rtctime_t()> getTime, HardwareSerial *serial,
|
||||
DigitalInputCard *inputCard, DigitalOutputCard *outputCard,
|
||||
ClimateCard *climateCard)
|
||||
void CUDDisplay::begin(std::function<rtctime_t()> getTime, DigitalInputCard *inputCard,
|
||||
DigitalOutputCard *outputCard, ClimateCard *climateCard)
|
||||
{
|
||||
this->getTime = getTime;
|
||||
this->sendClock();
|
||||
this->inputCard = inputCard;
|
||||
this->outputCard = outputCard;
|
||||
this->climateCard = climateCard;
|
||||
|
|
@ -20,9 +19,10 @@ void CUDDisplay::begin(std::function<rtctime_t()> getTime, HardwareSerial *seria
|
|||
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
||||
this->registerTouchCallback(bindedHandleTouch);
|
||||
this->reset();
|
||||
delay(500);
|
||||
delay(1000);
|
||||
this->jumpToPage(1);
|
||||
delay(100);
|
||||
this->sendClock();
|
||||
this->setACControlEnabled(true);
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +109,7 @@ void CUDDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t event)
|
|||
|
||||
void CUDDisplay::handlePWMChange(uint8_t pin, uint8_t value)
|
||||
{
|
||||
Serial.printf("PWM Change on Pin %d, Value %d\n", pin, value);
|
||||
// Is the pin a light, fan, or air purifier?
|
||||
if (pin >= 0 && pin <= 3)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ Pin Mapping
|
|||
*/
|
||||
class CUDDisplay : public ESPMegaDisplay {
|
||||
public:
|
||||
CUDDisplay();
|
||||
void begin(std::function<rtctime_t()> getTime, HardwareSerial* serial, DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
|
||||
CUDDisplay(HardwareSerial* adapter);
|
||||
void begin(std::function<rtctime_t()> getTime, DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
|
||||
void handleTouch(uint8_t page, uint8_t component, uint8_t event);
|
||||
void handlePWMChange(uint8_t pin, uint8_t value);
|
||||
void handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ AirConditioner ac = {
|
|||
***********************************************/
|
||||
|
||||
ESPMegaPRO espmega = ESPMegaPRO();
|
||||
CUDDisplay cudDisplay = CUDDisplay();
|
||||
CUDDisplay cudDisplay = CUDDisplay(&cudDisplayAdapter);
|
||||
|
||||
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
||||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||
|
|
@ -62,11 +62,12 @@ void setup() {
|
|||
espmega.iot->registerCard(3);
|
||||
cudDisplayAdapter.begin(CUD_DISPLAY_BAUD_RATE, SERIAL_8N1, CUD_DISPLAY_RX_PIN, CUD_DISPLAY_TX_PIN);
|
||||
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
||||
cudDisplay.begin(bindedGetTime, &cudDisplayAdapter, &espmega.inputs, &espmega.outputs, &climateCard);
|
||||
cudDisplay.begin(bindedGetTime, &espmega.inputs, &espmega.outputs, &climateCard);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
espmega.loop();
|
||||
cudDisplay.loop();
|
||||
}
|
||||
|
||||
void on_pin_change(uint8_t pin, uint8_t value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue