-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor extra .ino's to cpp files #109
base: proto5
Are you sure you want to change the base?
Conversation
const char* const SPECIAL_COMMANDS[] = { | ||
"SaveInter", | ||
"SaveTravel", | ||
"ClearData" | ||
// Add more commands as needed | ||
}; | ||
|
||
//NUM_SPECIAL_COMMANDS can be defined this way because all char* are pointers of the same size | ||
const int NUM_SPECIAL_COMMANDS = sizeof(SPECIAL_COMMANDS) / sizeof(SPECIAL_COMMANDS[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer an enum, and perhaps a std::map<ESpecialCommands, String>
if you do need to link them back to strings.
const char* const SPECIAL_COMMANDS[] = { | |
"SaveInter", | |
"SaveTravel", | |
"ClearData" | |
// Add more commands as needed | |
}; | |
//NUM_SPECIAL_COMMANDS can be defined this way because all char* are pointers of the same size | |
const int NUM_SPECIAL_COMMANDS = sizeof(SPECIAL_COMMANDS) / sizeof(SPECIAL_COMMANDS[0]); | |
enum ESpecialCommands { | |
SPECIAL_COMMAND_SAVE_INTER, | |
SPECIAL_COMMAND_SAVE_TRAVEL, | |
SPECIAL_COMMAND_CLEAR_DATA, | |
NUM_SPECIAL_COMMANDS | |
} |
if (recievedData.fields.specialCommandReceived){ | ||
if (recievedData.command == "ClearData") | ||
input.clearFlags(); | ||
else if (recievedData.command == "SaveInter") | ||
input.saveIntermediate(); | ||
else if (recievedData.command == "SaveTravel") | ||
input.saveTravel(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClearData
, SaveInter
, SaveTravel
are also strings defined elsewhere, having variables for the strings might help to avoid typos in the future.
Rather than taking advantage of Arduino IDE's .ino concatenation, convert all the extra .ino's into cpp files for greater compatibility, better style, and readability.