-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
speaker: add support for speaker on both circuitplay express and circ…
…uitplay bluefruit Signed-off-by: deadprogram <[email protected]>
- Loading branch information
1 parent
585c5a9
commit 774c581
Showing
3 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build circuitplay_bluefruit | ||
|
||
package gopherbot | ||
|
||
import ( | ||
"tinygo.org/x/drivers/buzzer" | ||
|
||
"machine" | ||
) | ||
|
||
// Speaker returns the SpeakerDevice. | ||
func Speaker() *SpeakerDevice { | ||
enable := machine.D11 | ||
enable.Configure(machine.PinConfig{Mode: machine.PinOutput}) | ||
enable.Set(true) | ||
|
||
speaker := machine.D12 | ||
speaker.Configure(machine.PinConfig{Mode: machine.PinOutput}) | ||
|
||
bzr := buzzer.New(speaker) | ||
return &SpeakerDevice{bzr} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build circuitplay_express | ||
|
||
package gopherbot | ||
|
||
import ( | ||
"machine" | ||
|
||
"tinygo.org/x/drivers/buzzer" | ||
) | ||
|
||
// Speaker returns the SpeakerDevice. | ||
func Speaker() *SpeakerDevice { | ||
enable := machine.PA30 | ||
enable.Configure(machine.PinConfig{Mode: machine.PinOutput}) | ||
enable.Set(true) | ||
|
||
speaker := machine.A0 | ||
speaker.Configure(machine.PinConfig{Mode: machine.PinOutput}) | ||
|
||
bzr := buzzer.New(speaker) | ||
return &SpeakerDevice{bzr} | ||
} |