add siwatlib
This commit is contained in:
parent
b242d5cb6e
commit
99432ea074
|
@ -0,0 +1,12 @@
|
||||||
|
from time import perf_counter as seconds
|
||||||
|
class debounce:
|
||||||
|
def __init__(self,state: bool, debounce_time: float) -> None:
|
||||||
|
self.last_pressed = seconds()
|
||||||
|
self.debounce_time = debounce_time
|
||||||
|
self.state = state
|
||||||
|
def set_state(self, state: bool) -> bool:
|
||||||
|
if seconds()-self.last_pressed > self.debounce_time:
|
||||||
|
self.state = state
|
||||||
|
return self.state
|
||||||
|
else:
|
||||||
|
return self.state
|
|
@ -0,0 +1,27 @@
|
||||||
|
from pysine import pysine
|
||||||
|
import winsound
|
||||||
|
import threading
|
||||||
|
|
||||||
|
MODE = 'pysine'
|
||||||
|
|
||||||
|
global __beeper__
|
||||||
|
|
||||||
|
def __beeper_therad__(frequency: float, duration: float):
|
||||||
|
if MODE == 'winsound':
|
||||||
|
winsound.Beep(frequency=int(frequency), duration=int(duration*1000))
|
||||||
|
elif MODE == 'pysine':
|
||||||
|
pysine.sine(frequency=frequency,duration=duration)
|
||||||
|
|
||||||
|
__beeper__ = threading.Thread(target=__beeper_therad__,
|
||||||
|
kwargs={'frequency': 0, 'duration': 0}
|
||||||
|
)
|
||||||
|
|
||||||
|
def beep(frequency: float, duration: float):
|
||||||
|
global __beeper__
|
||||||
|
if not __beeper__.is_alive():
|
||||||
|
__beeper__ = threading.Thread(target=__beeper_therad__,
|
||||||
|
kwargs={'frequency': frequency, 'duration': duration}
|
||||||
|
)
|
||||||
|
__beeper__.start()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue