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

Add smooth vibrate

parent 78fd5bee
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ python_modules = files(
'pride.py',
'ledfx.py',
'simple_menu.py',
'smooth_vibrate.py',
# MicroPython Standard-Library
'col_defaultdict.py',
......
import vibra
import utime
def vi(dur, sle):
"""
helper for repeater()
see repeater() params
"""
vibra.vibrate(dur)
utime.sleep_ms(sle)
def repeater(times, dur, sle):
"""
trigger vibration motor with three values
times => how often we should triger
dur => how long should we trigger for each iteration
sle => how long should we wait in between
combination out of this creates a fake PWM
that enables easy and smooth vibrations
"""
for i in range(times):
vi(dur, sle)
def simple():
"""
simple() is a short way of vibration
for example for button push/change status suitable
"""
repeater(5, 5, 10)
def select():
"""
select() is a little longer, but smoother
good for communicating something got selected
"""
repeater(10, 5, 20)
def pattern(n=None):
"""
very distinctive but long pattern
feels like duk-duk-duk
n = 2 and n = 1 feels the same
"""
n = n or 3
repeater(n, 20, 100)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment