Skip to content

add SPEAKER pin alias for PyPortal#1635

Merged
tannewt merged 2 commits into
adafruit:masterfrom
caternuson:iss1634_SPEAKER
Mar 12, 2019
Merged

add SPEAKER pin alias for PyPortal#1635
tannewt merged 2 commits into
adafruit:masterfrom
caternuson:iss1634_SPEAKER

Conversation

@caternuson
Copy link
Copy Markdown

Adafruit CircuitPython 4.0.0-alpha.2-807-g186e31591-dirty on 2019-03-11; Adafruit PyPortal with samd51j20
>>> import board
>>> dir(board)
['__class__', 'A0', 'A1', 'A2', 'A4', 'AUDIO_OUT', 'D13', 'D3', 'D4', 'DISPLAY', 'ESP_BUSY', 'ESP_CS', 'ESP_GPIO0', 'ESP_RESET', 'ESP_RTS', 'I2C', 'L', 'LCD_DATA0', 'LCD_DATA1', 'LCD_DATA2', 'LCD_DATA3', 'LCD_DATA4', 'LCD_DATA5', 'LCD_DATA6', 'LCD_DATA7', 'LIGHT', 'MISO', 'MOSI', 'NEOPIXEL', 'RX', 'SCK', 'SCL', 'SDA', 'SD_CARD_DETECT', 'SD_CS', 'SPEAKER', 'SPEAKER_ENABLE', 'SPI', 'TFT_BACKLIGHT', 'TFT_CS', 'TFT_DC', 'TFT_RD', 'TFT_RESET', 'TFT_RS', 'TFT_TE', 'TFT_WR', 'TOUCH_XL', 'TOUCH_XR', 'TOUCH_YD', 'TOUCH_YU', 'TX', 'UART']

Also tested with this program:

import time
import math
import array
import board
import audioio
import digitalio

length = 8000 // 440
sine_wave = array.array("H", [0] * length)
for i in range(length):
    sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15)

dac = audioio.AudioOut(board.SPEAKER)
sine_wave = audioio.RawSample(sine_wave, sample_rate=8000)

speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker_enable.direction = digitalio.Direction.OUTPUT

speaker_enable.value = True
dac.play(sine_wave, loop=True)
time.sleep(1)
speaker_enable.value = False
dac.stop()

Comment thread ports/atmel-samd/boards/pyportal/pins.c
Copy link
Copy Markdown
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks. Yay for consistency!

@tannewt tannewt merged commit 8f57606 into adafruit:master Mar 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants