2016-04-20 22:34:15 +02:00
|
|
|
#ifndef DEVICEIRTX_H
|
|
|
|
#define DEVICEIRTX_H
|
|
|
|
|
|
|
|
#include "Device.h"
|
|
|
|
#include <Homie.h>
|
|
|
|
#include <IRremoteESP8266.h>
|
|
|
|
|
|
|
|
class DeviceIrTx : public Device {
|
|
|
|
public:
|
|
|
|
inline DeviceIrTx(byte irtxPin):irsend(irtxPin) {
|
|
|
|
pin_irtx = irtxPin;
|
|
|
|
}
|
|
|
|
virtual void deviceSetup();
|
|
|
|
virtual void deviceRegister();
|
|
|
|
virtual void deviceLoop();
|
|
|
|
private:
|
|
|
|
byte pin_irtx;
|
|
|
|
IRsend irsend;
|
2016-04-20 22:45:47 +02:00
|
|
|
bool irTxHandler(String message);
|
2016-04-20 22:34:15 +02:00
|
|
|
HomieNode irTxNode = HomieNode("irtx", "irtx");
|
|
|
|
};
|
|
|
|
|
|
|
|
void DeviceIrTx::deviceSetup() {
|
|
|
|
pinMode(pin_irtx, OUTPUT);
|
|
|
|
}
|
|
|
|
|
2016-04-20 22:45:47 +02:00
|
|
|
bool DeviceIrTx::irTxHandler(String message) {
|
|
|
|
irsend.sendSony(0xa90, 12);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-20 22:34:15 +02:00
|
|
|
void DeviceIrTx::deviceRegister() {
|
2016-04-20 22:45:47 +02:00
|
|
|
irTxNode.subscribe("irtx", [this](String value) { return irTxHandler(value); });
|
2016-04-20 22:34:15 +02:00
|
|
|
Homie.registerNode(irTxNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeviceIrTx::deviceLoop() {
|
2016-04-20 22:45:47 +02:00
|
|
|
return;
|
2016-04-20 22:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|