-
-
Save embedded-creations/e49d7baeab57417a422bd9dd738aaaa2 to your computer and use it in GitHub Desktop.
Test FastLED.show timing on different Particle Photon pins.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Measurement of the FastLED.show() routine. | |
Soft SPI is only supported till now on the Photon. | |
However non-SPI pins seem to be 140us faster then when using the SPI pins. | |
Using those SPI pins in hardware design might be interesting for future compatibility | |
when hardware SPI gets supported. | |
Below the timing test of different pin combinations. The APA102 is updated at 16Mhz. | |
*/ | |
// A3/A5 max 593us | |
// D0/D1 max 456us | |
// D2/D3 max 453us | |
// A0/A1 max 456us | |
// A1/A2 max 452us | |
// A2/A3 max 549us (A2 clock, A3 data) | |
// A3/A2 max 496us (A3 clock, A2 data) | |
// A3/A4 max 592us | |
// A4/A5 max 592us | |
// A5/A6 max 593us | |
// A6/A7 max 592us | |
#include "application.h" | |
#include "SmartMatrix3_Photon_Apa102/SmartMatrix3_Photon_Apa102.h" | |
#include "FastLEDSmartMatrix/FastLEDSmartMatrix.h" | |
FASTLED_USING_NAMESPACE; | |
//#include "LumiBase.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 = 16; // known working: 16, 32, 48, 64 | |
const uint8_t kMatrixHeight = 8; // known working: 32, 64, 96, 128 | |
const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48 | |
const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate | |
const uint8_t kPanelType = 0; // 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); | |
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); | |
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); | |
// debug duration | |
unsigned long t1; // for measuring purposes | |
unsigned long t2; // for measuring purposes | |
unsigned long t3 = 0; // for measuring purposes | |
int counter = 0; | |
void setup() { | |
delay(500); | |
Serial.begin(57600); | |
matrix.addLayer(&backgroundLayer); | |
matrix.begin(); | |
matrix.setBrightness(255); | |
backgroundLayer.fillScreen({0,0,0}); | |
} | |
void setTime() { | |
t1 = micros(); | |
} | |
void printTime() { | |
t2 = micros()-t1; | |
if(t2>t3) t3 = t2; | |
Serial.print(F("update time: ")); | |
Serial.print(t3); | |
Serial.print(" "); | |
Serial.println(t2); | |
} | |
void loop() { | |
rgb24 *buffer = backgroundLayer.backBuffer(); | |
if(counter>255) { | |
counter = 0; | |
for(int i = 0; i < kMatrixWidth * kMatrixHeight; i++) { | |
buffer[i] = CRGB(counter,0,255-counter); | |
} | |
} | |
counter++; | |
setTime(); | |
backgroundLayer.swapBuffers(); | |
printTime(); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment