Skip to content
Snippets Groups Projects
Select Git revision
  • fb155bada40170feb313023470520a7156e9187a
  • master default protected
2 results

display.cpp

Blame
  • display.cpp 2.14 KiB
    #include <Arduino.h>
    #include "display.h"
    
    #define COLOR_DEPTH 24                  // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
    const uint8_t kMatrixWidth = 64;        // known working: 32, 64, 96, 128
    const uint8_t kMatrixHeight = 64;       // known working: 16, 32, 48, 64
    const uint8_t kRefreshDepth = 24;       // known working: 24, 36, 48
    const uint8_t kDmaBufferRows = 2;       // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
    const uint8_t kPanelType = SMARTMATRIX_HUB75_64ROW_MOD32SCAN;   // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
    const uint8_t kMatrixOptions = (SMARTMATRIX_OPTIONS_NONE);      // see http://docs.pixelmatix.com/SmartMatrix for options
    const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
    const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
    const uint8_t kIndexedLayerOptions = (SM_INDEXED_OPTIONS_NONE);
    
    const int defaultBrightness = (25*255)/100;        // (10%) brightness
    const int defaultScrollOffset = 6;
    const rgb24 defaultBackgroundColor = {0x40, 0, 0};
    
    SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
    SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
    SMARTMATRIX_ALLOCATE_SCROLLING_LAYER(scrollingLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kScrollingLayerOptions);
    SMARTMATRIX_ALLOCATE_INDEXED_LAYER(indexedLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kIndexedLayerOptions);
    
    void setupDisplay() {
      matrix.addLayer(&backgroundLayer); 
      matrix.addLayer(&scrollingLayer); 
      matrix.addLayer(&indexedLayer); 
      matrix.begin();
      matrix.setBrightness(defaultBrightness);
      scrollingLayer.setOffsetFromTop(defaultScrollOffset);
      backgroundLayer.enableColorCorrection(true);
    }
    
    void displayLoop() {
        scrollingLayer.setColor({0xff, 0xff, 0xff});
        scrollingLayer.setMode(wrapForward);
        scrollingLayer.setSpeed(40);
        scrollingLayer.setFont(font6x10);
        scrollingLayer.start("SmartMatrix Demo", 1);
        delay(5000);
    }