### Initialize Display Hardware with begin() Source: https://context7.com/2dom/pxmatrix/llms.txt Configure the row scan pattern and optional custom SPI pins. The row pattern must match the physical panel configuration. ```cpp void setup() { Serial.begin(9600); // Basic initialization with 1/8 row scan pattern display.begin(8); // Alternative: Initialize with custom SPI pins (ESP32 only) // begin(row_pattern, CLK, MOSI, MISO, SS) // display.begin(16, 14, 27, 12, 4); // For boards without default SPI pins display.clearDisplay(); Serial.println("Display initialized"); } ``` -------------------------------- ### PxMatrix begin() Method Source: https://context7.com/2dom/pxmatrix/llms.txt Initializes the display hardware and configures the row scan pattern. Supports optional custom SPI pins for ESP32. ```APIDOC ## begin() - Initialize the Display The `begin()` method initializes the display hardware and configures the row scan pattern. Pass the row pattern value (4, 8, 16, or 32) matching your panel's scan configuration. Optionally specify custom SPI pins for boards where default pins are unavailable. ```cpp void setup() { Serial.begin(9600); // Basic initialization with 1/8 row scan pattern display.begin(8); // Alternative: Initialize with custom SPI pins (ESP32 only) // begin(row_pattern, CLK, MOSI, MISO, SS) // display.begin(16, 14, 27, 12, 4); // For boards without default SPI pins display.clearDisplay(); Serial.println("Display initialized"); } ``` ``` -------------------------------- ### Initialize PxMATRIX Display Instance Source: https://context7.com/2dom/pxmatrix/llms.txt Create a display object by defining control pins and panel dimensions. The number of address pins required depends on the panel's row scan pattern. ```cpp #include // Pin definitions for ESP32 #define P_LAT 22 // Latch pin #define P_OE 16 // Output enable pin #define P_A 19 // Address pin A #define P_B 23 // Address pin B #define P_C 18 // Address pin C #define P_D 5 // Address pin D #define P_E 15 // Address pin E // For 32x16 panel with 1/8 scan (uses A, B, C pins) PxMATRIX display(32, 16, P_LAT, P_OE, P_A, P_B, P_C); // For 64x32 panel with 1/16 scan (uses A, B, C, D pins) // PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D); // For 64x64 panel with 1/32 scan (uses A, B, C, D, E pins) // PxMATRIX display(64, 64, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E); ``` -------------------------------- ### PxMatrix Constructor Source: https://context7.com/2dom/pxmatrix/llms.txt Demonstrates how to create a PxMATRIX display object with specified dimensions and control pins based on the panel's scan pattern. ```APIDOC ## Constructor - Creating a Display Instance The PxMATRIX constructor creates a display object with specified dimensions and control pins. The number of address pins (A, B, C, D, E) depends on your panel's row scan pattern - use 2 pins for 1/4 scan, 3 pins for 1/8 scan, 4 pins for 1/16 scan, and 5 pins for 1/32 scan panels. ```cpp #include // Pin definitions for ESP32 #define P_LAT 22 // Latch pin #define P_OE 16 // Output enable pin #define P_A 19 // Address pin A #define P_B 23 // Address pin B #define P_C 18 // Address pin C #define P_D 5 // Address pin D #define P_E 15 // Address pin E // For 32x16 panel with 1/8 scan (uses A, B, C pins) PxMATRIX display(32, 16, P_LAT, P_OE, P_A, P_B, P_C); // For 64x32 panel with 1/16 scan (uses A, B, C, D pins) // PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D); // For 64x64 panel with 1/32 scan (uses A, B, C, D, E pins) // PxMATRIX display(64, 64, P_LAT, P_OE, P_A, P_B, P_C, P_D, P_E); ``` ``` -------------------------------- ### Initialize Chained Displays Source: https://github.com/2dom/pxmatrix/blob/master/README.md Configure the display object for multiple chained panels and set the panel width. ```cpp #include PxMATRIX display(96,16,...); ... [] ... void setup(){ display.begin(4); display.setPanelsWidth(3); ... ``` -------------------------------- ### Configure Scan Pattern Source: https://context7.com/2dom/pxmatrix/llms.txt Shows how to set the scan pattern to match specific LED panel hardware configurations. ```cpp // Available scan patterns: // LINE - Standard left-to-right scanning (default) // ZIGZAG - Alternating direction per row section // ZZAGG - Zigzag with byte reordering // ZAGGIZ - Reversed bit order variant // WZAGZIG - Wide zigzag pattern // VZAG - Vertical zigzag pattern // ZAGZIG - Alternative zigzag // WZAGZIG2 - Wide zigzag variant 2 // ZZIAGG - Zigzag interleaved void setup() { display.begin(8); // Set scan pattern (try different values if display looks wrong) display.setScanPattern(LINE); // Default for most panels // display.setScanPattern(ZIGZAG); // For 1/4 scan panels // display.setScanPattern(ZAGGIZ); // Some Chinese panels display.clearDisplay(); } ``` -------------------------------- ### Configure Panel Scan and Mux Patterns Source: https://github.com/2dom/pxmatrix/blob/master/README.md Set the row scanning layout, scan pattern, and multiplex pattern for the LED matrix panel. Use `display.begin(x)` with x={4,8,16,32} for scanning layout, `display.setScanPattern(x)` with x={LINE, ZIGZAG, etc.} for scan pattern, and `display.setMuxPattern(x)` with x={BINARY, STRAIGHT, etc.} for multiplex pattern. ```cpp display.begin(4); display.setScanPattern(ZAGGIZ); display.setMuxPattern(STRAIGHT); ``` -------------------------------- ### Enable Performance Optimization with setFastUpdate() Source: https://context7.com/2dom/pxmatrix/llms.txt setFastUpdate(true) enables a timing optimization that clocks data while LEDs are still lit, reducing update latency and potentially increasing brightness. This method works best at full brightness (255). ```cpp void setup() { display.begin(8); display.setBrightness(255); // Required for fast update display.setFastUpdate(true); display.clearDisplay(); } ``` -------------------------------- ### Render Text on PxMatrix Source: https://context7.com/2dom/pxmatrix/llms.txt Demonstrates basic text rendering and a scrolling text implementation using Adafruit_GFX methods. ```cpp uint16_t myCYAN = display.color565(0, 255, 255); uint16_t myMAGENTA = display.color565(255, 0, 255); uint16_t myYELLOW = display.color565(255, 255, 0); void setup() { display.begin(8); display.clearDisplay(); // Basic text display display.setTextColor(myCYAN); display.setCursor(2, 0); display.print("Hello"); display.setTextColor(myMAGENTA); display.setCursor(2, 8); display.print("World"); } void scrollText(uint8_t ypos, String text, uint8_t r, uint8_t g, uint8_t b) { uint16_t textLength = text.length(); display.setTextWrap(false); // Disable wrap for scrolling display.setTextSize(1); display.setTextColor(display.color565(r, g, b)); // Scroll text from right to left for (int xpos = 32; xpos > -(int)(textLength * 6); xpos--) { display.clearDisplay(); display.setCursor(xpos, ypos); display.print(text); delay(50); } } void loop() { scrollText(4, "Welcome to PxMatrix!", 96, 96, 250); } ``` -------------------------------- ### Configure Driver IC Source: https://context7.com/2dom/pxmatrix/llms.txt Sets the library to use specific LED driver ICs that require unique initialization sequences. ```cpp // Available driver chips: // SHIFT - Standard shift register (default) // FM6124 - FM6124 driver chip // FM6126A - FM6126A driver chip void setup() { display.begin(32); // 1/32 scan for 64x64 panels // Configure for FM6126A driver chip (common in some 64x64 panels) display.setDriverChip(FM6126A); // Alternative for FM6124 // display.setDriverChip(FM6124); display.clearDisplay(); display.setTextColor(display.color565(0, 255, 255)); display.setCursor(2, 0); display.print("FM6126A"); } ``` -------------------------------- ### setDriverChip() - Configure Driver IC Source: https://context7.com/2dom/pxmatrix/llms.txt Configures the library for specific LED driver ICs that require special initialization sequences, such as FM6124 and FM6126A. ```APIDOC ## setDriverChip() - Configure Driver IC ### Description The `setDriverChip()` method configures the library for specific LED driver ICs that require special initialization sequences. FM6124 and FM6126A chips need register configuration for proper operation. Available driver chips: - SHIFT - Standard shift register (default) - FM6124 - FM6124 driver chip - FM6126A - FM6126A driver chip ### Method `void setDriverChip(uint8_t chip)` ### Parameters #### Path Parameters - **chip** (uint8_t) - Required - The driver chip to set. Use predefined constants like SHIFT, FM6124, FM6126A. ### Request Example ```cpp // Configure for FM6126A driver chip (common in some 64x64 panels) display.setDriverChip(FM6126A); // Alternative for FM6124 // display.setDriverChip(FM6124); ``` ### Response This method does not return a value. ``` -------------------------------- ### Draw Graphics Primitives Source: https://context7.com/2dom/pxmatrix/llms.txt Shows how to draw lines, rectangles, circles, and color gradients using standard GFX primitives. ```cpp uint16_t myRED = display.color565(255, 0, 0); uint16_t myGREEN = display.color565(0, 255, 0); uint16_t myBLUE = display.color565(0, 0, 255); uint16_t myWHITE = display.color565(255, 255, 255); void loop() { display.clearDisplay(); // Draw lines display.drawLine(0, 0, 31, 15, myRED); // Diagonal line display.drawLine(0, 15, 31, 0, myGREEN); // Opposite diagonal // Draw rectangles display.drawRect(5, 3, 10, 8, myBLUE); // Rectangle outline display.fillRect(18, 3, 10, 8, myWHITE); // Filled rectangle // Draw circles display.drawCircle(16, 8, 5, myCYAN); // Circle outline display.fillCircle(25, 8, 3, myMAGENTA); // Filled circle // Draw color gradient bars for (int x = 0; x < 16; x++) { display.drawLine(x + 16, 0, x + 16, 5, display.color565(x * 16, 0, 0)); display.drawLine(x + 16, 6, x + 16, 10, display.color565(0, x * 16, 0)); display.drawLine(x + 16, 11, x + 16, 15, display.color565(0, 0, x * 16)); } delay(1000); } ``` -------------------------------- ### Control Display Brightness Source: https://context7.com/2dom/pxmatrix/llms.txt Demonstrates adjusting display brightness using setBrightness() and creating fade effects. ```cpp void setup() { display.begin(8); display.setBrightness(255); // Full brightness display.setTextColor(display.color565(255, 255, 255)); display.setCursor(2, 4); display.print("Bright"); } void loop() { // Fade out effect for (uint8_t brightness = 255; brightness > 0; brightness--) { display.setBrightness(brightness); delay(5); } // Fade in effect for (uint8_t brightness = 0; brightness < 255; brightness++) { display.setBrightness(brightness); delay(5); } delay(500); } ``` -------------------------------- ### Configure Panel Chaining Source: https://context7.com/2dom/pxmatrix/llms.txt Allows treating multiple horizontally connected panels as a single wide display. ```cpp // Three 32x16 panels chained horizontally = 96x16 display PxMATRIX display(96, 16, P_LAT, P_OE, P_A, P_B, P_C); void setup() { display.begin(4); // 1/4 scan pattern display.setPanelsWidth(3); // 3 panels chained display.clearDisplay(); display.setTextColor(display.color565(255, 255, 0)); display.setCursor(0, 4); display.print("Wide Display!"); } void loop() { // Draw across all panels for (int x = 0; x < 96; x++) { display.drawPixel(x, 8, display.color565(x * 2, 255 - x * 2, 128)); } delay(100); } ``` -------------------------------- ### PxMatrix display() Method Source: https://context7.com/2dom/pxmatrix/llms.txt Refreshes the LED matrix. Should be called regularly from a timer interrupt or ticker. An optional parameter controls the LED on-time for brightness adjustment. ```APIDOC ## display() - Refresh the Display The `display()` method must be called regularly to refresh the LED matrix. It should be invoked from a timer interrupt or ticker to maintain a stable image. The optional parameter specifies the LED on-time in microseconds - larger values mean brighter display but risk crashes if too high. ```cpp #ifdef ESP32 hw_timer_t *timer = NULL; portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED; void IRAM_ATTR display_updater() { portENTER_CRITICAL_ISR(&timerMux); display.display(30); // 30 microseconds on-time portEXIT_CRITICAL_ISR(&timerMux); } void setup() { display.begin(16); // Setup timer interrupt for display refresh (every 4ms) timer = timerBegin(0, 80, true); timerAttachInterrupt(timer, &display_updater, true); timerAlarmWrite(timer, 4000, true); timerAlarmEnable(timer); } #endif #ifdef ESP8266 #include Ticker display_ticker; void display_updater() { display.display(30); } void setup() { display.begin(8); display_ticker.attach(0.004, display_updater); // Refresh every 4ms } #endif ``` ``` -------------------------------- ### Display Test Patterns for Debugging Source: https://context7.com/2dom/pxmatrix/llms.txt Use displayTestPattern() and displayTestPixel() for diagnosing display issues by showing predictable patterns. These are helpful when setting up a new panel or troubleshooting scan pattern problems. ```cpp void setup() { display.begin(4); display.flushDisplay(); // Clear shift registers } void loop() { // Display test pattern - shows progressive fill // Useful for verifying scan pattern configuration display.displayTestPattern(70); // Alternative: Test individual pixels // display.displayTestPixel(70); } ``` -------------------------------- ### setMuxDelay() Source: https://context7.com/2dom/pxmatrix/llms.txt Configures microsecond delays for row switching to accommodate slower multiplexer chips. ```APIDOC ## setMuxDelay(a, b, c, d, e) ### Description Adds microsecond delays when switching multiplex rows to fix missing rows or timing issues. ### Parameters #### Request Body - **a, b, c, d, e** (uint8_t) - Required - Delay values for each address line ### Request Example display.setMuxDelay(1, 1, 1, 1, 1); ``` -------------------------------- ### Adjust Row Switching Timing with setMuxDelay() Source: https://context7.com/2dom/pxmatrix/llms.txt The setMuxDelay() method introduces microsecond delays during multiplex row switching. This is useful if rows appear missing or the multiplexer chip is too slow. Delays can be set for all lines or selectively for specific lines. ```cpp void setup() { display.begin(8); // Add 1 microsecond delay to each address line transition // setMuxDelay(delay_A, delay_B, delay_C, delay_D, delay_E) display.setMuxDelay(1, 1, 1, 1, 1); // Or selective delays for specific lines // display.setMuxDelay(0, 1, 0, 0, 0); // Only delay on B line display.clearDisplay(); } ``` -------------------------------- ### Enable Double Buffering Source: https://context7.com/2dom/pxmatrix/llms.txt Prevents flicker by drawing to a background buffer. Requires defining PxMATRIX_DOUBLE_BUFFER before library inclusion. ```cpp #define PxMATRIX_DOUBLE_BUFFER true #include PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D); uint16_t textColor = display.color565(0, 0, 255); uint16_t lineColor = display.color565(255, 0, 0); uint16_t myBLACK = display.color565(0, 0, 0); struct BouncingText { int16_t x, y; int16_t dx, dy; uint16_t width, height; } text = {0, 0, 1, 1, 0, 0}; void setup() { display.begin(16); display.setTextWrap(false); // Get text dimensions for collision detection int16_t x1, y1; display.getTextBounds("Hello", 0, 0, &x1, &y1, &text.width, &text.height); } void loop() { // Draw to background buffer display.fillScreen(myBLACK); // Bouncing line animation static int16_t lineX = 0, lineDX = 1; if (lineX + lineDX >= display.width() || lineX + lineDX < 0) lineDX = -lineDX; lineX += lineDX; display.drawLine(lineX, 0, display.width() - lineX - 1, display.height() - 1, lineColor); // Bouncing text animation if (text.x + text.dx + text.width >= display.width() || text.x + text.dx < 0) text.dx = -text.dx; if (text.y + text.dy + text.height >= display.height() || text.y + text.dy < 0) text.dy = -text.dy; text.x += text.dx; text.y += text.dy; display.setTextColor(textColor); display.setCursor(text.x, text.y); display.print("Hello"); // Swap buffers to display the frame display.showBuffer(); delay(20); } ``` -------------------------------- ### setFastUpdate() Source: https://context7.com/2dom/pxmatrix/llms.txt Enables performance optimization for faster data clocking. ```APIDOC ## setFastUpdate(bool) ### Description Enables a timing optimization that clocks data while LEDs are lit. Requires brightness to be set to 255. ### Parameters #### Request Body - **enabled** (bool) - Required - Enable or disable fast update mode ### Request Example display.setFastUpdate(true); ``` -------------------------------- ### displayTestPattern() Source: https://context7.com/2dom/pxmatrix/llms.txt Diagnostic method to verify scan pattern configuration. ```APIDOC ## displayTestPattern(int) ### Description Displays a progressive fill pattern to diagnose scan pattern problems. ### Parameters #### Request Body - **delay** (int) - Required - Delay in milliseconds between pattern steps ### Request Example display.displayTestPattern(70); ``` -------------------------------- ### setPanelsWidth() - Panel Chaining Source: https://context7.com/2dom/pxmatrix/llms.txt Configures the library for horizontally chained panels, treating multiple displays as a single, wider display. ```APIDOC ## Panel Chaining - Multiple Displays ### Description The `setPanelsWidth()` method configures the library for horizontally chained panels. Connect panels using flat ribbon cables and treat the chain as one wide display. ### Method `void setPanelsWidth(uint8_t panels)` ### Parameters #### Path Parameters - **panels** (uint8_t) - Required - The number of panels chained horizontally. ### Request Example ```cpp // Three 32x16 panels chained horizontally = 96x16 display PxMATRIX display(96, 16, P_LAT, P_OE, P_A, P_B, P_C); void setup() { display.begin(4); // 1/4 scan pattern display.setPanelsWidth(3); // 3 panels chained // ... rest of setup ... } ``` ### Response This method does not return a value. ``` -------------------------------- ### Draw Pixels and Colors Source: https://context7.com/2dom/pxmatrix/llms.txt Set individual pixel colors using RGB565 or RGB888 formats. Use color565() to convert standard 8-bit RGB values to the required 16-bit format. ```cpp // Define colors using RGB565 format uint16_t myRED = display.color565(255, 0, 0); uint16_t myGREEN = display.color565(0, 255, 0); uint16_t myBLUE = display.color565(0, 0, 255); uint16_t myWHITE = display.color565(255, 255, 255); uint16_t myCYAN = display.color565(0, 255, 255); void loop() { display.clearDisplay(); // Draw individual pixels with RGB565 color display.drawPixel(0, 0, myRED); display.drawPixel(1, 1, myGREEN); display.drawPixel(2, 2, myBLUE); // Draw directly with RGB888 values (0-255 per channel) display.drawPixelRGB888(5, 5, 128, 0, 255); // Purple // Draw a gradient line for (int x = 0; x < 16; x++) { display.drawPixel(x + 10, 5, display.color565(x * 16, 0, 0)); } delay(100); } ``` -------------------------------- ### Drawing Images from PROGMEM Source: https://context7.com/2dom/pxmatrix/llms.txt Store bitmap data in program memory (PROGMEM) and draw images pixel by pixel. Images should be converted to RGB565 format. The drawImage function iterates through the image data, reads each pixel's color from PROGMEM, and draws it. ```cpp // Image data in PROGMEM (RGB565 format, 32x32 pixels) const uint16_t PROGMEM myImage[] = { 0x07FF, 0x07FF, 0xF800, 0xF800, // ... pixel data // ... rest of image data }; void drawImage(int x, int y, const uint16_t *image, int width, int height) { int counter = 0; for (int yy = 0; yy < height; yy++) { for (int xx = 0; xx < width; xx++) { uint16_t color = pgm_read_word(&image[counter]); display.drawPixel(xx + x, yy + y, color); counter++; } } } void loop() { display.clearDisplay(); drawImage(0, 0, myImage, 32, 32); delay(1000); } ``` -------------------------------- ### setRotate() and setFlip() - Display Orientation Source: https://context7.com/2dom/pxmatrix/llms.txt Adjusts display orientation by rotating or flipping the output, useful when panels are mounted in non-standard orientations. ```APIDOC ## Display Orientation - Rotate and Flip ### Description The `setRotate()` and `setFlip()` methods adjust display orientation. Use these when your panel is mounted in a different orientation than expected. ### Methods - `void setRotate(bool rotate)` - `void setFlip(bool flip)` ### Parameters #### Path Parameters - **rotate** (bool) - Required - Set to `true` to rotate the display 90 degrees clockwise. - **flip** (bool) - Required - Set to `true` to mirror/flip the display horizontally. ### Request Example ```cpp void setup() { display.begin(8); // Rotate display 90 degrees display.setRotate(true); // Mirror/flip display horizontally display.setFlip(true); // Both can be combined for 180 degree rotation effect // ... rest of setup ... } ``` ### Response These methods do not return a value. ``` -------------------------------- ### setMuxPattern() - Configure Multiplexing Source: https://context7.com/2dom/pxmatrix/llms.txt Defines how address pins A-E map to physical rows. Supports various multiplexing patterns like BINARY, STRAIGHT, and SHIFTREG variants. ```APIDOC ## setMuxPattern() - Configure Multiplexing ### Description The `setMuxPattern()` method defines how address pins A-E map to physical rows. Most panels use BINARY multiplexing, but some specialty panels (like those with RT5957 chips) require different patterns. Available mux patterns: - BINARY - Standard binary decoding A-E to rows (default) - STRAIGHT - Direct pin mapping for 1/2 or 1/4 scan - SHIFTREG_ABC - Shift register on A,B,C (for RT5957 chips) - SHIFTREG_SPI_SE - Shift register using SPI signals - SHIFTREG_ABC_BIN_DE - Hybrid shift register + binary (SM5266PH chips) ### Method `void setMuxPattern(uint8_t pattern)` ### Parameters #### Path Parameters - **pattern** (uint8_t) - Required - The multiplexing pattern to set. Use predefined constants like BINARY, STRAIGHT, etc. ### Request Example ```cpp // Standard binary multiplexing (most common) display.setMuxPattern(BINARY); // For strange displays, combine with scan pattern: display.begin(4); // display.setScanPattern(ZAGGIZ); // display.setMuxPattern(STRAIGHT); ``` ### Response This method does not return a value. ``` -------------------------------- ### Refresh Display via Timer Interrupts Source: https://context7.com/2dom/pxmatrix/llms.txt Maintain a stable image by calling display() periodically using hardware timers or tickers. The on-time parameter controls brightness but should be kept within safe limits. ```cpp #ifdef ESP32 hw_timer_t *timer = NULL; portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED; void IRAM_ATTR display_updater() { portENTER_CRITICAL_ISR(&timerMux); display.display(30); // 30 microseconds on-time portEXIT_CRITICAL_ISR(&timerMux); } void setup() { display.begin(16); // Setup timer interrupt for display refresh (every 4ms) timer = timerBegin(0, 80, true); timerAttachInterrupt(timer, &display_updater, true); timerAlarmWrite(timer, 4000, true); timerAlarmEnable(timer); } #endif #ifdef ESP8266 #include Ticker display_ticker; void display_updater() { display.display(30); } void setup() { display.begin(8); display_ticker.attach(0.004, display_updater); // Refresh every 4ms } #endif ``` -------------------------------- ### PxMatrix drawPixel() Method Source: https://context7.com/2dom/pxmatrix/llms.txt Draws a single pixel on the display using RGB565 color format. Supports direct RGB888 values and provides helper functions for color conversion. ```APIDOC ## drawPixel() - Draw Individual Pixels The `drawPixel()` method sets a single pixel to a specified color. Colors use RGB565 format (16-bit). Use `color565()` to convert 8-bit RGB values. Alternative methods `drawPixelRGB565()` and `drawPixelRGB888()` provide direct color format access. ```cpp // Define colors using RGB565 format uint16_t myRED = display.color565(255, 0, 0); uint16_t myGREEN = display.color565(0, 255, 0); uint16_t myBLUE = display.color565(0, 0, 255); uint16_t myWHITE = display.color565(255, 255, 255); uint16_t myCYAN = display.color565(0, 255, 255); void loop() { display.clearDisplay(); // Draw individual pixels with RGB565 color display.drawPixel(0, 0, myRED); display.drawPixel(1, 1, myGREEN); display.drawPixel(2, 2, myBLUE); // Draw directly with RGB888 values (0-255 per channel) display.drawPixelRGB888(5, 5, 128, 0, 255); // Purple // Draw a gradient line for (int x = 0; x < 16; x++) { display.drawPixel(x + 10, 5, display.color565(x * 16, 0, 0)); } delay(100); } ``` ``` -------------------------------- ### Configure Multiplexing Pattern Source: https://context7.com/2dom/pxmatrix/llms.txt Defines how address pins map to physical rows. Use BINARY for standard panels or specific patterns for specialty chips. ```cpp // Available mux patterns: // BINARY - Standard binary decoding A-E to rows (default) // STRAIGHT - Direct pin mapping for 1/2 or 1/4 scan // SHIFTREG_ABC - Shift register on A,B,C (for RT5957 chips) // SHIFTREG_SPI_SE - Shift register using SPI signals // SHIFTREG_ABC_BIN_DE - Hybrid shift register + binary (SM5266PH chips) void setup() { display.begin(8); // Standard binary multiplexing (most common) display.setMuxPattern(BINARY); // For strange displays, combine with scan pattern: // display.begin(4); // display.setScanPattern(ZAGGIZ); // display.setMuxPattern(STRAIGHT); display.clearDisplay(); } ``` -------------------------------- ### Double Buffering - Smooth Animations Source: https://context7.com/2dom/pxmatrix/llms.txt Enables double buffering to prevent flicker during animations by drawing to a background buffer and then swapping to the front buffer. ```APIDOC ## Double Buffering - Smooth Animations ### Description Double buffering prevents flicker during complex animations by drawing to a background buffer while displaying the front buffer. Enable by defining `PxMATRIX_DOUBLE_BUFFER` before including the library. Use `showBuffer()` to swap buffers. ### Method `void showBuffer()` ### Parameters This method does not take any parameters. ### Request Example ```cpp #define PxMATRIX_DOUBLE_BUFFER true #include PxMATRIX display(64, 32, P_LAT, P_OE, P_A, P_B, P_C, P_D); // ... setup and drawing code ... void loop() { // Draw to background buffer display.fillScreen(myBLACK); // ... drawing commands ... // Swap buffers to display the frame display.showBuffer(); delay(20); } ``` ### Response This method does not return a value. It swaps the front and back buffers. ``` -------------------------------- ### setColorOffset() Source: https://context7.com/2dom/pxmatrix/llms.txt Sets minimum color values to filter out low-intensity noise and reduce ghosting. ```APIDOC ## setColorOffset(r, g, b) ### Description Sets the minimum color threshold for each channel. Values below these thresholds are treated as off. ### Parameters #### Request Body - **r** (uint8_t) - Required - Minimum red threshold - **g** (uint8_t) - Required - Minimum green threshold - **b** (uint8_t) - Required - Minimum blue threshold ### Request Example display.setColorOffset(5, 5, 5); ``` -------------------------------- ### Set Minimum Color Threshold with setColorOffset() Source: https://context7.com/2dom/pxmatrix/llms.txt Use setColorOffset() to define the minimum color values for active pixels, helping to reduce ghosting and improve color accuracy by filtering out very low color values. ```cpp void setup() { display.begin(8); // Set minimum color threshold for each channel // Values below these will be treated as off display.setColorOffset(5, 5, 5); display.clearDisplay(); } ``` -------------------------------- ### Adjust Display Orientation Source: https://context7.com/2dom/pxmatrix/llms.txt Rotates or flips the display output to match physical mounting orientation. ```cpp void setup() { display.begin(8); // Rotate display 90 degrees display.setRotate(true); // Mirror/flip display horizontally display.setFlip(true); // Both can be combined for 180 degree rotation effect display.clearDisplay(); display.setTextColor(display.color565(255, 255, 255)); display.setCursor(0, 0); display.print("Rotated"); } ``` -------------------------------- ### Adjust Multiplexing Delay Source: https://github.com/2dom/pxmatrix/blob/master/README.md Add delay to multiplexing channels to resolve issues with slow panels displaying partial images. ```cpp display.setMuxDelay(1,1,1,1,1) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.