add case toggle functions
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
WebServer to use as replacement for Sony RM-D27M to control Sony MiniDisc decks.
|
WebServer to use as replacement for Sony RM-D27M to control Sony MiniDisc decks.
|
||||||
|
|
||||||
Based on the the following sketches:
|
Based on the the following sketches:
|
||||||
@@ -7,12 +6,6 @@
|
|||||||
- ESP32/SD_Test
|
- ESP32/SD_Test
|
||||||
- IRremote/SendDemo
|
- IRremote/SendDemo
|
||||||
|
|
||||||
|
|
||||||
If the IP address of your shield is yourAddress:
|
|
||||||
http://yourAddress/H turns the LED on
|
|
||||||
http://yourAddress/L turns it off
|
|
||||||
|
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
- LED attached to pin 13 (optional)
|
- LED attached to pin 13 (optional)
|
||||||
- IR Transmitter attached to pin 4 (connect to 5v or 3v3)
|
- IR Transmitter attached to pin 4 (connect to 5v or 3v3)
|
||||||
@@ -153,82 +146,6 @@ void notFound(AsyncWebServerRequest *request)
|
|||||||
request->send(404, "text/plain", "Not found");
|
request->send(404, "text/plain", "Not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------
|
|
||||||
//-------------- SD-Card Functions ---------------
|
|
||||||
/* void initSDCard()
|
|
||||||
{
|
|
||||||
if (!SD.begin())
|
|
||||||
{
|
|
||||||
Serial.println("Card Mount Failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint8_t cardType = SD.cardType();
|
|
||||||
|
|
||||||
if (cardType == CARD_NONE)
|
|
||||||
{
|
|
||||||
Serial.println("No SD card attached");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Serial.print("SD Card Type: ");
|
|
||||||
if (cardType == CARD_MMC)
|
|
||||||
{
|
|
||||||
Serial.println("MMC");
|
|
||||||
}
|
|
||||||
else if (cardType == CARD_SD)
|
|
||||||
{
|
|
||||||
Serial.println("SDSC");
|
|
||||||
}
|
|
||||||
else if (cardType == CARD_SDHC)
|
|
||||||
{
|
|
||||||
Serial.println("SDHC");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.println("UNKNOWN");
|
|
||||||
}
|
|
||||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
|
||||||
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
|
||||||
} */
|
|
||||||
|
|
||||||
/* void listDir(fs::FS &fs, const char *dirname, uint8_t levels)
|
|
||||||
{
|
|
||||||
Serial.printf("Listing directory: %s\n", dirname);
|
|
||||||
|
|
||||||
File root = fs.open(dirname);
|
|
||||||
if (!root)
|
|
||||||
{
|
|
||||||
Serial.println("Failed to open directory");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!root.isDirectory())
|
|
||||||
{
|
|
||||||
Serial.println("Not a directory");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
File file = root.openNextFile();
|
|
||||||
while (file)
|
|
||||||
{
|
|
||||||
if (file.isDirectory())
|
|
||||||
{
|
|
||||||
Serial.print(" DIR : ");
|
|
||||||
Serial.println(file.name());
|
|
||||||
if (levels)
|
|
||||||
{
|
|
||||||
listDir(fs, file.path(), levels - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Serial.print(" FILE: ");
|
|
||||||
Serial.print(file.name());
|
|
||||||
Serial.print(" SIZE: ");
|
|
||||||
Serial.println(file.size());
|
|
||||||
}
|
|
||||||
file = root.openNextFile();
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//--------------- IR Functions -------------------
|
//--------------- IR Functions -------------------
|
||||||
|
|
||||||
@@ -300,6 +217,45 @@ void sendCommand20(String commandString)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! void findCommandAndSend(String char)
|
||||||
|
//! { find char in Array and use value to send command }
|
||||||
|
|
||||||
|
void caseToggleLow()
|
||||||
|
{
|
||||||
|
if (wasNumber == true)
|
||||||
|
Serial.println("toggle to char");
|
||||||
|
wasNumber = false;
|
||||||
|
if (wasLowercase == false)
|
||||||
|
Serial.println("toggle case low");
|
||||||
|
if (wasLowercase == true)
|
||||||
|
Serial.println("no toggle");
|
||||||
|
}
|
||||||
|
|
||||||
|
void caseToggleUp()
|
||||||
|
{
|
||||||
|
if (wasNumber == true)
|
||||||
|
Serial.println("toggle to char");
|
||||||
|
wasNumber = false;
|
||||||
|
if (wasLowercase == true)
|
||||||
|
Serial.println("toggle case up");
|
||||||
|
if (wasLowercase == false)
|
||||||
|
Serial.println("no toggle");
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleDigit()
|
||||||
|
{
|
||||||
|
if (wasNumber == true)
|
||||||
|
Serial.println("no toggle");
|
||||||
|
if (wasNumber == false)
|
||||||
|
Serial.println("toggle to digit");
|
||||||
|
wasNumber = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void finalizeTrack()
|
||||||
|
{
|
||||||
|
Serial.println("Finalize track");
|
||||||
|
}
|
||||||
|
|
||||||
void nameSingleTrack(String titlestring)
|
void nameSingleTrack(String titlestring)
|
||||||
{
|
{
|
||||||
Serial.print("track name: ");
|
Serial.print("track name: ");
|
||||||
@@ -317,16 +273,54 @@ void nameSingleTrack(String titlestring)
|
|||||||
for (int i = 0; i < str_len; i++) // Loop over array
|
for (int i = 0; i < str_len; i++) // Loop over array
|
||||||
{
|
{
|
||||||
int s = char_array[i];
|
int s = char_array[i];
|
||||||
Serial.print("char: ");
|
|
||||||
Serial.println(char_array[i]);
|
|
||||||
|
|
||||||
//! Hier müssen verschiedene Sachen getestet werden:
|
//! Hier müssen verschiedene Sachen getestet werden:
|
||||||
//! Ist das Array-Ende erreicht? Ist der case ein anderer als vom vorigen char? Prüft aktuelle char und entscheidet, welches Command gesendet wird
|
//! Ist das Array-Ende erreicht? Ist der case ein anderer als vom vorigen char? Prüft aktuelle char und entscheidet, welches Command gesendet wird
|
||||||
//! Wie kann ich das in eigene Funktionen verpacken?
|
//! Wie kann ich das in eigene Funktionen verpacken?
|
||||||
|
|
||||||
|
if (i == str_len - 1)
|
||||||
|
{
|
||||||
|
Serial.println("End of line.");
|
||||||
|
finalizeTrack();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println(i);
|
||||||
|
Serial.println("char: ");
|
||||||
|
Serial.println(char_array[i]);
|
||||||
// Test if char is a lowerCase letter
|
// Test if char is a lowerCase letter
|
||||||
if (isLowerCase(char_array[i]))
|
if (isLowerCase(char_array[i]))
|
||||||
{
|
{
|
||||||
Serial.println("The character is lower case");
|
Serial.println("The character is lower case");
|
||||||
|
caseToggleLow();
|
||||||
|
wasLowercase = true;
|
||||||
|
wasNumber = false;
|
||||||
|
}
|
||||||
|
// Test if char is a upperCase letter
|
||||||
|
if (isUpperCase(char_array[i]))
|
||||||
|
{
|
||||||
|
Serial.println("The character is upper case");
|
||||||
|
caseToggleUp();
|
||||||
|
wasLowercase = false;
|
||||||
|
wasNumber = false;
|
||||||
|
}
|
||||||
|
// Test if char is a digit
|
||||||
|
if (isDigit(char_array[i]))
|
||||||
|
{
|
||||||
|
Serial.println("The character is digit");
|
||||||
|
toggleDigit();
|
||||||
|
wasNumber = true;
|
||||||
|
}
|
||||||
|
// Test if char is special char
|
||||||
|
if (isPunct(char_array[i]))
|
||||||
|
{
|
||||||
|
Serial.println("The character is special char");
|
||||||
|
}
|
||||||
|
// Test if char is a space
|
||||||
|
if (isSpace(char_array[i]))
|
||||||
|
{
|
||||||
|
Serial.println("The character is a space");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,22 +333,6 @@ void nameAllTracks(String message)
|
|||||||
// use nameSingleTrack with each track
|
// use nameSingleTrack with each track
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------
|
|
||||||
//------------- Webserver Functions --------------
|
|
||||||
|
|
||||||
/* void initWiFi()
|
|
||||||
{
|
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
WiFi.begin(SSID, PASSWORD);
|
|
||||||
Serial.print("Connecting to WiFi ..");
|
|
||||||
while (WiFi.status() != WL_CONNECTED)
|
|
||||||
{
|
|
||||||
Serial.print('.');
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
Serial.println(WiFi.localIP());
|
|
||||||
} */
|
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
//-------------------- Setup ---------------------
|
//-------------------- Setup ---------------------
|
||||||
void setup()
|
void setup()
|
||||||
|
|||||||
Reference in New Issue
Block a user