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

fix(vibra): Stop timer if duration <= 0

parent b13681e7
Branches
No related tags found
No related merge requests found
Pipeline #4672 passed
......@@ -27,22 +27,24 @@ void epic_vibra_vibrate(int millis)
{
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) {
vibra_timer = xTimerCreateStatic(
"vibratimer",
ticks,
1,
pdFALSE, /* one-shot */
0,
vTimerCallback,
&vibra_timer_data);
}
/* Make sure the duration is valid */
if (ticks < 1) {
/* Disable a potentially running motor / timer */
epic_vibra_set(0);
xTimerStop(vibra_timer, 0);
return;
}
if (vibra_timer != NULL) {
epic_vibra_set(1);
xTimerChangePeriod(vibra_timer, ticks, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment