24 lines
597 B
C++
24 lines
597 B
C++
#include "DeviceIrRx.h"
|
|
|
|
void DeviceIrRx::deviceSetup() {
|
|
// pinMode(pin_irrx, INPUT); // this is done by enableIRIn()
|
|
irrecv.enableIRIn();
|
|
pinMode(pin_power, OUTPUT);
|
|
digitalWrite(pin_power, HIGH);
|
|
}
|
|
|
|
void DeviceIrRx::deviceRegister() {
|
|
Homie.registerNode(irRxNode);
|
|
}
|
|
|
|
void DeviceIrRx::deviceLoop() {
|
|
if (irrecv.decode(&results)) {
|
|
Serial.print("IR-Rx: ");
|
|
Serial.println(results.value, HEX);
|
|
if (!Homie.setNodeProperty(irRxNode, "value", String(results.value), false)) {
|
|
Serial.println("Sending failed");
|
|
}
|
|
irrecv.resume(); // Receive the next value
|
|
}
|
|
}
|