Arduino AudioKit HAL
All Classes Files Functions Variables Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
audiokit::AudioKit Class Reference

AudioKit API using the audio_hal. More...

#include <AudioKitHAL.h>

Public Member Functions

AudioKitConfig defaultConfig (AudioKitInOut inout=AudioInputOutput)
 Provides the default configuration for input or output.
 
bool begin (AudioKitConfig config)
 Starts the codec.
 
bool end ()
 Stops the CODEC.
 
AudioKitConfigconfig ()
 Provides the actual configuration.
 
bool setActive (bool active)
 Sets the codec active / inactive.
 
bool setMute (bool mute)
 Mutes the output.
 
bool setVolume (int vol)
 Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
 
int volume ()
 Determines the volume %.
 
bool setSampleRate (audio_hal_iface_samples_t sample_rate)
 Just update the sample rate.
 
int8_t pinAuxin ()
 Get the gpio number for auxin detection. More...
 
int8_t pinHeadphoneDetect ()
 Get the gpio number for headphone detection. More...
 
int8_t pinPaEnable ()
 Get the gpio number for PA enable. More...
 
int8_t pinAdcDetect ()
 Get the gpio number for adc detection. More...
 
int8_t pinEs7243Mclk ()
 Get the mclk gpio number of es7243. More...
 
int8_t pinInputRec ()
 Get the record-button id for adc-button. More...
 
int8_t pinInputMode ()
 Get the number for mode-button. More...
 
int8_t pinInputSet ()
 Get number for set function. More...
 
int8_t pinInputPlay ()
 Get number for play function. More...
 
int8_t pinVolumeUp ()
 number for volume up function More...
 
int8_t pinVolumeDown ()
 Get number for volume down function. More...
 
int8_t pinResetCodec ()
 Get reset codec gpio number. More...
 
int8_t pinResetBoard ()
 Get gpio number to reset the board. More...
 
int8_t pinGreenLed ()
 Get gpio number for green led. More...
 
int8_t pinBlueLed ()
 Get blue led gpio number. More...
 
void setSpeakerActive (bool active)
 Activates/deactivates the speaker amplifier output This is working only if the driver is supporting the functionality. More...
 
bool headphoneStatus ()
 Returns true if the headphone was detected. More...
 
bool isSDActive ()
 checks if the SD is active
 
void log_i2c ()
 

Static Public Member Functions

static void actionHeadphoneDetection ()
 Switch off the PA if the headphone in plugged in and switch it on again if the headphone is unplugged.
 

Protected Member Functions

void setupDriverPins ()
 
void setupHeadphoneDetection ()
 Setup the headphone detection.
 
void setupSPI ()
 Setup the SPI so that we can access the SD Drive.
 
bool setupI2S (AudioKitConfig cnfg)
 

Protected Attributes

bool is_active = false
 
AudioKitConfig cfg
 
audio_hal_codec_config_t audio_hal_conf
 
audio_hal_handle_t hal_handle = 0
 
audio_hal_codec_i2s_iface_t iface
 
int8_t spi_cs_pin
 
bool headphoneIsConnected = false
 
unsigned long speakerChangeTimeout = 0
 
board_driver driver
 
SPIClass * p_spi = &AUDIOKIT_SD_SPI
 

Detailed Description

AudioKit API using the audio_hal.

Definition at line 240 of file AudioKitHAL.h.

Member Function Documentation

◆ headphoneStatus()

bool audiokit::AudioKit::headphoneStatus ( )
inline

Returns true if the headphone was detected.

Returns
true
false

Definition at line 605 of file AudioKitHAL.h.

606  {
607  int headphonePin = config().pins.detect_headphone;
608  return headphonePin > 0 ? !digitalRead(headphonePin) : false;
609  }
AudioKitConfig & config()
Provides the actual configuration.
Definition: AudioKitHAL.h:354
audio_kit_pins pins
defines all relevant pins
Definition: AudioKitHAL.h:84

◆ pinAdcDetect()

int8_t audiokit::AudioKit::pinAdcDetect ( )
inline

Get the gpio number for adc detection.

Returns
-1 non-existent Others gpio number

Definition at line 471 of file AudioKitHAL.h.

471 { return driver.get_adc_detect_gpio(); }

◆ pinAuxin()

int8_t audiokit::AudioKit::pinAuxin ( )
inline

Get the gpio number for auxin detection.

Returns
-1 non-existent Others gpio number

Definition at line 447 of file AudioKitHAL.h.

447 { return driver.get_auxin_detect_gpio(); }

◆ pinBlueLed()

int8_t audiokit::AudioKit::pinBlueLed ( )
inline

Get blue led gpio number.

Returns
-1 non-existent Others gpio number

Definition at line 559 of file AudioKitHAL.h.

559 { return driver.get_blue_led_gpio(); }

◆ pinEs7243Mclk()

int8_t audiokit::AudioKit::pinEs7243Mclk ( )
inline

Get the mclk gpio number of es7243.

Returns
-1 non-existent Others gpio number

Definition at line 479 of file AudioKitHAL.h.

479 { return driver.get_es7243_mclk_gpio(); }

◆ pinGreenLed()

int8_t audiokit::AudioKit::pinGreenLed ( )
inline

Get gpio number for green led.

Returns
-1 non-existent Others gpio number

Definition at line 551 of file AudioKitHAL.h.

551 { return driver.get_green_led_gpio(); }

◆ pinHeadphoneDetect()

int8_t audiokit::AudioKit::pinHeadphoneDetect ( )
inline

Get the gpio number for headphone detection.

Returns
-1 non-existent Others gpio number

Definition at line 455 of file AudioKitHAL.h.

455 { return driver.get_headphone_detect_gpio(); }

◆ pinInputMode()

int8_t audiokit::AudioKit::pinInputMode ( )
inline

Get the number for mode-button.

Returns
-1 non-existent Others number

Definition at line 495 of file AudioKitHAL.h.

495 { return driver.get_input_mode_id(); }

◆ pinInputPlay()

int8_t audiokit::AudioKit::pinInputPlay ( )
inline

Get number for play function.

Returns
-1 non-existent Others number

Definition at line 511 of file AudioKitHAL.h.

511 { return driver.get_input_play_id(); }

◆ pinInputRec()

int8_t audiokit::AudioKit::pinInputRec ( )
inline

Get the record-button id for adc-button.

Returns
-1 non-existent Others button id

Definition at line 487 of file AudioKitHAL.h.

487 { return driver.get_input_rec_id(); }

◆ pinInputSet()

int8_t audiokit::AudioKit::pinInputSet ( )
inline

Get number for set function.

Returns
-1 non-existent Others number

Definition at line 503 of file AudioKitHAL.h.

503 { return driver.get_input_set_id(); };

◆ pinPaEnable()

int8_t audiokit::AudioKit::pinPaEnable ( )
inline

Get the gpio number for PA enable.

Returns
-1 non-existent Others gpio number

Definition at line 463 of file AudioKitHAL.h.

463 { return driver.get_pa_enable_gpio(); }

◆ pinResetBoard()

int8_t audiokit::AudioKit::pinResetBoard ( )
inline

Get gpio number to reset the board.

Returns
-1 non-existent Others gpio number

Definition at line 543 of file AudioKitHAL.h.

543 { return driver.get_reset_board_gpio(); }

◆ pinResetCodec()

int8_t audiokit::AudioKit::pinResetCodec ( )
inline

Get reset codec gpio number.

Returns
-1 non-existent Others gpio number

Definition at line 535 of file AudioKitHAL.h.

535 { return driver.get_reset_codec_gpio(); }

◆ pinVolumeDown()

int8_t audiokit::AudioKit::pinVolumeDown ( )
inline

Get number for volume down function.

Returns
-1 non-existent Others number

Definition at line 527 of file AudioKitHAL.h.

527 { return driver.get_input_voldown_id(); }

◆ pinVolumeUp()

int8_t audiokit::AudioKit::pinVolumeUp ( )
inline

number for volume up function

Returns
-1 non-existent Others number

Definition at line 519 of file AudioKitHAL.h.

519 { return driver.get_input_volup_id(); }

◆ setSpeakerActive()

void audiokit::AudioKit::setSpeakerActive ( bool  active)
inline

Activates/deactivates the speaker amplifier output This is working only if the driver is supporting the functionality.

Parameters
active

Definition at line 566 of file AudioKitHAL.h.

567  {
568  int paPin = driver.get_pa_enable_gpio();
569  if (paPin > 0) {
570  digitalWrite(paPin, active);
571  } else {
572  KIT_LOGW("setSpeakerActive not supported");
573  }
574  }

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