refactor sony 12 bit command function
This commit is contained in:
@@ -147,14 +147,62 @@ void initIR()
|
||||
Serial.println(IR_SEND_PIN);
|
||||
}
|
||||
|
||||
void sendButton(int command)
|
||||
void sendButton12(int command)
|
||||
{
|
||||
Serial.println("sendButton command: ");
|
||||
Serial.print("sendButton12 command: ");
|
||||
Serial.println(command);
|
||||
Serial.flush();
|
||||
IrSender.sendSony(0xF, command, 2, 12);
|
||||
}
|
||||
|
||||
void sendCommand12(String commandString)
|
||||
{
|
||||
if (commandString == "POWER")
|
||||
sendButton12(POWER);
|
||||
if (commandString == "PLAY")
|
||||
sendButton12(PLAY);
|
||||
if (commandString == "PAUSE")
|
||||
sendButton12(PAUSE);
|
||||
if (commandString == "STOP")
|
||||
sendButton12(STOP);
|
||||
if (commandString == "PREV")
|
||||
sendButton12(PREV);
|
||||
if (commandString == "NEXT")
|
||||
sendButton12(NEXT);
|
||||
else
|
||||
{
|
||||
Serial.println("wrong command!");
|
||||
}
|
||||
}
|
||||
|
||||
void sendButton20(int command)
|
||||
{
|
||||
Serial.print(F("Send Sony/SIRCS with 7 command and 13 address bits: "));
|
||||
Serial.println(command);
|
||||
Serial.flush();
|
||||
IrSender.sendSony(0xF & 0x1FFF, command & 0x7F, 2, SIRCS_20_PROTOCOL);
|
||||
}
|
||||
|
||||
void sendCommand20(String commandString)
|
||||
{
|
||||
if (commandString == "Q")
|
||||
sendButton20(Q);
|
||||
if (commandString == "W")
|
||||
sendButton20(W);
|
||||
if (commandString == "E")
|
||||
sendButton20(E);
|
||||
if (commandString == "R")
|
||||
sendButton20(R);
|
||||
if (commandString == "T")
|
||||
sendButton20(T);
|
||||
if (commandString == "Z")
|
||||
sendButton20(Z);
|
||||
else
|
||||
{
|
||||
Serial.println("wrong command!");
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//------------- Webserver Functions --------------
|
||||
|
||||
@@ -236,20 +284,19 @@ void setup()
|
||||
String message;
|
||||
if (request->hasParam("control", true)) {
|
||||
message = request->getParam("control", true)->value();
|
||||
//Serial.print(message);
|
||||
sendButton(message);
|
||||
/* if (message == "POWER")
|
||||
sendButton(POWER);
|
||||
if (message == "PLAY")
|
||||
sendButton(PLAY);
|
||||
if (message == "PAUSE")
|
||||
sendButton(PAUSE);
|
||||
if (message == "STOP")
|
||||
sendButton(STOP);
|
||||
if (message == "PREV")
|
||||
sendButton(PREV);
|
||||
if (message == "NEXT")
|
||||
sendButton(NEXT); */
|
||||
sendCommand12(message);
|
||||
} else {
|
||||
message = "No message sent";
|
||||
}
|
||||
request->send(SD, "/index.html", "text/html"); });
|
||||
|
||||
// Send a POST request to <IP>/api/keyboard-input with a form field message set to <message>
|
||||
server.on("/api/keyboard-input", HTTP_POST, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
String message;
|
||||
if (request->hasParam("key", true)) {
|
||||
message = request->getParam("key", true)->value();
|
||||
sendCommand20(message);
|
||||
} else {
|
||||
message = "No message sent";
|
||||
}
|
||||
|
||||
@@ -4,18 +4,28 @@
|
||||
|
||||
// IR commands (Sony 12bit)
|
||||
|
||||
int POWER = 0x15; //Das ist noch ein Fehler. Eigentlich brauche ich eine Möglichkeit key/value Paare auszulesen.
|
||||
// int POWER = 0x15; //Das ist noch ein Fehler. Eigentlich brauche ich eine Möglichkeit key/value Paare auszulesen.
|
||||
|
||||
//#define POWER 0x15
|
||||
#define POWER 0x15
|
||||
#define PLAY 0x2A
|
||||
#define PAUSE 0x29
|
||||
#define STOP 0x28
|
||||
#define PREV 0x20 //geraten
|
||||
#define PREV 0x20 // geraten
|
||||
#define NEXT 0x21
|
||||
|
||||
//old commands
|
||||
// IR commands (Sony 20bit)
|
||||
#define Q 0x41
|
||||
#define W 0x47
|
||||
#define E 0x1A
|
||||
#define R 0x42
|
||||
#define T 0x44
|
||||
#define Z 0x4A
|
||||
#define SPACE 0x4C
|
||||
#define COMMA 0x4E
|
||||
|
||||
// old commands
|
||||
#define EJECT 0x69E
|
||||
//#define POWER 0xA9E
|
||||
// #define POWER 0xA9E
|
||||
#define DISPLAY 0x19E
|
||||
#define SCROLL 0x99E
|
||||
#define CONTINUE 0xB9E
|
||||
|
||||
+64
-14
@@ -63,6 +63,10 @@
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.width-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.text-white {
|
||||
color: white;
|
||||
}
|
||||
@@ -123,7 +127,7 @@
|
||||
border-right-color: black;
|
||||
}
|
||||
|
||||
.textinput-wrapper {
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
@@ -132,8 +136,21 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.textinput-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.textinput-group {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.textinput {
|
||||
width: 100%;
|
||||
/* width: 100%; */
|
||||
padding: 12px 20px;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid #ccc;
|
||||
@@ -152,6 +169,8 @@
|
||||
<body>
|
||||
<main>
|
||||
<h2 class="headline">SONY RM-D27M Remote</h2>
|
||||
|
||||
<section>
|
||||
<span class="text-white text-with-line">LED Test Mode</span>
|
||||
<div class="upper-buttonbox">
|
||||
<form action="/api/control-led" method="post">
|
||||
@@ -163,21 +182,23 @@
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<span class="text-orange text-with-line">Title Editing</span>
|
||||
<form action="/api/gettext" method="post" class="textinput-wrapper">
|
||||
<form action="/api/gettext" method="post" class="form">
|
||||
<textarea name="text_box" rows="4" cols="50"></textarea>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<section>
|
||||
<form action="/api/gettextinput" method="get" class="textinput-wrapper">
|
||||
<form action="/api/gettextinput" method="get" class="form">
|
||||
<label for="text_input">Change Title</label>
|
||||
<input type="text" name="text_input" class="textinput" />
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="text-orange text-with-line">Deck Control</span>
|
||||
<div class="upper-buttonbox">
|
||||
<form action="/api/control-deck" method="post">
|
||||
@@ -189,7 +210,12 @@
|
||||
>
|
||||
power
|
||||
</button>
|
||||
<button name="control" type="submit" value="PLAY" class="smallbutton">
|
||||
<button
|
||||
name="control"
|
||||
type="submit"
|
||||
value="PLAY"
|
||||
class="smallbutton"
|
||||
>
|
||||
play
|
||||
</button>
|
||||
<button
|
||||
@@ -200,27 +226,51 @@
|
||||
>
|
||||
pause
|
||||
</button>
|
||||
<button name="control" type="submit" value="STOP" class="smallbutton">
|
||||
<button
|
||||
name="control"
|
||||
type="submit"
|
||||
value="STOP"
|
||||
class="smallbutton"
|
||||
>
|
||||
stop
|
||||
</button>
|
||||
<button name="control" type="submit" value="PREV" class="smallbutton">
|
||||
<button
|
||||
name="control"
|
||||
type="submit"
|
||||
value="PREV"
|
||||
class="smallbutton"
|
||||
>
|
||||
previous
|
||||
</button>
|
||||
<button name="control" type="submit" value="NEXT" class="smallbutton">
|
||||
<button
|
||||
name="control"
|
||||
type="submit"
|
||||
value="NEXT"
|
||||
class="smallbutton"
|
||||
>
|
||||
next
|
||||
</button>
|
||||
<button class="roundbutton"></button>
|
||||
<button class="roundbutton"></button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="text-orange text-with-line"
|
||||
>20 Bit Keyboard Input Test</span
|
||||
>
|
||||
<div class="lower-buttonbox">
|
||||
<button>Q</button>
|
||||
<button>W</button>
|
||||
<button>E</button>
|
||||
<button>R</button>
|
||||
<button>T</button>
|
||||
<button>Z</button>
|
||||
<form action="/api/keyboard-input" method="post">
|
||||
<button name="key" type="submit" value="Q">Q</button>
|
||||
<button name="key" type="submit" value="W">W</button>
|
||||
<button name="key" type="submit" value="E">E</button>
|
||||
<button name="key" type="submit" value="R">R</button>
|
||||
<button name="key" type="submit" value="T">T</button>
|
||||
<button name="key" type="submit" value="Z">Z</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<footer>
|
||||
<p>KEY BOARD REMOTE COMMANDER</p>
|
||||
|
||||
Reference in New Issue
Block a user