loop over array of chars
This commit is contained in:
@@ -155,6 +155,14 @@ void sendButton12(int command)
|
||||
IrSender.sendSony(0xF, command, 2, 12);
|
||||
}
|
||||
|
||||
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 sendCommand12(String commandString)
|
||||
{
|
||||
if (commandString == "POWER")
|
||||
@@ -175,34 +183,60 @@ void sendCommand12(String commandString)
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
//! Ich brauche eine Funktion, die den vorherigen und den folgenden char prüft und checked, ob der lowercase, oder num ist und dann entsprechend den Modus umschaltet.
|
||||
|
||||
//! Ich brauche eine Funktion, die den char mit einem IR command vergleicht und den IrSender.sendSony() ausführt.
|
||||
|
||||
void sendCommand20(String commandString)
|
||||
{
|
||||
if (commandString == "Q")
|
||||
sendButton20(Q);
|
||||
sendButton12(keyQ);
|
||||
if (commandString == "W")
|
||||
sendButton20(W);
|
||||
sendButton12(keyW);
|
||||
if (commandString == "E")
|
||||
sendButton20(E);
|
||||
sendButton12(keyE);
|
||||
if (commandString == "R")
|
||||
sendButton20(R);
|
||||
sendButton12(keyR);
|
||||
if (commandString == "T")
|
||||
sendButton20(T);
|
||||
sendButton12(keyT);
|
||||
if (commandString == "Z")
|
||||
sendButton20(Z);
|
||||
sendButton12(keyZ);
|
||||
else
|
||||
{
|
||||
Serial.println("wrong command!");
|
||||
}
|
||||
}
|
||||
|
||||
void nameSingleTrack(String titlestring)
|
||||
{
|
||||
Serial.print("track name: ");
|
||||
Serial.println(titlestring);
|
||||
|
||||
//! Brauche ich den null terminator?
|
||||
int str_len = titlestring.length() + 1; // Length (with one extra character for the null terminator)
|
||||
Serial.print("string length: ");
|
||||
Serial.println(str_len);
|
||||
|
||||
char char_array[str_len]; // Prepare the character array (the buffer)
|
||||
|
||||
titlestring.toCharArray(char_array, str_len); // Copy it over
|
||||
|
||||
for (int i = 0; i < str_len; i++) // Loop over array
|
||||
{
|
||||
int s = char_array[i];
|
||||
Serial.print("char: ");
|
||||
Serial.println(char_array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void nameAllTracks(String message)
|
||||
{
|
||||
Serial.print("track list: ");
|
||||
Serial.println(message);
|
||||
// split into array of strings after each line break
|
||||
// use nameSingleTrack with each track
|
||||
}
|
||||
|
||||
//------------------------------------------------
|
||||
//------------- Webserver Functions --------------
|
||||
|
||||
@@ -236,21 +270,6 @@ void setup()
|
||||
|
||||
server.serveStatic("/", SD, "/");
|
||||
|
||||
// Send a GET request to <IP>/api/gettextinput?message=<message>
|
||||
server.on("/api/gettextinput", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
String message;
|
||||
if (request->hasParam("text_input"))
|
||||
{
|
||||
message = request->getParam("text_input")->value();
|
||||
Serial.println(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "No message sent";
|
||||
}
|
||||
request->send(SD, "/index.html", "text/html"); });
|
||||
|
||||
// Send a POST request to <IP>/api/control-led with a form field message set to <message>
|
||||
server.on("/api/control-led", HTTP_POST, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
@@ -267,17 +286,34 @@ void setup()
|
||||
request->send(SD, "/index.html", "text/html"); });
|
||||
|
||||
// Send a POST request to <IP>/api/gettext with a form field message set to <message>
|
||||
server.on("/api/gettext", HTTP_POST, [](AsyncWebServerRequest *request)
|
||||
server.on("/api/gettracklist", HTTP_POST, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
String message;
|
||||
if (request->hasParam("text_box", true)) {
|
||||
message = request->getParam("text_box", true)->value();
|
||||
Serial.println(message);
|
||||
if (request->hasParam("tracklist", true)) {
|
||||
message = request->getParam("tracklist", true)->value();
|
||||
//Serial.println(message);
|
||||
nameAllTracks(message);
|
||||
} else {
|
||||
message = "No message sent";
|
||||
}
|
||||
request->send(SD, "/index.html", "text/html"); });
|
||||
|
||||
// Send a GET request to <IP>/api/gettextinput?message=<message>
|
||||
server.on("/api/gettrack", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
String message;
|
||||
if (request->hasParam("singletrack"))
|
||||
{
|
||||
message = request->getParam("singletrack")->value();
|
||||
//Serial.println(message);
|
||||
nameSingleTrack(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "No message sent";
|
||||
}
|
||||
request->send(SD, "/index.html", "text/html"); });
|
||||
|
||||
// Send a POST request to <IP>/api/control-deck with a form field message set to <message>
|
||||
server.on("/api/control-deck", HTTP_POST, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user