From 1ac48e5397ee22a59a18a314c4acf44c23dfe946 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Tue, 31 May 2022 14:22:52 +0300 Subject: [PATCH] Better handling of unsupported chips (#398) --- CMakeLists.txt | 12 +++++++----- conversions/esp_jpg_decode.c | 4 ++-- conversions/to_bmp.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7265820..105e419 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,6 @@ +# get IDF version for comparison +set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}") + # set conversion sources set(COMPONENT_SRCS conversions/yuv.c @@ -16,6 +19,8 @@ set(COMPONENT_ADD_INCLUDEDIRS conversions/include ) +set(COMPONENT_REQUIRES driver) + # set driver sources only for supported platforms if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") list(APPEND COMPONENT_SRCS @@ -68,14 +73,11 @@ if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET ST ) endif() - set(COMPONENT_REQUIRES driver) set(COMPONENT_PRIV_REQUIRES freertos nvs_flash) - set(min_supported_idf_version "4.2") - set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}") - if (idf_version VERSION_GREATER_EQUAL min_supported_idf_version) + set(min_version_for_esp_timer "4.2") + if (idf_version VERSION_GREATER_EQUAL min_version_for_esp_timer) list(APPEND COMPONENT_PRIV_REQUIRES esp_timer) - message(WARNING "ESP-IDF version detected: '${idf_version}'.") endif() endif() diff --git a/conversions/esp_jpg_decode.c b/conversions/esp_jpg_decode.c index 95c8360..52833a7 100644 --- a/conversions/esp_jpg_decode.c +++ b/conversions/esp_jpg_decode.c @@ -61,7 +61,7 @@ static const char * jd_errors[] = { "Not supported JPEG standard" }; -static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) +static unsigned int _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) { uint16_t x = rect->left; uint16_t y = rect->top; @@ -77,7 +77,7 @@ static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) return 0; } -static uint32_t _jpg_read(JDEC *decoder, uint8_t *buf, uint32_t len) +static unsigned int _jpg_read(JDEC *decoder, uint8_t *buf, unsigned int len) { esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; if (jpeg->len && len > (jpeg->len - jpeg->index)) { diff --git a/conversions/to_bmp.c b/conversions/to_bmp.c index 508ede6..e267c78 100644 --- a/conversions/to_bmp.c +++ b/conversions/to_bmp.c @@ -160,7 +160,7 @@ static bool _rgb565_write(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16 } //input buffer -static uint32_t _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) +static unsigned int _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) { rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; if(buf) {