4 #ifndef __M5UNIFIED_HPP__
5 #define __M5UNIFIED_HPP__
9 #if __has_include(<sdkconfig.h>)
10 #include <sdkconfig.h>
73 #if defined ( ARDUINO )
76 uint32_t serial_baudrate = 115200;
147 #if defined (CONFIG_IDF_TARGET_ESP32S3)
148 = board_t::board_M5AtomS3Lite;
149 #elif defined (CONFIG_IDF_TARGET_ESP32C3)
150 = board_t::board_M5StampC3;
151 #elif defined (CONFIG_IDF_TARGET_ESP32) || !defined (CONFIG_IDF_TARGET)
152 = board_t::board_M5Atom;
154 = board_t::board_unknown;
160 [[deprecated(
"Change to external_speaker")]]
170 #if defined ( __M5GFX_M5ATOMDISPLAY__ )
173 #if defined ( __M5GFX_M5MODULEDISPLAY__ )
176 #if defined ( __M5GFX_M5MODULERCA__ )
179 #if defined ( __M5GFX_M5UNITGLASS__ )
182 #if defined ( __M5GFX_M5UNITGLASS2__ )
185 #if defined ( __M5GFX_M5UNITOLED__ )
188 #if defined ( __M5GFX_M5UNITMINIOLED__ )
191 #if defined ( __M5GFX_M5UNITLCD__ )
194 #if defined ( __M5GFX_M5UNITRCA__ )
249 int32_t
getDisplayIndex(std::initializer_list<m5gfx::board_t> board_list);
276 static inline void delay(uint32_t msec)
278 #if defined (ESP_PLATFORM)
279 vTaskDelay( msec / portTICK_PERIOD_MS );
287 return m5gfx::millis();
292 return m5gfx::micros();
305 if (_board != m5gfx::board_t::board_unknown) {
return; }
314 if (_board != m5gfx::board_t::board_unknown) {
return; }
316 #if defined ( CONFIG_IDF_TARGET_ESP32S3 )
318 m5gfx::gpio_hi(GPIO_NUM_46);
319 m5gfx::pinMode(GPIO_NUM_46, m5gfx::pin_mode_t::output);
322 auto brightness =
Display.getBrightness();
324 bool res =
Display.init_without_reset();
325 auto board = _check_boardtype(
Display.getBoard());
326 if (board == board_t::board_unknown) { board = cfg.
fallback_board; }
328 _setup_pinmap(board);
334 #if defined ( __M5GFX_M5ATOMDISPLAY__ )
335 #if !defined (CONFIG_IDF_TARGET) || defined (CONFIG_IDF_TARGET_ESP32) || defined (CONFIG_IDF_TARGET_ESP32S3)
337 if (_board == board_t::board_M5Atom || _board == board_t::board_M5AtomPsram || _board == board_t::board_M5AtomS3 || _board == board_t::board_M5AtomS3Lite)
340 if (dsp.init_without_reset()) {
352 #if defined ( __M5GFX_M5MODULEDISPLAY__ )
353 #if !defined (CONFIG_IDF_TARGET) || defined (CONFIG_IDF_TARGET_ESP32) || defined (CONFIG_IDF_TARGET_ESP32S3)
355 if (_board == board_t::board_M5Stack || _board == board_t::board_M5StackCore2 || _board == board_t::board_M5Tough || _board == board_t::board_M5StackCoreS3)
369 bool port_a_used = _begin_rtc_imu(cfg);
374 #if defined ( __M5GFX_M5UNITOLED__ )
377 #if defined (ESP_PLATFORM)
391 #if defined ( __M5GFX_M5UNITMINIOLED__ )
394 #if defined (ESP_PLATFORM)
408 #if defined ( __M5GFX_M5UNITGLASS__ )
411 #if defined (ESP_PLATFORM)
425 #if defined ( __M5GFX_M5UNITGLASS2__ )
428 #if defined (ESP_PLATFORM)
442 #if defined ( __M5GFX_M5UNITLCD__ )
445 #if defined (ESP_PLATFORM)
465 #if !defined (CONFIG_IDF_TARGET) || defined (CONFIG_IDF_TARGET_ESP32)
466 #if defined ( __M5GFX_M5MODULERCA__ ) || defined ( __M5GFX_M5UNITRCA__ )
470 #if defined ( __M5GFX_M5MODULERCA__ )
473 if (board == board_t::board_M5Stack
474 || board == board_t::board_M5StackCore2
475 || board == board_t::board_M5Tough
486 #if defined ( __M5GFX_M5UNITRCA__ )
489 if ( board == board_t::board_M5Stack
490 || board == board_t::board_M5StackCore2
491 || board == board_t::board_M5Paper
492 || board == board_t::board_M5Tough
493 || board == board_t::board_M5Station
494 || (!port_a_used && (
495 board == board_t::board_M5Atom
496 || board == board_t::board_M5AtomPsram
497 || board == board_t::board_M5AtomU
512 if (
Display.getBoard() != board_t::board_unknown)
514 Display.setBrightness(brightness);
521 static constexpr std::size_t BTNPWR_MIN_UPDATE_MSEC = 4;
523 std::vector<M5GFX> _displays;
524 std::uint32_t _updateMsec = 0;
527 std::uint8_t _primary_display_index = -1;
528 bool use_pmic_button =
false;
529 bool use_hat_spk =
false;
531 void _begin(
const config_t& cfg);
532 void _begin_spk(config_t& cfg);
533 bool _begin_rtc_imu(
const config_t& cfg);
538 static void _setup_pinmap(
board_t);
539 static bool _speaker_enabled_cb(
void* args,
bool enabled);
540 static bool _microphone_enabled_cb(
void* args,
bool enabled);
m5::M5Unified M5
global instance.
int8_t getSDA(void) const
int8_t getSCL(void) const
i2c_port_t getPort(void) const
void begin(void)
Perform initialization process at startup.
bool setPrimaryDisplayType(std::initializer_list< m5gfx::board_t > board_list)
void setLogDisplayIndex(size_t index)
Set the display to show logs.
std::uint32_t getUpdateMsec(void) const
milli seconds at the time the update was called
I2C_Class & Ex_I2C
for external I2C device (Port.A)
void setLogDisplayType(std::initializer_list< m5gfx::board_t > board_list)
board_t getBoard(void) const
static config_t config(void)
std::size_t addDisplay(M5GFX &dsp)
M5GFX & Displays(size_t index)
M5GFX & getDisplay(size_t index)
std::size_t getDisplayCount(void) const
void update(void)
To call this function in a loop function.
static void delay(uint32_t msec)
void setLogDisplayType(m5gfx::board_t board)
bool setPrimaryDisplay(std::size_t index)
static int8_t getPin(pin_name_t name)
I2C_Class & In_I2C
for internal I2C device
static uint32_t micros(void)
int32_t getDisplayIndex(m5gfx::board_t board)
void begin(config_t cfg)
Perform initialization process at startup.
bool setPrimaryDisplayType(m5gfx::board_t board)
static uint32_t millis(void)
I2C_Class Ex_I2C
for external I2C device
Touch_Class::touch_detail_t touch_detail_t
m5gfx::touch_point_t touch_point_t
I2C_Class In_I2C
for internal I2C device
struct m5::M5Unified::config_t::@4::@8 external_spk_detail
uint16_t external_display_value
bool external_imu
use Unit Accel & Gyro.
bool internal_mic
use the microphone.
uint8_t led_brightness
system LED brightness (0=off / 255=max) (※ not RGBcolorLED)
bool output_power
5V output to external port.
bool internal_spk
use the speaker.
bool disable_rtc_irq
Turn off the IRQ bit of the RTC at startup.
struct m5::M5Unified::config_t::@0::@6 external_speaker
bool internal_rtc
use internal RTC.
bool pmic_button
use PMIC(AXP192) pek for M5.BtnPWR.
uint8_t external_speaker_value
bool internal_imu
use internal IMU.
bool clear_display
Clear the screen when startup.
bool external_rtc
use Unit RTC.
board_t fallback_board
If auto-detection fails, the board will operate as the board configured here.
struct m5::M5Unified::config_t::@2::@7 external_display