mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Update
This commit is contained in:
parent
3cb0784e01
commit
84bb29d089
@ -1,3 +1,10 @@
|
||||
/**
|
||||
* This code is based on the esp_lcd_ssd1681 driver from https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_ssd1681
|
||||
* The esp_lcd_ssd1681 driver is copyrighted by "2023 Espressif Systems (Shanghai) CO LTD" and was distributed under Apache License:
|
||||
* https://github.com/espressif/esp-bsp/blob/master/components/lcd/esp_lcd_ssd1681/license.txt
|
||||
*
|
||||
* The gdeq driver is licensed under Tactility's GPL v2 license.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@ -21,11 +28,6 @@
|
||||
|
||||
static const char* TAG = "lcd_panel.epaper";
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_epaper_panel_cb_t callback_ptr;
|
||||
void* args;
|
||||
} epaper_panel_callback_t;
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_t base;
|
||||
esp_lcd_panel_io_handle_t io;
|
||||
@ -34,8 +36,6 @@ typedef struct {
|
||||
bool full_refresh;
|
||||
bool fast_refresh;
|
||||
int busy_gpio_num;
|
||||
// Configurations from e-Paper specific public functions
|
||||
epaper_panel_callback_t epaper_refresh_done_isr_callback;
|
||||
uint8_t* _framebuffer;
|
||||
} epaper_panel_t;
|
||||
|
||||
@ -54,18 +54,10 @@ static esp_err_t epaper_panel_set_gap(esp_lcd_panel_t* panel, int x_gap, int y_g
|
||||
static esp_err_t epaper_panel_disp_on_off(esp_lcd_panel_t* panel, bool on_off);
|
||||
|
||||
static esp_err_t panel_epaper_wait_busy(esp_lcd_panel_t* panel) {
|
||||
epaper_panel_t* epaper_panel = __containerof(panel, epaper_panel_t, base);
|
||||
// TODO: Fix this
|
||||
// epaper_panel_t* epaper_panel = __containerof(panel, epaper_panel_t, base);
|
||||
// Wait until busy pin is high (busy means low)
|
||||
while (gpio_get_level(epaper_panel->busy_gpio_num) != 0) { vTaskDelay(pdMS_TO_TICKS(15)); }
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t epaper_panel_register_event_callbacks(esp_lcd_panel_t* panel, epaper_panel_callbacks_t* cbs, void* user_ctx) {
|
||||
ESP_RETURN_ON_FALSE(panel, ESP_ERR_INVALID_ARG, TAG, "panel handler is NULL");
|
||||
ESP_RETURN_ON_FALSE(cbs, ESP_ERR_INVALID_ARG, TAG, "cbs is NULL");
|
||||
epaper_panel_t* epaper_panel = __containerof(panel, epaper_panel_t, base);
|
||||
(epaper_panel->epaper_refresh_done_isr_callback).callback_ptr = cbs->on_epaper_refresh_done;
|
||||
(epaper_panel->epaper_refresh_done_isr_callback).args = user_ctx;
|
||||
// while (gpio_get_level(epaper_panel->busy_gpio_num) != 0) { vTaskDelay(pdMS_TO_TICKS(15)); }
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -199,11 +191,6 @@ static esp_err_t epaper_panel_reset(esp_lcd_panel_t* panel) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t epaper_panel_set_bitmap_color(esp_lcd_panel_t* panel, esp_lcd_gdeq_bitmap_color_t color) {
|
||||
// Not implemented
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
static esp_err_t epaper_panel_init(esp_lcd_panel_t* panel) {
|
||||
epaper_panel_t* epaper_panel = __containerof(panel, epaper_panel_t, base);
|
||||
esp_lcd_panel_io_handle_t io = epaper_panel->io;
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
/**
|
||||
* This code is based on the esp_lcd_ssd1681 driver from https://github.com/espressif/esp-bsp/tree/master/components/lcd/esp_lcd_ssd1681
|
||||
* The esp_lcd_ssd1681 driver is copyrighted by "2023 Espressif Systems (Shanghai) CO LTD" and was distributed under Apache License:
|
||||
* https://github.com/espressif/esp-bsp/blob/master/components/lcd/esp_lcd_ssd1681/license.txt
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* The gdeq driver is licensed under Tactility's GPL v2 license.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -15,40 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Prototype of ssd1681 driver event callback
|
||||
*
|
||||
* @param[in] handle esp_lcd_panel_handle_t esp_lcd driver handle
|
||||
* @param[in] edata reserved
|
||||
* @param[in] user_data User registered context, registered in `epaper_panel_register_event_callbacks()`
|
||||
*
|
||||
* @return Whether a high priority task is woken up by this function
|
||||
*/
|
||||
typedef bool (*esp_lcd_epaper_panel_cb_t)(const esp_lcd_panel_handle_t handle, const void *edata, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Type of ssd1681 e-paper callbacks
|
||||
*/
|
||||
typedef struct {
|
||||
esp_lcd_epaper_panel_cb_t on_epaper_refresh_done; /*!< Callback invoked when e-paper refresh finishes */
|
||||
} epaper_panel_callbacks_t;
|
||||
|
||||
/**
|
||||
* @brief Enum of colors available of ssd1681 e-paper
|
||||
* Some of the ssd1681 e-paper panels support not only black pixels but also red pixels.
|
||||
* Use this enum to select the color of the bitmap you want to display.
|
||||
* Need be set using `epaper_panel_set_bitmap_color()` before calling `epaper_panel_draw_bitmap()`.
|
||||
* @note Default to `SSD1681_EPAPER_BITMAP_BLACK` if not set.
|
||||
*/
|
||||
typedef enum {
|
||||
SSD1681_EPAPER_BITMAP_BLACK, /*!< Draw the bitmap in black */
|
||||
SSD1681_EPAPER_BITMAP_RED /*!< Draw the bitmap in red */
|
||||
} esp_lcd_gdeq_bitmap_color_t;
|
||||
|
||||
/**
|
||||
* @brief Create LCD panel for model ssd1681 e-Paper
|
||||
* @attention
|
||||
* Need to call `gpio_install_isr_service()` before calling this function.
|
||||
* @param[in] io LCD panel IO handle
|
||||
* @brief Create panel for display model gdeq031t10
|
||||
* @param[in] io panel IO handle
|
||||
* @param[in] panel_dev_config general panel device configuration
|
||||
* @param[out] ret_panel Returned LCD panel handle
|
||||
* @return
|
||||
@ -56,70 +26,21 @@ typedef enum {
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_lcd_new_panel_gdeq031t10(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config,
|
||||
esp_lcd_panel_handle_t *ret_panel);
|
||||
esp_err_t esp_lcd_new_panel_gdeq031t10(esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel);
|
||||
|
||||
/**
|
||||
* @brief Refresh the e-Paper
|
||||
*
|
||||
* @note This function is called automatically in `draw_bitmap()` function.
|
||||
* This function will return right after the refresh commands finish transmitting.
|
||||
* @attention
|
||||
* If you want to call this function, you have to wait manually until the BUSY pin goes LOW
|
||||
* before calling other functions that interacts with the e-paper.
|
||||
* @brief Refresh the display
|
||||
*
|
||||
* @param[in] panel LCD panel handle
|
||||
* @param[in] fast whether to refresh fast or regularly
|
||||
* @param[in] full whether to do a full refresh (slower) or a partial one
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t epaper_panel_refresh_screen(esp_lcd_panel_t *panel, bool fast, bool full);
|
||||
|
||||
/**
|
||||
* @brief Set the color of the next bitmap
|
||||
*
|
||||
* @note The SSD1681 has two separate vrams. One for black and the other for red(or maybe some other color).
|
||||
* Call this function to set which vram the next bitmap would write into.
|
||||
* If you set `epaper_panel_invert_color()` to false, then 0 means WHITE.
|
||||
*
|
||||
* @param[in] panel LCD panel handle
|
||||
* @param[in] color a enum value, SSD1681_EPAPER_BITMAP_BLACK or SSD1681_EPAPER_BITMAP_RED
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t epaper_panel_set_bitmap_color(esp_lcd_panel_t *panel, esp_lcd_gdeq_bitmap_color_t color);
|
||||
|
||||
/**
|
||||
* @brief Set the callback function
|
||||
*
|
||||
* @note The callback function `on_epaper_refresh_done` will only be called right after a `draw_bitmap()` caused refresh finishes.
|
||||
* @note You could set the `epaper_panel_callbacks_t->esp_lcd_epaper_panel_cb_t` to NULL to unregister the callback.
|
||||
* @attention
|
||||
* The callback function `on_epaper_refresh_done` will be called in isr context, so please keep it as neat as possible.
|
||||
*
|
||||
* @param[in] panel LCD panel handle
|
||||
* @param[in] cbs callback functions
|
||||
* @param[in] user_ctx arg to be passed to your callback function
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
*/
|
||||
esp_err_t epaper_panel_register_event_callbacks(esp_lcd_panel_t *panel, epaper_panel_callbacks_t *cbs, void *user_ctx);
|
||||
|
||||
/**
|
||||
* @brief Set a custom waveform lut
|
||||
*
|
||||
* @note Set a custom waveform lut for your e-paper panel.
|
||||
* @note You do not have to call this function because e-paper panels usually have waveform lut built-in.
|
||||
* @note You could call `disp_on_off(panel_handle, true)` to reset the waveform LUT to the built-in one
|
||||
*
|
||||
* @param[in] panel LCD panel handle
|
||||
* @param[in] lut your custom lut array
|
||||
* @param[in] size size of your lut array, make sure it is SSD1681_LUT_SIZE bytes
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
*/
|
||||
esp_err_t epaper_panel_set_custom_lut(esp_lcd_panel_t *panel, uint8_t *lut, size_t size);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user