added new device type IrRx (infrared receiver)
This commit is contained in:
parent
7cafe6cccb
commit
5691267905
36
things/DeviceIrRx.h
Normal file
36
things/DeviceIrRx.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef DEVICEIRRX_H
|
||||
#define DEVICEIRRX_H
|
||||
|
||||
#include "Device.h"
|
||||
#include <Homie.h>
|
||||
|
||||
class DeviceIrRx : public Device {
|
||||
public:
|
||||
inline DeviceIrRx(byte irrxPin, byte powerPin) {
|
||||
pin_irrx = irrxPin;
|
||||
pin_power = powerPin;
|
||||
}
|
||||
virtual void deviceSetup();
|
||||
virtual void deviceRegister();
|
||||
virtual void deviceLoop();
|
||||
private:
|
||||
byte pin_irrx;
|
||||
byte pin_power;
|
||||
HomieNode irRxNode = HomieNode("irrx", "irrx");
|
||||
};
|
||||
|
||||
void DeviceIrRx::deviceSetup() {
|
||||
pinMode(pin_irrx, INPUT);
|
||||
pinMode(pin_power, OUTPUT);
|
||||
digitalWrite(pin_power, HIGH);
|
||||
}
|
||||
|
||||
void DeviceIrRx::deviceRegister() {
|
||||
Homie.registerNode(irRxNode);
|
||||
}
|
||||
|
||||
void DeviceIrRx::deviceLoop() {
|
||||
// TODO receive IR
|
||||
}
|
||||
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
#include "DeviceLed.h"
|
||||
#include "DeviceLdr.h"
|
||||
#include "DeviceDht.h"
|
||||
#include "DeviceIrRx.h"
|
||||
|
||||
// HAS_LED
|
||||
#define PIN_LED_RED D8
|
||||
@ -19,7 +20,12 @@ DeviceLdr deviceLdr(PIN_LDR);
|
||||
#define TYPE_DHT DHT22
|
||||
DeviceDht deviceDht(PIN_DHT, TYPE_DHT);
|
||||
|
||||
Device* devices[] = { &deviceLed, &deviceLdr };
|
||||
// HAS_IRRX
|
||||
#define PIN_IRRX D1
|
||||
#define PIN_POWER D2
|
||||
DeviceIrRx deviceIrRx(PIN_IRRX, PIN_POWER);
|
||||
|
||||
Device* devices[] = { &deviceLed, &deviceLdr, &deviceIrRx };
|
||||
|
||||
void setupHandler() {
|
||||
for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user