compat w new esp-gfx

This commit is contained in:
2026-08-21 00:27:08 +02:00
parent df7d135577
commit 6c2de65e90
3 changed files with 19 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
version: "2.0.0" version: "2.0.1"
description: "ST7567 128x64 display driver" description: "ST7567 128x64 display driver"
url: "https://git.drath.cc/drath/esp-st7567" url: "https://git.drath.cc/drath/esp-st7567"
dependencies: dependencies:

View File

@@ -4,6 +4,7 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include <driver/i2c_master.h> #include <driver/i2c_master.h>
#include <driver/gpio.h>
static const char *TAG = "ST7567"; 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); 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)); 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); st7567_clear_buffer(dev);
return st7567_update_screen(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++) { for (uint8_t page = 0; page < ST7567_PAGES; page++) {
esp_err_t ret; esp_err_t ret;
if ((ret = st7567_send_cmd(dev, ST7567_CMD_PAGE_ADDR | page)) != ESP_OK) 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); 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); 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); st7567_set_pixel_color(dev, x, y, 0);
return ESP_OK;
} }

View File

@@ -5,7 +5,6 @@
#include <soc/gpio_num.h> #include <soc/gpio_num.h>
#include <driver/spi_master.h> #include <driver/spi_master.h>
#include <driver/i2c_master.h> #include <driver/i2c_master.h>
#include <driver/gpio.h>
// Display dimensions // Display dimensions
#define ST7567_WIDTH 128 #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) * @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) * @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 * @param dev Device handle
* @return esp_err_t ESP_OK on success * @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) * @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 * @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 * @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 * @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 x x coordinate
* @param y y 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 * @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 x x coordinate
* @param y y coordinate * @param y y coordinate
*/ */
void st7567_clear_pixel(void *dev, uint8_t x, uint8_t y); esp_err_t st7567_clear_pixel(void *dev, uint8_t x, uint8_t y);