diff options
| author | chegewara <esp32@esp32.eu.org> | 2022-12-17 12:54:54 +0100 |
|---|---|---|
| committer | chegewara <esp32@esp32.eu.org> | 2022-12-17 12:54:54 +0100 |
| commit | b8367d95d20da4edd149f207dd86665c3cc70588 (patch) | |
| tree | 4c40280fa4b423abf5f26b78ce0f8606163f0363 /src | |
| parent | 361d410ee3167ce76e343d9bcef082357e8beb3d (diff) | |
Add esp-idf standalone support,
tested with esp-idf v5.0
Diffstat (limited to 'src')
| -rw-r--r-- | src/ESP32-HUB75-MatrixPanel-I2S-DMA.h | 1 | ||||
| -rw-r--r-- | src/ESP32-HUB75-MatrixPanel-leddrivers.cpp | 36 | ||||
| -rw-r--r-- | src/platforms/esp32s3/gdma_lcd_parallel16.cpp | 9 |
3 files changed, 28 insertions, 18 deletions
diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h index a18b6bb..0a70e5d 100644 --- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -6,6 +6,7 @@ #include <memory> #include <esp_err.h> #include <esp_log.h> +#include "esp_attr.h" //#include <Arduino.h> #include "platforms/platform_detect.hpp" 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 diff --git a/src/platforms/esp32s3/gdma_lcd_parallel16.cpp b/src/platforms/esp32s3/gdma_lcd_parallel16.cpp index d9460e2..edea630 100644 --- a/src/platforms/esp32s3/gdma_lcd_parallel16.cpp +++ b/src/platforms/esp32s3/gdma_lcd_parallel16.cpp @@ -19,8 +19,11 @@ #if __has_include (<hal/lcd_ll.h>) // Stop compile errors: /src/platforms/esp32s3/gdma_lcd_parallel16.hpp:64:10: fatal error: hal/lcd_ll.h: No such file or directory +#ifdef ARDUINO_ARCH_ESP32 #include <Arduino.h> +#endif #include "gdma_lcd_parallel16.hpp" + #include "esp_attr.h" static const char* TAG = "gdma_lcd_parallel16"; @@ -80,9 +83,9 @@ esp_rom_delay_us(100); // uint32_t lcd_clkm_div_num = ((160000000 + 1) / _cfg.bus_freq); - ESP_LOGI(TAG, "Cpu frequecny is %d", getCpuFrequencyMhz()); + ESP_LOGI(TAG, "Cpu frequecny is %" PRIu16 "", CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ); - uint32_t lcd_clkm_div_num = ( ((getCpuFrequencyMhz()*1000000)+1) / _cfg.bus_freq ) / 4; + uint32_t lcd_clkm_div_num = ( ((CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ*1000000)+1) / _cfg.bus_freq ) / 4; //ESP_LOGI(TAG, "Clock divider is %d", lcd_clkm_div_num); @@ -378,7 +381,7 @@ if ( _dmadesc_a_idx >= _dmadesc_count) { - ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated. Expecting max %d descriptors.", _dmadesc_count); + ESP_LOGE(TAG, "Attempted to create more DMA descriptors than allocated. Expecting max %" PRIu32 " descriptors.", _dmadesc_count); return; } |
