From 6c2de65e90008db900b41dad8de7c81e4d1d07f0 Mon Sep 17 00:00:00 2001 From: Drath Date: Fri, 21 Aug 2026 00:27:08 +0200 Subject: [PATCH] compat w new esp-gfx --- idf_component.yml | 2 +- st7567/st7567.c | 16 +++++++++++----- st7567/st7567.h | 15 +++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/idf_component.yml b/idf_component.yml index cb6f83d..5ef3d55 100644 --- a/idf_component.yml +++ b/idf_component.yml @@ -1,4 +1,4 @@ -version: "2.0.0" +version: "2.0.1" description: "ST7567 128x64 display driver" url: "https://git.drath.cc/drath/esp-st7567" dependencies: diff --git a/st7567/st7567.c b/st7567/st7567.c index b18b994..45ac48f 100644 --- a/st7567/st7567.c +++ b/st7567/st7567.c @@ -4,6 +4,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include +#include static const char *TAG = "ST7567"; @@ -154,16 +155,19 @@ esp_err_t st7567_set_contrast(const st7567_device_t *dev, uint8_t contrast) { return st7567_send_cmd(dev, contrast); } -void st7567_clear_buffer(st7567_device_t *dev) { +esp_err_t st7567_clear_buffer(void *p) { + st7567_device_t* dev = p; memset(dev->framebuffer, 0, sizeof(dev->framebuffer)); + return ESP_OK; } -esp_err_t st7567_clear(st7567_device_t *dev) { +esp_err_t st7567_clear(void *dev) { st7567_clear_buffer(dev); return st7567_update_screen(dev); } -esp_err_t st7567_update_screen(const st7567_device_t *dev) { +esp_err_t st7567_update_screen(const void *p) { + const st7567_device_t* dev = p; for (uint8_t page = 0; page < ST7567_PAGES; page++) { esp_err_t ret; if ((ret = st7567_send_cmd(dev, ST7567_CMD_PAGE_ADDR | page)) != ESP_OK) @@ -192,10 +196,12 @@ static void st7567_set_pixel_color(st7567_device_t *dev, const uint8_t x, const dev->framebuffer[byte_index] &= ~(1 << bit_index); } -void st7567_draw_pixel(void *dev, const uint8_t x, const uint8_t y) { +esp_err_t st7567_draw_pixel(void *dev, const uint8_t x, const uint8_t y) { st7567_set_pixel_color(dev, x, y, 1); + return ESP_OK; } -void st7567_clear_pixel(void *dev, const uint8_t x, const uint8_t y) { +esp_err_t st7567_clear_pixel(void *dev, const uint8_t x, const uint8_t y) { st7567_set_pixel_color(dev, x, y, 0); + return ESP_OK; } \ No newline at end of file diff --git a/st7567/st7567.h b/st7567/st7567.h index d48454b..3092000 100644 --- a/st7567/st7567.h +++ b/st7567/st7567.h @@ -5,7 +5,6 @@ #include #include #include -#include // Display dimensions #define ST7567_WIDTH 128 @@ -98,9 +97,9 @@ esp_err_t st7567_init_spi(const st7567_config_spi_t *config, st7567_device_t *de /** * @brief Clear the display (just wipe framebuffer, don't send any commands) * - * @param dev Device handle + * @param p Device handle */ -void st7567_clear_buffer(st7567_device_t *dev); +esp_err_t st7567_clear_buffer(void *p); /** * @brief Clear the display (both GDRAM and local framebuffer) @@ -108,7 +107,7 @@ void st7567_clear_buffer(st7567_device_t *dev); * @param dev Device handle * @return esp_err_t ESP_OK on success */ -esp_err_t st7567_clear(st7567_device_t *dev); +esp_err_t st7567_clear(void *dev); /** * @brief Set contrast (electronic volume) @@ -122,10 +121,10 @@ esp_err_t st7567_set_contrast(const st7567_device_t *dev, uint8_t contrast); /** * @brief Push the local framebuffer contents to the display * - * @param dev Device handle + * @param p Device handle * @return esp_err_t ESP_OK on success */ -esp_err_t st7567_update_screen(const st7567_device_t *dev); +esp_err_t st7567_update_screen(const void *p); /** * @brief Turn a pixel ON at given coordinates @@ -133,7 +132,7 @@ esp_err_t st7567_update_screen(const st7567_device_t *dev); * @param x x coordinate * @param y y coordinate */ -void st7567_draw_pixel(void *dev, uint8_t x, uint8_t y); +esp_err_t st7567_draw_pixel(void *dev, uint8_t x, uint8_t y); /** * @brief Turn a pixel OFF at given coordinates @@ -141,4 +140,4 @@ void st7567_draw_pixel(void *dev, uint8_t x, uint8_t y); * @param x x coordinate * @param y y coordinate */ -void st7567_clear_pixel(void *dev, uint8_t x, uint8_t y); \ No newline at end of file +esp_err_t st7567_clear_pixel(void *dev, uint8_t x, uint8_t y); \ No newline at end of file