@red_car
I want to turn my screen off at night, but when the screen comes back on in the morning, it doesn't reprint everything. Why is that?
void loop() {
unsigned int IntensityOfLight;
IntensityOfLight = analogRead(A0);
myRTC.updateTime();
sensors.requestTemperatures();
if (IntensityOfLight >= 500) {
tft.fillScreen(BLACK);
}
else {
if (myRTC.dayofmonth != prevDay)
{
prevDay = myRTC.dayofmonth;
tft.setCursor(5, 3);
tft.fillRect(5, 3, 33, 21, BLACK);
if (myRTC.dayofmonth < 10)
{
tft.print("0");
tft.print(myRTC.dayofmonth);
}
else
{
tft.print(myRTC.dayofmonth);
}
moonPhase();
}
tft.setCursor(41, 3);
tft.print("/");
if (myRTC.month != prevMonth)
{
prevMonth = myRTC.month;
tft.setCursor(59, 3);
tft.fillRect(59, 3, 33, 21, BLACK);
if (myRTC.month < 10) {
tft.print("0");
tft.print(myRTC.month);
}
else {
tft.print(myRTC.month);
}
}
tft.setCursor(95, 3);
tft.print("/");
if (myRTC.year != prevYear)
{
prevYear = myRTC.year;
tft.setCursor(113, 3);
tft.fillRect(113, 3, 70, 21, BLACK);
tft.print(myRTC.year);
}
if (myRTC.hours != prevHour)
{
prevHour = myRTC.hours;
tft.setCursor(246, 3);
tft.fillRect(246, 3, 33, 21, BLACK);
if (myRTC.hours < 10) {
tft.print("0");
tft.print(myRTC.hours);
}
else {
tft.print(myRTC.hours);
}
}
tft.setCursor(279, 3);
tft.print(":");
if (myRTC.minutes != prevMin)
{
prevMin = myRTC.minutes;
tft.setCursor(295, 3);
tft.fillRect(295, 3, 33, 21, BLACK);
if (myRTC.minutes < 10) {
tft.print("0");
tft.print(myRTC.minutes);
}
else {
tft.print(myRTC.minutes);
}
}
tft.setCursor(329, 3);
tft.print(":");
if (myRTC.seconds != prevSec)
{
prevSec = myRTC.seconds;
tft.setCursor(345, 3);
tft.fillRect(345, 3, 33, 21, BLACK);
if (myRTC.seconds < 10) {
tft.print("0");
tft.print(myRTC.seconds);
}
else {
tft.print(myRTC.seconds);
}
}
int sensor = analogRead(A1);
float voltage = (sensor * 5.0) / 1023;
tft.setTextSize(3);
if (voltage != prevVolt)
{
prevVolt = voltage;
battery();
}
if (sensors.getTempCByIndex(0) != prevTemp)
{
prevTemp = sensors.getTempCByIndex(0);
tft.setCursor(5, 294);
tft.fillRect(5, 294, 90, 21, BLACK);
tft.print(sensors.getTempCByIndex(0));
}
}
}