### Install Build Essentials on Linux Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Installs essential build tools on Linux systems using apt. This is a prerequisite for compiling native applications. ```bash sudo apt update sudo apt install build-essential ``` -------------------------------- ### Install SDL2 Development Libraries on Linux Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Installs the SDL2 library and its development headers on Linux systems using apt. This is required for SDL2-based applications. ```bash sudo apt-get install libsdl2 libsdl2-dev ``` -------------------------------- ### Install SDL2 using Homebrew on macOS Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Installs the SDL2 library on macOS using the Homebrew package manager. This provides the necessary runtime and development files for SDL2. ```bash brew install sdl2 ``` -------------------------------- ### Initialize and Draw Pixels with ATOM Display Source: https://github.com/m5stack/m5gfx/blob/master/docs/ATOMDisplay.md Initializes the display, sets rotation and color depth, and then draws individual pixels with a calculated color. This is a basic setup for drawing to the display. ```cpp #include // Create an instance of M5AtomDisplay // M5AtomDisplay のインスタンスを用意 M5AtomDisplay display; // Set the resolution in the argument (width, height, refresh rate). default : 1280, 720, 60 . // The value of width x height x refresh rate must be within 55,296,000. // If the display does not match the supported resolution or frequency of the display, it will not be displayed correctly. // 引数で解像度(幅,高さ,リフレッシュレート)を設定できます。 省略時は 1280, 720, 60 // 幅 × 高さ × リフレッシュレート の値が 55,296,000 以下である必要があります。 // また、ディスプレイが指定の解像度や周波数に対応していない場合は正しく表示されません。 // M5AtomDisplay display(1920, 480); // M5AtomDisplay display(1280, 720); // M5AtomDisplay display(1024, 768); // M5AtomDisplay display( 960, 540); // M5AtomDisplay display( 800, 600); // M5AtomDisplay display( 640, 480); // M5AtomDisplay display( 640, 400); // M5AtomDisplay display( 640, 360); // M5AtomDisplay display( 512, 212); // M5AtomDisplay display( 256, 192); // M5AtomDisplay display( 320, 240); // M5AtomDisplay display( 240, 320); // M5AtomDisplay display( 200, 200); // M5AtomDisplay display( 240, 135); // M5AtomDisplay display( 135, 240); // M5AtomDisplay display( 160, 160); // M5AtomDisplay display( 160, 80); // M5AtomDisplay display( 80, 160); // M5AtomDisplay display( 80, 80); // M5AtomDisplay display( 480, 1920); // M5AtomDisplay display(1920, 1080, 24); // M5AtomDisplay display(1920, 960, 30); // Depending on the supported resolution of the display, it may not be displayed correctly. // Arguments 4 and 5 allow you to set the resolution (width and height) to be output to the display. // Arguments 6 and 7 allow you to set the scaling factor for width and height. // Argument 8 allows you to set the pixel clock frequency. // If the enlarged resolution is less than the output resolution, there will be a gap around the perimeter of the screen. // ディスプレイの対応解像度によっては正しく表示できない場合があります。 // 引数4と5でディスプレイに出力する解像度(幅,高さ)を設定できます。 // 引数6と7で幅と高さの拡大倍率を設定できます。 // 引数8でピクセルクロックの周波数を設定できます。 // なお拡大後の解像度が出力解像度に満たない場合、画面外周に隙間が生じます。 // M5AtomDisplay display ( 512, 384, 60, 1280, 800, 2, 2, 74250000 ); // ※ The width scaling factor must be a number that is divisible by the width of the output resolution. // ※ 幅の拡大倍率は、出力解像度の幅を割り切れる数である必要があります。 // ex: M5AtomDisplay display ( 400, 250, 60, 1280, 800, 3, 3, 74250000 ); // In this example, 1280 is not divisible by 3, so the horizontal scaling factor will be changed to 2. // この例は 1280 を 3で割り切れないため、横方向の拡大倍率は2に変更されます。 void setup(void) { // initialize // 初期化 display.init(); // Set the display orientation // ディスプレイの向きを設定 // 0 = 270 deg / 1 = normal / 2 = 90 deg / 3 = 180 deg / 4~7 = upside down display.setRotation(1); // Set the color depth ( bpp ) // 色深度を設定 display.setColorDepth(24); // 24bit per pixel color setting //display.setColorDepth(16); // 16bit per pixel color setting ( default ) //display.setColorDepth( 8); // 8bit per pixel color setting display.startWrite(); for (int y = 0; y < display.height(); ++y) { for (int x = 0; x < display.width(); ++x) { display.writePixel(x, y, display.color888(x, x+y, y)); } } display.endWrite(); for (int i = 0; i < 16; ++i) { int x = rand() % display.width(); int y = rand() % display.height(); display.drawCircle(x, y, 16, rand()); } } ``` -------------------------------- ### Install Xcode Command Line Tools on macOS Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Installs the Xcode Command Line Tools on macOS, which include necessary compilers and development utilities for native builds. ```bash xcode-select --install ``` -------------------------------- ### Install GCC and GDB on MSYS2 Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Installs the GCC compiler and GDB debugger on Windows using MSYS2. Ensure these are added to your system's PATH environment variable. ```msys2 pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-gdb ``` -------------------------------- ### M5UnitRCA Constructor and Initialization Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Demonstrates how to instantiate and initialize the M5UnitRCA object, specifying resolution, signal type, and GPIO pin. Default values are provided if arguments are omitted. ```APIDOC ## M5UnitRCA Constructor and Initialization ### Description Instantiates the M5UnitRCA object with specified parameters or uses default values. The constructor allows setting logical width, logical height, output width, output height, signal type, PSRAM usage, GPIO pin, and output level. ### Constructor Signature ```cpp M5UnitRCA ( uint16_t logical_width, uint16_t logical_height, uint16_t output_width, uint16_t output_height, signal_type_t signal_type = signal_type_t::PAL, use_psram_t use_psram = use_psram_t::psram_half_use, uint8_t pin = 26, uint8_t output_level = 128 ); ``` ### Default Values - logical_width: Not specified, must be provided. - logical_height: Not specified, must be provided. - output_width: Not specified, must be provided. - output_height: Not specified, must be provided. - signal_type: `M5UnitRCA::signal_type_t::PAL` - use_psram: `M5UnitRCA::use_psram_t::psram_half_use` - pin: `26` - output_level: `128` ### Example Usage ```cpp // Example with all parameters specified M5UnitRCA display ( 216, // logical_width 144, // logical_height 256, // output_width 160, // output_height M5UnitRCA::signal_type_t::PAL, // signal_type M5UnitRCA::use_psram_t::psram_half_use, // use_psram 26, // GPIO pin 128 // output level ); // Example using default values for signal_type, use_psram, pin, and output_level M5UnitRCA display_default(216, 144, 256, 160); ``` ### Notes - If `output_width` and `output_height` are larger than `logical_width` and `logical_height`, margins will appear on the screen edges. - Maximum output resolution depends on the `signal_type`: - 720 x 480 (PAL_M, NTSC, NTSC_J) - 720 x 576 (PAL_N) - 864 x 576 (PAL) - High resolutions may lead to insufficient memory and prevent operation. ``` -------------------------------- ### Initialize M5UnitRCA with Custom Parameters Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Instantiate M5UnitRCA by specifying logical and output resolutions, signal type, PSRAM usage, GPIO pin, and output level. If arguments are omitted, default values are used (216x144, PAL, GPIO 26). Ensure the resolution is not too high for available memory. ```cpp #include #include // Resolution, signal type, and output pin number can be specified in the constructor or init function. // If the argument is omitted, the resolution is set to 216x144, PAL format, and GPIO 26 pins. // If the resolution is too high, it may not work due to insufficient memory. // 解像度、信号の種類、出力ピン番号はコンストラクタまたはinit関数で指定できます。 // 引数の省略時は 解像度 216x144 , PAL形式 , GPIO26ピン が設定されます。 // 解像度が高すぎる場合はメモリ不足のため動作しない可能性があります。 // M5ModuleRCA or M5UnitRCA M5UnitRCA display ( 216 // logical_width , 144 // logical_height , 256 // output_width , 160 // output_height , M5UnitRCA::signal_type_t::PAL // signal_type , M5UnitRCA::use_psram_t::psram_half_use // use_psram , 26 // GPIO pin , 128 // output level ); ``` -------------------------------- ### PlatformIO Configuration for M5 PaperS3 Source: https://github.com/m5stack/m5gfx/blob/master/docs/M5PaperS3.md This configuration is for PlatformIO and specifies the board, framework, flash size, memory type, build flags, and library dependencies for the M5 PaperS3. Ensure PSRAM is enabled and set to Octal SPI (OPI). ```ini [env:PaperS3] platform = espressif32 board = esp32-s3-devkitm-1 framework = arduino board_upload.flash_size = 16MB board_upload.maximum_size = 16777216 board_build.arduino.memory_type = qio_opi build_flags = -DBOARD_HAS_PSRAM lib_deps = epdiy=https://github.com/vroland/epdiy.git ``` -------------------------------- ### Configure M5UnitRCA Display Settings Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Adjust display settings after instantiation, including output boost, output level, GPIO pin, signal type, PSRAM allocation, color depth, and rotation. Note that PSRAM usage may cause video disturbances under high load. ```cpp // If output_width and output_height are set larger than logical_width and logical_height, there will be margins at the edge of the screen. // signal_type can be selected from NTSC / NTSC_J / PAL / PAL_M / PAL_N. // The maximum output resolution depends on the signal_type. // 720 x 480 (PAL_M,NTSC,NTSC_J) // 720 x 576 (PAL_N) // 864 x 576 (PAL) // output_width,output_height を logical_width,logical_height より大きく設定すると、画面端に余白ができます。 // signal_typeは NTSC / NTSC_J / PAL / PAL_M / PAL_N から選択できます。 // 出力できる最大解像度はsignal_typeによって異なります。 void setup(void) { // For models with a protection resistor on the GPIO (M5Stack Core2), the voltage of the output signal drops. // This function sets the amplification of the output signal. // GPIOに保護抵抗がついた機種 (M5Stack Core2) の場合、出力信号の電圧が低下します。 // こちらの関数で出力信号の増幅を設定します。 // display.setOutputBoost(true); // // For more fine-tuning, use this function. // より細かく調整したい場合はこちらの関数を使用します。 // display.setOutputLevel(200); // default=128 // If you want to change the GPIO pin number of the output destination, specify it with this function. // 出力先のGPIOピン番号を変更したい場合、この関数で指定します。 // display.setOutputPin(25); // Only GPIO 25 or 26 can be used. // To change the output signal type, specify it with this function. // 出力信号の種類を変更したい場合、この関数で指定します。 // display.setSignalType(M5UnitRCA::signal_type_t::NTSC); // display.setSignalType(M5UnitRCA::signal_type_t::NTSC_J); // display.setSignalType(M5UnitRCA::signal_type_t::PAL); // display.setSignalType(M5UnitRCA::signal_type_t::PAL_M); // display.setSignalType(M5UnitRCA::signal_type_t::PAL_N); // If you wish to allocate PSRAM for buffer memory, specify it with this function. // ※ When PSRAM is used, video may be disturbed under high load. // バッファメモリにPSRAMを割当てたい場合、この関数で指定します。 // ※ PSRAMを使用した場合は高負荷時に映像が乱れる場合があります。 // display.setPsram(M5UnitRCA::use_psram_t::psram_use); // All use PSRAM. // display.setPsram(M5UnitRCA::use_psram_t::psram_half_use); // Half PSRAM and half SRAM. // display.setPsram(M5UnitRCA::use_psram_t::psram_no_use); // All use SRAM. no use PSRAM. // Selects the number of colors. The default value is 8 (RGB332). // 色数を選択します。初期値は 8 (RGB332) です。 // display.setColorDepth( 8); // 8bit RGB332 256 colors. display.setColorDepth(16); // 16bit RGB565 65536 colors. // display.setColorDepth(m5gfx::color_depth_t::grayscale_8bit); // 8bit Grayscale 256 level. // initialize // 初期化 display.init(); // Set the display orientation // ディスプレイの向きを設定 // 0 = 270 deg / 1 = normal / 2 = 90 deg / 3 = 180 deg / 4~7 = upside down display.setRotation(0); for (int y = 0; y < display.height(); ++y) { for (int x = 0; x < display.width(); ++x) { display.drawPixel(x, y, display.color888(x, x+y, y)); } } for (int i = 0; i < 16; ++i) { ``` -------------------------------- ### Initialize and Draw on Unit GLASS Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitGLASS.md Initializes the Unit GLASS display with specified I2C settings and draws pixels and circles. Ensure correct GPIO pins and I2C frequency are used for initialization. The display rotation can be set to orient the output. ```cpp #include M5UnitGLASS display; void setup(void) { // initialize // 初期化 // SDA, SCL, Freq, I2C PortNumber display.init(GPIO_NUM_21, GPIO_NUM_22, 400000u); // Set the display orientation // ディスプレイの向きを設定 // 0 = 270 deg / 1 = normal / 2 = 90 deg / 3 = 180 deg / 4~7 = upside down display.setRotation(1); display.startWrite(); for (int y = 0; y < display.height(); ++y) { for (int x = 0; x < display.width(); ++x) { display.drawPixel(x, y, display.color888(x*2, x*2+y*2, y*2)); } } display.endWrite(); for (int i = 0; i < 16; ++i) { int x = rand() % display.width(); int y = rand() % display.height(); display.drawCircle(x, y, 16, rand()); } } bool buz_en = false; void loop(void) { static constexpr const char hello_str[] = "Hello Unit GLASS !"; int i_end = -display.textWidth(hello_str); for (int i = display.width(); i > i_end; --i) { // get key A status : 0==pressed / 0!=released if (display.getKey(0) == 0) { buz_en = !buz_en; display.setBuzzerEnable(buz_en); } // get key B status : 0==pressed / 0!=released if (display.getKey(1) == 0) { display.setBuzzer((i - i_end) << 4, 128); } display.drawString(hello_str, i, (display.height() - display.fontHeight()) >> 1); } delay(5); } ``` -------------------------------- ### M5UnitRCA Configuration Functions Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Provides functions to modify display settings after initialization, including output boost, output level, GPIO pin, signal type, PSRAM usage, color depth, rotation, and initialization. ```APIDOC ## M5UnitRCA Configuration Functions ### Description These functions allow runtime modification of the M5UnitRCA display's behavior, including signal amplification, output pin, signal type, PSRAM allocation, color depth, and display orientation. ### Functions #### `setOutputBoost(bool enable)` - **Description**: Enables or disables output signal amplification. Useful for models with protection resistors on GPIOs (e.g., M5Stack Core2) where signal voltage might drop. - **Parameters**: - `enable` (bool): `true` to enable boost, `false` to disable. #### `setOutputLevel(uint8_t level)` - **Description**: Sets a finer level of control for the output signal amplification. - **Parameters**: - `level` (uint8_t): The output level value (default is 128). #### `setOutputPin(uint8_t pin)` - **Description**: Changes the GPIO pin used for video output. - **Parameters**: - `pin` (uint8_t): The GPIO pin number. Only GPIO 25 or 26 can be used. #### `setSignalType(signal_type_t type)` - **Description**: Changes the output signal type. - **Parameters**: - `type` (`M5UnitRCA::signal_type_t`): The desired signal type. Options include `NTSC`, `NTSC_J`, `PAL`, `PAL_M`, `PAL_N`. #### `setPsram(use_psram_t use_psram)` - **Description**: Configures PSRAM allocation for buffer memory. Note that using PSRAM may cause video disturbances under high load. - **Parameters**: - `use_psram` (`M5UnitRCA::use_psram_t`): Specifies PSRAM usage. Options are: - `psram_use`: All PSRAM is used. - `psram_half_use`: Half PSRAM and half SRAM are used. - `psram_no_use`: No PSRAM is used; all SRAM is used. #### `setColorDepth(color_depth_t depth)` - **Description**: Selects the number of colors for the display. The default is 8-bit RGB332 (256 colors). - **Parameters**: - `depth` (`m5gfx::color_depth_t`): The desired color depth. Options include: - `8`: 8-bit RGB332 (256 colors). - `16`: 16-bit RGB565 (65536 colors). - `grayscale_8bit`: 8-bit Grayscale (256 levels). #### `init()` - **Description**: Initializes the display with the configured settings. #### `setRotation(uint8_t rotation)` - **Description**: Sets the display orientation. - **Parameters**: - `rotation` (uint8_t): Orientation value. `0` for 270 degrees, `1` for normal, `2` for 90 degrees, `3` for 180 degrees. Values `4` to `7` are for upside-down orientations. ### Example Usage in `setup()` ```cpp // Enable output boost for M5Stack Core2 // display.setOutputBoost(true); // Set a custom output level // display.setOutputLevel(200); // Change the output pin to GPIO 25 // display.setOutputPin(25); // Change signal type to NTSC // display.setSignalType(M5UnitRCA::signal_type_t::NTSC); // Configure PSRAM usage to full PSRAM // display.setPsram(M5UnitRCA::use_psram_t::psram_use); // Set color depth to 16-bit RGB565 display.setColorDepth(16); // Initialize the display display.init(); // Set display rotation to 0 degrees (270 degrees orientation) display.setRotation(0); ``` ``` -------------------------------- ### Configure VS Code Debugger for macOS Source: https://github.com/m5stack/m5gfx/blob/master/examples/PlatformIO_SDL/README.md Sets up the LLDB debugger in VS Code for macOS by modifying the launch.json file. Ensure the 'program' path matches your PlatformIO build output. ```json "program": "${workspaceRoot}/.pio/build/native/program" ``` -------------------------------- ### Display Text with ATOM Display Source: https://github.com/m5stack/m5gfx/blob/master/docs/ATOMDisplay.md Demonstrates how to display text on the ATOM Display. It sets a font and then draws a string repeatedly to create a scrolling effect. ```cpp void loop(void) { display.startWrite(); static constexpr const char hello_str[] = "Hello ATOM Display !"; display.setFont(&fonts::Orbitron_Light_32); for (int i = -display.textWidth(hello_str); i < display.width(); ++i) { display.drawString(hello_str, i, (display.height() - display.fontHeight()) >> 1); } display.endWrite(); } ``` -------------------------------- ### Recommended Output Resolutions Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Provides a table of recommended output resolutions and maximum resolutions for different video signal types (PAL-M, NTSC, NTSC-J, PAL-N, PAL). ```APIDOC ## Recommended Output Resolutions ### Description This section outlines the recommended and maximum output resolutions supported by the M5GFX Unit RCA for various video standards. ### Resolution Table | Feature | PAL-M / NTSC / NTSC-J | PAL-N | PAL | |----------------------|-----------------------|-------|-------| | **Max Width** | 720 | 720 | 864 | | **Max Height** | 480 | 576 | 576 | | **Recommended Width**| 720, 480, 360, 240, 180, 144 | 720, 576, 432, 288, 216, 173, 144 | 864, 576, 432, 288, 216, 173, 144 | | **Recommended Height**| 480, 240, 160, 120, 96, 80 | 576, 288, 192, 144, 113, 96, 72 | 576, 288, 192, 144, 113, 96, 72 | ### Notes - The `recommended_width` and `recommended_height` values are derived by dividing the `max_width` and `max_height` by various factors (e.g., 1, 1.5, 2, 3, 4, 5, 6, 8). - Ensure that the chosen resolution does not exceed the maximum capabilities for the selected `signal_type` to avoid display issues. ``` -------------------------------- ### Draw Random Circle on UnitRCA Display Source: https://github.com/m5stack/m5gfx/blob/master/docs/UnitRCA.md Generates random coordinates and draws a circle with a random color on the display. Ensure the display object is initialized before use. ```cpp int x = rand() % display.width(); int y = rand() % display.height(); display.drawCircle(x, y, 16, rand()); } } void loop(void) { static constexpr const char hello_str[] = "Hello Unit RCA !"; display.setFont(&fonts::Orbitron_Light_32); int i_end = -display.textWidth(hello_str); for (int i = display.width(); i > i_end; --i) { display.drawString(hello_str, i, (display.height() - display.fontHeight()) >> 1); delay(5); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.