I am having a problem with my ESP32 TTGO T-Display device. If I wake from sleep using an ext wakeup the code below works as it should, if the voltage is below 3.35 the screen will not turn on and if above 3.35v it turns on but if I do a hard reset the screen turns on even if the voltage is below the 3.35v any idea as to why the reset seems to ignore the if (battery_voltage <= 3.35) statement?
float v = analogRead(34);
float cutoff_voltage = ((float)v / 4095.0) * 2.0 * 3.3 * (vref / 1000.0);
if (battery_voltage <= 3.35) {
Serial.println(String("display off"));
ledcSetup(pwmLedChannelTFT, pwmFreq, pwmResolution);
ledcAttachPin(TFT_BL, pwmLedChannelTFT);
ledcWrite(pwmLedChannelTFT, 0);
DisplayOff = true;
} else {
tft.init();
Serial.print("Configuring PWM for TFT backlight... ");
ledcSetup(pwmLedChannelTFT, pwmFreq, pwmResolution);
ledcAttachPin(TFT_BL, pwmLedChannelTFT);
Serial.println("DONE");
Serial.print("Setting PWM for TFT backlight to default intensity... ");
ledcWrite(pwmLedChannelTFT, BrightnessLevel);
Serial.println("DONE");
tft.fillScreen(TFT_BLACK);
tft.setRotation(3);
tft.drawXBitmap(30, 30, logo, 175, 72, tft.color565(0, 59, 161));
delay(2000);
tft.fillScreen(TFT_RED);
tft.setRotation(0);
tft.setTextSize(1);
tft.setFreeFont(GenFnt); // Select the font
tft.setTextColor(0xFFE0, TFT_BLACK); // White characters on black background
tft.drawString(Punit, 15, 45); // Print the name of the font
tft.drawString(Tunit, 15, 140); // Print the name of the font
tft.drawXBitmap(50, 6, BTlogo, BTlogoWidth, BTlogoHeight, TFT_DARKGREY);
DisplayOff = false;
}