Atomic Echo Base

The following products are supported:

Atomic Echo Base

Below is the detailed support for Speaker on the host:

Controller

Atomic Echo Base

Atom Echo

Atom Lite

Atom Matrix

AtomS3

AtomS3 Lite

AtomS3R

AtomS3R-CAM

AtomS3R-Ext

Micropython Example:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import I2C
 9from hardware import Pin
10from base import ATOMEchoBase
11
12
13i2c1 = None
14base_echo = None
15
16
17def setup():
18    global i2c1, base_echo
19
20    M5.begin()
21    i2c1 = I2C(1, scl=Pin(39), sda=Pin(38), freq=100000)
22    base_echo = ATOMEchoBase(i2c1, 0x18, 1, 44100, 8, 6, 7, 5)
23    base_echo.speaker.playWavFile("/flash/res/audio/66.wav")
24
25
26def loop():
27    global i2c1, base_echo
28    M5.update()
29
30
31if __name__ == "__main__":
32    try:
33        setup()
34        while True:
35            loop()
36    except (Exception, KeyboardInterrupt) as e:
37        try:
38            from utility import print_error_msg
39
40            print_error_msg(e)
41        except ImportError:
42            print("please update to latest firmware")

UIFLOW2 Example:

example.png

atoms3_echo_example.m5f2

class ATOMEchoBase

Constructors

class ATOMEchoBase(i2c, address: int = 0x18, i2s_port: int = 1, sample_rate: int = 44100, i2s_sck: int = -1, i2s_ws: int = -1, i2s_di: int = -1, i2s_do: int = -1)

Create an ATOMEchoBase object.

参数:
  • i2c (I2C) – I2C object

  • address (int) – The I2C address of the ES8311. Default is 0x18.

  • i2s_port (int) – The I2S port number. Default is 1.

  • sample_rate (int) – The sample rate of the audio. Default is 44100.

  • i2s_sck (int) – The I2S SCK pin. Default is -1.

  • i2s_ws (int) – The I2S WS pin. Default is -1.

  • i2s_di (int) – The I2S DI pin. Default is -1.

  • i2s_do (int) – The I2S DO pin. Default is -1.

UIFLOW2:

init.png

Micropython:

from hardware import I2C
from hardware import Pin
from base import ATOMEchoBase

# atom echo
i2c1 = I2C(1, scl=Pin(21), sda=Pin(25), freq=100000)
echo = ATOMEchoBase(i2c1, address=0x18, i2s_port=1, sample_rate=44100, i2s_sck=33, i2s_ws=19, i2s_di=23, i2s_do=22)

# atom lite
i2c1 = I2C(1, scl=Pin(21), sda=Pin(25), freq=100000)
echo = ATOMEchoBase(i2c1, address=0x18, i2s_port=1, sample_rate=44100, i2s_sck=33, i2s_ws=19, i2s_di=23, i2s_do=22)

# atom matrix
i2c1 = I2C(1, scl=Pin(21), sda=Pin(25), freq=100000)
echo = ATOMEchoBase(i2c1, address=0x18, i2s_port=1, sample_rate=44100, i2s_sck=33, i2s_ws=19, i2s_di=23, i2s_do=22)

# atoms3 / atoms3 lite
i2c1 = I2C(1, scl=Pin(39), sda=Pin(38), freq=100000)
echo = ATOMEchoBase(i2c1, address=0x18, i2s_port=1, sample_rate=44100, i2s_sck=8, i2s_ws=6, i2s_di=7, i2s_do=5)

# atoms3r / atoms3r-cam / atoms3-ext
i2c1 = I2C(1, scl=Pin(39), sda=Pin(38), freq=100000)
echo = ATOMEchoBase(i2c1, address=0x18, i2s_port=1, sample_rate=44100, i2s_sck=8, i2s_ws=6, i2s_di=7, i2s_do=5)

echo.speaker.tone(2000, 1000)
echo.speaker.playWavFile('res/audio/66.wav')

Attributes

ATOMEchoBase.speaker

Objects of the Speaker class.

See hardware.Speaker.Methods for more details on how to use the ATOMEchoBase.speaker properties.

ATOMEchoBase.microphone

Objects of the Microphone class.

See hardware.Mic.Methods for more details on how to use the ATOMEchoBase.microphone properties.

备注

Microphone is not quite ready yet.