diff --git a/docs/api/audio.rst b/docs/api/audio.rst index c96ebffd57fedf49417d80d7281f970a5d5d8c7d..41e835065b070b92718e42ee9c79b54f7e5d87d9 100644 --- a/docs/api/audio.rst +++ b/docs/api/audio.rst @@ -97,6 +97,50 @@ the "headphone" variant is chosen, else the "speaker" variant is chosen. :code:`audio_{headphones_/speaker_/}set_{maximum/minimum}_volume_` and 0 if in a fake mute condition. +.. py:function:: headphones_line_in_set_hardware_thru(enable : bool) +.. py:function:: speaker_line_in_set_hardware_thru(enable : bool) +.. py:function:: line_in_set_hardware_thru(enable : bool) + + These route whatever is on the line in port directly to the headphones or + speaker respectively (enable = 1), or don't (enable = 0). Is affected by mute + and coarse hardware volume settings, however software fine volume is not + applied. + + Good for testing, might deprecate later, idk~ + +.. py:function:: input_set_source(source : int) +.. py:function:: input_get_source() -> int + + The codec can transmit audio data from different sources. This function + enables one or no source as provided by the ``INPUT_SOURCE_*`` constants. + + Note: The onboard digital mic turns on an LED on the top board if it receives + a clock signal which is considered a good proxy for its capability of reading + data. + +.. py:data:: INPUT_SOURCE_NONE +.. py:data:: INPUT_SOURCE_LINE_IN +.. py:data:: INPUT_SOURCE_HEADSET_MIC +.. py:data:: INPUT_SOURCE_ONBOARD_MIC + +.. py:function:: headset_set_gain_dB(gain_dB : int) +.. py:function:: headset_get_gain_dB() -> int + + Hardware preamp gain, 0dB-50dB. TODO: figure out if int/float inconsistency + is a good thing here compared to all other _dB functions. + +.. py:function:: input_thru_set_volume_dB(vol_dB : float) +.. py:function:: input_thru_get_volume_dB() -> float +.. py:function:: input_thru_set_mute(mute : bool) +.. py:function:: input_thru_get_mute() -> bool + + You can route whatever source is selected with input_set_source() to + the audio output. Use these to control volume and mute. + +.. py:function:: codec_i2c_write(reg : int, data : int) + + Write audio codec register. Obviously very unsafe. Have fun. + Headphone port policy --------------------- diff --git a/usermodule/mp_audio.c b/usermodule/mp_audio.c index 00844616091e38f2aec2e1687d1ff6baac543aec..dc44a04d80499c1500d0f38825478847495ec6cc 100644 --- a/usermodule/mp_audio.c +++ b/usermodule/mp_audio.c @@ -215,7 +215,7 @@ STATIC mp_obj_t mp_line_in_set_hardware_thru(mp_obj_t enable) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_line_in_set_hardware_thru_obj, mp_line_in_set_hardware_thru); -STATIC mp_obj_t mp_input_set_source(mp_obj_t enable) { +STATIC mp_obj_t mp_input_set_source(mp_obj_t source) { st3m_audio_input_set_source(mp_obj_get_int(enable)); return mp_const_none; }