@@ -79,9 +79,9 @@ int get_audio_volume() {
7979
8080static esp_err_t i2s_driver_init (void )
8181{
82- printf (" initializing i2s driver...\n " );
82+ fmt::print (" initializing i2s driver...\n " );
8383 auto ret_val = ESP_OK;
84- printf (" Using newer I2S standard\n " );
84+ fmt::print (" Using newer I2S standard\n " );
8585 i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG (i2s_port, I2S_ROLE_MASTER);
8686 chan_cfg.auto_clear = true ; // Auto clear the legacy data in the DMA buffer
8787 ESP_ERROR_CHECK (i2s_new_channel (&chan_cfg, &tx_handle, &rx_handle));
@@ -114,7 +114,7 @@ static esp_err_t i2s_driver_init(void)
114114// es7210 is for audio input codec
115115static esp_err_t es7210_init_default (void )
116116{
117- printf (" initializing es7210 codec...\n " );
117+ fmt::print (" initializing es7210 codec...\n " );
118118 esp_err_t ret_val = ESP_OK;
119119 audio_hal_codec_config_t cfg;
120120 memset (&cfg, 0 , sizeof (cfg));
@@ -131,7 +131,7 @@ static esp_err_t es7210_init_default(void)
131131 ret_val |= es7210_adc_ctrl_state (cfg.codec_mode , AUDIO_HAL_CTRL_START);
132132
133133 if (ESP_OK != ret_val) {
134- printf (" Failed initialize codec\n " );
134+ fmt::print (" Failed initialize codec\n " );
135135 }
136136
137137 return ret_val;
@@ -140,7 +140,7 @@ static esp_err_t es7210_init_default(void)
140140// es8311 is for audio output codec
141141static esp_err_t es8311_init_default (void )
142142{
143- printf (" initializing es8311 codec...\n " );
143+ fmt::print (" initializing es8311 codec...\n " );
144144 esp_err_t ret_val = ESP_OK;
145145 audio_hal_codec_config_t cfg;
146146 memset (&cfg, 0 , sizeof (cfg));
@@ -158,7 +158,7 @@ static esp_err_t es8311_init_default(void)
158158 ret_val |= es8311_codec_ctrl_state (cfg.codec_mode , AUDIO_HAL_CTRL_START);
159159
160160 if (ESP_OK != ret_val) {
161- printf (" Failed initialize codec\n " );
161+ fmt::print (" Failed initialize codec\n " );
162162 }
163163
164164 return ret_val;
@@ -212,10 +212,10 @@ static void init_mute_button(void) {
212212 .callback = [](auto &m, auto &cv) -> bool {
213213 static gpio_num_t io_num;
214214 if (xQueueReceive (gpio_evt_queue, &io_num, portMAX_DELAY)) {
215- // invert the state since these are active low switches
216- bool pressed = !gpio_get_level (io_num);
217215 // see if it's the mute button
218216 if (io_num == mute_pin) {
217+ // invert the state since these are active low switches
218+ bool pressed = !gpio_get_level (io_num);
219219 // NOTE: the MUTE is actually connected to a flip-flop which holds
220220 // state, so pressing it actually toggles the state that we see on
221221 // the ESP pin. Therefore, when we get an edge trigger, we should
@@ -251,7 +251,7 @@ void audio_init() {
251251
252252 /* Checko IO config result */
253253 if (ESP_OK != bsp_io_config_state) {
254- printf (" Failed initialize power control IO\n " );
254+ fmt::print (" Failed initialize power control IO\n " );
255255 }
256256
257257 gpio_set_level (sound_power_pin, 1 );
@@ -282,9 +282,9 @@ void audio_play_frame(uint8_t *data, uint32_t num_bytes) {
282282 auto err = ESP_OK;
283283 err = i2s_channel_write (tx_handle, data, num_bytes, &bytes_written, 1000 );
284284 if (num_bytes != bytes_written) {
285- printf (" ERROR to write %ld != written %d \n " , num_bytes, bytes_written);
285+ fmt::print (" ERROR to write {} != written {} \n " , num_bytes, bytes_written);
286286 }
287287 if (err != ESP_OK) {
288- printf (" ERROR writing i2s channel: %d , '%s '\n " , err, esp_err_to_name (err));
288+ fmt::print (" ERROR writing i2s channel: {} , '{} '\n " , err, esp_err_to_name (err));
289289 }
290290}
0 commit comments