hello
you must forgive me but I do not know much about programming
I wanted to ask you can make a kind of screensaver?
when for a certain period of time is not touched, the display turns off
#include <UTFT.h>
#include <UTouch.h>
#include <DS1307henning.h>
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFontPlus[];
unsigned long previousMillis_1 = 0;
unsigned long previousMillis_2 = 0;
int interval = 20; // In seconds
UTFT myGLCD(ITDB32WD,38,39,40,41);
// UTouch myTouch(6,5,4,3,2); // For DIY controller
UTouch myTouch(7,6,5,4,3); // For Ferduino Mega 2560
// (SDA,SCL)
//DS1307 rtc(20, 21); // For DIY controller
DS1307 rtc(18, 19); // For Ferduino Mega 2560
Time t_temp, t;
void setup()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
rtc.halt(false);
mainScreen();
previousMillis_1 = millis();
}
void loop()
{
if(myTouch.dataAvailable())
{
myGLCD.clrScr();
myGLCD.setFont(BigFont);
myGLCD.setColor(255, 0, 0);
myGLCD.print("Touch received!", CENTER, 110);
delay(1000);
previousMillis_2 = millis();
}
if((millis() - previousMillis_1) > 5000)
{
if((millis() - previousMillis_2) > interval * 1000)
{
clockScreen();
}
else
{
mainScreen();
}
previousMillis_1 = millis();
}
}
void mainScreen()
{
myGLCD.clrScr();
myGLCD.setColor(255, 255, 255);
myGLCD.setFont(BigFont);
myGLCD.print("Waiting for touch...", CENTER, 110);
myGLCD.setColor(0, 255, 0);
myGLCD.print("0 degrees", 0, 0, 0);
myGLCD.print("90 degrees", 399, 0, 90);
myGLCD.print("180 degrees", 399, 239, 180);
myGLCD.print("270 degrees", 0, 239, 270);
}
void clockScreen()
{
myGLCD.clrScr();
myGLCD.setFont(SevenSegNumFontPlus);
myGLCD.setColor(0, 174, 255);
myGLCD.print(rtc.getTimeStr(FORMAT_LONG), CENTER, 100);
}
if((millis() - previousMillis_1) > 5000)
{
if((millis() - previousMillis_2) > interval * 1000)
{
clockScreen();
}
else
{
mainScreen();
}
previousMillis_1 = millis();
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFontPlus[];
int dispScreen = 0;
unsigned long previousMillis_2 = 0;
int interval = 20; // In seconds
void clockScreen()
{
myGLCD.clrScr();
myGLCD.setFont(SevenSegNumFontPlus);
myGLCD.setColor(0, 174, 255);
myGLCD.print(rtc.getTimeStr(FORMAT_LONG), CENTER, 100);
}
processMyTouch();
if(((millis() - previousMillis_2) > interval * 1000) && (dispScreen == 0))
{
clearScreen();
mainScreen(true);
}
else
{
processMyTouch();
}
previousMillis_2 = millis();
mainScreen();
if((millis() - previousMillis_2) > interval * 1000)
{
clockScreen();
}
else
{
mainScreen();
}
int interval = 35; // In seconds
Users viewing this topic: No registered users and 1 guest