added led
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@@ -12,7 +11,6 @@ WebServer server(80);
|
|||||||
|
|
||||||
const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@@ -89,42 +87,6 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Input field styling */
|
|
||||||
#channel-input input {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 300px;
|
|
||||||
height: 50px;
|
|
||||||
font-size: 18px;
|
|
||||||
text-align: center;
|
|
||||||
border: none;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
padding: 10px;
|
|
||||||
box-shadow: var(--box-shadow);
|
|
||||||
transition: box-shadow 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
#channel-input input:focus {
|
|
||||||
outline: none;
|
|
||||||
box-shadow: 0px 4px 12px rgba(0, 123, 255, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cross-browser compatibility for hiding spinner arrows */
|
|
||||||
#channel-input input[type="number"] {
|
|
||||||
appearance: textfield;
|
|
||||||
/* Standard property */
|
|
||||||
-webkit-appearance: none;
|
|
||||||
/* WebKit browsers (Chrome, Safari, Edge) */
|
|
||||||
-moz-appearance: textfield;
|
|
||||||
/* Firefox */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Explicitly remove outer and inner spin buttons in WebKit browsers */
|
|
||||||
#channel-input input[type="number"]::-webkit-outer-spin-button,
|
|
||||||
#channel-input input[type="number"]::-webkit-inner-spin-button {
|
|
||||||
-webkit-appearance: none;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Numpad specific styles */
|
/* Numpad specific styles */
|
||||||
#numpad {
|
#numpad {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -189,14 +151,8 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
height: 60px;
|
height: 60px;
|
||||||
/* Keep a consistent height for the number 0 button */
|
/* Keep a consistent height for the number 0 button */
|
||||||
}
|
}
|
||||||
|
|
||||||
#channel-input input {
|
|
||||||
height: 40px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
function sendButtonSignal(buttonCode) {
|
function sendButtonSignal(buttonCode) {
|
||||||
fetch('/sendSignal', {
|
fetch('/sendSignal', {
|
||||||
@@ -206,9 +162,7 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="buttons" class="flex-container">
|
<div id="buttons" class="flex-container">
|
||||||
<div id="power" onclick="sendButtonSignal(0x15)">Power</div>
|
<div id="power" onclick="sendButtonSignal(0x15)">Power</div>
|
||||||
@@ -217,7 +171,6 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
<div id="mute" onclick="sendButtonSignal(0x16)">Mute</div>
|
<div id="mute" onclick="sendButtonSignal(0x16)">Mute</div>
|
||||||
<div id="source" onclick="sendButtonSignal(0x12)">Source</div>
|
<div id="source" onclick="sendButtonSignal(0x12)">Source</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<div id="volume" class="flex-container-column">
|
<div id="volume" class="flex-container-column">
|
||||||
<div id="volume-up" onclick="sendButtonSignal(0x1B)">Volume up</div>
|
<div id="volume-up" onclick="sendButtonSignal(0x1B)">Volume up</div>
|
||||||
@@ -228,7 +181,6 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
<div id="channel-down" onclick="sendButtonSignal(0x18)">Channel down</div>
|
<div id="channel-down" onclick="sendButtonSignal(0x18)">Channel down</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="numpad">
|
<div id="numpad">
|
||||||
<div id="numpad-row-1" class="flex-container">
|
<div id="numpad-row-1" class="flex-container">
|
||||||
<div id="number-1" onclick="sendButtonSignal(0x1)">1</div>
|
<div id="number-1" onclick="sendButtonSignal(0x1)">1</div>
|
||||||
@@ -249,12 +201,14 @@ const char webpage[] PROGMEM = R"rawliteral(<!DOCTYPE html>
|
|||||||
<div id="number-0" onclick="sendButtonSignal(0x0)">0</div>
|
<div id="number-0" onclick="sendButtonSignal(0x0)">0</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="arrows" class="flex-container">
|
||||||
<div id="channel-input" class="flex-container">
|
<div id="Up" onclick="sendButtonSignal(0xC)>Up</div>
|
||||||
<input id="channel-input-field" type="number" value="0" placeholder="Enter Channel" onchange="sendButtonSignalfield()"/>
|
<div id="Down" onclick="sendButtonSignal(0xD)>Down</div>
|
||||||
|
<div id="Left" onclick="sendButtonSignal(0xF)>Left</div>
|
||||||
|
<div id="Right" onclick="sendButtonSignal(0xE)>Right</div>
|
||||||
|
<div id="Enter" onclick="sendButtonSignal(0x10)>Enter</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>)rawliteral";
|
</html>)rawliteral";
|
||||||
|
|
||||||
unsigned long lastTime = 0;
|
unsigned long lastTime = 0;
|
||||||
@@ -266,7 +220,7 @@ unsigned long timeDelay = 5000;
|
|||||||
#define IR_RECEIVE_PIN 2
|
#define IR_RECEIVE_PIN 2
|
||||||
#define IR_TRANSMIT_PIN 3
|
#define IR_TRANSMIT_PIN 3
|
||||||
#define LED 4
|
#define LED 4
|
||||||
#include <IRremote.hpp> // include the library
|
#include <IRremote.hpp>
|
||||||
|
|
||||||
#define DELAY_AFTER_SEND 1000
|
#define DELAY_AFTER_SEND 1000
|
||||||
#define DELAY_AFTER_LOOP 5000
|
#define DELAY_AFTER_LOOP 5000
|
||||||
@@ -274,17 +228,21 @@ unsigned long timeDelay = 5000;
|
|||||||
bool switching = false;
|
bool switching = false;
|
||||||
|
|
||||||
void SendNecSignal(int buttonCode) {
|
void SendNecSignal(int buttonCode) {
|
||||||
|
digitalWrite(LED, HIGH);
|
||||||
Serial.print(F("Send NEC with 8 bit address code: "));
|
Serial.print(F("Send NEC with 8 bit address code: "));
|
||||||
Serial.println(buttonCode);
|
Serial.println(buttonCode);
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
IrSender.sendNEC(0x7F00, buttonCode, 1);
|
IrSender.sendNEC(0x7F00, buttonCode, 1);
|
||||||
delay(DELAY_AFTER_SEND); //delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
delay(DELAY_AFTER_SEND); //delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
|
||||||
|
digitalWrite(LED, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
pinMode(LED, OUTPUT);
|
||||||
|
digitalWrite(LED, HIGH);
|
||||||
|
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
Serial.println("connecting to wifi");
|
Serial.println("connecting to wifi");
|
||||||
|
|
||||||
@@ -308,9 +266,6 @@ void setup() {
|
|||||||
Serial.print(F("Ready to receive IR signals of protocols: "));
|
Serial.print(F("Ready to receive IR signals of protocols: "));
|
||||||
printActiveIRProtocols(&Serial);
|
printActiveIRProtocols(&Serial);
|
||||||
|
|
||||||
pinMode(LED, OUTPUT);
|
|
||||||
|
|
||||||
|
|
||||||
// Define route for root
|
// Define route for root
|
||||||
server.on("/", HTTP_GET, []() {
|
server.on("/", HTTP_GET, []() {
|
||||||
server.send(200, "text/html", webpage);
|
server.send(200, "text/html", webpage);
|
||||||
@@ -344,6 +299,7 @@ void setup() {
|
|||||||
|
|
||||||
// Start the server
|
// Start the server
|
||||||
server.begin();
|
server.begin();
|
||||||
|
digitalWrite(LED, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user