fix readme move files and edit gitignore

This commit is contained in:
Thies Mueller
2026-06-11 16:56:32 +02:00
parent 0e70ae7d06
commit 585e0a5aac
4 changed files with 18 additions and 9 deletions
+108
View File
@@ -0,0 +1,108 @@
#include <WiFi.h>
#include <WebServer.h>
#include "driver/rmt.h"
#include "signals.h"
#define TX_PIN 17
#define EN_PIN 16
#define RMT_CHANNEL RMT_CHANNEL_0
#define CLK_DIV 80
const char* ssid = "RegattaTech.DE";
const char* password = "<hierdaspasswort>";
WebServer server(80);
rmt_item32_t items[64];
void setupRMT() {
rmt_config_t config = {};
config.rmt_mode = RMT_MODE_TX;
config.channel = RMT_CHANNEL;
config.gpio_num = (gpio_num_t)TX_PIN;
config.clk_div = CLK_DIV;
config.mem_block_num = 1;
config.tx_config.loop_en = false;
config.tx_config.carrier_en = false;
config.tx_config.idle_level = RMT_IDLE_LEVEL_LOW;
config.tx_config.idle_output_en = true;
rmt_config(&config);
rmt_driver_install(RMT_CHANNEL, 0, 0);
}
void sendSignal(const int* rawSignal, int RAW_LEN) {
digitalWrite(EN_PIN, HIGH);
delayMicroseconds(300);
int idx = 0;
while (idx < RAW_LEN - 1) {
int itemCount = 0;
while (itemCount < 64 && idx < RAW_LEN - 1) {
items[itemCount].level0 = rawSignal[idx] > 0 ? 1 : 0;
items[itemCount].duration0 = abs(rawSignal[idx]);
items[itemCount].level1 = rawSignal[idx+1] > 0 ? 1 : 0;
items[itemCount].duration1 = abs(rawSignal[idx+1]);
idx += 2;
itemCount++;
}
rmt_write_items(RMT_CHANNEL, items, itemCount, true);
rmt_wait_tx_done(RMT_CHANNEL, portMAX_DELAY);
}
digitalWrite(EN_PIN, LOW);
}
void handleCall() {
String uri = server.uri(); // /call/P101
String name = uri.substring(6);
for (int i = 0; i < SIGNAL_COUNT; i++) {
if (name.equals(signals[i].name)) {
sendSignal(signals[i].data, signals[i].len);
server.send(200, "text/plain", "OK");
return;
}
}
server.send(404, "text/plain", "Not found");
}
void setup() {
Serial.begin(115200);
pinMode(EN_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW);
setupRMT();
WiFi.begin(ssid, password);
Serial.print("Connecting WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected!");
Serial.println(WiFi.localIP());
server.onNotFound([](){
if (server.uri().startsWith("/call/")) {
handleCall();
} else {
server.send(404, "text/plain", "Invalid endpoint");
}
});
server.begin();
}
void loop() {
server.handleClient();
}