lvgl_esp32_drivers/lvgl_tft/calepd_epaper.cpp

85 lines
2.6 KiB
C++
Raw Normal View History

2021-06-01 14:15:31 +00:00
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
2021-06-03 11:38:23 +00:00
#include "calepd_epaper.h"
2021-06-01 14:15:31 +00:00
// NOTE: This needs Epdiy component https://github.com/vroland/epdiy
// Run idf.py menuconfig-> Component Config -> E-Paper driver and select:
// Display type: LILIGO 4.7 ED047TC1
// Board: LILIGO T5-4.7 Epaper
// In the same section Component Config -> ESP32 Specifics -> Enable PSRAM
2021-06-03 11:38:23 +00:00
//#include "parallel/ED047TC1.h"
//Ed047TC1 display;
// SPI Generic epapers (Goodisplay/ Waveshare)
// Select the right class for your SPI epaper: https://github.com/martinberlin/cale-idf/wiki
//#include <gdew0583t7.h>
#include <gdew027w3.h>
Gdew027w3 display(io);
EpdSpi io;
//Gdew0583T7 display(io);
/** test Display dimensions
* Do not forget to set: menuconfig -> Components -> LVGL configuration
* Max. Horizontal resolution 264 -> WIDTH of your epaper
* Max. Vertical resolution 176 -> HEIGHT
*/
2021-06-01 14:15:31 +00:00
/*********************
* DEFINES
*********************/
#define TAG "EPDIY"
uint16_t flushcalls = 0;
/* Display initialization routine */
2021-06-03 11:38:23 +00:00
void calepd_init(void)
2021-06-01 14:15:31 +00:00
{
2021-06-03 11:38:23 +00:00
printf("calepd_init\n");
2021-06-01 14:15:31 +00:00
display.init();
display.setRotation(0);
2021-06-03 11:38:23 +00:00
// Clear screen
//display.update();
2021-06-01 14:15:31 +00:00
}
/* Required by LVGL */
2021-06-03 11:38:23 +00:00
void calepd_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
2021-06-01 14:15:31 +00:00
{
++flushcalls;
2021-06-03 11:38:23 +00:00
printf("flush %d x:%d y:%d w:%d h:%d\n", flushcalls,area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area));
2021-06-01 14:15:31 +00:00
// Full update
if (lv_area_get_width(area)==display.width() && lv_area_get_height(area)==display.height()) {
display.update();
} else {
2021-06-03 11:38:23 +00:00
// Partial update:
display.update(); // Uncomment to disable partial update
//display.updateWindow(area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area), true);
//display.updateWindow(area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area));
2021-06-01 14:15:31 +00:00
}
/* IMPORTANT!!!
* Inform the graphics library that you are ready with the flushing */
lv_disp_flush_ready(drv);
}
/* Called for each pixel */
2021-06-03 11:38:23 +00:00
void calepd_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf,
2021-06-01 14:15:31 +00:00
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa)
{
2021-06-03 11:38:23 +00:00
//If not drawing anything: Debug to see if this function is called:
//printf("set_px %d %d\n",(int16_t)x,(int16_t)y);
2021-06-01 14:15:31 +00:00
// Test using RGB232
int16_t epd_color = EPD_WHITE;
// Color setting use: RGB232
2021-06-03 11:38:23 +00:00
// Only monochrome:All what is not white, turn black
if ((int16_t)color.full<254) {
epd_color = EPD_BLACK;
2021-06-01 14:15:31 +00:00
}
display.drawPixel((int16_t)x, (int16_t)y, epd_color);
}