2019-08-19 12:21:54 +01:00
|
|
|
/*
|
2019-10-27 10:13:24 +00:00
|
|
|
xdsp_05_epaper.ino - Display e-paper support for Tasmota
|
2019-08-19 12:21:54 +01:00
|
|
|
|
2021-01-01 12:44:04 +00:00
|
|
|
Copyright (C) 2021 Theo Arends, Gerhard Mutz and Waveshare
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-08-23 09:26:09 +01:00
|
|
|
|
2019-08-19 12:21:54 +01:00
|
|
|
#ifdef USE_SPI
|
|
|
|
#ifdef USE_DISPLAY
|
2019-08-23 16:33:30 +01:00
|
|
|
#ifdef USE_DISPLAY_EPAPER_42
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
#define XDSP_06 6
|
|
|
|
|
|
|
|
#define COLORED42 1
|
|
|
|
#define UNCOLORED42 0
|
|
|
|
|
|
|
|
// using font 8 is opional (num=3)
|
|
|
|
// very badly readable, but may be useful for graphs
|
|
|
|
#define USE_TINY_FONT
|
|
|
|
|
|
|
|
#include <epd4in2.h>
|
|
|
|
#include <epdpaint.h>
|
|
|
|
|
2020-12-31 15:17:30 +00:00
|
|
|
bool epd42_init_done = false;
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
Epd42 *epd42;
|
|
|
|
|
2019-08-23 09:26:09 +01:00
|
|
|
|
2019-08-19 12:21:54 +01:00
|
|
|
/*********************************************************************************************/
|
|
|
|
|
2020-12-31 15:17:30 +00:00
|
|
|
void EpdInitDriver42() {
|
|
|
|
if (PinUsed(GPIO_EPAPER42_CS) &&
|
|
|
|
((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) {
|
2019-08-19 12:21:54 +01:00
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
Settings->display_model = XDSP_06;
|
2019-08-19 12:21:54 +01:00
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
if (Settings->display_width != EPD_WIDTH42) {
|
|
|
|
Settings->display_width = EPD_WIDTH42;
|
2019-08-19 12:21:54 +01:00
|
|
|
}
|
2021-06-11 17:14:12 +01:00
|
|
|
if (Settings->display_height != EPD_HEIGHT42) {
|
|
|
|
Settings->display_height = EPD_HEIGHT42;
|
2019-08-19 12:21:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// init renderer
|
2020-12-31 15:17:30 +00:00
|
|
|
epd42 = new Epd42(EPD_WIDTH42, EPD_HEIGHT42);
|
|
|
|
|
|
|
|
if (TasmotaGlobal.soft_spi_enabled) {
|
|
|
|
epd42->Begin(Pin(GPIO_EPAPER42_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK));
|
|
|
|
}
|
|
|
|
else if (TasmotaGlobal.spi_enabled) {
|
|
|
|
epd42->Begin(Pin(GPIO_EPAPER42_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK));
|
|
|
|
}
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
renderer = epd42;
|
|
|
|
|
|
|
|
epd42->Init();
|
|
|
|
|
|
|
|
renderer->fillScreen(0);
|
|
|
|
|
|
|
|
// whiten display with full update, takes 4 seconds
|
|
|
|
epd42->Init(DISPLAY_INIT_FULL);
|
|
|
|
|
2021-06-11 17:14:12 +01:00
|
|
|
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings->display_size,Settings->display_rotate,Settings->display_font);
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
epd42->ClearFrame();
|
|
|
|
renderer->Updateframe();
|
|
|
|
delay(3000);
|
|
|
|
renderer->setTextColor(1,0);
|
|
|
|
|
|
|
|
#ifdef SHOW_SPLASH
|
2022-03-05 21:56:24 +00:00
|
|
|
if (!Settings->flag5.display_no_splash) {
|
|
|
|
// Welcome text
|
|
|
|
renderer->setTextFont(2);
|
|
|
|
renderer->DrawStringAt(50, 140, "Waveshare E-Paper!", COLORED42,0);
|
|
|
|
renderer->Updateframe();
|
|
|
|
delay(350);
|
|
|
|
renderer->fillScreen(0);
|
|
|
|
}
|
2019-08-19 12:21:54 +01:00
|
|
|
#endif
|
|
|
|
|
2020-12-31 15:17:30 +00:00
|
|
|
epd42_init_done = true;
|
2021-01-23 16:10:06 +00:00
|
|
|
AddLog(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2"));
|
2019-08-19 12:21:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************************/
|
|
|
|
|
|
|
|
#ifdef USE_DISPLAY_MODES1TO5
|
|
|
|
|
|
|
|
void EpdRefresh42() // Every second
|
|
|
|
{
|
2021-06-11 17:14:12 +01:00
|
|
|
if (Settings->display_mode) { // Mode 0 is User text
|
2019-08-19 12:21:54 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // USE_DISPLAY_MODES1TO5
|
|
|
|
|
2019-08-23 09:26:09 +01:00
|
|
|
|
2019-08-19 12:21:54 +01:00
|
|
|
/*********************************************************************************************\
|
|
|
|
* Interface
|
|
|
|
\*********************************************************************************************/
|
|
|
|
|
2022-11-11 09:44:56 +00:00
|
|
|
bool Xdsp06(uint32_t function)
|
2019-08-19 12:21:54 +01:00
|
|
|
{
|
|
|
|
bool result = false;
|
|
|
|
|
2020-12-31 15:17:30 +00:00
|
|
|
if (FUNC_DISPLAY_INIT_DRIVER == function) {
|
|
|
|
EpdInitDriver42();
|
|
|
|
}
|
2021-06-11 17:14:12 +01:00
|
|
|
else if (epd42_init_done && (XDSP_06 == Settings->display_model)) {
|
2020-12-31 15:17:30 +00:00
|
|
|
switch (function) {
|
|
|
|
case FUNC_DISPLAY_MODEL:
|
|
|
|
result = true;
|
|
|
|
break;
|
2019-08-19 12:21:54 +01:00
|
|
|
#ifdef USE_DISPLAY_MODES1TO5
|
2020-12-31 15:17:30 +00:00
|
|
|
case FUNC_DISPLAY_EVERY_SECOND:
|
|
|
|
EpdRefresh42();
|
|
|
|
break;
|
2019-08-19 12:21:54 +01:00
|
|
|
#endif // USE_DISPLAY_MODES1TO5
|
|
|
|
}
|
2020-12-31 15:17:30 +00:00
|
|
|
}
|
2019-08-19 12:21:54 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // USE_DISPLAY_EPAPER42
|
|
|
|
#endif // USE_DISPLAY
|
|
|
|
#endif // USE_SPI
|