diff --git a/components/badge23/audio.c b/components/badge23/audio.c index d964cc734bf063fff387728807cb0188a5923e20..c0faa76e116cb398077c4afb9a4c05e06c172c7c 100644 --- a/components/badge23/audio.c +++ b/components/badge23/audio.c @@ -100,6 +100,10 @@ static esp_err_t max98091_i2c_write_readback(const uint8_t reg, const uint8_t da return ret; } +void audio_codec_i2c_write(const uint8_t reg, const uint8_t data) { + max98091_i2c_write_readback(reg, data); +} + void audio_headphones_line_in_set_hardware_thru(bool enable){ max98091_i2c_write_readback(0x2B, (1<<5) | (1<<4)); // Enable Headphone Mixer uint8_t trust_issue = enable ? 1 : 0; diff --git a/components/badge23/include/badge23/audio.h b/components/badge23/include/badge23/audio.h index f4182d2cb78b930801ff6222fc6971f16452e697..06f52ee2820109107d00bc1ccf2669dc303c7ba0 100644 --- a/components/badge23/include/badge23/audio.h +++ b/components/badge23/include/badge23/audio.h @@ -163,6 +163,8 @@ float audio_input_thru_get_volume_dB(); void audio_input_thru_set_mute(bool mute); bool audio_input_thru_get_mute(); +/* For when you need to add violence */ +void audio_codec_i2c_write(const uint8_t reg, const uint8_t data); /* HEADPHONE PORT POLICY diff --git a/usermodule/mp_audio.c b/usermodule/mp_audio.c index 145216b211bde2992d23850faac569af9419c8ab..8ecaf0af3487f43a6b6b43066860de977966004c 100644 --- a/usermodule/mp_audio.c +++ b/usermodule/mp_audio.c @@ -250,6 +250,15 @@ STATIC mp_obj_t mp_input_thru_get_mute() { STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_input_thru_get_mute_obj, mp_input_thru_get_mute); +STATIC mp_obj_t mp_codec_i2c_write(mp_obj_t reg_in, mp_obj_t data_in) { + uint8_t reg = mp_obj_get_int(reg_in); + uint8_t data = mp_obj_get_int(data_in); + audio_codec_i2c_write(reg, data); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_codec_i2c_write_obj, mp_codec_i2c_write); + + STATIC const mp_rom_map_elem_t mp_module_audio_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audio) }, @@ -306,6 +315,8 @@ STATIC const mp_rom_map_elem_t mp_module_audio_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_input_thru_set_mute), MP_ROM_PTR(&mp_input_thru_set_mute_obj) }, { MP_ROM_QSTR(MP_QSTR_input_thru_get_mute), MP_ROM_PTR(&mp_input_thru_get_mute_obj) }, + { MP_ROM_QSTR(MP_QSTR_codec_i2c_write), MP_ROM_PTR(&mp_codec_i2c_write_obj) }, + { MP_ROM_QSTR(MP_QSTR_INPUT_SOURCE_NONE), MP_ROM_INT(AUDIO_INPUT_SOURCE_NONE) }, { MP_ROM_QSTR(MP_QSTR_INPUT_SOURCE_LINE_IN), MP_ROM_INT(AUDIO_INPUT_SOURCE_LINE_IN) }, { MP_ROM_QSTR(MP_QSTR_INPUT_SOURCE_HEADSET_MIC), MP_ROM_INT(AUDIO_INPUT_SOURCE_HEADSET_MIC) },