-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(monitor): reduce motor.monitor() to send every MONITOR_WAIT_MS #13
Conversation
WalkthroughThe recent updates involve enhancing the project's configuration and improving the functionality related to monitoring motor variables. A new file exclusion has been added to the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- .gitignore (1 hunks)
- src/main.cpp (5 hunks)
Additional comments: 3
.gitignore (1)
- 83-83: LGTM!
src/main.cpp (2)
- 10-12: LGTM!
- 105-105: Correct initialization of
last_monitor_ms
insetup()
.
if (millis() - last_monitor_ms > MONITOR_WAIT_MS) { | ||
last_monitor_ms = millis(); | ||
// function intended to be used with serial plotter to monitor motor variables | ||
// significantly slowing the execution down!!!! | ||
motor.monitor(); | ||
} |
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.
The conditional check and update of last_monitor_ms
in the loop()
function are correctly implemented to ensure monitoring data is sent at intervals defined by MONITOR_WAIT_MS
. However, consider extracting the monitoring logic into a separate function for better modularity and readability.
void monitorMotor() {
if (millis() - last_monitor_ms > MONITOR_WAIT_MS) {
last_monitor_ms = millis();
motor.monitor();
}
}
void loop() {
motor.loopFOC();
motor.move(target_angle);
+ monitorMotor();
command.run();
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if (millis() - last_monitor_ms > MONITOR_WAIT_MS) { | |
last_monitor_ms = millis(); | |
// function intended to be used with serial plotter to monitor motor variables | |
// significantly slowing the execution down!!!! | |
motor.monitor(); | |
} | |
void monitorMotor() { | |
if (millis() - last_monitor_ms > MONITOR_WAIT_MS) { | |
last_monitor_ms = millis(); | |
motor.monitor(); | |
} | |
} | |
void loop() { | |
motor.loopFOC(); | |
motor.move(target_angle); | |
monitorMotor(); | |
command.run(); | |
} |
Summary by CodeRabbit
.gitignore
to exclude specific system-generated files, ensuring cleaner project management.