Add esp-idf standalone support,

tested with esp-idf v5.0
This commit is contained in:
chegewara 2022-12-17 12:54:54 +01:00
parent 361d410ee3
commit b8367d95d2
4 changed files with 47 additions and 20 deletions

View file

@ -3,10 +3,18 @@
# MIT License # MIT License
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
idf_build_get_property(target IDF_TARGET)
if(ARDUINO_ARCH_ESP32)
list(APPEND arduino_build arduino Adafruit-GFX-Library)
else()
list(APPEND esp_idf_build esp_lcd driver)
endif()
idf_component_register(SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp" "src/ESP32-HUB75-MatrixPanel-leddrivers.cpp" idf_component_register(SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp" "src/ESP32-HUB75-MatrixPanel-leddrivers.cpp"
INCLUDE_DIRS "." src/platforms/${target}/gdma_lcd_parallel16.cpp
REQUIRES arduino Adafruit-GFX-Library) INCLUDE_DIRS "./src"
PRIV_REQUIRES ${arduino_build} ${esp_idf_build}
)
# In case you are running into issues with "missing" header files from 3rd party libraries # In case you are running into issues with "missing" header files from 3rd party libraries
# you can add them to the REQUIRES section above. If you use some of the build options below # you can add them to the REQUIRES section above. If you use some of the build options below
@ -16,6 +24,15 @@ idf_component_register(SRCS "src/platforms/esp32/esp32_i2s_parallel_dma.cpp" "sr
# target_compile_options(${COMPONENT_TARGET} PUBLIC -DUSE_GFX_ROOT) # target_compile_options(${COMPONENT_TARGET} PUBLIC -DUSE_GFX_ROOT)
# target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX) # target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX)
# esp-idf does not have any GFX library support yet, so we need to define NO_GFX
if(ARDUINO_ARCH_ESP32)
else()
target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX)
if(${target} STREQUAL "esp32s3")
target_compile_options(${COMPONENT_TARGET} PUBLIC -DSPIRAM_FRAMEBUFFER)
endif()
endif()
# You can also use multiple options like this # You can also use multiple options like this
# target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX -DNO_FAST_FUNCTIONS) # target_compile_options(${COMPONENT_TARGET} PUBLIC -DNO_GFX -DNO_FAST_FUNCTIONS)

View file

@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include <esp_err.h> #include <esp_err.h>
#include <esp_log.h> #include <esp_log.h>
#include "esp_attr.h"
//#include <Arduino.h> //#include <Arduino.h>
#include "platforms/platform_detect.hpp" #include "platforms/platform_detect.hpp"

View file

@ -3,10 +3,16 @@
*/ */
#ifdef ARDUINO_ARCH_ESP32
#include <Arduino.h> #include <Arduino.h>
#else
#include <driver/gpio.h>
#define LOW 0
#define HIGH 1
#endif
#include "ESP32-HUB75-MatrixPanel-I2S-DMA.h" #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 * @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 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}){ 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); gpio_set_direction((gpio_num_t) _pin, GPIO_MODE_OUTPUT);
digitalWrite(_pin, LOW); 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 // Send Data to control register REG1
// this sets the matrix brightness actually // this sets the matrix brightness actually
for (int l = 0; l < PIXELS_PER_ROW; l++){ 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}) 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 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 CLK_PULSE
} }
// drop the latch and save data to the REG1 all over the FM6124 chips // 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) // Send Data to control register REG2 (enable LED output)
for (int l = 0; l < PIXELS_PER_ROW; l++){ 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}) 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 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 CLK_PULSE
} }
// drop the latch and save data to the REG1 all over the FM6126 chips // 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 // 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}) 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){ for (int l = 0; l < PIXELS_PER_ROW; ++l){
CLK_PULSE CLK_PULSE
} }
digitalWrite(_cfg.gpio.lat, HIGH); gpio_set_level((gpio_num_t) _cfg.gpio.lat, HIGH);
CLK_PULSE CLK_PULSE
digitalWrite(_cfg.gpio.lat, LOW); gpio_set_level((gpio_num_t) _cfg.gpio.lat, LOW);
digitalWrite(_cfg.gpio.oe, LOW); // Enable Display gpio_set_level((gpio_num_t) _cfg.gpio.oe, LOW); // Enable Display
CLK_PULSE CLK_PULSE
} }

View file

@ -19,8 +19,11 @@
#if __has_include (<hal/lcd_ll.h>) #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 // 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> #include <Arduino.h>
#endif
#include "gdma_lcd_parallel16.hpp" #include "gdma_lcd_parallel16.hpp"
#include "esp_attr.h"
static const char* TAG = "gdma_lcd_parallel16"; static const char* TAG = "gdma_lcd_parallel16";
@ -80,9 +83,9 @@
esp_rom_delay_us(100); esp_rom_delay_us(100);
// uint32_t lcd_clkm_div_num = ((160000000 + 1) / _cfg.bus_freq); // 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); //ESP_LOGI(TAG, "Clock divider is %d", lcd_clkm_div_num);
@ -378,7 +381,7 @@
if ( _dmadesc_a_idx >= _dmadesc_count) 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; return;
} }