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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user