Skip to content
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

Open
wants to merge 19 commits into
base: proto5
Choose a base branch
from
Open

Refactor extra .ino's to cpp files #109

wants to merge 19 commits into from

Conversation

lucas-vrtech
Copy link
Member

@lucas-vrtech lucas-vrtech commented Aug 3, 2023

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.

@lucas-vrtech lucas-vrtech changed the title Ino refactor Refactor extra .ino's to cpp files Aug 3, 2023
firmware/lucidgloves-firmware/src/Main.h Outdated Show resolved Hide resolved
Comment on lines +4 to +12
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]);
Copy link
Member

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.

Suggested change
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
}

firmware/lucidgloves-firmware/src/Main.h Show resolved Hide resolved
firmware/lucidgloves-firmware/src/Encoding/IEncoding.h Outdated Show resolved Hide resolved
Comment on lines 133 to 140
if (recievedData.fields.specialCommandReceived){
if (recievedData.command == "ClearData")
input.clearFlags();
else if (recievedData.command == "SaveInter")
input.saveIntermediate();
else if (recievedData.command == "SaveTravel")
input.saveTravel();
}
Copy link
Member

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.

firmware/lucidgloves-firmware/src/Util/ConfigUtils.h Outdated Show resolved Hide resolved
firmware/lucidgloves-firmware/src/Main.h Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants