aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEmil Muratov <gpm@hotplug.ru>2020-11-28 03:19:20 +0300
committerEmil Muratov <gpm@hotplug.ru>2020-11-28 03:19:20 +0300
commit10bbc4e73ab6bc6e90a14d524a07340b17d51902 (patch)
tree751a2eed500524060249b8f80decc9182ef1e361 /examples
parentb64ead007499badcb88d46cf7c889290bfef9903 (diff)
FM6126 init procedure embeded into lib
- example updated - allow MATRIX params to be defined outside the lib during compilation time Signed-off-by: Emil Muratov <gpm@hotplug.ru>
Diffstat (limited to 'examples')
-rw-r--r--examples/FM6126Panel/FM6126Panel.ino174
1 files changed, 57 insertions, 117 deletions
diff --git a/examples/FM6126Panel/FM6126Panel.ino b/examples/FM6126Panel/FM6126Panel.ino
index 923dd34..8b8bd17 100644
--- a/examples/FM6126Panel/FM6126Panel.ino
+++ b/examples/FM6126Panel/FM6126Panel.ino
@@ -4,153 +4,93 @@
#include <Arduino.h>
#include <ESP32-RGB64x32MatrixPanel-I2S-DMA.h>
-RGB64x32MatrixPanel_I2S_DMA matrix;
+RGB64x32MatrixPanel_I2S_DMA dma_display;
+
+#include <FastLED.h>
////////////////////////////////////////////////////////////////////
// Reset Panel
-// This needs to be near the top of the code
-//
-// Change these to whatever suits
-// recommended settings and patches are by
+// FM6126 support is still experimental
//
// pinout for ESP38 38pin module
// http://arduinoinfo.mywikis.net/wiki/Esp32#KS0413_keyestudio_ESP32_Core_Board
//
+// HUB75E pinout
// R1 | G1
// B1 | GND
// R2 | G2
// B2 | E
-// A | B
-// C | D
+// A | B
+// C | D
// CLK| LAT
// OE | GND
#define R1 25
#define G1 26
#define BL1 27
-#define R2 5 // 21 SDA
-#define G2 19 // 22 SDL
-#define BL2 23
-#define CH_A 12
-#define CH_B 16
-#define CH_C 17
-#define CH_D 18
-#define CH_E -1 // assign to pin if using two panels
-#define CLK 15
-#define LAT 32
-#define OE 33
+#define R2 14 // 21 SDA
+#define G2 12 // 22 SDL
+#define BL2 13
+#define CH_A 23
+#define CH_B 19
+#define CH_C 5
+#define CH_D 17
+#define CH_E 32 // assign to any available pin if using two panels or 64x64 panels with 1/32 scan
+#define CLK 16
+#define LAT 4
+#define OE 15
-void resetPanel()
-{
-int MaxLed = 64;
+// End of default setup for RGB Matrix 64x32 panel
+///////////////////////////////////////////////////////////////
-int C12[16] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-int C13[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0};
+int time_counter = 0;
+int cycles = 0;
-pinMode(R1, OUTPUT);
-pinMode(G1, OUTPUT);
-pinMode(BL1, OUTPUT);
-pinMode(R2, OUTPUT);
-pinMode(G2, OUTPUT);
-pinMode(BL2, OUTPUT);
-pinMode(CH_A, OUTPUT);
-pinMode(CH_B, OUTPUT);
-pinMode(CH_C, OUTPUT);
-pinMode(CH_D, OUTPUT);
-pinMode(CH_E, OUTPUT);
-pinMode(CLK, OUTPUT);
-pinMode(LAT, OUTPUT);
-pinMode(OE, OUTPUT);
+CRGB currentColor;
+CRGBPalette16 palettes[] = {HeatColors_p, LavaColors_p, RainbowColors_p, RainbowStripeColors_p, CloudColors_p};
+CRGBPalette16 currentPalette = palettes[0];
-// Send Data to control register 11
-digitalWrite(OE, HIGH); // Display reset
-digitalWrite(LAT, LOW);
-digitalWrite(CLK, LOW);
-for (int l = 0; l < MaxLed; l++)
-{
-int y = l % 16;
-digitalWrite(R1, LOW);
-digitalWrite(G1, LOW);
-digitalWrite(BL1, LOW);
-digitalWrite(R2, LOW);
-digitalWrite(G2, LOW);
-digitalWrite(BL2, LOW);
-if (C12[y] == 1)
-{
-digitalWrite(R1, HIGH);
-digitalWrite(G1, HIGH);
-digitalWrite(BL1, HIGH);
-digitalWrite(R2, HIGH);
-digitalWrite(G2, HIGH);
-digitalWrite(BL2, HIGH);
-}
-if (l > MaxLed - 12)
-{
-digitalWrite(LAT, HIGH);
-}
-else
-{
-digitalWrite(LAT, LOW);
-}
-digitalWrite(CLK, HIGH);
-digitalWrite(CLK, LOW);
-}
-digitalWrite(LAT, LOW);
-digitalWrite(CLK, LOW);
-// Send Data to control register 12
-for (int l = 0; l < MaxLed; l++)
-{
-int y = l % 16;
-digitalWrite(R1, LOW);
-digitalWrite(G1, LOW);
-digitalWrite(BL1, LOW);
-digitalWrite(R2, LOW);
-digitalWrite(G2, LOW);
-digitalWrite(BL2, LOW);
-if (C13[y] == 1)
-{
-digitalWrite(R1, HIGH);
-digitalWrite(G1, HIGH);
-digitalWrite(BL1, HIGH);
-digitalWrite(R2, HIGH);
-digitalWrite(G2, HIGH);
-digitalWrite(BL2, HIGH);
-}
-if (l > MaxLed - 13)
-{
-digitalWrite(LAT, HIGH);
-}
-else
-{
-digitalWrite(LAT, LOW);
-}
-digitalWrite(CLK, HIGH);
-digitalWrite(CLK, LOW);
-}
-digitalWrite(LAT, LOW);
-digitalWrite(CLK, LOW);
+
+CRGB ColorFromCurrentPalette(uint8_t index = 0, uint8_t brightness = 255, TBlendType blendType = LINEARBLEND) {
+ return ColorFromPalette(currentPalette, index, brightness, blendType);
}
-// End of default setup for RGB Matrix 64x32 panel
-///////////////////////////////////////////////////////////////
void setup(){
-resetPanel(); // do this before matrix.begin
+ // If you experience ghosting, you will need to reduce the brightness level, not all RGB Matrix
+ // Panels are the same - some seem to display ghosting artefacts at lower brightness levels.
+ // In the setup() function do something like:
-// If you experience ghosting, you will need to reduce the brightness level, not all RGB Matrix
-// Panels are the same - some seem to display ghosting artefacts at lower brightness levels.
-// In the setup() function do something like:
-
-matrix.setPanelBrightness(10); // SETS THE BRIGHTNESS HERE. 60 OR LOWER IDEAL.
-
-matrix.begin(R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK); // setup the LED matrix
-matrix.setTextColor(matrix.Color(96, 0, 96)); // r,g,b
-matrix.setCursor(1, 15);
-matrix.println("Hello World");
+ dma_display.setPanelBrightness(30); // SETS THE BRIGHTNESS HERE. 60 OR LOWER IDEAL.
+ /**
+ * be sure to specify 'FM6126A' as last parametr to the begin(),
+ * it would reset 6126 registers and enables the matrix
+ */
+ dma_display.begin(R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK, FM6126A);
}
void loop(){
+ for (int x = 0; x < dma_display.width(); x++) {
+ for (int y = 0; y < dma_display.height(); y++) {
+ int16_t v = 0;
+ uint8_t wibble = sin8(time_counter);
+ v += sin16(x * wibble * 3 + time_counter);
+ v += cos16(y * (128 - wibble) + time_counter);
+ v += sin16(y * x * cos8(-time_counter) / 8);
+
+ currentColor = ColorFromPalette(currentPalette, (v >> 8) + 127); //, brightness, currentBlendType);
+ dma_display.drawPixelRGB888(x, y, currentColor.r, currentColor.g, currentColor.b);
+ }
+ }
+
+ time_counter += 1;
+ cycles++;
+ if (cycles >= 1024) {
+ time_counter = 0;
+ cycles = 0;
+ currentPalette = palettes[random(0,sizeof(palettes))];
+ }
} \ No newline at end of file