aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authormrfaptastic <12006953+mrfaptastic@users.noreply.github.com>2023-04-02 13:12:53 +0100
committermrfaptastic <12006953+mrfaptastic@users.noreply.github.com>2023-04-02 13:12:53 +0100
commit7c2d527dd8d92efe03d71b5743f46f230b309758 (patch)
tree0b77c30c0751c39983bc578460f9185aab13ae09 /examples
parentb101ae69971d11fe23f52791d5ab29897218a587 (diff)
Cleanup
Diffstat (limited to 'examples')
-rw-r--r--examples/3_DoubleBuffer/3_DoubleBuffer.ino (renamed from examples/BouncingSquares/BouncingSquares.ino)22
-rw-r--r--examples/4_HueValueSpectrumDemo/4_HueValueSpectrumDemo.ino75
-rw-r--r--examples/4_OtherShiftDriverPanel/4_OtherShiftDriverPanel.ino (renamed from examples/3_FM6126Panel/3_FM6126Panel.ino)40
-rw-r--r--examples/4_OtherShiftDriverPanel/FM6126A.md (renamed from examples/3_FM6126Panel/FM6126A.md)0
-rw-r--r--examples/4_OtherShiftDriverPanel/README.md (renamed from examples/3_FM6126Panel/README.md)0
5 files changed, 40 insertions, 97 deletions
diff --git a/examples/BouncingSquares/BouncingSquares.ino b/examples/3_DoubleBuffer/3_DoubleBuffer.ino
index 6a01225..5a41d67 100644
--- a/examples/BouncingSquares/BouncingSquares.ino
+++ b/examples/3_DoubleBuffer/3_DoubleBuffer.ino
@@ -1,3 +1,9 @@
+// Example uses the following configuration: mxconfig.double_buff = true;
+// to enable double buffering, which means display->flipDMABuffer(); is required.
+
+// Bounce squares around the screen, doing the re-drawing in the background back-buffer.
+// Double buffering is not always required in reality.
+
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
MatrixPanel_I2S_DMA *display = nullptr;
@@ -32,14 +38,14 @@ void setup()
Serial.println("...Starting Display");
HUB75_I2S_CFG mxconfig;
- //mxconfig.double_buff = true; // Turn of double buffer
- mxconfig.clkphase = false;
+ mxconfig.double_buff = true; // <------------- Turn on double buffer
+ //mxconfig.clkphase = false;
// OK, now we can create our matrix object
display = new MatrixPanel_I2S_DMA(mxconfig);
display->begin(); // setup display with pins as pre-defined in the library
- // Create some Squares
+ // Create some random squares
for (int i = 0; i < numSquares; i++)
{
Squares[i].square_size = random(2,10);
@@ -47,8 +53,6 @@ void setup()
Squares[i].ypos = random(0, display->height() - Squares[i].square_size);
Squares[i].velocityx = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
Squares[i].velocityy = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
- //Squares[i].xdir = (random(2) == 1) ? true:false;
- //Squares[i].ydir = (random(2) == 1) ? true:false;
int random_num = random(6);
Squares[i].colour = colours[random_num];
@@ -57,9 +61,11 @@ void setup()
void loop()
{
- display->flipDMABuffer(); // not used if double buffering isn't enabled
- delay(25);
- display->clearScreen();
+
+ display->flipDMABuffer(); // Show the back buffer, set currently output buffer to the back (i.e. no longer being sent to LED panels)
+ display->clearScreen(); // Now clear the back-buffer
+
+ delay(16); // <----------- Shouldn't see this clearscreen occur as it happens on the back buffer when double buffering is enabled.
for (int i = 0; i < numSquares; i++)
{
diff --git a/examples/4_HueValueSpectrumDemo/4_HueValueSpectrumDemo.ino b/examples/4_HueValueSpectrumDemo/4_HueValueSpectrumDemo.ino
deleted file mode 100644
index e64d419..0000000
--- a/examples/4_HueValueSpectrumDemo/4_HueValueSpectrumDemo.ino
+++ /dev/null
@@ -1,75 +0,0 @@
-#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
-#define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module.
-#define PANEL_CHAIN 1 // Total number of panels chained one to another
-
-#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
-
-MatrixPanel_I2S_DMA *dma_display = nullptr;
-
-void setup() {
- HUB75_I2S_CFG::i2s_pins _pins={
- 25, //R1_PIN,
- 26, //G1_PIN,
- 27, //B1_PIN,
- 14, //R2_PIN,
- 12, //G2_PIN,
- 13, //B2_PIN,
- 23, //A_PIN,
- 19, //B_PIN,
- 5, //C_PIN,
- 17, //D_PIN,
- 18, //E_PIN,
- 4, //LAT_PIN,
- 15, //OE_PIN,
- 16, //CLK_PIN
- };
- HUB75_I2S_CFG mxconfig(
- PANEL_RES_X, // Module width
- PANEL_RES_Y, // Module height
- PANEL_CHAIN, // chain length
- _pins // pin mapping
- );
- //mxconfig.clkphase = false;
- //mxconfig.driver = HUB75_I2S_CFG::FM6126A;
-
- // Display Setup
- dma_display = new MatrixPanel_I2S_DMA(mxconfig);
- dma_display->begin();
- dma_display->clearScreen();
-}
-
-void loop() {
- // Canvas loop
- float t = (float)(millis()%4000)/4000.f;
- float tt = (float)((millis()%16000)/16000.f;
-
- for(int x = 0; x < PANEL_RES_X*PANEL_CHAIN; x++){
- // calculate the overal shade
- float f = ((sin(tt-(float)x/PANEL_RES_Y/32.)*2.f*PI)+1)/2)*255;
- // calculate hue spectrum into rgb
- float r = max(min(cosf(2.f*PI*(t+((float)x/PANEL_RES_Y+0.f)/3.f))+0.5f,1.f),0.f);
- float g = max(min(cosf(2.f*PI*(t+((float)x/PANEL_RES_Y+1.f)/3.f))+0.5f,1.f),0.f);
- float b = max(min(cosf(2.f*PI*(t+((float)x/PANEL_RES_Y+2.f)/3.f))+0.5f,1.f),0.f);
-
- // iterate pixels for every row
- for(int y = 0; y < PANEL_RES_Y; y++){
- if(y*2 < PANEL_RES_Y){
- // top-middle part of screen, transition of value
- float t = (2.f*y+1)/PANEL_RES_Y;
- dma_display->drawPixelRGB888(x,y,
- (r*t)*f,
- (g*t)*f,
- (b*t)*f
- );
- }else{
- // middle to bottom of screen, transition of saturation
- float t = (2.f*(PANEL_RES_Y-y)-1)/PANEL_RES_Y;
- dma_display->drawPixelRGB888(x,y,
- (r*t+1-t)*f,
- (g*t+1-t)*f,
- (b*t+1-t)*f
- );
- }
- }
- }
-}
diff --git a/examples/3_FM6126Panel/3_FM6126Panel.ino b/examples/4_OtherShiftDriverPanel/4_OtherShiftDriverPanel.ino
index 3b706e1..e62cecc 100644
--- a/examples/3_FM6126Panel/3_FM6126Panel.ino
+++ b/examples/4_OtherShiftDriverPanel/4_OtherShiftDriverPanel.ino
@@ -1,19 +1,30 @@
-// How to use this library with a FM6126 panel, thanks goes to:
-// https://github.com/hzeller/rpi-rgb-led-matrix/issues/746
+/**********************************************************************
+ * The library by default supports simple 'shift register' based panels
+ * with A,B,C,D,E lines to select a specific row, but there are plenty
+ * of examples of new chips coming on the market that work different.
+ *
+ * Please search through the project's issues. For some of these chips
+ * (you will need to look at the back of your panel to identify), this
+ * library has workarounds. This can be configured through using one of:
+
+ // mxconfig.driver = HUB75_I2S_CFG::FM6126A;
+ //mxconfig.driver = HUB75_I2S_CFG::ICN2038S;
+ //mxconfig.driver = HUB75_I2S_CFG::FM6124;
+ //mxconfig.driver = HUB75_I2S_CFG::MBI5124;
+ */
+
#include <Arduino.h>
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include <FastLED.h>
////////////////////////////////////////////////////////////////////
-// FM6126 support is still experimental
// Output resolution and panel chain length configuration
#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
#define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module.
#define PANEL_CHAIN 1 // Total number of panels chained one to another
-
// placeholder for the matrix object
MatrixPanel_I2S_DMA *dma_display = nullptr;
@@ -33,14 +44,6 @@ CRGB ColorFromCurrentPalette(uint8_t index = 0, uint8_t brightness = 255, TBlend
}
void setup(){
-
- /*
- The configuration for MatrixPanel_I2S_DMA object is held in HUB75_I2S_CFG structure,
- All options has it's predefined default values. So we can create a new structure and redefine only the options we need
-
- Please refer to the '2_PatternPlasma.ino' example for detailed example of how to use the MatrixPanel_I2S_DMA configuration
- if you need to change the pin mappings etc.
- */
HUB75_I2S_CFG mxconfig(
PANEL_RES_X, // module width
@@ -48,7 +51,12 @@ void setup(){
PANEL_CHAIN // Chain length
);
- mxconfig.driver = HUB75_I2S_CFG::FM6126A; // in case that we use panels based on FM6126A chip, we can set it here before creating MatrixPanel_I2S_DMA object
+ // in case that we use panels based on FM6126A chip, we can set it here before creating MatrixPanel_I2S_DMA object
+ mxconfig.driver = HUB75_I2S_CFG::FM6126A;
+ //mxconfig.driver = HUB75_I2S_CFG::ICN2038S;
+ //mxconfig.driver = HUB75_I2S_CFG::FM6124;
+ //mxconfig.driver = HUB75_I2S_CFG::MBI5124;
+
// OK, now we can create our matrix object
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
@@ -99,4 +107,8 @@ void loop(){
fps_timer = millis();
fps = 0;
}
-} \ No newline at end of file
+}
+
+
+// FM6126 panel , thanks goes to:
+// https://github.com/hzeller/rpi-rgb-led-matrix/issues/746
diff --git a/examples/3_FM6126Panel/FM6126A.md b/examples/4_OtherShiftDriverPanel/FM6126A.md
index 1641c16..1641c16 100644
--- a/examples/3_FM6126Panel/FM6126A.md
+++ b/examples/4_OtherShiftDriverPanel/FM6126A.md
diff --git a/examples/3_FM6126Panel/README.md b/examples/4_OtherShiftDriverPanel/README.md
index 65019e6..65019e6 100644
--- a/examples/3_FM6126Panel/README.md
+++ b/examples/4_OtherShiftDriverPanel/README.md