arduino-audio-driver
Loading...
Searching...
No Matches
AudioDriverWM8978Class Class Reference

Driver API for the wm8978 codec chip. More...

#include <AudioDriver.h>

Inheritance diagram for AudioDriverWM8978Class:
AudioDriver

Public Member Functions

 AudioDriverWM8978Class (uint16_t deviceAddr=WM8978::WM8978_ADDR)
bool begin (CodecConfig codecCfg, DriverDeviceInfo &pins) override
 Starts the processing.
WM8978 & driver ()
bool end () override
 Ends the processing: shut down dac and adc.
API_GPIO & getGPIO ()
virtual int getI2CAddress ()
 Provides the i2c address.
int getVolume () override
 Determines the actual volume (range: 0-100).
bool isInputVolumeSupported () override
 Determines if setInputVolume() is supported.
bool isVolumeSupported () override
 Determines if setVolume() is suppored.
 operator bool ()
virtual DriverDeviceInfo & pins ()
 Provides the pin information.
bool setConfig (CodecConfig codecCfg) override
 changes the configuration
virtual bool setI2CAddress (uint16_t adr)
 Defines the i2c address.
bool setInputVolume (int volume) override
 Defines the input volume (range: 0-100) if supported.
bool setMute (bool mute) override
 Mutes all output lines.
bool setMute (bool mute, int line) override
 Mute line 0 = speaker, line 1 = headphones.
bool setPAPower (bool enable)
 Sets the PA Power pin to active or inactive.
void setPins (DriverDeviceInfo &pins)
void setupI2CAddress ()
 If no address is defined in the pins we provide it here.
bool setVolume (int volume) override
 Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.

Protected Member Functions

virtual bool configInterface (codec_mode_t mode, I2SDefinition iface)
virtual bool controlState (codec_mode_t mode)
virtual bool deinit ()
virtual i2c_bus_handle_t getI2C ()
 Determine the TwoWire object from the I2C config or use Wire.
virtual bool init (codec_config_t codec_cfg)
int limitValue (int volume, int min=0, int max=100)
int mapVolume (int x, int in_min, int in_max, int out_min, int out_max)
int toBits (sample_bits_t bits)
int toI2S (i2s_format_t fmt)

Protected Attributes

CodecConfig codec_cfg
int i2c_default_address = -1
DriverDeviceInfo * p_pins = nullptr
int volume = 0
WM8978 wm8078

Detailed Description

Driver API for the wm8978 codec chip.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioDriverWM8978Class()

AudioDriverWM8978Class ( uint16_t deviceAddr = WM8978::WM8978_ADDR)
inline

Member Function Documentation

◆ begin()

bool begin ( CodecConfig codecCfg,
DriverDeviceInfo & pins )
inlineoverridevirtual

Starts the processing.

Reimplemented from AudioDriver.

◆ configInterface()

◆ controlState()

◆ deinit()

◆ driver()

WM8978 & driver ( )
inline

◆ end()

bool end ( void )
inlineoverridevirtual

Ends the processing: shut down dac and adc.

Reimplemented from AudioDriver.

◆ getGPIO()

API_GPIO & getGPIO ( )
inlineinherited

◆ getI2C()

virtual i2c_bus_handle_t getI2C ( )
inlineprotectedvirtualinherited

Determine the TwoWire object from the I2C config or use Wire.

◆ getI2CAddress()

virtual int getI2CAddress ( )
inlinevirtualinherited

Provides the i2c address.

◆ getVolume()

int getVolume ( )
inlineoverridevirtual

Determines the actual volume (range: 0-100).

Implements AudioDriver.

◆ init()

◆ isInputVolumeSupported()

bool isInputVolumeSupported ( )
inlineoverridevirtual

Determines if setInputVolume() is supported.

Reimplemented from AudioDriver.

◆ isVolumeSupported()

bool isVolumeSupported ( )
inlineoverridevirtual

Determines if setVolume() is suppored.

Reimplemented from AudioDriver.

◆ limitValue()

int limitValue ( int volume,
int min = 0,
int max = 100 )
inlineprotectedinherited

make sure that value is in range

Parameters
volume
Returns

◆ mapVolume()

int mapVolume ( int x,
int in_min,
int in_max,
int out_min,
int out_max )
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlineinherited

◆ pins()

virtual DriverDeviceInfo & pins ( )
inlinevirtualinherited

Provides the pin information.

Reimplemented in AudioDriverCS42448Class.

◆ setConfig()

bool setConfig ( CodecConfig codecCfg)
inlineoverridevirtual

changes the configuration

Reimplemented from AudioDriver.

◆ setI2CAddress()

virtual bool setI2CAddress ( uint16_t adr)
inlinevirtualinherited

Defines the i2c address.

◆ setInputVolume()

bool setInputVolume ( int volume)
inlineoverridevirtual

Defines the input volume (range: 0-100) if supported.

Reimplemented from AudioDriver.

◆ setMute() [1/2]

bool setMute ( bool enable)
inlineoverridevirtual

Mutes all output lines.

Implements AudioDriver.

◆ setMute() [2/2]

bool setMute ( bool mute,
int line )
inlineoverridevirtual

Mute line 0 = speaker, line 1 = headphones.

Reimplemented from AudioDriver.

◆ setPAPower()

bool setPAPower ( bool enable)
inlineinherited

Sets the PA Power pin to active or inactive.

◆ setPins()

void setPins ( DriverDeviceInfo & pins)
inlineinherited

◆ setupI2CAddress()

void setupI2CAddress ( )
inlineinherited

If no address is defined in the pins we provide it here.

◆ setVolume()

bool setVolume ( int volume)
inlineoverridevirtual

Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.

Implements AudioDriver.

◆ toBits()

int toBits ( sample_bits_t bits)
inlineprotected

◆ toI2S()

int toI2S ( i2s_format_t fmt)
inlineprotected

fmt:0,LSB(right-aligned);1,MSB(left-aligned);2,Philips standard, I2S;3,PCM/DSP;

Member Data Documentation

◆ codec_cfg

CodecConfig codec_cfg
protectedinherited

◆ i2c_default_address

int i2c_default_address = -1
protectedinherited

◆ p_pins

DriverDeviceInfo* p_pins = nullptr
protectedinherited

◆ volume

int volume = 0
protected

◆ wm8078

WM8978 wm8078
protected

The documentation for this class was generated from the following file: