Skip to content
Snippets Groups Projects
Commit 9568ea17 authored by norpol's avatar norpol
Browse files

Refactor

parent dbea1e86
No related branches found
No related tags found
No related merge requests found
...@@ -2,16 +2,7 @@ import vibra ...@@ -2,16 +2,7 @@ import vibra
import utime import utime
def vi(dur, sle): def vibrate(times=None, dur=None, sle=None):
"""
helper for repeater()
see repeater() params
"""
vibra.vibrate(dur)
utime.sleep_ms(sle)
def repeater(times, dur, sle):
""" """
trigger vibration motor with three values trigger vibration motor with three values
times => how often we should triger times => how often we should triger
...@@ -21,8 +12,11 @@ def repeater(times, dur, sle): ...@@ -21,8 +12,11 @@ def repeater(times, dur, sle):
combination out of this creates a fake PWM combination out of this creates a fake PWM
that enables easy and smooth vibrations that enables easy and smooth vibrations
""" """
times = times or 1
for i in range(times): for i in range(times):
vi(dur, sle) vibra.vibrate(dur)
utime.sleep_ms(sle)
def simple(): def simple():
...@@ -30,7 +24,7 @@ def simple(): ...@@ -30,7 +24,7 @@ def simple():
simple() is a short way of vibration simple() is a short way of vibration
for example for button push/change status suitable for example for button push/change status suitable
""" """
repeater(5, 5, 10) vibrate(5, 5, 10)
def select(): def select():
...@@ -38,7 +32,7 @@ def select(): ...@@ -38,7 +32,7 @@ def select():
select() is a little longer, but smoother select() is a little longer, but smoother
good for communicating something got selected good for communicating something got selected
""" """
repeater(10, 5, 20) vibrate(10, 5, 20)
def pattern(n=None): def pattern(n=None):
...@@ -48,4 +42,4 @@ def pattern(n=None): ...@@ -48,4 +42,4 @@ def pattern(n=None):
n = 2 and n = 1 feels the same n = 2 and n = 1 feels the same
""" """
n = n or 3 n = n or 3
repeater(n, 20, 100) vibrate(n, 20, 100)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment