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)
|
||||
{
|
||||
|
||||
@@ -10,23 +10,57 @@
|
||||
#define PLAY 0x2A
|
||||
#define PAUSE 0x29
|
||||
#define STOP 0x28
|
||||
#define PREV 0x20 // geraten
|
||||
#define PREV 0x20
|
||||
#define NEXT 0x21
|
||||
|
||||
// IR commands (Sony 20bit)
|
||||
#define Q 0x41
|
||||
#define W 0x47
|
||||
#define E 0x1A
|
||||
#define R 0x42
|
||||
#define T 0x44
|
||||
#define Z 0x4A
|
||||
#define MINUS 0x4B
|
||||
#define SPACE 0x4C
|
||||
#define PERIOD 0x4D
|
||||
#define COMMA 0x4E
|
||||
#define SLASH 0xA
|
||||
#define QUESTION 0x26
|
||||
#define EXCLAMATION 0x27
|
||||
#define BRACKETOPEN 0x33
|
||||
#define BRACKETCLOSE 0x34
|
||||
|
||||
#define NAME 0x3C
|
||||
#define CHAR 0x36
|
||||
#define NUM 0x37
|
||||
#define CLEAR 0xF
|
||||
|
||||
#define keyA 0x1D
|
||||
#define keyB 0x1E
|
||||
#define keyC 0x1F
|
||||
#define keyD 0x1B
|
||||
#define keyE 0x1A
|
||||
#define keyF 0x0
|
||||
#define keyG 0x1
|
||||
#define keyH 0x2
|
||||
#define keyI 0x3
|
||||
#define keyJ 0x4
|
||||
#define keyK 0x5
|
||||
#define keyL 0x6
|
||||
#define keyM 0x7
|
||||
#define keyN 0x8
|
||||
#define keyO 0x9
|
||||
#define keyP 0x40
|
||||
#define keyQ 0x41
|
||||
#define keyR 0x42
|
||||
#define keyS 0x43
|
||||
#define keyT 0x44
|
||||
#define keyU 0x45
|
||||
#define keyV 0x46
|
||||
#define keyW 0x47
|
||||
#define keyX 0x48
|
||||
#define keyY 0x49
|
||||
#define keyZ 0x4A
|
||||
|
||||
// IR commands (Sony 20bit)
|
||||
|
||||
// old commands
|
||||
#define EJECT 0x69E
|
||||
// #define EJECT 0x69E
|
||||
// #define POWER 0xA9E
|
||||
#define DISPLAY 0x19E
|
||||
/* #define DISPLAY 0x19E
|
||||
#define SCROLL 0x99E
|
||||
#define CONTINUE 0xB9E
|
||||
#define SHUFFLE 0x79E
|
||||
@@ -66,15 +100,15 @@
|
||||
#define NAME 0x3DE
|
||||
#define CHAR 0x6DE
|
||||
#define NUM 0xEDE
|
||||
#define CLEAR 0xF1E
|
||||
#define CLEAR 0xF1E */
|
||||
// #define PLAY 0x55E
|
||||
// #define PAUSE 0x95E
|
||||
// #define STOP 0x15E
|
||||
// #define AMSPREV 0x05E
|
||||
// #define AMSNEXT 0x85E
|
||||
#define RECORD 0xB5E
|
||||
/* #define RECORD 0xB5E
|
||||
#define REWIND 0xD5E
|
||||
#define FASTFORWARD 0x35E
|
||||
#define TREC 0x0DE
|
||||
#define MUSICSYNC 0xFDE
|
||||
#define NAMESELECT 0x87E
|
||||
#define NAMESELECT 0x87E */
|
||||
|
||||
+25
-15
@@ -184,22 +184,8 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<span class="text-orange text-with-line">Title Editing</span>
|
||||
<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="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>
|
||||
<span class="text-orange text-with-line">MD Function</span>
|
||||
<div class="upper-buttonbox">
|
||||
<form action="/api/control-deck" method="post">
|
||||
<button
|
||||
@@ -256,6 +242,30 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<form action="/api/gettracklist" method="post" class="form">
|
||||
<label for="tracklist">
|
||||
<span class="text-orange text-with-line"
|
||||
>Track List Editing</span
|
||||
></label
|
||||
>
|
||||
<textarea name="tracklist" rows="4" cols="50"></textarea>
|
||||
<button type="submit" class="smallbutton">Submit</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<form action="/api/gettrack" method="get" class="form">
|
||||
<label for="singletrack"
|
||||
><span class="text-orange text-with-line"
|
||||
>Single Title Editing</span
|
||||
></label
|
||||
>
|
||||
<input type="text" name="singletrack" class="textinput" />
|
||||
<button type="submit" class="smallbutton">Submit</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="text-orange text-with-line"
|
||||
>20 Bit Keyboard Input Test</span
|
||||
|
||||
Reference in New Issue
Block a user