From e984ffa46b2643c58026715d684fff58fd64f198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Thu, 13 Mar 2025 16:01:57 +0100 Subject: [PATCH] infrared remote --- platformio.ini | 1 + src/main.cpp | 5 ++++- src/remote.cpp | 30 ++++++++++++++++++++++++++++++ src/remote.h | 8 ++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/remote.cpp create mode 100644 src/remote.h diff --git a/platformio.ini b/platformio.ini index c148024..d733a51 100644 --- a/platformio.ini +++ b/platformio.ini @@ -4,6 +4,7 @@ board = esp32dev framework = arduino board_build.filesystem = littlefs lib_deps = https://github.com/adafruit/Adafruit_NeoPixel + https://github.com/Arduino-IRremote/Arduino-IRremote upload_port = /dev/ttyUSB0 upload_speed = 460800 monitor_speed = 115200 diff --git a/src/main.cpp b/src/main.cpp index 3baa5c5..ff2328a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,15 +3,17 @@ #include "buzzer.h" #include "countdown.h" #include "display.h" +#include "remote.h" void setup() { delay(500); Serial.begin(115200); - Serial.println("\n\n\nstartup"); + Serial.println("\n\n\nStartup"); beeperSetup(); buttonSetup(); buzzerSetup(); + remoteSetup(); displaySetup(); @@ -21,5 +23,6 @@ void setup() { void loop() { beeperLoop(); buttonLoop(); + remoteLoop(); countdownLoop(); } diff --git a/src/remote.cpp b/src/remote.cpp new file mode 100644 index 0000000..d204c0d --- /dev/null +++ b/src/remote.cpp @@ -0,0 +1,30 @@ +#include "remote.h" + +#include + +void remoteSetup() { + IrReceiver.begin(21); +} + +void remoteLoop() { + if (IrReceiver.decode()) { + Serial.println("--------------------------------------------------------------"); + IrReceiver.printIRResultShort(&Serial); + if (IrReceiver.decodedIRData.flags & IRDATA_FLAGS_WAS_OVERFLOW) { + Serial.println("OVERFLOW"); + } else { + Serial.println(getProtocolString(IrReceiver.decodedIRData.protocol)); + IrReceiver.printIRSendUsage(&Serial); + IrReceiver.printIRResultRawFormatted(&Serial, false); + IrReceiver.printIRResultRawFormatted(&Serial, true); + IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, false); + IrReceiver.compensateAndPrintIRResultAsCArray(&Serial, true); + IrReceiver.printIRResultAsCVariables(&Serial); + IrReceiver.compensateAndPrintIRResultAsPronto(&Serial); + } + IrReceiver.resume(); + Serial.println("--------------------------------------------------------------"); + Serial.println(); + Serial.println(); + } +} diff --git a/src/remote.h b/src/remote.h new file mode 100644 index 0000000..6f4ff5b --- /dev/null +++ b/src/remote.h @@ -0,0 +1,8 @@ +#ifndef REMOTE_H +#define REMOTE_H + +void remoteSetup(); + +void remoteLoop(); + +#endif