### FastLED Panel Plus APA Example Source: http://docs.pixelmatix.com/SmartMatrix/shield-t4.html An example sketch for driving APA102 LEDs with the SmartMatrix Shield using the FastLED library. ```c++ See the `FastLED_Panel_Plus_APA` sketch in the SmartMatrix Library for an example of driving the APA102 LEDs with the SmartMatrix Shield ``` -------------------------------- ### Include Header and Initialize for 32x32 Panel Source: http://docs.pixelmatix.com/SmartMatrix/library.html Include the specific header for a 32x32 panel and declare the SmartMatrix object. This is the first step before initializing the library in `setup()`. ```cpp #include SmartMatrix matrix; ``` -------------------------------- ### Initialize SmartMatrix Library Source: http://docs.pixelmatix.com/SmartMatrix/library.html Call the `begin()` method within the `setup()` function to initialize the SmartMatrix library. This must be done after including the header and declaring the matrix object. ```cpp void setup() { matrix.begin() } ``` -------------------------------- ### Include Header and Initialize for 16x32 Panel Source: http://docs.pixelmatix.com/SmartMatrix/library.html Include the specific header for a 16x32 panel and declare the SmartMatrix object. This is the first step before initializing the library in `setup()`. ```cpp #include SmartMatrix matrix; ``` -------------------------------- ### Get Screen Dimensions Source: http://docs.pixelmatix.com/SmartMatrix/library.html Retrieve the current width and height of the display buffer after potential rotation. ```cpp uint16_t getScreenWidth(void); uint16_t getScreenHeight(void); ``` -------------------------------- ### Draw Border with Dynamic Dimensions Source: http://docs.pixelmatix.com/SmartMatrix/library.html Draw a white border around the screen using dynamically retrieved screen dimensions, ensuring compatibility with various rotations and display sizes. ```cpp matrix.drawRectangle(0,0, matrix.getScreenHeight()-1, matrix.getScreenWidth()-1, {0xff, 0xff, 0xff}); ``` -------------------------------- ### Rotate Display and Redraw Source: http://docs.pixelmatix.com/SmartMatrix/library.html Clear the screen, swap buffers, rotate the display, and then redraw the content. This is necessary if rotation needs to change mid-program. ```cpp matrix.fillScreen({0,0,0}); // clear screen by filling with black matrix.swapBuffers(); matrix.setRotation(rotation90); // rotate to 90 degree position // now draw your screen again ``` -------------------------------- ### Configure and Display Scrolling Text Source: http://docs.pixelmatix.com/SmartMatrix/library.html Set scrolling mode, speed, font, and color before displaying text. Use a negative scroll count for infinite scrolling. ```cpp matrix.setScrollMode(wrapForward); matrix.setScrollSpeed(10); matrix.setScrollFont(font3x5); matrix.setScrollColor({0xff,0xff,0xff}); matrix.scrollText("Wrap message 4 times", 4); ``` ```cpp matrix.setScrollMode(bounceForward); matrix.setScrollSpeed(20); matrix.setFont(font5x7); matrix.setScrollColor({0x00,0xff,0x00}); matrix.scrollText("Bounce Forever", -1); ``` -------------------------------- ### Include SmartLED Shield for Teensy 4 (V5) Source: http://docs.pixelmatix.com/SmartMatrix/shield-t4.html Uncomment this line in your sketch to specify that you are using the SmartLED Shield for Teensy 4 (V5). This is necessary for correct compilation and operation. ```cpp #include // SmartLED Shield for Teensy 4 (V5) ``` -------------------------------- ### Set Color Correction Mode Source: http://docs.pixelmatix.com/SmartMatrix/library.html Enable or disable color correction. `ccNone` disables it, while `cc24` enables a specific correction mode. ```cpp void setColorCorrection(colorCorrectionModes mode); matrix.setColorCorrection(ccNone); matrix.drawRectangle(0,0, matrix.getScreenHeight(), matrix.getScreenWidth()/3, fullRed); matrix.drawRectangle(matrix.getScreenWidth()/3,0, matrix.getScreenHeight(), matrix.getScreenWidth()/3, halfRed); matrix.drawRectangle(matrix.getScreenWidth()/3*2,0, matrix.getScreenHeight(), matrix.getScreenWidth()/3, quarterRed); matrix.swapBuffers(); ``` ```cpp matrix.setColorCorrection(cc24); ``` -------------------------------- ### Swap Buffers to Display Drawing Source: http://docs.pixelmatix.com/SmartMatrix/library.html Call `swapBuffers()` to update the display with the contents of the drawing buffer. This method waits for the next refresh cycle to ensure a clean update. ```cpp matrix.swapBuffers(); ``` -------------------------------- ### Include SmartLED Shield V4 Header Source: http://docs.pixelmatix.com/SmartMatrix/shield-v4.html Uncomment this line in your sketch to specify that you are using the SmartLED Shield for Teensy 3 (V4). This is essential for the SmartMatrix library to correctly configure the hardware. ```c++ #include // SmartLED Shield for Teensy 3 (V4) ``` -------------------------------- ### Set Display Brightness Source: http://docs.pixelmatix.com/SmartMatrix/library.html Adjust the display brightness without sacrificing color depth. Values range from 0 (off) to 255 (max). ```cpp void setBrightness(uint8_t brightness); matrix.setBrightness(255); // max brightness matrix.setBrightness(25); // 10% brightness, for a dark room ``` -------------------------------- ### Set Display Rotation Source: http://docs.pixelmatix.com/SmartMatrix/library.html Rotate the display by multiples of 90 degrees. This should be done early in the program before drawing. ```cpp matrix.setRotation(rotation180); ``` -------------------------------- ### Draw a Pixel with a Defined Color Source: http://docs.pixelmatix.com/SmartMatrix/library.html Use the `drawPixel()` function with a pre-defined `rgb24` color variable to set the color of a specific pixel at given coordinates. ```cpp rgb24 myColor = {0xff, 0xff, 0xff}; // white drawPixel(0,0,myColor); ``` -------------------------------- ### Set Primary Colors Directly Source: http://docs.pixelmatix.com/SmartMatrix/library.html Assign values directly to the `red`, `green`, and `blue` members of an `rgb24` structure to set a specific color. This is an alternative to initializing with a struct literal. ```cpp rgb24 myColor; myColor.red = 0xff; myColor.green = 0; myColor.blue = 0; ``` -------------------------------- ### Wait for Scrolling Text to Complete Source: http://docs.pixelmatix.com/SmartMatrix/library.html Display text and then wait for all scrolling instances to finish before proceeding. The `scrollText()` function returns the remaining scroll count. ```cpp matrix.scrollText("Display this message twice", 2); // wait for scrolling to finish while(matrix.scrollText()); matrix.scrollText("Then display this message once", 1); ``` -------------------------------- ### Alternate Clock Pin for I2S Output Source: http://docs.pixelmatix.com/SmartMatrix/shield-t4.html Use this option if you need I2S OUT1A and are willing to reroute the HUB75 clock pin. This requires cutting jumper JP4 and soldering to connect pin 8 to the HUB75 panel. ```cpp const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_T4_CLK_PIN_ALT); ``` -------------------------------- ### Define a Color Variable Source: http://docs.pixelmatix.com/SmartMatrix/library.html Declare an `rgb24` variable and assign values to its red, green, and blue members to define a specific color. This color can then be used in drawing functions. ```cpp rgb24 myColor = {0xff, 0xff, 0xff}; // white ``` -------------------------------- ### Stop Scrolling Text Source: http://docs.pixelmatix.com/SmartMatrix/library.html Initiate scrolling text and then stop it after a delay. Useful for temporary text displays. ```cpp matrix.scrollText("Scroll this text forever", -1); delay(1000); matrix.stopScrollText(); ``` -------------------------------- ### APA102 SPI Bus Connection Source: http://docs.pixelmatix.com/SmartMatrix/shield-t4.html Optional configuration for driving APA102 LEDs with the SPI bus. DAT connects to Teensy pin 11 and CLK to Teensy pin 13. This conflicts with the HUB75 pinout. ```c++ DAT to Teensy pin 11, and CLK to Teensy pin 13 ``` -------------------------------- ### APA102 LED Data and Clock Pins Source: http://docs.pixelmatix.com/SmartMatrix/shield-t4.html Connects APA102 LEDs to the SmartLED Shield. DAT is connected to Teensy pin 5 and CLK to Teensy pin 4. VEXT/+5V supplies power from the APA102 strip to the shield. ```c++ DAT is connected to Teensy pin 5 CLK is connected to Teensy pin 4 VEXT/+5V is used to supply 5V from the APA102 strip to the SmartLED Shield ``` -------------------------------- ### Draw a Pixel with an Inline Color Source: http://docs.pixelmatix.com/SmartMatrix/library.html Call `drawPixel()` and define the `rgb24` color directly within the function call using a struct literal. This is useful for one-off color assignments. ```cpp drawPixel(0,0, {0xff, 0, 0}); ``` -------------------------------- ### Define rgb24 Color Structure Source: http://docs.pixelmatix.com/SmartMatrix/library.html The `rgb24` structure defines a color with 8 bits for red, green, and blue components. This is used for all color-related drawing functions in the library. ```c typedef struct rgb24 { uint8_t red; uint8_t green; uint8_t blue; } rgb24; ``` -------------------------------- ### Swap Buffers Without Copying Drawing Buffer Source: http://docs.pixelmatix.com/SmartMatrix/library.html Use `swapBuffers(false)` to disable the copying of the drawing buffer after swapping. This can improve performance if the entire buffer is redrawn each frame. ```cpp matrix.fillScreen({0xff,0,0}); matrix.swapBuffers(false); delay(1000); matrix.fillScreen({0,0xff,0}); matrix.swapBuffers(false); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.