Exemplo n.º 1
0
// Sets the system volume to the specified argument in range [0, 100].
func SetVolume(volume uint8) {
	if volume > 100 {
		volume = 100
	}

	utilities.WriteUIntValue("/sys/devices/platform/snd-legoev3", "volume", uint64(volume))
}
Exemplo n.º 2
0
// Plays a tone at the given frequency for the given duration (in ms). To play a sequence of tones asynchronously, call PlayTone repeatedly in a goroutine.
func PlayTone(freq uint32, duration uint64) {
	utilities.WriteUIntValue("/sys/devices/platform/snd-legoev3", "tone", uint64(freq))
	time.Sleep(time.Duration(duration) * time.Millisecond)
	utilities.WriteUIntValue("/sys/devices/platform/snd-legoev3", "tone", 0)
}