I've been using a GDEM029T94 with a esp32-S3 In the past with my code no problem, i have a version of my code that uses deep sleep and one without. My GDEM029T94 worked well with both versions of my code. Now i switched to a GDEY029T94 (2.9 inch E Ink screen fast refresh, SPI e-paper display, GDEY029T94_Good Display) SSD1680. And my code that doesn't utilize deep sleep works as it should, but when i try to use my code that uses deep sleep the screen wont do partial updates. At the end of my code right before deep sleep i run this code:
display.firstPage();
display.setPartialWindow(timex-4, timey-5, 45, 18);
do {
display.fillScreen(GxEPD_WHITE);
u8g2Fonts.setCursor(timex, timey + 10);
u8g2Fonts.print(millis());
PrintSec(seconds);
PrintColon();
PrintMin(minutes);
}
while (display.nextPage());
sleepSensor(1000);
}
After this my screen doesnt do the partial update and only shows the initial print on the screen, but i can tell that there is some updating happening on the screen (borders flicker when trying to update), and after about a minute or two i can see the numbers faintly beginning to show (ghosting of the numbers). Now the weird thing is that if i run the update code twice (everything before sleepSensor(1000) right after each other. then it does the partial update as it should. This only happens with the new screen, partial update works in my code that doesn't utilize deep sleep and it cant tell any difference in the way the display method is implemented.
I would appreciate if anyone could give me a clue about what the problem could be. Here is the whole code. I've tried everything i could find but to no avail. If you need more information to help please tell me, i appreciate any help.
#include <WiFi.h>
#include "esp_wifi.h"
#include "esp_bt.h"
#include "esp_bt_main.h"
//
#include "GxEPD2_display_selection_added.h"
#define USE_HSPI_FOR_EPD
#define ENABLE_GxEPD2_GFX 0
int timex = 47;
int timey = 90;
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <GxEPD2_4C.h>
#include <GxEPD2_7C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <U8g2_for_Adafruit_GFX.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "Bitmap.h"
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW
#define GxEPD2_DRIVER_CLASS GxEPD2_290_GDEY029T94
#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)
unsigned long oldTime; // The previous time the flow rate was calculated
GxEPD2_BW<GxEPD2_290_GDEY029T94, GxEPD2_290_GDEY029T94::HEIGHT> display(GxEPD2_290_GDEY029T94(/*CS=*/ 12, /*DC=*/ 11, /*RST=*/ 10, /*BUSY=*/ 9)); // GDEY029T94 128x296, SSD1680, (FPC-A005 20.06.15)
unsigned long currentMillis;
int seconds;
int minutes;
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
SPIClass hspi(HSPI);
#endif
/////////////////DRAWING FUNCTIONS ///////////////////
#define BLACK 0x0000
#define WHITE 0xFFFF
////////////////////////////////////////////////////////////////////////////////////
U8G2_FOR_ADAFRUIT_GFX u8g2Fonts;
/////////////////////////////////SETUP////////////////////////////////////////
void PrintSec(int seconds) {
u8g2Fonts.setCursor(timex + 20, timey + 10);
//u8g2Fonts.print(millis());
u8g2Fonts.print(seconds);
}
void PrintColon() {
u8g2Fonts.setCursor(timex + 12, timey + 10);
//u8g2Fonts.print(millis());
u8g2Fonts.print(":");
}
void PrintMin(int minutes) {
if (minutes > 9) {
u8g2Fonts.setCursor(timex - 4, timey + 10);
//u8g2Fonts.print(millis());
u8g2Fonts.print(minutes);
} else {
u8g2Fonts.setCursor(timex + 6, timey + 10);
//u8g2Fonts.print(millis());
u8g2Fonts.print(minutes);
}
}
void drawBitmaps(const unsigned char *bitmap) {
// Configure the display according to our preferences
display.setRotation(0);
display.setFullWindow();
// Display the bitmap image
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
display.drawInvertedBitmap(0, 0, bitmap, display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
} while (display.nextPage());
}
//////Deep SLeep ////////
RTC_DATA_ATTR unsigned long millisOffset = 0;
RTC_DATA_ATTR int bootCount = 0;
#define uS_TO_mS_FACTOR 1000
unsigned long offsetMillis()
{
return millis() + millisOffset;
}
void sleepSensor(unsigned long sleepMillis)
{
esp_sleep_enable_timer_wakeup(sleepMillis * uS_TO_mS_FACTOR);
millisOffset = offsetMillis() + sleepMillis;
esp_deep_sleep_start();
}
void setup() {
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
hspi.begin(13, -1, 14, 12); // remap hspi for EPD (swap pins)
display.epd2.selectSPI(hspi, SPISettings(8000000, MSBFIRST, SPI_MODE0));
#endif
esp_bluedroid_disable();
esp_bt_controller_disable();
esp_wifi_stop();
setCpuFrequencyMhz(180);
WiFi.mode(WIFI_OFF);
// Turning off Bluetooth
btStop();
if (bootCount == 0) {
display.init();
bootCount++;
display.firstPage();
display.setTextColor(GxEPD_BLACK);
//drawBitmaps(epd_bitmap_front4);
display.setRotation(1);
u8g2Fonts.begin(display); // connect u8g2 procedures to Adafruit GFX
u8g2Fonts.setFont(u8g2_font_10x20_tf);
uint16_t bg = GxEPD_WHITE;
uint16_t fg = GxEPD_BLACK;
u8g2Fonts.setForegroundColor(fg); // apply Adafruit GFX color
u8g2Fonts.setBackgroundColor(bg);
} else {
display.init(0, false);
bootCount++;
display.setRotation(1);
u8g2Fonts.begin(display); // connect u8g2 procedures to Adafruit GFX
u8g2Fonts.setFont(u8g2_font_10x20_tf);
uint16_t bg = GxEPD_WHITE;
uint16_t fg = GxEPD_BLACK;
u8g2Fonts.setForegroundColor(fg); // apply Adafruit GFX color
u8g2Fonts.setBackgroundColor(bg);
}
currentMillis = millis() + millisOffset;
seconds = currentMillis / 1000;
minutes = seconds / 60;
currentMillis %= 1000;
seconds %= 60;
minutes %= 60;
currentMillis %= 1000;
seconds %= 60;
minutes %= 60;
display.firstPage();
display.setPartialWindow(timex-4, timey-5, 45, 18);
do {
display.fillScreen(GxEPD_WHITE);
u8g2Fonts.setCursor(timex, timey + 10);
u8g2Fonts.print(millis());
PrintSec(seconds);
PrintColon();
PrintMin(minutes);
}
while (display.nextPage());
sleepSensor(1000);
}