This commit is contained in:
Your Name
2026-05-15 10:03:21 +02:00
commit 73adb96d21
2 changed files with 161 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env python3
import pigpio
import time
GPIO = 18
FREQ = 38000
DUTY = 500000 # 50%
raw = [
9003, -4483,
583, -568,
592, -535,
557, -570,
563, -564,
558, -569,
588, -540,
557, -545,
583, -569,
559, -1694,
565, -1692,
560, -1693,
561, -1693,
565, -1690,
564, -1691,
585, -1670,
562, -1695,
558, -570,
581, -546,
584, -544,
554, -572,
588, -1666,
560, -567,
557, -570,
586, -516,
607, -1671,
555, -1698,
586, -1669,
558, -1694,
559, -546,
581, -1696,
557, -1697,
588, -1667,
556
]
pi = pigpio.pi()
if not pi.connected:
raise RuntimeError("pigpio daemon läuft nicht")
waves = []
for t in raw:
if t > 0:
pi.wave_add_new()
pi.wave_add_generic([
pigpio.pulse(1 << GPIO, 0, t)
])
wid = pi.wave_create()
waves.append(wid)
else:
pi.wave_add_new()
pi.wave_add_generic([
pigpio.pulse(0, 1 << GPIO, abs(t))
])
wid = pi.wave_create()
waves.append(wid)
pi.hardware_PWM(GPIO, FREQ, DUTY)
chain = []
for wid in waves:
chain.append(wid)
pi.wave_chain(chain)
while pi.wave_tx_busy():
time.sleep(0.01)
for wid in waves:
pi.wave_delete(wid)
pi.hardware_PWM(GPIO, 0, 0)
pi.stop()