-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
On Wemos D1 mini (ESP8266) I am getting:
Traceback (most recent call last):
File "<stdin>", line 34, in <module>
File "/lib/buzzer_music.py", line 263, in tick
AttributeError: 'PWM' object has no attribute 'duty_u16'
The lack of said attribute can be confirmed by:
from machine import Pin, PWM
p = PWM(Pin(12))
print(dir(p))
# returns ['__class__', 'deinit', 'duty', 'freq', 'init'] on ESP8266 platform
In order to make it work on ESP8266 while retaining Pico compatibility this can be done:
if hasattr(pwm, 'duty_u16'):
pwm.duty_u16(self.duty)
else:
pwm.duty(self.duty)
While testing with D1 mini buzzer shield (https://www.wemos.cc/en/latest/d1_mini_shield/buzzer.html) I also had to lower duty (set to 100) as the default value (2512) only produced almost inaudible clicks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels