-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor project, add drivers for TFT display and touch, integrate LVGL.
Board config, platform.io, drivers and build settings for new board and display are borrowed from https://github.com/GthiN89/JC3248W535EN. Big thanks to @GthiN89! Setting new version of Arduino framework borrowed from this issue platformio/platform-espressif32#1211 and solution suggested by @maxgerhardt.
- Loading branch information
Showing
23 changed files
with
49,046 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "esp_check.h" | ||
#include "sdkconfig.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Assert on error, if selected in menuconfig. Otherwise return error code. */ | ||
#if CONFIG_BSP_ERROR_CHECK | ||
#define BSP_ERROR_CHECK_RETURN_ERR(x) ESP_ERROR_CHECK(x) | ||
#define BSP_ERROR_CHECK_RETURN_NULL(x) ESP_ERROR_CHECK(x) | ||
#define BSP_ERROR_CHECK(x, ret) ESP_ERROR_CHECK(x) | ||
#define BSP_NULL_CHECK(x, ret) assert(x) | ||
#define BSP_NULL_CHECK_GOTO(x, goto_tag) assert(x) | ||
#else | ||
#define BSP_ERROR_CHECK_RETURN_ERR(x) do { \ | ||
esp_err_t err_rc_ = (x); \ | ||
if (unlikely(err_rc_ != ESP_OK)) { \ | ||
return err_rc_; \ | ||
} \ | ||
} while(0) | ||
|
||
#define BSP_ERROR_CHECK_RETURN_NULL(x) do { \ | ||
if (unlikely((x) != ESP_OK)) { \ | ||
return NULL; \ | ||
} \ | ||
} while(0) | ||
|
||
#define BSP_NULL_CHECK(x, ret) do { \ | ||
if ((x) == NULL) { \ | ||
return ret; \ | ||
} \ | ||
} while(0) | ||
|
||
#define BSP_ERROR_CHECK(x, ret) do { \ | ||
if (unlikely((x) != ESP_OK)) { \ | ||
return ret; \ | ||
} \ | ||
} while(0) | ||
|
||
#define BSP_NULL_CHECK_GOTO(x, goto_tag) do { \ | ||
if ((x) == NULL) { \ | ||
goto goto_tag; \ | ||
} \ | ||
} while(0) | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* @file | ||
* @brief BSP LCD | ||
* | ||
* This file offers API for basic LCD control. | ||
* It is useful for users who want to use the LCD without the default Graphical Library LVGL. | ||
* | ||
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start(). | ||
*/ | ||
|
||
#pragma once | ||
#include "esp_lcd_types.h" | ||
#include "driver/gpio.h" | ||
|
||
/* LCD color formats */ | ||
#define ESP_LCD_COLOR_FORMAT_RGB565 (1) | ||
#define ESP_LCD_COLOR_FORMAT_RGB888 (2) | ||
|
||
/* LCD display color format */ | ||
#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB565) | ||
/* LCD display color bytes endianness */ | ||
#define BSP_LCD_BIGENDIAN (1) | ||
/* LCD display color bits */ | ||
#define BSP_LCD_BITS_PER_PIXEL (16) | ||
/* LCD display color space */ | ||
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_RGB) | ||
/* LCD definition */ | ||
#define LCD_I80_H_RES (170) | ||
#define LCD_I80_V_RES (560) | ||
|
||
#define LCD_QSPI_H_RES (320) | ||
#define LCD_QSPI_V_RES (480) | ||
|
||
/** | ||
* @brief Tear configuration structure | ||
* | ||
*/ | ||
#define BSP_SYNC_TASK_CONFIG(te_io, intr_type) \ | ||
{ \ | ||
.task_priority = 4, \ | ||
.task_stack = 2048, \ | ||
.task_affinity = -1, \ | ||
.time_Tvdl = 13, \ | ||
.time_Tvdh = 3, \ | ||
.te_gpio_num = te_io, \ | ||
.tear_intr_type = intr_type, \ | ||
} | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief BSP display configuration structure | ||
* | ||
*/ | ||
typedef struct { | ||
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */ | ||
struct { | ||
int task_priority; /*!< Tear task priority */ | ||
int task_stack; /*!< Tear task stack size */ | ||
int task_affinity; /*!< Tear task pinned to core (-1 is no affinity) */ | ||
uint32_t time_Tvdl; /*!< The display panel is updated from the Frame Memory, Reference specifications */ | ||
uint32_t time_Tvdh; /*!< The display panel is not updated from the Frame Memory, Reference specifications */ | ||
int te_gpio_num; /*!< Tear gpio num */ | ||
gpio_int_type_t tear_intr_type; /*!< Tear intr type */ | ||
} tear_cfg; | ||
} bsp_display_config_t; | ||
|
||
/** | ||
* @brief Create new display panel | ||
* | ||
* For maximum flexibility, this function performs only reset and initialization of the display. | ||
* You must turn on the display explicitly by calling esp_lcd_panel_disp_on_off(). | ||
* The display's backlight is not turned on either. You can use bsp_display_backlight_on/off(), | ||
* bsp_display_brightness_set() (on supported boards) or implement your own backlight control. | ||
* | ||
* If you want to free resources allocated by this function, you can use esp_lcd API, ie.: | ||
* | ||
* \code{.c} | ||
* esp_lcd_panel_del(panel); | ||
* esp_lcd_panel_io_del(io); | ||
* spi_bus_free(spi_num_from_configuration); | ||
* \endcode | ||
* | ||
* @param[in] config display configuration | ||
* @param[out] ret_panel esp_lcd panel handle | ||
* @param[out] ret_io esp_lcd IO handle | ||
* @return | ||
* - ESP_OK On success | ||
* - Else esp_lcd failure | ||
*/ | ||
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io); | ||
|
||
/** | ||
* @brief Set display's brightness | ||
* | ||
* Brightness is controlled with PWM signal to a pin controlling backlight. | ||
* Display must be already initialized by calling bsp_display_new() | ||
* | ||
* @param[in] brightness_percent Brightness in [%] | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG Parameter error | ||
*/ | ||
esp_err_t bsp_display_brightness_set(int brightness_percent); | ||
|
||
/** | ||
* @brief Turn on display backlight | ||
* | ||
* Display must be already initialized by calling bsp_display_new() | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG Parameter error | ||
*/ | ||
esp_err_t bsp_display_backlight_on(void); | ||
|
||
/** | ||
* @brief Turn off display backlight | ||
* | ||
* Display must be already initialized by calling bsp_display_new() | ||
* | ||
* @return | ||
* - ESP_OK On success | ||
* - ESP_ERR_INVALID_ARG Parameter error | ||
*/ | ||
esp_err_t bsp_display_backlight_off(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include <cmath> | ||
|
||
#include <GxEPD2_BW.h> | ||
#include <GxEPD2_3C.h> | ||
|
||
#define USE_HSPI_FOR_EPD | ||
#define ENABLE_GxEPD2_GFX 0 | ||
|
||
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW | ||
#define GxEPD2_DRIVER_CLASS GxEPD2_420_M01 | ||
|
||
#define GxEPD2_BW_IS_GxEPD2_BW true | ||
#define GxEPD2_3C_IS_GxEPD2_3C true | ||
#define GxEPD2_7C_IS_GxEPD2_7C true | ||
#define GxEPD2_1248_IS_GxEPD2_1248 true | ||
#define IS_GxEPD(c, x) (c##x) | ||
#define IS_GxEPD2_BW(x) IS_GxEPD(GxEPD2_BW_IS_, x) | ||
#define IS_GxEPD2_3C(x) IS_GxEPD(GxEPD2_3C_IS_, x) | ||
#define IS_GxEPD2_7C(x) IS_GxEPD(GxEPD2_7C_IS_, x) | ||
#define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x) | ||
|
||
/** | ||
* Setup the display. | ||
*/ | ||
void setup_display_eink(); | ||
|
||
/** | ||
* Power off the display. | ||
*/ | ||
void power_off_display_eink(); | ||
|
||
/** | ||
* Clear the display. | ||
*/ | ||
void clear_display_eink(); | ||
|
||
/** | ||
* Draw speed in knots. | ||
* | ||
* @param speed | ||
*/ | ||
void draw_speed_eink(float speed); | ||
|
||
/** | ||
* Draw top status bar. | ||
*/ | ||
void draw_top_bar_eink(); | ||
|
||
/** | ||
* Draw bottom status bar. | ||
*/ | ||
void draw_bottom_bar_eink(); | ||
|
||
/** | ||
* Draw status text. | ||
* | ||
* @param text | ||
*/ | ||
void draw_status_eink(String text); | ||
|
||
/** | ||
* Clear status text area. | ||
*/ | ||
void clear_status_eink(); | ||
|
||
/** | ||
* Draw battery capacity indicator. | ||
* | ||
* @param percentage Battery capacity. | ||
*/ | ||
void draw_battery_status_eink(int percentage); | ||
|
||
/** | ||
* Draw time. | ||
* | ||
* @param hours | ||
* @param minutes | ||
* @param seconds | ||
*/ | ||
void draw_time_eink(int hours, int minutes, int seconds); | ||
|
||
/** | ||
* Draw units. | ||
* | ||
* @param text | ||
*/ | ||
void draw_units_eink(String text); | ||
|
||
/** | ||
* Draw rectangle on the screen. | ||
* | ||
* @param x Start point X coordinate. | ||
* @param y Start point Y coordinate. | ||
* @param w Width of the rectangle. | ||
* @param h Height of the rectangle. | ||
* @param partial Partial or full screen draw. | ||
*/ | ||
void draw_box_eink(uint16_t x, uint16_t y, uint16_t w, uint16_t h, bool partial); |
Oops, something went wrong.
1f9c6c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!