Skip to content

Commit

Permalink
get ready for ESP-IDF v5 (#180)
Browse files Browse the repository at this point in the history
* 160 remove board defines (#168)

* Add board HAL (Hardware abstraction layer)

Instead of using defines to set the board hardware definitions each
board get its own file with the routines to access the hardware
functions. This way also third party boards can be implemented
without being required to modify the epdiy source.

So far only logic from display_ops.c has been ported. Work still
also exists to optimize duplicated code.

Care has been taken to not break existing code bases. If a board is
defined in menuconfig this will still be used.

* Move content of config_reg_v4.h into epd_board_v5.c

The goal is to get rid of the config_reg_v*.h files

* Move content of config_reg_v4.h into epd_board_v4.c

* Move content of config_reg_v6.h into epd_board_v6.c

* Move content of config_reg_v2.h into epd_board_v2_v3.c

* Move content of config_reg_v2.h into epd_board_lilygo_t5_47.c

* Remove board specific defines from display_ops.h

* Free the i2s clock pin in i2s code

This should not be done for individual boards.

* Deprecate v6 board specific functions as generic function.

Boards specific code should be marked as such.

* Move temperature readings into board code

* Implement a control interface for gpios

Move signals oe, mode and stv to this
Implement start_frame using the ctrl interface

* Move logic of end_frame() from board to display_opts

* Remove uneccesary function latch_row()

* Move logic for latch_row from board to display_opts

* Remove warning about v6_wait_for_interrupt() is unused

* Optimize set_ctrl by supplying a mask with the changed signals

* Share the temperature readings between boards v2 to v5

* Deprecate epd_powerdown() and make it to a board specific function instead

* Read vcom voltage from epd_board_vcom_v6()

This makes vcom voltage available at runtime and not at compile time

* enable CI runs on latest ESP-IDF version

Revert "disable CI runs on latest ESP-IDF for now"

This reverts commit 0e2bd15.

* replace deprecated portTICK_RATE_MS macro

The drop-in replacement is portTICK_PERIOD_MS.

See espressif/esp-idf#51.

* add missing headers

Some symbols and macros were not longer implicitly imported.

* update clock usage

Co-authored-by: jdoubleu <[email protected]>

* update GPIO usage

Co-authored-by: jdoubleu <[email protected]>

* add missing libsodium component as dependency

Disable the component manager in ESP-IDF <5.

See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/removed-components.html#components-moved-to-idf-component-registry

* fix minor errors in examples

For a thorough exaplanation of the st.c changes see https://stackoverflow.com/a/60696378/7201.

* migrate TCP/IP adapter API in mpd_status

See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/tcpip-adapter.html

* update component registration in weather example

Use the recommended flow.

* disable CI job to build arduino-esp32 with ESP-IDF v5

arduino-esp32 does not support ESP-IDF v5, yet (see https://github.com/espressif/arduino-esp32/blob/master/CMakeLists.txt#L8-L9).

* Use gpio port correctly instead of pin when getting LL device

* Fix log print format specifer in www-image example

* Add 'rules' to idf_component yaml file in mpd_status example to correctly pull in libsodium between eps-idf 4.X and 5.X

* Fix pointer arg to error handling function

* Switch between format specifiers based on esp-idf version in www-image example

* remove IRAM_ATTR macros from header declarations

* fix warnings about type incompatibilities

* replace deprecated header

See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/peripherals.html#peripheral-clock-gating

* Empty commit to kick CI to see if new esp-idf releave_v4.3 container pushed 2 days ago fixes libsodium build error

* Update cmakelists to support v5.0-beta1 driver and adc component changes. Compilation failing still, esp_adc_cal functionality neesd to be ported to new adc_cali.h and driver/esp_adc functionality

* Fix CMakeLists to support correct component lists for both idf 4.X and 5.X

* Switch 'latest' esp-idf container tag to 'v5.0-beta1'

* Explicitly add missing components to mpd_status and www-image examples cmakelists that were just inferred in 4.X

* Bump to newly release esp-idf 5.0 docker container for CI

* fix log statements after uint32_t alias changed

Co-authored-by: Micke Prag <[email protected]>
Co-authored-by: dot4qu <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2023
1 parent 562432a commit 12c67ce
Show file tree
Hide file tree
Showing 28 changed files with 203 additions and 72 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
version:
- release-v4.3
- release-v4.4
- release-v5.0
example:
- calibration_helper
- demo
Expand All @@ -23,7 +24,7 @@ jobs:
- mpd_status
- terminal
- www-image

continue-on-error: ${{ matrix.version == 'latest' }}

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ fp-info-cache
__pycache__
examples/weather/components
sdkconfig
managed_components/
3 changes: 2 additions & 1 deletion examples/demo/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

#include "epd_driver.h"
#include "epd_highlevel.h"
Expand Down Expand Up @@ -105,7 +106,7 @@ void idf_loop() {
err = epd_hl_update_screen(&hl, MODE_GL16, temperature);
t2 = millis();
epd_poweroff();
printf("EPD update %dms. err: %d\n", t2 - t1, err);
printf("EPD update %"PRIu32"ms. err: %u\n", t2 - t1, err);

for (int i=0; i < 6; i++) {
epd_poweron();
Expand Down
1 change: 1 addition & 0 deletions examples/mpd_status/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.16.0)
set(EXTRA_COMPONENT_DIRS "../../src/")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

project(mpd_status)
3 changes: 2 additions & 1 deletion examples/mpd_status/components/libmpdclient/src/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>

static int
handle_error(struct mpd_connection *c)
Expand Down Expand Up @@ -169,7 +170,7 @@ int main(int argc, char ** argv) {

audio_format = mpd_status_get_audio_format(status);
if (audio_format != NULL) {
printf("sampleRate: %i\n", audio_format->sample_rate);
printf("sampleRate: %"PRIu32"\n", audio_format->sample_rate);
printf("bits: %i\n", audio_format->bits);
printf("channels: %i\n", audio_format->channels);
}
Expand Down
15 changes: 15 additions & 0 deletions examples/mpd_status/dependencies.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
dependencies:
espressif/libsodium:
component_hash: 36e9832f40c909c0a9135a3e775fcbdd7a2a13d47a1c052ee5b21499eb3eddb5
source:
service_url: https://api.components.espressif.com/
type: service
version: 1.0.20
idf:
component_hash: null
source:
type: idf
version: 5.0.0
manifest_hash: 9d4dcd3c8f27cde5e52f2fba13d202ee2deaa3855572295835aeeb508b8b2c24
target: esp32
version: 1.0.0
2 changes: 1 addition & 1 deletion examples/mpd_status/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set(app_sources "main.c" "mpd_image.c" "mpd_info.c")

idf_component_register(SRCS ${app_sources} REQUIRES epd_driver libmpdclient nvs_flash libsodium)
idf_component_register(SRCS ${app_sources} REQUIRES epd_driver libmpdclient nvs_flash libsodium esp_event esp_wifi)
22 changes: 22 additions & 0 deletions examples/mpd_status/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## IDF Component Manager Manifest File
# This file is only required since ESP-IDF v5.
dependencies:
## Required IDF version
idf:
version: ">=4.1"
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
espressif/libsodium:
version: "~1.0.20"
rules:
- if: "idf_version >= 5.0.0"

22 changes: 19 additions & 3 deletions examples/mpd_status/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

#include "epd_driver.h"
#include "epd_highlevel.h"
Expand All @@ -29,6 +30,13 @@
#include "mpd_image.h"
#include "mpd_info.h"

#include "esp_system.h" // for ESP_IDF_VERSION_VAL
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
#include "esp_netif.h"
#else
#include "tcpip_adapter.h"
#endif

const int queue_x_start = 900;
const int album_cover_x = 100;
const int album_cover_y = 100;
Expand Down Expand Up @@ -106,8 +114,16 @@ void epd_task() {
}

ESP_ERROR_CHECK(ret);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
esp_netif_init();
#else
tcpip_adapter_init();
#endif

ESP_ERROR_CHECK(esp_event_loop_create_default());
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
esp_netif_create_default_wifi_sta();
#endif

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
Expand Down Expand Up @@ -188,7 +204,7 @@ void epd_task() {
free_playback_info(playback_info);

playback_info = new_info;
ESP_LOGW("info", "info is null? %X", (uint32_t)new_info);
ESP_LOGW("info", "info is null? %"PRIX32"", (uint32_t)new_info);
ESP_LOGW("info", "do update? %d", do_update);

// no song playing
Expand Down Expand Up @@ -301,7 +317,7 @@ void epd_task() {
.x = album_cover_x,
.y = album_cover_y,
};
printf("album cover dimensions: %dx%d\n", album_cover->width,
printf("album cover dimensions: %"PRIu32"x%"PRIu32"\n", album_cover->width,
album_cover->height);
album_height = album_cover->height;
epd_copy_to_framebuffer(area, album_cover->data, img_buf);
Expand All @@ -312,7 +328,7 @@ void epd_task() {
.x = album_cover_x,
.y = album_cover_y,
};
printf("album cover dimensions: %dx%d\n", DefaultAlbum_width, DefaultAlbum_height);
printf("album cover dimensions: %"PRIu32"x%"PRIu32"\n", DefaultAlbum_width, DefaultAlbum_height);
album_height = DefaultAlbum_height;
epd_copy_to_framebuffer(area, (uint8_t*)DefaultAlbum_data, img_buf);
}
Expand Down
19 changes: 10 additions & 9 deletions examples/mpd_status/main/mpd_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>

#include "mpd_image.h"

Expand Down Expand Up @@ -41,7 +42,7 @@ feed_jpg_chunk(JDEC *jd, /* Decompressor object */
image_fetch_context_t *context = jd->device;
if (context->chunk_data == NULL) {
char offset_s[32];
snprintf(offset_s, sizeof(offset_s), "%u", context->cover_offset);
snprintf(offset_s, sizeof(offset_s), "%"PRIu32"", context->cover_offset);

printf("use albumart: %d\n", context->use_albumart);
struct mpd_connection *c = context->conn;
Expand Down Expand Up @@ -69,7 +70,7 @@ feed_jpg_chunk(JDEC *jd, /* Decompressor object */
context->use_albumart = true;
ESP_LOGI("mpd_image", "no image with readpicture, trying albumart...\n");
if (!mpd_response_finish(c)) {
handle_error(c);
handle_error(&c);
return -1;
}
int returned = feed_jpg_chunk(jd, buff, nd);
Expand All @@ -78,7 +79,7 @@ feed_jpg_chunk(JDEC *jd, /* Decompressor object */
}

if (!mpd_response_finish(c)) {
handle_error(c);
handle_error(&c);
return -1;
}
fprintf(stderr, "No 'size'\n");
Expand All @@ -91,36 +92,36 @@ feed_jpg_chunk(JDEC *jd, /* Decompressor object */
pair = mpd_recv_pair_named(c, "binary");
if (pair == NULL) {
if (mpd_connection_get_error(c) != MPD_ERROR_SUCCESS) {
handle_error(c);
handle_error(&c);
return -1;
}
fprintf(stderr, "No 'binary'\n");
return -1;
}

uint32_t chunk_size = strtoull(pair->value, NULL, 10);
printf("chunk size: %d\n", chunk_size);
printf("chunk size: %"PRIu32"\n", chunk_size);
mpd_return_pair(c, pair);

if (chunk_size == 0) {
if (!mpd_response_finish(c)) {
handle_error(c);
handle_error(&c);
return -1;
}
return 0;
}

context->chunk_data = malloc(chunk_size);
if (!mpd_recv_binary(c, context->chunk_data, chunk_size)) {
handle_error(c);
handle_error(&c);
return -1;
}

context->chunk_data_size = chunk_size;
context->chunk_data_offset = 0;

if (!mpd_response_finish(c)) {
handle_error(c);
handle_error(&c);
return -1;
}
context->cover_offset += chunk_size;
Expand Down Expand Up @@ -236,7 +237,7 @@ album_cover_t *readpicture(struct mpd_connection *c, char *uri,
context.decoded_image = buf;
context.scale = scale;
printf("orig width: %d orig height: %d\n", jd.width, jd.height);
printf("scaled width: %d scaled height: %d\n", width, height);
printf("scaled width: %"PRIu32" scaled height: %"PRIu32"\n", width, height);

/* Start to decompress the JPEG file */
rc = jd_decomp(&jd, tjd_output, scale);
Expand Down
7 changes: 6 additions & 1 deletion examples/terminal/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* clears execute in 1.075 seconds and images are drawn in 1.531 seconds.
*/

#include "esp_system.h" // for ESP_IDF_VERSION_VAL
#include "driver/uart.h"
#include "esp_heap_caps.h"
#include "driver/gpio.h"
Expand Down Expand Up @@ -77,7 +78,11 @@ void app_main() {
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.use_ref_tick = true,
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
.source_clk = UART_SCLK_REF_TICK
#else
.use_ref_tick = true
#endif
};
uart_param_config(UART_NUM_1, &uart_config);
// Change here to modify tx/rx pins
Expand Down
5 changes: 3 additions & 2 deletions examples/terminal/main/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "esp_sleep.h"
#include "st.h"
#include "config.h"
#include "esp_timer.h"

//#include "win.h"

Expand Down Expand Up @@ -225,7 +226,7 @@ static char utf8encodebyte(Rune, size_t);
static size_t utf8validate(Rune *, size_t);

static char *base64dec(const char *);
static char base64dec_getc(const char **);
static char base64dec_getc(const signed char **);

//static ssize_t xwrite(int, const char *, size_t);
static const EpdFont* get_font(Glyph g);
Expand Down Expand Up @@ -422,7 +423,7 @@ static const char base64_digits[] = {
};

char
base64dec_getc(const char **src)
base64dec_getc(const signed char **src)
{
while (**src && !isprint(**src))
(*src)++;
Expand Down
6 changes: 3 additions & 3 deletions examples/weather/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(COMPONENT_SRCS "weather.cpp" )
set(COMPONENT_ADD_INCLUDEDIRS "")
set(app_sources "weather.cpp")

register_component()
idf_component_register(SRCS ${app_sources}
REQUIRES epd_driver arduino)
4 changes: 2 additions & 2 deletions examples/www-image/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set(
)

idf_component_register(SRCS ${app_sources}
REQUIRES epd_driver
REQUIRES epd_driver esp_wifi
# Add only if you use jpgdec-render.cpp example
jpegdec
nvs_flash esp-tls esp_http_client
# Embed the server root certificate into the final binary
EMBED_TXTFILES ${project_dir}/ssl_cert/server_cert.pem
)
)
Loading

0 comments on commit 12c67ce

Please sign in to comment.