From 546c2b31168e927f5ed20c454d9917256c734cad Mon Sep 17 00:00:00 2001 From: Tinyu Date: Wed, 17 Jun 2026 09:44:36 +0800 Subject: [PATCH] Add Unit PoEP4 HDMI. --- examples/Basic/Displays/Displays.ino | 21 +++++++++++++++++++-- examples/Basic/HowToUse/HowToUse.ino | 17 +++++++++++++++++ src/M5Unified.hpp | 20 ++++++++++++++++++-- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/examples/Basic/Displays/Displays.ino b/examples/Basic/Displays/Displays.ino index 0093ddf..da40830 100644 --- a/examples/Basic/Displays/Displays.ino +++ b/examples/Basic/Displays/Displays.ino @@ -42,6 +42,9 @@ // If you use UnitRCA (for Video output), write this. #include +// If you use AddOn Display Out For PoE-P4, write this. +#include + // * The display header must be included before the M5Unified library. //---------------------------------------------------------------- @@ -64,7 +67,7 @@ void setup(void) cfg.external_display.unit_lcd = false; // default=true. use UnitLCD cfg.external_display.unit_rca = false; // default=true. use UnitRCA VideoOutput cfg.external_display.module_rca = false; // default=true. use ModuleRCA VideoOutput - + cfg.external_display.unit_poep4_hdmi = false; // default=true. use AddOn Display Out For PoE-P4 /* ※ Unit OLED, Unit Mini OLED, Unit GLASS2 cannot be distinguished at runtime and may be misidentified as each other. @@ -163,6 +166,16 @@ void setup(void) // cfg.unit_lcd.i2c_addr = 0x3E; // cfg.unit_lcd.i2c_freq = 400000; // cfg.unit_lcd.i2c_port = I2C_NUM_0; +#endif +#if defined ( __M5GFX_M5UNITPOEP4HDMI__ ) // setting for AddOn Display Out For PoE-P4. +// Supported timings only. Choose one of the following two modes: +cfg.unit_poep4_hdmi.width = 1280; +cfg.unit_poep4_hdmi.height = 720; +cfg.unit_poep4_hdmi.refresh_rate = 60; + +// cfg.unit_poep4_hdmi.width = 1920; +// cfg.unit_poep4_hdmi.height = 1080; +// cfg.unit_poep4_hdmi.refresh_rate = 30; #endif @@ -194,6 +207,7 @@ void setup(void) // m5::board_t::board_M5UnitOLED, // m5::board_t::board_M5UnitLCD, // m5::board_t::board_M5UnitRCA, +// m5::board_t::board_M5UnitPoEP4HDMI } ); @@ -211,7 +225,7 @@ void setup(void) int index_unit_mini_oled = M5.getDisplayIndex(m5::board_t::board_M5UnitMiniOLED); int index_unit_lcd = M5.getDisplayIndex(m5::board_t::board_M5UnitLCD); int index_unit_rca = M5.getDisplayIndex(m5::board_t::board_M5UnitRCA); - + int index_unit_poep4_hdmi = M5.getDisplayIndex(m5::board_t::board_M5UnitPoEP4HDMI); if (index_module_display >= 0) { M5.Displays(index_module_display).print("This is Module Display\n"); } @@ -239,6 +253,9 @@ void setup(void) if (index_unit_rca >= 0) { M5.Displays(index_unit_rca).print("This is Unit RCA\n"); } + if (index_unit_poep4_hdmi >= 0) { + M5.Displays(index_unit_poep4_hdmi).print("This is Unit PoE-P4 HDMI\n"); + } M5.delay(5000); } diff --git a/examples/Basic/HowToUse/HowToUse.ino b/examples/Basic/HowToUse/HowToUse.ino index 63c0f94..aff6870 100644 --- a/examples/Basic/HowToUse/HowToUse.ino +++ b/examples/Basic/HowToUse/HowToUse.ino @@ -49,6 +49,9 @@ // If you use UnitRCA (for Video output), write this. #include +// If you use AddOn Display Out For PoE-P4, write this. +#include + // * The display header must be included before the M5Unified library. //---------------------------------------------------------------- @@ -101,6 +104,7 @@ void setup(void) cfg.external_display.unit_lcd = false; // default=true. use UnitLCD cfg.external_display.unit_rca = false; // default=true. use UnitRCA VideoOutput cfg.external_display.module_rca = false; // default=true. use ModuleRCA VideoOutput + cfg.external_display.unit_poep4_hdmi = false; // default=true. use AddOn Display Out For PoE-P4 /* ※ Unit OLED, Unit Mini OLED, Unit GLASS2 cannot be distinguished at runtime and may be misidentified as each other. @@ -112,6 +116,7 @@ void setup(void) - unit_oled - unit_mini_oled - unit_lcd + - unit_poep4_hdmi ※ Displays that cannot be auto-detected - module_rca @@ -180,6 +185,16 @@ void setup(void) // cfg.unit_lcd.i2c_addr = 0x3E; // cfg.unit_lcd.i2c_freq = 400000; // cfg.unit_lcd.i2c_port = I2C_NUM_0; +#endif +#if defined ( __M5GFX_M5UNITPOEP4HDMI__ ) // setting for AddOn Display Out For PoE-P4. +// Supported timings only. Choose one of the following two modes: +// cfg.unit_poep4_hdmi.width = 1280; +// cfg.unit_poep4_hdmi.height = 720; +// cfg.unit_poep4_hdmi.refresh_rate = 60; + +// cfg.unit_poep4_hdmi.width = 1920; +// cfg.unit_poep4_hdmi.height = 1080; +// cfg.unit_poep4_hdmi.refresh_rate = 30; #endif // begin M5Unified. @@ -197,6 +212,7 @@ void setup(void) // m5::board_t::board_M5UnitOLED, // m5::board_t::board_M5UnitLCD, // m5::board_t::board_M5UnitRCA, +// m5::board_t::board_M5UnitPoEP4HDMI, } ); if (M5.Speaker.isEnabled()) @@ -298,6 +314,7 @@ void setup(void) case m5::board_t::board_NanoH2: name = "NanoH2"; break; #elif defined (CONFIG_IDF_TARGET_ESP32P4) case m5::board_t::board_M5Tab5: name = "Tab5"; break; + case m5::board_t::board_M5UnitPoEP4: name = "UnitPoEP4"; break; #else case m5::board_t::board_M5Stack: name = "Stack"; break; case m5::board_t::board_M5StackCore2: name = "StackCore2"; break; diff --git a/src/M5Unified.hpp b/src/M5Unified.hpp index 3ac7b82..791aaca 100644 --- a/src/M5Unified.hpp +++ b/src/M5Unified.hpp @@ -120,7 +120,8 @@ namespace m5 uint16_t unit_glass2 : 1; uint16_t unit_rca : 1; uint16_t module_rca : 1; - uint16_t reserve : 7; + uint16_t unit_poep4_hdmi : 1; + uint16_t reserve : 6; } external_display; uint16_t external_display_value = 0xFFFF; }; @@ -209,6 +210,9 @@ namespace m5 #if defined ( __M5GFX_M5UNITLCD__ ) M5UnitLCD::config_t unit_lcd; #endif +#if defined ( __M5GFX_M5UNITPOEP4HDMI__ ) + M5UnitPoEP4HDMI::config_t unit_poep4_hdmi; +#endif #if defined ( __M5GFX_M5UNITRCA__ ) M5UnitRCA::config_t unit_rca; #endif @@ -382,6 +386,18 @@ namespace m5 _begin(cfg); + // Unit PoEP4 has no built-in LCD; attach its LT8912B HDMI output as a board display. +#if defined ( __M5GFX_M5UNITPOEP4HDMI__ ) + if (cfg.external_display.unit_poep4_hdmi && _board == board_t::board_M5UnitPoEP4 && getDisplayCount() == 0) + { + M5UnitPoEP4HDMI dsp(cfg.unit_poep4_hdmi); + dsp.setI2C(&In_I2C); + if (cfg.clear_display ? dsp.init() : dsp.init_without_reset(false)) { + addDisplay(dsp); + } + } +#endif + // Module Display / Unit OLED / Unit LCD is determined after _begin (because it must be after external power supply) #if defined ( __M5GFX_M5MODULEDISPLAY__ ) if (cfg.external_display.module_display) { @@ -663,4 +679,4 @@ namespace m5 extern m5::M5Unified M5; -#endif \ No newline at end of file +#endif