fixed access violation when no scene was active
This commit is contained in:
parent
a33c9989ff
commit
a5e117d54d
2 changed files with 79 additions and 46 deletions
|
@ -158,10 +158,15 @@ void executeCommandWithData(std::string command, commandData commandData, std::s
|
||||||
}
|
}
|
||||||
|
|
||||||
void executeCommand(std::string command, std::string additionalPayload) {
|
void executeCommand(std::string command, std::string additionalPayload) {
|
||||||
if (commands.count(command) > 0) {
|
try {
|
||||||
Serial.printf("command: will execute command '%s'\r\n", command.c_str());
|
if (commands.count(command) > 0) {
|
||||||
executeCommandWithData(command, commands[command], additionalPayload);
|
Serial.printf("command: will execute command '%s'\r\n", command.c_str());
|
||||||
} else {
|
executeCommandWithData(command, commands.at(command), additionalPayload);
|
||||||
Serial.printf("command: command '%s' not found\r\n", command.c_str());
|
} else {
|
||||||
|
Serial.printf("command: command '%s' not found\r\n", command.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("executeCommand: internal error, command not registered\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,64 +74,92 @@ bool sceneExists(std::string sceneName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void scene_start_sequence_from_registry(std::string sceneName) {
|
void scene_start_sequence_from_registry(std::string sceneName) {
|
||||||
registered_scenes[sceneName].this_scene_start_sequence();
|
try {
|
||||||
|
registered_scenes.at(sceneName).this_scene_start_sequence();
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("scene_start_sequence_from_registry: internal error, sceneName not registered\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scene_end_sequence_from_registry(std::string sceneName) {
|
void scene_end_sequence_from_registry(std::string sceneName) {
|
||||||
registered_scenes[sceneName].this_scene_end_sequence();
|
try {
|
||||||
|
registered_scenes.at(sceneName).this_scene_end_sequence();
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("scene_end_sequence_from_registry: internal error, sceneName not registered\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repeatModes get_key_repeatMode(std::string sceneName, char keyChar) {
|
repeatModes get_key_repeatMode(std::string sceneName, char keyChar) {
|
||||||
// look if the map of the current scene has a definition for it
|
try {
|
||||||
if (registered_scenes[sceneName].this_key_repeatModes->count(keyChar) > 0) {
|
// look if the map of the current scene has a definition for it
|
||||||
// Serial.printf("get_key_repeatMode: will use key from scene %s\r\n", sceneName.c_str());
|
if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_repeatModes->count(keyChar) > 0)) {
|
||||||
return registered_scenes[sceneName].this_key_repeatModes->at(keyChar);
|
// Serial.printf("get_key_repeatMode: will use key from scene %s\r\n", sceneName.c_str());
|
||||||
|
return registered_scenes.at(sceneName).this_key_repeatModes->at(keyChar);
|
||||||
// look if there is a default definition
|
|
||||||
} else if (key_repeatModes_default.count(keyChar) > 0) {
|
// look if there is a default definition
|
||||||
// Serial.printf("get_key_repeatMode: will use default key\r\n");
|
} else if (key_repeatModes_default.count(keyChar) > 0) {
|
||||||
return key_repeatModes_default[keyChar];
|
// Serial.printf("get_key_repeatMode: will use default key\r\n");
|
||||||
|
return key_repeatModes_default.at(keyChar);
|
||||||
// no key definition found
|
|
||||||
} else {
|
// no key definition found
|
||||||
// Serial.printf("get_key_repeatMode: WARNING no key definition found\r\n");
|
} else {
|
||||||
|
// Serial.printf("get_key_repeatMode: WARNING no key definition found\r\n");
|
||||||
|
return REPEAT_MODE_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("get_key_repeatMode: internal error, sceneName not registered\r\n");
|
||||||
return REPEAT_MODE_UNKNOWN;
|
return REPEAT_MODE_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_command_short(std::string sceneName, char keyChar) {
|
std::string get_command_short(std::string sceneName, char keyChar) {
|
||||||
// look if the map of the current scene has a definition for it
|
try {
|
||||||
if (registered_scenes[sceneName].this_key_commands_short->count(keyChar) > 0) {
|
// look if the map of the current scene has a definition for it
|
||||||
Serial.printf("get_command_short: will use key from scene %s\r\n", sceneName.c_str());
|
if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_commands_short->count(keyChar) > 0)) {
|
||||||
return registered_scenes[sceneName].this_key_commands_short->at(keyChar);
|
Serial.printf("get_command_short: will use key from scene %s\r\n", sceneName.c_str());
|
||||||
|
return registered_scenes.at(sceneName).this_key_commands_short->at(keyChar);
|
||||||
// look if there is a default definition
|
|
||||||
} else if (key_commands_short_default.count(keyChar) > 0) {
|
// look if there is a default definition
|
||||||
Serial.printf("get_command_short: will use default key\r\n");
|
} else if (key_commands_short_default.count(keyChar) > 0) {
|
||||||
return key_commands_short_default[keyChar];
|
Serial.printf("get_command_short: will use default key\r\n");
|
||||||
|
return key_commands_short_default.at(keyChar);
|
||||||
// no key definition found
|
|
||||||
} else {
|
// no key definition found
|
||||||
Serial.printf("get_command_short: WARNING no key definition found\r\n");
|
} else {
|
||||||
|
Serial.printf("get_command_short: WARNING no key definition found\r\n");
|
||||||
|
return COMMAND_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("get_command_short: internal error, sceneName not registered\r\n");
|
||||||
return COMMAND_UNKNOWN;
|
return COMMAND_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_command_long(std::string sceneName, char keyChar) {
|
std::string get_command_long(std::string sceneName, char keyChar) {
|
||||||
// look if the map of the current scene has a definition for it
|
try {
|
||||||
if (registered_scenes[sceneName].this_key_commands_long->count(keyChar) > 0) {
|
// look if the map of the current scene has a definition for it
|
||||||
Serial.printf("get_command_long: will use key from scene %s\r\n", sceneName.c_str());
|
if ((registered_scenes.count(sceneName) > 0) && (registered_scenes.at(sceneName).this_key_commands_long->count(keyChar) > 0)) {
|
||||||
return registered_scenes[sceneName].this_key_commands_long->at(keyChar);
|
Serial.printf("get_command_long: will use key from scene %s\r\n", sceneName.c_str());
|
||||||
|
return registered_scenes.at(sceneName).this_key_commands_long->at(keyChar);
|
||||||
// look if there is a default definition
|
|
||||||
} else if (key_commands_long_default.count(keyChar) > 0) {
|
// look if there is a default definition
|
||||||
Serial.printf("get_command_long: will use default key\r\n");
|
} else if (key_commands_long_default.count(keyChar) > 0) {
|
||||||
return key_commands_long_default[keyChar];
|
Serial.printf("get_command_long: will use default key\r\n");
|
||||||
|
return key_commands_long_default.at(keyChar);
|
||||||
// no key definition found
|
|
||||||
} else {
|
// no key definition found
|
||||||
Serial.printf("get_command_long: WARNING no key definition found\r\n");
|
} else {
|
||||||
|
Serial.printf("get_command_long: WARNING no key definition found\r\n");
|
||||||
|
return COMMAND_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::out_of_range& oor) {
|
||||||
|
Serial.printf("get_command_long: internal error, sceneName not registered\r\n");
|
||||||
return COMMAND_UNKNOWN;
|
return COMMAND_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue