From 5928e7cb07a84d3382aad810adae4449caf25229 Mon Sep 17 00:00:00 2001 From: Tinyu Date: Fri, 17 Jul 2026 18:31:54 +0800 Subject: [PATCH] Add Paper Mono microphone power support --- src/M5Unified.cpp | 24 ++++++++++++++++++++++++ src/M5Unified.hpp | 1 + 2 files changed, 25 insertions(+) diff --git a/src/M5Unified.cpp b/src/M5Unified.cpp index 2e1d675..7458a43 100644 --- a/src/M5Unified.cpp +++ b/src/M5Unified.cpp @@ -1051,6 +1051,29 @@ static constexpr const uint8_t _pin_table_mbus[][31] = { return true; } + bool M5Unified::_microphone_enabled_cb_papermono(void* args, bool enabled) + { +#if defined (CONFIG_IDF_TARGET_ESP32S3) + auto self = (M5Unified*)args; + auto& ioe1 = self->getIOExpander(0); + bool result = true; + if (enabled) + { + // The factory firmware enables PM1 BOOST before powering the PDM mic. + result = self->Power.M5pm1.setExtOutput(true); + } + // M5IOE1 GPIO12 is the Paper Mono PDM microphone power enable. + ioe1.setHighImpedance(M5IOE1_Class::gpio12, false); + ioe1.setDirection(M5IOE1_Class::gpio12, true); + ioe1.digitalWrite(M5IOE1_Class::gpio12, enabled); + return result; +#else + (void)args; + (void)enabled; +#endif + return true; + } + bool M5Unified::_microphone_enabled_cb_stopwatch(void* args, bool enabled) { @@ -2213,6 +2236,7 @@ static constexpr const uint8_t _pin_table_mbus[][31] = { { /// builtin PDM mic mic_cfg.pin_ws = GPIO_NUM_45; mic_cfg.pin_data_in = GPIO_NUM_46; + mic_enable_cb = _microphone_enabled_cb_papermono; } break; diff --git a/src/M5Unified.hpp b/src/M5Unified.hpp index 03fa01d..093f364 100644 --- a/src/M5Unified.hpp +++ b/src/M5Unified.hpp @@ -670,6 +670,7 @@ namespace m5 static bool _microphone_enabled_cb_stickc(void* args, bool enabled); static bool _microphone_enabled_cb_sticks3(void* args, bool enabled); static bool _microphone_enabled_cb_papercolor(void* args, bool enabled); + static bool _microphone_enabled_cb_papermono(void* args, bool enabled); static bool _microphone_enabled_cb_stopwatch(void* args, bool enabled); static bool _microphone_enabled_cb_chain_captain(void* args, bool enabled); static bool _microphone_enabled_cb_tab5(void* args, bool enabled);