aboutsummaryrefslogtreecommitdiff
path: root/src/ESP32-HUB75-MatrixPanel-leddrivers.cpp
diff options
context:
space:
mode:
authorchegewara <esp32@esp32.eu.org>2022-12-17 12:54:54 +0100
committerchegewara <esp32@esp32.eu.org>2022-12-17 12:54:54 +0100
commitb8367d95d20da4edd149f207dd86665c3cc70588 (patch)
tree4c40280fa4b423abf5f26b78ce0f8606163f0363 /src/ESP32-HUB75-MatrixPanel-leddrivers.cpp
parent361d410ee3167ce76e343d9bcef082357e8beb3d (diff)
Add esp-idf standalone support,
tested with esp-idf v5.0
Diffstat (limited to 'src/ESP32-HUB75-MatrixPanel-leddrivers.cpp')
-rw-r--r--src/ESP32-HUB75-MatrixPanel-leddrivers.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/ESP32-HUB75-MatrixPanel-leddrivers.cpp b/src/ESP32-HUB75-MatrixPanel-leddrivers.cpp
index 2c9139e..0bb20f7 100644
--- a/src/ESP32-HUB75-MatrixPanel-leddrivers.cpp
+++ b/src/ESP32-HUB75-MatrixPanel-leddrivers.cpp
@@ -3,10 +3,16 @@
*/
-#include <Arduino.h>
+#ifdef ARDUINO_ARCH_ESP32
+ #include <Arduino.h>
+#else
+ #include <driver/gpio.h>
+ #define LOW 0
+ #define HIGH 1
+#endif
#include "ESP32-HUB75-MatrixPanel-I2S-DMA.h"
-#define CLK_PULSE digitalWrite(_cfg.gpio.clk, HIGH); digitalWrite(_cfg.gpio.clk, LOW);
+#define CLK_PULSE gpio_set_level((gpio_num_t) _cfg.gpio.clk, HIGH); gpio_set_level((gpio_num_t) _cfg.gpio.clk, LOW);
/**
* @brief - pre-init procedures for specific led-drivers
@@ -43,52 +49,52 @@ void MatrixPanel_I2S_DMA::fm6124init(const HUB75_I2S_CFG& _cfg) {
bool REG2[16] = {0,0,0,0,0, 0,0,0,0,1,0, 0,0,0,0,0}; // a single bit enables the matrix output
for (uint8_t _pin:{_cfg.gpio.r1, _cfg.gpio.r2, _cfg.gpio.g1, _cfg.gpio.g2, _cfg.gpio.b1, _cfg.gpio.b2, _cfg.gpio.clk, _cfg.gpio.lat, _cfg.gpio.oe}){
- pinMode(_pin, OUTPUT);
- digitalWrite(_pin, LOW);
+ gpio_set_direction((gpio_num_t) _pin, GPIO_MODE_OUTPUT);
+ gpio_set_level((gpio_num_t) _pin, LOW);
}
- digitalWrite(_cfg.gpio.oe, HIGH); // Disable Display
+ gpio_set_level((gpio_num_t) _cfg.gpio.oe, HIGH); // Disable Display
// Send Data to control register REG1
// this sets the matrix brightness actually
for (int l = 0; l < PIXELS_PER_ROW; l++){
for (uint8_t _pin:{_cfg.gpio.r1, _cfg.gpio.r2, _cfg.gpio.g1, _cfg.gpio.g2, _cfg.gpio.b1, _cfg.gpio.b2})
- digitalWrite(_pin, REG1[l%16]); // we have 16 bits shifters and write the same value all over the matrix array
+ gpio_set_level((gpio_num_t) _pin, REG1[l%16]); // we have 16 bits shifters and write the same value all over the matrix array
if (l > PIXELS_PER_ROW - 12){ // pull the latch 11 clocks before the end of matrix so that REG1 starts counting to save the value
- digitalWrite(_cfg.gpio.lat, HIGH);
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, HIGH);
}
CLK_PULSE
}
// drop the latch and save data to the REG1 all over the FM6124 chips
- digitalWrite(_cfg.gpio.lat, LOW);
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, LOW);
// Send Data to control register REG2 (enable LED output)
for (int l = 0; l < PIXELS_PER_ROW; l++){
for (uint8_t _pin:{_cfg.gpio.r1, _cfg.gpio.r2, _cfg.gpio.g1, _cfg.gpio.g2, _cfg.gpio.b1, _cfg.gpio.b2})
- digitalWrite(_pin, REG2[l%16]); // we have 16 bits shifters and we write the same value all over the matrix array
+ gpio_set_level((gpio_num_t) _pin, REG2[l%16]); // we have 16 bits shifters and we write the same value all over the matrix array
if (l > PIXELS_PER_ROW - 13){ // pull the latch 12 clocks before the end of matrix so that reg2 stars counting to save the value
- digitalWrite(_cfg.gpio.lat, HIGH);
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, HIGH);
}
CLK_PULSE
}
// drop the latch and save data to the REG1 all over the FM6126 chips
- digitalWrite(_cfg.gpio.lat, LOW);
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, LOW);
// blank data regs to keep matrix clear after manipulations
for (uint8_t _pin:{_cfg.gpio.r1, _cfg.gpio.r2, _cfg.gpio.g1, _cfg.gpio.g2, _cfg.gpio.b1, _cfg.gpio.b2})
- digitalWrite(_pin, LOW);
+ gpio_set_level((gpio_num_t) _pin, LOW);
for (int l = 0; l < PIXELS_PER_ROW; ++l){
CLK_PULSE
}
- digitalWrite(_cfg.gpio.lat, HIGH);
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, HIGH);
CLK_PULSE
- digitalWrite(_cfg.gpio.lat, LOW);
- digitalWrite(_cfg.gpio.oe, LOW); // Enable Display
+ gpio_set_level((gpio_num_t) _cfg.gpio.lat, LOW);
+ gpio_set_level((gpio_num_t) _cfg.gpio.oe, LOW); // Enable Display
CLK_PULSE
} \ No newline at end of file