Skip to content
Snippets Groups Projects
Commit b13681e7 authored by schneider's avatar schneider
Browse files

fix(vibra): Deal with durations <= 0

parent de1e0902
No related branches found
No related tags found
No related merge requests found
Pipeline #4670 passed
...@@ -27,15 +27,21 @@ void epic_vibra_vibrate(int millis) ...@@ -27,15 +27,21 @@ void epic_vibra_vibrate(int millis)
{ {
int ticks = millis * (configTICK_RATE_HZ / 1000); int ticks = millis * (configTICK_RATE_HZ / 1000);
/* Make sure the duration is valid */
if (ticks < 1) {
/* Disable a potentially running motor */
epic_vibra_set(0);
return;
}
if (vibra_timer == NULL) { if (vibra_timer == NULL) {
vibra_timer = xTimerCreateStatic( vibra_timer = xTimerCreateStatic(
"vibratimer", "vibratimer",
ticks, ticks,
pdFALSE, pdFALSE, /* one-shot */
0, 0,
vTimerCallback, vTimerCallback,
&vibra_timer_data &vibra_timer_data);
);
} }
if (vibra_timer != NULL) { if (vibra_timer != NULL) {
epic_vibra_set(1); epic_vibra_set(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment