From a0eaa70ff4720386e3c57960516221bfcc1d3443 Mon Sep 17 00:00:00 2001 From: zhang00963 <14372128+zhang00963@users.noreply.github.com> Date: Sun, 11 Apr 2021 02:19:31 +0800 Subject: [PATCH] Realize the automatic recognition of audio chip, including ak4951en/wm8731/wm8731s,Try to fix the max2837 temperature problem --- firmware/application/apps/ui_debug.cpp | 3 ++- firmware/application/portapack.cpp | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/firmware/application/apps/ui_debug.cpp b/firmware/application/apps/ui_debug.cpp index 8622911c9..2bec78fae 100644 --- a/firmware/application/apps/ui_debug.cpp +++ b/firmware/application/apps/ui_debug.cpp @@ -121,7 +121,8 @@ void TemperatureWidget::paint(Painter& painter) { } TemperatureWidget::temperature_t TemperatureWidget::temperature(const sample_t sensor_value) const { - return -35 + sensor_value * 4; //max2837 datasheet temp 25ºC has sensor value: 15 + /*It seems to be a temperature difference of 25C*/ + return -40 +(sensor_value * 4.31)+25; //max2837 datasheet temp 25ºC has sensor value: 15 } std::string TemperatureWidget::temperature_str(const temperature_t temperature) const { diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index 99843aec3..44fc1db74 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -179,20 +179,23 @@ static PortaPackModel portapack_model() { static Optional model; if( !model.is_valid() ) { - if( audio_codec_wm8731.detected() ) { - model = PortaPackModel::R1_20150901; - } else { + /*For the time being, it is impossible to distinguish the hardware of R1 and R2 from the software level*/ + /*At this point, I2c is not ready.*/ + //if( audio_codec_wm8731.detected() ) { + // model = PortaPackModel::R1_20150901; + //} else { model = PortaPackModel::R2_20170522; - } + //} } return model.value(); } static audio::Codec* portapack_audio_codec() { - return (portapack_model() == PortaPackModel::R2_20170522) - ? static_cast(&audio_codec_ak4951) - : static_cast(&audio_codec_wm8731) + /* I2C ready OK, Automatic recognition of audio chip */ + return (audio_codec_wm8731.detected()) + ? static_cast(&audio_codec_wm8731) + : static_cast(&audio_codec_ak4951) ; }