The code is big - so here is part 1:
// UTFT_Analog_Clock
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program was made simply because I was bored.
//
// Hardware requirements:
// - Arduino Mega
// - Display module supported by UTFT
// - DS1307 RTC
// - Some method of connecting the display module to the Arduino
// like the old ITDB02 Mega Shield v1.1 as it already contains
// the DS1307 or the All in One Super Screw Shield from
// AquaLEDSource which also has everything you need on the
// shield.
//
// Software requirements:
// - UTFT library UTFT - Rinky-Dink Electronics
// - UTouch library UTouch - Rinky-Dink Electronics
// - DS1307 library DS1307 - Rinky-Dink Electronics
//
// This program should work on all the supported display modules
// from the 2.4" ones and up to the 5.0" ones, but keep in mind
// that this program was made to work on a 320x240 module, so it
// may look a little silly on larger displays.
// It will not work on the 2.2" modules without modification as
// the resolution on those modules are too low.
//
// Default serial speed for this sketch is 115200 baud.
//
// You can buy the AquaLEDSource All in One Super Screw Shield here:
// English: http://www.aqualedsource.com/prods/screwshield.php
// Portuguese: http://www.aqualed-light.com/?sec=home&id=1818
//
/**************************************************************************/
// Enable (1) or disable (0) VT100 terminal mode
// Enable this if your terminal program supports VT100 control sequences.
// The Serial Monitor in the Arduino IDE does not support VT100 control sequences.
// If using the Serial Monitor the line ending should be set to 'No line ending'.
#define VT100_MODE 1
// Enable or disable the use of the AquaLEDSource All in One Super Screw Shield
// Uncomment the following line if you are using this shield
//#define AQUALED_SHIELD 1
#include <UTFT.h>
#include <DS1307.h>
#include <UTouch.h>
// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
UTFT myGLCD(ITDB32S,38,39,40,41); // Remember to change the model parameter to suit your display module!
#ifndef AQUALED_SHIELD
UTouch myTouch(6,5,4,3,2);
#else
UTouch myTouch(62,63,64,65,66);
#endif
// Init the DS1307
DS1307 rtc(20, 21);
// Init a Time-data structure
Time t;
int clockCenterX=119;
int clockCenterY=119;
int oldsec=0;
void setup()
{
myGLCD.InitLCD();
myGLCD.setFont(BigFont);
myTouch.InitTouch();
myTouch.setPrecision(PREC_HI);
// Set the clock to run-mode
rtc.halt(false);
Serial.begin(115200);
Serial.println("Send any character to enter serial mode...");
Serial.println();
}
void drawDisplay()
{
// Clear screen
myGLCD.clrScr();
// Draw Clockface
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
for (int i=0; i<5; i++)
{
myGLCD.drawCircle(clockCenterX, clockCenterY, 119-i);
}
for (int i=0; i<5; i++)
{
myGLCD.drawCircle(clockCenterX, clockCenterY, i);
}
myGLCD.setColor(192, 192, 255);
myGLCD.print("3", clockCenterX+92, clockCenterY-8);
myGLCD.print("6", clockCenterX-8, clockCenterY+95);
myGLCD.print("9", clockCenterX-109, clockCenterY-8);
myGLCD.print("12", clockCenterX-16, clockCenterY-109);
for (int i=0; i<12; i++)
{
if ((i % 3)!=0)
drawMark(i);
}
t = rtc.getTime();
drawMin(t.min);
drawHour(t.hour, t.min);
drawSec(t.sec);
oldsec=t.sec;
// Draw calendar
myGLCD.setColor(255, 255, 255);
myGLCD.fillRoundRect(240, 0, 319, 85);
myGLCD.setColor(0, 0, 0);
for (int i=0; i<7; i++)
{
myGLCD.drawLine(249+(i10), 0, 248+(i10), 3);
myGLCD.drawLine(250+(i10), 0, 249+(i10), 3);
myGLCD.drawLine(251+(i10), 0, 250+(i10), 3);
}
// Draw SET button
myGLCD.setColor(64, 64, 128);
myGLCD.fillRoundRect(260, 200, 319, 239);
myGLCD.setColor(255, 255, 255);
myGLCD.drawRoundRect(260, 200, 319, 239);
myGLCD.setBackColor(64, 64, 128);
myGLCD.print("SET", 266, 212);
myGLCD.setBackColor(0, 0, 0);
}
void drawMark(int h)
{
float x1, y1, x2, y2;
h=h*30;
h=h+270;
x1=110cos(h0.0175);
y1=110sin(h0.0175);
x2=100cos(h0.0175);
y2=100sin(h0.0175);
myGLCD.drawLine(x1+clockCenterX, y1+clockCenterY, x2+clockCenterX, y2+clockCenterY);
}
void drawSec(int s)
{
float x1, y1, x2, y2;
int ps = s-1;
myGLCD.setColor(0, 0, 0);
if (ps==-1)
ps=59;
ps=ps*6;
ps=ps+270;
x1=95cos(ps0.0175);
y1=95sin(ps0.0175);
x2=80cos(ps0.0175);
y2=80sin(ps0.0175);
myGLCD.drawLine(x1+clockCenterX, y1+clockCenterY, x2+clockCenterX, y2+clockCenterY);
myGLCD.setColor(255, 0, 0);
s=s*6;
s=s+270;
x1=95cos(s0.0175);
y1=95sin(s0.0175);
x2=80cos(s0.0175);
y2=80sin(s0.0175);
myGLCD.drawLine(x1+clockCenterX, y1+clockCenterY, x2+clockCenterX, y2+clockCenterY);
}
void drawMin(int m)
{
float x1, y1, x2, y2, x3, y3, x4, y4;
int pm = m-1;
myGLCD.setColor(0, 0, 0);
if (pm==-1)
pm=59;
pm=pm*6;
pm=pm+270;