first test transmitting IR

This commit is contained in:
Ronald Schaten 2016-04-20 22:34:15 +02:00
parent 0d85404ba4
commit e01e13cd9f
2 changed files with 42 additions and 0 deletions

36
things/DeviceIrTx.h Normal file
View File

@ -0,0 +1,36 @@
#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;
decode_results results;
HomieNode irTxNode = HomieNode("irtx", "irtx");
};
void DeviceIrTx::deviceSetup() {
pinMode(pin_irtx, OUTPUT);
}
void DeviceIrTx::deviceRegister() {
Homie.registerNode(irTxNode);
}
void DeviceIrTx::deviceLoop() {
irsend.sendSony(0xa90, 12);
delay(500);
}
#endif

View File

@ -4,6 +4,7 @@
#include "DeviceLdr.h" #include "DeviceLdr.h"
#include "DeviceDht.h" #include "DeviceDht.h"
#include "DeviceIrRx.h" #include "DeviceIrRx.h"
#include "DeviceIrTx.h"
// HAS_LED // HAS_LED
#define PIN_LED_RED D8 #define PIN_LED_RED D8
@ -25,11 +26,16 @@ DeviceDht deviceDht(PIN_DHT, TYPE_DHT);
#define PIN_POWER D0 #define PIN_POWER D0
DeviceIrRx deviceIrRx(PIN_IRRX, PIN_POWER); DeviceIrRx deviceIrRx(PIN_IRRX, PIN_POWER);
// HAS_IRTX
#define PIN_IRTX D2
DeviceIrTx deviceIrTx(PIN_IRTX);
Device* devices[] = { Device* devices[] = {
&deviceLed, &deviceLed,
&deviceLdr, &deviceLdr,
&deviceDht, &deviceDht,
&deviceIrRx, &deviceIrRx,
&deviceIrTx,
}; };
void setupHandler() { void setupHandler() {