pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Spk2

Example Program

Plays a tone every second for a duration of one second, setting the volume to 6.

from m5stack import *
from m5ui import *
from uiflow import *
import time
import hat

setScreenColor(0x111111)

hat_spk2_0 = hat.get(hat.SPEAKER_I2S)

while True:
  hat_spk2_0.playTone(220, 1, volume=6)
  wait(1)
  hat_spk2_0.playTone(247, 1, volume=6)
  wait(1)
  hat_spk2_0.playTone(131, 1, volume=6)
  wait(1)
  wait_ms(2)

API

hat_spk2_0.playCloudWAV('', volume=0)
  • Plays a WAV audio file from a provided cloud URL with adjustable volume.
hat_spk2_0.playTone(220, 1, volume=0)
  • Plays a specified tone (e.g., Low A) for 1 beat, with adjustable volume.
hat_spk2_0.playTone(220, 1, volume=0)
  • Plays a tone at a specified frequency (e.g., 220 Hz) for 1 beat, with adjustable volume.
/
  • Selects a WAV audio file from local storage to play, with adjustable volume.
hat_spk2_0.playWAV('', rate=44100, data_format=hat_spk2_0.F16B, channel=hat_spk2_0.CHN_LR, volume=0)
  • Plays a specified WAV file with customizable sample rate, data format, channel, and volume.
On This Page