### Getting Power State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to get the current power state of the TAS5805M DAC. ```cpp TAS5805M_CTRL_STATE state; esp_err_t ret = tas5805m_get_state(&state); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get power state"); } else { ESP_LOGI("TAS5805M", "Current power state: %s", tas5805m_map_amp_state(state)); } ``` -------------------------------- ### Getting DAC Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to get the current DAC mode of the TAS5805M. ```cpp TAS5805M_DAC_MODE mode; esp_err_t ret = tas5805m_get_dac_mode(&mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get DAC mode"); } else { ESP_LOGI("TAS5805M", "Current DAC mode: %d", mode); } ``` -------------------------------- ### Getting Current EQ Profile Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Shows how to get the currently active EQ profile using the `Tas5805m.getEqProfile` method. ```cpp TAS5805M_EQ_PROFILE eq_profile; Tas5805m.getEqProfile(&eq_profile); ESP_LOGI("EQ", "Current EQ profile: %d", eq_profile); ``` -------------------------------- ### Getting Mute State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to get the current mute state of the TAS5805M DAC. ```cpp bool mute; esp_err_t ret = tas5805m_get_mute(&mute); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get mute state"); } else { ESP_LOGI("TAS5805M", "Mute state: %s", mute ? "Muted" : "Unmuted"); } ``` -------------------------------- ### CLI Commands for EQ Profile Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Provides CLI commands to get and set the EQ profile. ```bash eqp get eqp set ``` -------------------------------- ### Getting Mixer Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to retrieve the current mixer mode from the TAS5805M DAC. ```cpp TAS5805M_MIXER_MODE mode; esp_err_t ret = tas5805m_get_mixer_mode(&mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get mixer mode"); } else { ESP_LOGI("TAS5805M", "Current mixer mode: %d", mode); } ``` -------------------------------- ### Arduino Wrapper Initialization Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of initializing the TAS5805M DAC using the C++ wrapper in an Arduino environment. ```cpp #include tas5805m Tas5805m(&Wire); ``` ```cpp const int sampleRate = 16000; const int bps = 16; I2S.begin(I2S_PHILIPS_MODE, sampleRate, bps); Wire.begin(PIN_I2S_SDA, PIN_I2S_SCL); Tas5805m.init(); ``` -------------------------------- ### Setting Mute State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to set the mute state of the TAS5805M DAC. ```cpp bool mute = true; // Mute the DAC esp_err_t ret = tas5805m_set_mute(mute); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set mute state"); } ``` -------------------------------- ### ESP-IDF Initialization Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of initializing the TAS5805M DAC using the low-level C driver in an ESP-IDF application. ```c #include "tas5805m.h" void app_main() { esp_err_t ret = tas5805m_init(); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to initialize TAS5805M"); } } ``` -------------------------------- ### Getting Modulation Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to retrieve the current modulation mode, switching frequency, and digital filter frequency from the TAS5805M DAC. ```cpp TAS5805M_MOD_MODE mode; TAS5805M_SW_FREQ freq; TAS5805M_BD_FREQ bd_freq; esp_err_t ret = tas5805m_get_modulation_mode(&mode, &freq, &bd_freq); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get modulation mode"); } else { ESP_LOGI("TAS5805M", "Modulation mode: %d, SW freq: %d, BD freq: %d", mode, freq, bd_freq); } ``` -------------------------------- ### Getting Sample Rate Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current sample rate of the DAC. ```cpp TAS5805M_FS_FREQ freq; esp_err_t ret = tas5805m_get_fs_freq(&freq); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get sample rate"); } else { ESP_LOGI("TAS5805M", "Sample rate: %d", freq); } ``` -------------------------------- ### Setting Mixer Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to set the mixer mode for the TAS5805M DAC. ```cpp // one of MIXER_STEREO, MIXER_STEREO_INVERSE, MIXER_MONO, MIXER_LEFT, MIXER_RIGHT TAS5805M_MIXER_MODE mode = MIXER_STEREO; esp_err_t ret = tas5805m_set_mixer_mode(mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set mixer mode"); } ``` -------------------------------- ### Setting Power State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to set the power state of the TAS5805M DAC to sleep. ```cpp TAS5805M_CTRL_STATE state = TAS5805M_CTRL_SLEEP; esp_err_t ret = tas5805m_set_state(state); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set power state"); } ``` -------------------------------- ### Setting DAC Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to set the DAC mode to Bridge Tied Load (BTL) for stereo output. ```cpp TAS5805M_DAC_MODE mode = TAS5805M_DAC_MODE_BTL; // Set to Bridge Tied Load mode esp_err_t ret = tas5805m_set_dac_mode(mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set DAC mode"); } ``` -------------------------------- ### Get Analog Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current analog gain setting. ```cpp uint8_t gain; esp_err_t ret = tas5805m_get_again(&gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get analog gain"); } else { ESP_LOGI("TAS5805M", "Current analog gain: %d", gain); } ``` -------------------------------- ### Getting EQ Profile for a Specific Channel Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Shows how to retrieve the EQ profile for a specific channel using `tas5805m_get_eq_profile_channel`. ```cpp TAS5805M_EQ_CHANNELS channel = TAS5805M_EQ_CHANNELS_LEFT; // or TAS5805M_EQ_CHANNELS_RIGHT TAS5805M_EQ_PROFILE profile; esp_err_t ret = tas5805m_get_eq_profile_channel(channel, &profile); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get EQ profile for channel"); } else { ESP_LOGI("TAS5805M", "EQ profile for channel %d: %d", channel, profile); } ``` -------------------------------- ### Getting Clipper Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Reads the current clipper gain and makeup gain settings for both channels. ```cpp int32_t clipper_gain_db10, makeup_left_db10, makeup_right_db10; esp_err_t ret = tas5805m_get_clipper_gain(&clipper_gain_db10, &makeup_left_db10, &makeup_right_db10); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get clipper gain"); } else { ESP_LOGI("TAS5805M", "Clipper gain: %d deci-dB, Makeup L: %d deci-dB, Makeup R: %d deci-dB", clipper_gain_db10, makeup_left_db10, makeup_right_db10); } ``` -------------------------------- ### Get EQ State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current EQ state (enabled or disabled). ```cpp bool eq_enabled; esp_err_t ret = tas5805m_get_eq(&eq_enabled); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get EQ state"); } else { ESP_LOGI("TAS5805M", "EQ state: %s", eq_enabled ? "Enabled" : "Disabled"); } ``` -------------------------------- ### Getting Automute State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the automute status for the right and left channels. ```cpp bool is_r_muted, is_l_muted; esp_err_t ret = tas5805m_get_automute_state(&is_r_muted, &is_l_muted); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get automute state"); } else { ESP_LOGI("TAS5805M", "Right automute: %s, Left automute: %s", is_r_muted ? "Muted" : "Unmuted", is_l_muted ? "Muted" : "Unmuted"); } ``` -------------------------------- ### Getting BCK Ratio Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current Bit Clock (BCK) ratio of the DAC. ```cpp uint8_t ratio; esp_err_t ret = tas5805m_get_bck_ratio(&ratio); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get BCK ratio"); } else { ESP_LOGI("TAS5805M", "BCK ratio: %d", ratio); } ``` -------------------------------- ### Get Volume (Percentage) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current volume set using the percentage scale. ```cpp uint8_t volume; esp_err_t ret = tas5805m_get_volume_pct(&volume); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get volume"); } else { ESP_LOGI("TAS5805M", "Current volume: %d", volume); } ``` -------------------------------- ### Get EQ Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current EQ mode (e.g., ganged, bi-amp). ```cpp TAS5805M_EQ_MODE eq_mode; esp_err_t ret = tas5805m_get_eq_mode(&eq_mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get EQ mode"); } else { ESP_LOGI("TAS5805M", "Current EQ mode: %d", eq_mode); } ``` -------------------------------- ### Getting EQ Gain for a Specific Channel Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Demonstrates how to retrieve the current EQ gain for a specific channel using the `tas5805m_get_eq_gain_channel` function. ```cpp TAS5805M_EQ_CHANNELS channel = TAS5805M_EQ_CHANNELS_LEFT; // or TAS5805M_EQ_CHANNELS_RIGHT int band = 3; // EQ band index int gain; esp_err_t ret = tas5805m_get_eq_gain_channel(channel, band, &gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get EQ gain for channel"); } else { ESP_LOGI("TAS5805M", "EQ gain for channel %d, band %d: %d", channel, band, gain); } ``` -------------------------------- ### Getting Power State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the precise power state of the DAC directly from the register. ```cpp TAS5805M_CTRL_STATE state; esp_err_t ret = tas5805m_get_power_state(&state); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get power state"); } else { ESP_LOGI("TAS5805M", "Power state: %d", state); } ``` -------------------------------- ### Setting Modulation Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Example of how to set the modulation mode, switching frequency, and digital filter frequency for the TAS5805M DAC. ```cpp TAS5805M_MOD_MODE mode = MOD_MODE_BD; TAS5805M_SW_FREQ freq = SW_FREQ_768K; TAS5805M_BD_FREQ bd_freq = SW_FREQ_80K; esp_err_t ret = tas5805m_set_modulation_mode(mode, freq, bd_freq); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set modulation mode"); } ``` -------------------------------- ### Get Automute State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the automute status for the left and right channels. ```cpp bool l_muted, r_muted; esp_err_t ret = tas5805m_get_automute_state(&r_muted, &l_muted); if (ret == ESP_OK) { printf("Automute - Left: %s, Right: %s\n", l_muted ? "Muted" : "Active", r_muted ? "Muted" : "Active"); } ``` -------------------------------- ### Get Fault States Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current fault states from the TAS5805M DAC. ```cpp TAS5805M_FAULT fault; esp_err_t ret = tas5805m_get_faults(&fault); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get fault states"); } else { ESP_LOGI("TAS5805M", "Fault states: err0=%d, err1=%d, err2=%d, ot_warn=%d", fault.err0, fault.err1, fault.err2, fault.ot_warn); } ``` -------------------------------- ### Get Volume (DAC Native Scale) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current volume set using the DAC's native scale. ```cpp uint8_t volume; esp_err_t ret = tas5805m_get_volume(&volume); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get volume"); } else { ESP_LOGI("TAS5805M", "Current volume: %d", volume); } ``` -------------------------------- ### Get EQ Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the current gain for a specific EQ band in ganged mode. ```cpp int band = 1; // EQ band int gain; esp_err_t ret = tas5805m_get_eq_gain(band, &gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to get EQ gain"); } else { ESP_LOGI("TAS5805M", "EQ gain for band %d: %d", band, gain); } ``` -------------------------------- ### Get Level Meter (Raw Value) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Extracts the raw 32-bit values for the left and right channel level meters. ```cpp uint32_t left, right; esp_err_t ret = tas5805m_get_level_meter(&left, &right); if (ret == ESP_OK) { printf("Level meter - Left: %u, Right: %u\n", left, right); } ``` -------------------------------- ### Get mixer gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Retrieves the mixer gain for a specific channel. The gain is a 32-bit integer in Q9.23 fixed-point format. ```cpp uint32_t gain_9_23; esp_err_t ret = tas5805m_get_mixer_gain(TAS5805M_MIXER_CHANNEL_LEFT_TO_LEFT, &gain_9_23); if (ret == ESP_OK) { ESP_LOGI(TAG, "Mixer gain for channel %d is 0x%08x, which is decimal %.2f", TAS5805M_MIXER_CHANNEL_LEFT_TO_LEFT, gain_9_23, tas5805m_q9_23_to_float(gain_9_23) ); } ``` -------------------------------- ### Get Level Meter (dB Value) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Converts the level meter values to deci-deci-bell (ddB) in the range of [-1200..0]. ```cpp uint32_t left_raw, right_raw; esp_err_t ret = tas5805m_get_level_meter(&left_raw, &right_raw); int32_t left_db = tas5805m_float_to_db10(tas5805m_q1_31_to_float(left_raw)); int32_t right_db = tas5805m_float_to_db10(tas5805m_q1_31_to_float(right_raw)); /* optionally trim if (left_db < -1200) left_db = -1200; if (right_db < -1200) right_db = -1200; if (left_db > 0) left_db = 0; if (right_db > 0) right_db = 0; */ int32_t left = left_db; int32_t right = right_db; ``` -------------------------------- ### Get Level Meter (Float Value) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Interprets the raw level meter values as float in the [0..1] range using helper functions. ```cpp uint32_t left_raw, right_raw; esp_err_t ret = tas5805m_get_level_meter(&left_raw, &right_raw); float left = tas5805m_q1_31_to_float(left_raw); float right = tas5805m_q1_31_to_float(right_raw); ``` -------------------------------- ### Setting EQ Profile Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Demonstrates how to set a specific EQ profile using the `Tas5805m.setEqProfile` method. ```cpp TAS5805M_EQ_PROFILE profile = LF_80HZ_CUTOFF; // For example, LF_80HZ Tas5805m.setEqProfile(profile); ``` -------------------------------- ### Clone the repository Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md This command clones the ESP32 TAS5805M DAC library repository from GitHub. ```sh git clone https://github.com/yourusername/esp32-tas5805m-dac.git ``` -------------------------------- ### Setting EQ Profile for a Specific Channel Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Illustrates how to set an EQ profile for an individual channel (left or right) using `tas5805m_set_eq_profile_channel`. ```cpp TAS5805M_EQ_CHANNELS channel = TAS5805M_EQ_CHANNELS_LEFT; // or TAS5805M_EQ_CHANNELS_RIGHT TAS5805M_EQ_PROFILE profile = LF_80HZ_CUTOFF; // Example profile esp_err_t ret = tas5805m_set_eq_profile_channel(channel, profile); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set EQ profile for channel"); } ``` -------------------------------- ### Include the library Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md This C++ include directive adds the TAS5805M DAC library to your project. ```cpp #include "tas5805m.h" ``` -------------------------------- ### Setting EQ Gain for a Specific Channel Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Demonstrates how to set the EQ gain for either the left or right channel using the `tas5805m_set_eq_gain_channel` function. ```cpp TAS5805M_EQ_CHANNELS channel = TAS5805M_EQ_CHANNELS_LEFT; // or TAS5805M_EQ_CHANNELS_RIGHT int band = 3; // EQ band index int gain = 7; // Gain value esp_err_t ret = tas5805m_set_eq_gain_channel(channel, band, gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set EQ gain for channel"); } ``` -------------------------------- ### Set Volume (Percentage) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the volume using a percentage scale (0-100%). Values up to 124 are accepted, but values above 100% may cause clipping. ```cpp uint8_t volume = 75; // Volume level (0-124) esp_err_t ret = tas5805m_set_volume_pct(volume); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set volume"); } ``` -------------------------------- ### Setting Clipper Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the soft clipping threshold and makeup gain for left and right channels. Gains are specified in deci-dB (10 = 1.0 dB). ```cpp int32_t clipper_gain_db10 = 30; // Soft clip threshold, e.g. 3.0 dB int32_t makeup_left_db10 = 20; // Makeup gain for left channel, e.g. 2.0 dB int32_t makeup_right_db10 = 20; // Makeup gain for right channel, e.g. 2.0 dB esp_err_t ret = tas5805m_set_clipper_gain(clipper_gain_db10, makeup_left_db10, makeup_right_db10); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set clipper gain"); } ``` -------------------------------- ### Set Volume (DAC Native Scale) Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the volume using the DAC's native scale (0-255). 0 is +24 dB gain, 255 is mute. ```cpp uint8_t volume = 80; // Volume level (0-255) esp_err_t ret = tas5805m_set_volume(volume); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set volume"); } ``` -------------------------------- ### Set EQ Mode Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the EQ mode, such as bi-amp mode. ```cpp TAS5805M_EQ_MODE eq_mode = TAS5805M_EQ_MODE_BIAMP; // Example: set to bi-amp mode esp_err_t ret = tas5805m_set_eq_mode(eq_mode); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set EQ mode"); } ``` -------------------------------- ### Set EQ State Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Enables or disables the EQ functionality. ```cpp bool eq_enabled = true; // Enable EQ esp_err_t ret = tas5805m_set_eq(eq_enabled); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set EQ state"); } ``` -------------------------------- ### Map Sample Rate Enum to String Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Converts the sample rate enum to a human-readable string. ```cpp TAS5805M_FS_FREQ freq; tas5805m_get_fs_freq(&freq); const char* freq_str = tas5805m_map_fs_freq(freq); // Example: "48K", "96K", etc. ``` -------------------------------- ### Set EQ Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the gain for a specific EQ band in ganged mode. ```cpp int band = 1; // EQ band int gain = 5; // Gain level esp_err_t ret = tas5805m_set_eq_gain(band, gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set EQ gain"); } ``` -------------------------------- ### Map Amplifier State to String Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Converts the internal amplifier state enum to a human-readable string. ```cpp TAS5805M_CTRL_STATE state; tas5805m_get_state(&state); const char* state_str = tas5805m_map_amp_state(state); // Example: "PLAY", "MUTE", etc. ``` -------------------------------- ### Set Analog Gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the analog gain in 0.5 dB steps. The input value is in an inverted scale [0..31] representing 0 dB to -15.5 dB. ```cpp uint8_t gain = 10; // Gain level of -5 Db esp_err_t ret = tas5805m_set_again(gain); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to set analog gain"); } ``` -------------------------------- ### Decode Fault Errors Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Decodes fault errors from the TAS5805M DAC. ```cpp TAS5805M_FAULT fault = { .err0 = 1, .err1 = 0, .err2 = 0, .ot_warn = 1 }; tas5805m_decode_faults(fault); ``` -------------------------------- ### Clear Fault States Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Clears any existing fault states on the TAS5805M DAC. ```cpp esp_err_t ret = tas5805m_clear_faults(); if (ret != ESP_OK) { ESP_LOGE("TAS5805M", "Failed to clear fault states"); } ``` -------------------------------- ### Set mixer gain Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md Sets the mixer gain for a specific channel. The gain value is converted from float to Q9.23 fixed-point format. ```cpp float gain = 2; // +6Db uint32_t gain_9_23 = tas5805m_float_to_q9_23(gain); // Q9.23 format esp_err_t ret = tas5805m_set_mixer_gain(TAS5805M_MIXER_CHANNEL_LEFT_TO_LEFT, gain_9_23); ``` -------------------------------- ### Check and Clear Fault States Source: https://github.com/sonocotta/esp32-tas5805m-dac/blob/main/README.md This function periodically checks the fault registers of the TAS5805M DAC, logs the current state, and clears any detected faults. ```cpp static void checkFaults() { TAS5805M_FS_FREQ freq; uint8_t ratio; Tas5805m.getFsFreq(&freq); Tas5805m.getBckRatio(&ratio); TAS5805M_CTRL_STATE state; Tas5805m.getPowerState(&state); bool is_r_muted, is_l_muted; Tas5805m.getAutomuteState(&is_r_muted, &is_l_muted); ESP_LOGI(TAG, "FS Frequency: %s, BCK ratio: %d; Power state: %s; Automute: R: %d, L: %d", tas5805m_map_fs_freq(freq), ratio, tas5805m_map_amp_state(state), is_r_muted, is_l_muted ); TAS5805M_FAULT fault; Tas5805m.getFaultState(&fault); Tas5805m.decodeFaults(fault); if (fault.err0 || fault.err1 || fault.err2 || fault.ot_warn) { ESP_LOGI(TAG, "Clearing fault states"); Tas5805m.clearFaultState(); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.