hygain-ir-controller.ino aktualisiert
This commit is contained in:
parent
db2feb0fa6
commit
41f731d516
|
@ -33,6 +33,7 @@ const uint16_t IRCodes[] = {
|
|||
};
|
||||
|
||||
|
||||
// other possible codes:
|
||||
// rotate CCW: 0x43
|
||||
// rotate CW: 0x45
|
||||
// initial: 0x42
|
||||
|
@ -110,39 +111,12 @@ void notFound(AsyncWebServerRequest *request) {
|
|||
|
||||
// Function to get value by key
|
||||
const uint16_t getValueByKey(char key) {
|
||||
// Convert key to uppercase for consistency
|
||||
key = toupper(key);
|
||||
|
||||
// Calculate index
|
||||
int index = key - 'A';
|
||||
|
||||
// Return value at index
|
||||
return IRCodes[index];
|
||||
}
|
||||
|
||||
|
||||
int extractValidHeading(String inputString) {
|
||||
int foundNumber = -1; // Default value if no valid number is found
|
||||
|
||||
// Loop through each character in the string
|
||||
for (int i = 0; i < inputString.length(); i++) {
|
||||
// Check if the current character is a digit
|
||||
if (isdigit(inputString.charAt(i))) {
|
||||
// Parse the number starting from this position
|
||||
foundNumber = inputString.substring(i).toInt();
|
||||
|
||||
// Check if the parsed number is within the valid range (0-360)
|
||||
if (foundNumber >= 0 && foundNumber <= 360) {
|
||||
return foundNumber; // Return the valid number
|
||||
} else {
|
||||
return -1; // Return -1 if the number is outside the valid range
|
||||
}
|
||||
}
|
||||
}
|
||||
return foundNumber; // Return -1 if no number is found in the string
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
|
||||
// Start serial
|
||||
|
|
Loading…
Reference in New Issue