Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Buzzer to Presto module. #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modules/py_frozen/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@
from ezwifi import EzWiFi

from collections import namedtuple
from machine import Pin, PWM
from picographics import PicoGraphics, DISPLAY_PRESTO, DISPLAY_PRESTO_FULL_RES


Touch = namedtuple("touch", ("x", "y", "touched"))


class Buzzer:
def __init__(self, pin):
self.pwm = PWM(Pin(pin))

def set_tone(self, freq, duty=0.5):
if freq < 50.0: # uh... https://github.com/micropython/micropython/blob/af64c2ddbd758ab6bac0fcca94c66d89046663be/ports/rp2/machine_pwm.c#L105-L119
self.pwm.duty_u16(0)
return False

self.pwm.freq(freq)
self.pwm.duty_u16(int(65535 * duty))
return True


class Presto():
NUM_LEDS = 7
LED_PIN = 33
Expand Down
Loading