Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
17
.vscode/settings.json
vendored
17
.vscode/settings.json
vendored
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"array": "cpp",
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"vector": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"functional": "cpp",
|
|
||||||
"iomanip": "cpp",
|
|
||||||
"istream": "cpp",
|
|
||||||
"limits": "cpp",
|
|
||||||
"ostream": "cpp",
|
|
||||||
"ratio": "cpp",
|
|
||||||
"sstream": "cpp",
|
|
||||||
"streambuf": "cpp"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
LICENSE.md
21
LICENSE.md
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2025 Fritz Heiden
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@ -13,4 +13,3 @@ platform = espressif32
|
|||||||
board = esp32doit-devkit-v1
|
board = esp32doit-devkit-v1
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
lib_deps = bblanchon/ArduinoJson@^7.3.1
|
|
||||||
|
|||||||
92
src/main.cpp
92
src/main.cpp
@ -1,89 +1,53 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <ArduinoJson.h>
|
const int IR_SEND_PIN = 12; // GPIO12 for the IR LED
|
||||||
const int IR_SEND_PIN = 12;
|
|
||||||
const int IR_RECEIVE_PIN = 14;
|
|
||||||
const int CONTROL_LED_PIN = 13;
|
|
||||||
#include <IRremote.hpp>
|
#include <IRremote.hpp>
|
||||||
#include "BluetoothSerial.h"
|
|
||||||
|
|
||||||
BluetoothSerial SerialBT;
|
const int ReceiverPin = 14; // GPIO14 for the IR receiver (TSOP48)
|
||||||
|
const int LedPin = 13; // GPIO13 for the external LED
|
||||||
|
|
||||||
void handleIncomingSerialBTData(void *pvParameters);
|
IRData data;
|
||||||
void handleIncomingIRSignals(void *pvParameters);
|
|
||||||
|
|
||||||
void sendDataBT(String data);
|
|
||||||
|
// put function declarations here:
|
||||||
|
int myFunction(int, int);
|
||||||
|
void parallelLoop(void *pvParameters);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200); // Start the serial communication
|
Serial.begin(115200); // Start the serial communication
|
||||||
SerialBT.begin("ESP32");
|
pinMode(LedPin, OUTPUT); // Set LED pin as output
|
||||||
pinMode(CONTROL_LED_PIN, OUTPUT); // Set LED pin as output
|
|
||||||
pinMode(IR_SEND_PIN, OUTPUT); // Set IR LED pin as output
|
pinMode(IR_SEND_PIN, OUTPUT); // Set IR LED pin as output
|
||||||
IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK); // Initialize the IR receiver
|
IrReceiver.begin(ReceiverPin, DISABLE_LED_FEEDBACK); // Initialize the IR receiver
|
||||||
IrSender.begin(IR_SEND_PIN); // Initialize the IR sender
|
|
||||||
Serial.println("IR Receiver Ready!");
|
Serial.println("IR Receiver Ready!");
|
||||||
|
xTaskCreate(parallelLoop, "parallelLoop", 2048, NULL, 1, NULL); // Create a task for parallel loop
|
||||||
xTaskCreate(handleIncomingSerialBTData, "handleIncomingSerialBTData", 2048, NULL, 1, NULL);
|
|
||||||
xTaskCreate(handleIncomingIRSignals, "handleIncomingIRSignals", 2048, NULL, 1, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
|
||||||
delay(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleIncomingIRSignals(void *pvParameters)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
if (IrReceiver.decode())
|
if (IrReceiver.decode())
|
||||||
{
|
{ // Check if IR signal is received
|
||||||
IRData data;
|
IrReceiver.printIRResultShort(&Serial); // Print IR signal details to Serial Monitor
|
||||||
data = IrReceiver.decodedIRData;
|
data = IrReceiver.decodedIRData;
|
||||||
IrReceiver.printIRResultShort(&Serial, &data, false);
|
digitalWrite(LedPin, HIGH); // Turn on the LED
|
||||||
digitalWrite(CONTROL_LED_PIN, HIGH);
|
delay(200); // Keep LED on for 200ms
|
||||||
delay(200);
|
digitalWrite(LedPin, LOW); // Turn off the LED
|
||||||
digitalWrite(CONTROL_LED_PIN, LOW);
|
IrReceiver.resume(); // Prepare to receive the next IR signal
|
||||||
IrReceiver.resume();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIncomingSerialBTData(void *pvParameters)
|
void parallelLoop(void *pvParameters)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
String data = "";
|
delay(5000);
|
||||||
while (SerialBT.available())
|
digitalWrite(IR_SEND_PIN, HIGH);
|
||||||
|
delay(5000);
|
||||||
|
digitalWrite(IR_SEND_PIN, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// put function definitions here:
|
||||||
|
int myFunction(int x, int y)
|
||||||
{
|
{
|
||||||
char c = SerialBT.read();
|
return x + y;
|
||||||
data.concat(c);
|
|
||||||
}
|
|
||||||
if (data != "")
|
|
||||||
{
|
|
||||||
Serial.println(data);
|
|
||||||
|
|
||||||
JsonDocument doc;
|
|
||||||
deserializeJson(doc, data);
|
|
||||||
String protocol = doc["protocol"];
|
|
||||||
int address = doc["address"];
|
|
||||||
int command = doc["command"];
|
|
||||||
|
|
||||||
digitalWrite(CONTROL_LED_PIN, HIGH);
|
|
||||||
if (protocol == "samsung") {
|
|
||||||
|
|
||||||
IrSender.sendSamsung(address, command, 1);
|
|
||||||
}
|
|
||||||
digitalWrite(CONTROL_LED_PIN, LOW);
|
|
||||||
}
|
|
||||||
delay(25);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendDataBT(String data)
|
|
||||||
{
|
|
||||||
uint8_t buf[data.length()];
|
|
||||||
memcpy(buf, data.c_str(), data.length());
|
|
||||||
SerialBT.write(buf, data.length());
|
|
||||||
SerialBT.println();
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user