19 {PCM1863_REG_PAGE, PCM1863_PAGE_0},
20 {PCM1863_REG_POWER_CTRL, PCM1863_PWR_CTRL_RSV},
23void PCM1863::dump_config() {
25 "PCM1863 audio ADC:\n"
26 " Bits Per Sample: %s\n"
30 LOG_STR_ARG(InputStrings::get_log_str(this->
input_, 0)), this->
mic_gain_);
31#ifdef USE_PCM1863_SELECT
32 LOG_SELECT(
" ",
"Input", this->input_select_);
48#ifdef USE_PCM1863_SELECT
50 PUBLISH_STATE(this->input_select_, this->
input_);
54bool PCM1863::set_mic_gain(
float mic_gain) {
58 this->
mic_gain_ = clamp<float>(mic_gain, PCM1863_MIC_GAIN_MIN, PCM1863_MIC_GAIN_MAX);
66 const auto reg_val =
static_cast<uint8_t
>(lroundf(this->
mic_gain_ / PCM1863_MIC_GAIN_STEP));
67 return this->
write_byte(PCM1863_REG_PGA_VAL_CH1_L, reg_val) && this->
write_byte(PCM1863_REG_PGA_VAL_CH1_R, reg_val);
82 const uint8_t reg_val = PCM1863_INPUT_SEL_RSV | mux;
83 return this->
write_byte(PCM1863_REG_ADC1_INPUT_SEL_L, reg_val) &&
84 this->
write_byte(PCM1863_REG_ADC1_INPUT_SEL_R, reg_val);
89 const uint8_t reg_val =
90 (wlen << PCM1863_PCM_CFG_RX_WLEN_SHIFT) | (wlen << PCM1863_PCM_CFG_TX_WLEN_SHIFT) | PCM1863_PCM_CFG_FMT_I2S;
91 return this->
write_byte(PCM1863_REG_PCM_CFG, reg_val);
virtual void setup()
Where the component's initialization should happen.
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
bool write_byte(uint8_t a_register, uint8_t data) const
bool write_registers(const I2CRegValue *table, size_t count) const
Write each register and value of table in order, stopping at the first failure.
bool configure_mic_gain_()
PCM1863BitsPerSample bits_per_sample_
bool configure_i2s_format_()
PROGMEM_STRING_TABLE(BitsPerSampleStrings, "32", "24", "20", "16")
ESPHOME_LOG_TAG(TAG, "pcm1863")
void HOT delay(uint32_t ms)
One register write for I2CDevice::write_registers(); tables of these may live in PROGMEM.