From e01e13cd9fe7261d79c109aea70c87b41333b6e7 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Wed, 20 Apr 2016 22:34:15 +0200 Subject: [PATCH] first test transmitting IR --- things/DeviceIrTx.h | 36 ++++++++++++++++++++++++++++++++++++ things/things.ino | 6 ++++++ 2 files changed, 42 insertions(+) create mode 100644 things/DeviceIrTx.h diff --git a/things/DeviceIrTx.h b/things/DeviceIrTx.h new file mode 100644 index 0000000..016c88b --- /dev/null +++ b/things/DeviceIrTx.h @@ -0,0 +1,36 @@ +#ifndef DEVICEIRTX_H +#define DEVICEIRTX_H + +#include "Device.h" +#include +#include + +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 diff --git a/things/things.ino b/things/things.ino index dbed565..5a032cc 100644 --- a/things/things.ino +++ b/things/things.ino @@ -4,6 +4,7 @@ #include "DeviceLdr.h" #include "DeviceDht.h" #include "DeviceIrRx.h" +#include "DeviceIrTx.h" // HAS_LED #define PIN_LED_RED D8 @@ -25,11 +26,16 @@ DeviceDht deviceDht(PIN_DHT, TYPE_DHT); #define PIN_POWER D0 DeviceIrRx deviceIrRx(PIN_IRRX, PIN_POWER); +// HAS_IRTX +#define PIN_IRTX D2 +DeviceIrTx deviceIrTx(PIN_IRTX); + Device* devices[] = { &deviceLed, &deviceLdr, &deviceDht, &deviceIrRx, + &deviceIrTx, }; void setupHandler() {