Contains the main execution of the clock uses headers to import functions

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

Committer:
mlin
Date:
Thu May 25 12:05:17 2017 +0000
Revision:
25:ff73360cd038
Parent:
24:93e1474d6d8b
Child:
26:47271cf8d6b2
updated the drawing intracacies

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Owenmatthewmcgowan 24:93e1474d6d8b 1 int setting_press(){
Owenmatthewmcgowan 24:93e1474d6d8b 2 int x = readX();
Owenmatthewmcgowan 24:93e1474d6d8b 3 int y = readY();
Owenmatthewmcgowan 24:93e1474d6d8b 4 if (touching == 1) {
Owenmatthewmcgowan 24:93e1474d6d8b 5 if (x > 0 && x < 50 && y > 0 & y < 100) // side button 1 (set)
Owenmatthewmcgowan 24:93e1474d6d8b 6 {
Owenmatthewmcgowan 24:93e1474d6d8b 7 //set desired state to 1
Owenmatthewmcgowan 24:93e1474d6d8b 8 return 1;
Owenmatthewmcgowan 24:93e1474d6d8b 9 }
Owenmatthewmcgowan 24:93e1474d6d8b 10 else if (x > 0 && x < 50 && y > 100 & y < 200) //side button 2 (cancel)
Owenmatthewmcgowan 24:93e1474d6d8b 11 {
Owenmatthewmcgowan 24:93e1474d6d8b 12 //set desired state to 2
Owenmatthewmcgowan 24:93e1474d6d8b 13 return 2;
Owenmatthewmcgowan 24:93e1474d6d8b 14 }
Owenmatthewmcgowan 24:93e1474d6d8b 15 else if (x > 0 && x < 50 && y > 200 && y < 240) // button home
Owenmatthewmcgowan 24:93e1474d6d8b 16 {
Owenmatthewmcgowan 24:93e1474d6d8b 17 //set desired state to 0
Owenmatthewmcgowan 24:93e1474d6d8b 18 return 0;
Owenmatthewmcgowan 24:93e1474d6d8b 19 }
Owenmatthewmcgowan 24:93e1474d6d8b 20 else if (x > 50 && x < 185 && y > 0 && y < 100) // Alarm Hour
Owenmatthewmcgowan 24:93e1474d6d8b 21 {
Owenmatthewmcgowan 24:93e1474d6d8b 22 return 11;
Owenmatthewmcgowan 24:93e1474d6d8b 23 }
Owenmatthewmcgowan 24:93e1474d6d8b 24 else if (x > 185 && x < 320 && y > 0 && y < 100) // Alarm Min
Owenmatthewmcgowan 24:93e1474d6d8b 25 {
Owenmatthewmcgowan 24:93e1474d6d8b 26 return 12;
Owenmatthewmcgowan 24:93e1474d6d8b 27 }
Owenmatthewmcgowan 24:93e1474d6d8b 28 else if (x > 50 && x < 185 && y > 100 && y < 200) //Time Hour
Owenmatthewmcgowan 24:93e1474d6d8b 29 {
Owenmatthewmcgowan 24:93e1474d6d8b 30 return 13;
Owenmatthewmcgowan 24:93e1474d6d8b 31 }
Owenmatthewmcgowan 24:93e1474d6d8b 32 else if (x > 185 && x < 320 && y > 100 && y < 200)//Time Min
Owenmatthewmcgowan 24:93e1474d6d8b 33 {
Owenmatthewmcgowan 24:93e1474d6d8b 34 return 14;
Owenmatthewmcgowan 24:93e1474d6d8b 35 }
Owenmatthewmcgowan 24:93e1474d6d8b 36 else if (x > 50 && x < 140 && y > 200 && y < 300)//Time Date
Owenmatthewmcgowan 24:93e1474d6d8b 37 {
Owenmatthewmcgowan 24:93e1474d6d8b 38 return 15;
Owenmatthewmcgowan 24:93e1474d6d8b 39 }
Owenmatthewmcgowan 24:93e1474d6d8b 40 else if (x > 140 && x < 230 && y > 200 && y < 300)//Time Month
Owenmatthewmcgowan 24:93e1474d6d8b 41 {
Owenmatthewmcgowan 24:93e1474d6d8b 42 return 16;
Owenmatthewmcgowan 24:93e1474d6d8b 43 }
Owenmatthewmcgowan 24:93e1474d6d8b 44 else if (x > 230 && x < 320 && y > 200 && y < 300) //Time Year
Owenmatthewmcgowan 24:93e1474d6d8b 45 {
Owenmatthewmcgowan 24:93e1474d6d8b 46 return 17;
Owenmatthewmcgowan 24:93e1474d6d8b 47 }
Owenmatthewmcgowan 24:93e1474d6d8b 48 }
Owenmatthewmcgowan 24:93e1474d6d8b 49 return -1;
Owenmatthewmcgowan 24:93e1474d6d8b 50 }
Owenmatthewmcgowan 12:50289d0ac834 51
Owenmatthewmcgowan 15:796e17680825 52 void drawsettingback() //Navigation Buttons
Owenmatthewmcgowan 12:50289d0ac834 53 {
Owenmatthewmcgowan 15:796e17680825 54 TFT.fillrect(0,0,50,100,Blue); //set alarm button
Owenmatthewmcgowan 12:50289d0ac834 55 TFT.fillrect(0,100,50,200,White); //set time button
Owenmatthewmcgowan 12:50289d0ac834 56
Owenmatthewmcgowan 12:50289d0ac834 57
Owenmatthewmcgowan 12:50289d0ac834 58 TFT.rect(0,0,50,100,Blue); //outlines
Owenmatthewmcgowan 12:50289d0ac834 59 TFT.rect(0,100,50,200,White); //outlines
Owenmatthewmcgowan 12:50289d0ac834 60 TFT.rect(0,200,50,240,White); //outlines
Owenmatthewmcgowan 12:50289d0ac834 61
Owenmatthewmcgowan 15:796e17680825 62 //alarm/time colons
Owenmatthewmcgowan 15:796e17680825 63 int tx,ty = 0;
Owenmatthewmcgowan 15:796e17680825 64 ty = 50;
Owenmatthewmcgowan 15:796e17680825 65 tx = 185;
Owenmatthewmcgowan 15:796e17680825 66 TFT.fillcircle(tx, ty - 10, 2, White);
Owenmatthewmcgowan 15:796e17680825 67 TFT.fillcircle(tx, ty + 10, 2, White);
Owenmatthewmcgowan 15:796e17680825 68 ty = 150;
Owenmatthewmcgowan 15:796e17680825 69 TFT.fillcircle(tx, ty - 10, 2, White);
Owenmatthewmcgowan 15:796e17680825 70 TFT.fillcircle(tx, ty + 10, 2, White);
mlin 25:ff73360cd038 71 TFT.rect(50,0,320,100,Blue); //set alarm box
Owenmatthewmcgowan 12:50289d0ac834 72 TFT.rect(50,100,320,200,White); //set time box
Owenmatthewmcgowan 12:50289d0ac834 73 TFT.rect(50,200,320,240,White); //set date box
Owenmatthewmcgowan 13:e74e09de81e4 74
Owenmatthewmcgowan 12:50289d0ac834 75 TFT.set_font((unsigned char*) Arial12x12); //set alarm title
Owenmatthewmcgowan 15:796e17680825 76 TFT.locate(157,8);
Owenmatthewmcgowan 12:50289d0ac834 77 TFT.printf("Set Alarm");
mlin 25:ff73360cd038 78 //Cancel button
mlin 25:ff73360cd038 79 TFT.set_font((unsigned char*) Arial12x12);
mlin 25:ff73360cd038 80 TFT.locate(62,20);
mlin 25:ff73360cd038 81 TFT.set_orientation(0);
mlin 25:ff73360cd038 82 TFT.background(White);
mlin 25:ff73360cd038 83 TFT.foreground(Black);
mlin 25:ff73360cd038 84 TFT.printf("Cancel");
mlin 25:ff73360cd038 85 TFT.background(Black);
mlin 25:ff73360cd038 86 TFT.foreground(White);
mlin 25:ff73360cd038 87 TFT.set_orientation(1);
mlin 25:ff73360cd038 88
mlin 25:ff73360cd038 89 //Set New button (used to set new alarm/time/date)
mlin 25:ff73360cd038 90
mlin 25:ff73360cd038 91 TFT.locate(161,20);
mlin 25:ff73360cd038 92 TFT.set_orientation(0);
mlin 25:ff73360cd038 93 TFT.background(Blue);
mlin 25:ff73360cd038 94 TFT.printf("Set New");
mlin 25:ff73360cd038 95 TFT.background(Black);
mlin 25:ff73360cd038 96 TFT.set_orientation(1);
mlin 25:ff73360cd038 97 //home button
mlin 25:ff73360cd038 98 TFT.locate(5,217);
mlin 25:ff73360cd038 99 TFT.foreground(Blue);
mlin 25:ff73360cd038 100 TFT.printf("Home");
mlin 25:ff73360cd038 101 TFT.foreground(White);
mlin 25:ff73360cd038 102 }
mlin 25:ff73360cd038 103
mlin 25:ff73360cd038 104 void drawsettinganimate() //draw alarm, time, date
mlin 25:ff73360cd038 105 {
mlin 25:ff73360cd038 106
Owenmatthewmcgowan 12:50289d0ac834 107
mlin 18:02667782b06f 108
Owenmatthewmcgowan 12:50289d0ac834 109 TFT.set_font((unsigned char*) Arial28x28); //set alarm hour
mlin 18:02667782b06f 110
Owenmatthewmcgowan 15:796e17680825 111 TFT.locate(90,40);
Owenmatthewmcgowan 20:e4572fc1b10d 112
Owenmatthewmcgowan 13:e74e09de81e4 113 TFT.printf("AH");//Alarm_Hour
Owenmatthewmcgowan 12:50289d0ac834 114
Owenmatthewmcgowan 12:50289d0ac834 115 //set alarm mins
Owenmatthewmcgowan 15:796e17680825 116 TFT.locate(230,40);
Owenmatthewmcgowan 15:796e17680825 117 TFT.printf("AM");//Alarm_Min
Owenmatthewmcgowan 12:50289d0ac834 118 TFT.set_font((unsigned char*) Arial12x12); //set time title
Owenmatthewmcgowan 15:796e17680825 119 TFT.locate(157,108);
Owenmatthewmcgowan 12:50289d0ac834 120 TFT.printf("Set Time");
Owenmatthewmcgowan 12:50289d0ac834 121
Owenmatthewmcgowan 12:50289d0ac834 122 TFT.set_font((unsigned char*) Arial28x28); //set time hour
Owenmatthewmcgowan 15:796e17680825 123 TFT.locate(90,140);
Owenmatthewmcgowan 13:e74e09de81e4 124 TFT.printf("TH"); // Time_hour
Owenmatthewmcgowan 12:50289d0ac834 125
Owenmatthewmcgowan 12:50289d0ac834 126 //set time mins
Owenmatthewmcgowan 15:796e17680825 127 TFT.locate(230,140);
Owenmatthewmcgowan 13:e74e09de81e4 128 TFT.printf("TM");//Time Min
Owenmatthewmcgowan 12:50289d0ac834 129
Owenmatthewmcgowan 15:796e17680825 130 //set date day
Owenmatthewmcgowan 15:796e17680825 131 TFT.set_font((unsigned char*) Arial12x12);
Owenmatthewmcgowan 15:796e17680825 132 TFT.locate(60,215);
Owenmatthewmcgowan 12:50289d0ac834 133 TFT.printf("day");
Owenmatthewmcgowan 12:50289d0ac834 134
Owenmatthewmcgowan 12:50289d0ac834 135 //set date month
Owenmatthewmcgowan 15:796e17680825 136 TFT.locate(150,215);
Owenmatthewmcgowan 12:50289d0ac834 137 TFT.printf("month");
Owenmatthewmcgowan 12:50289d0ac834 138
Owenmatthewmcgowan 12:50289d0ac834 139 //set date year
Owenmatthewmcgowan 15:796e17680825 140 TFT.locate(265,215);
Owenmatthewmcgowan 12:50289d0ac834 141 TFT.printf("year");
Owenmatthewmcgowan 12:50289d0ac834 142
Owenmatthewmcgowan 15:796e17680825 143
Owenmatthewmcgowan 15:796e17680825 144
Owenmatthewmcgowan 12:50289d0ac834 145
mlin 16:3cb9b1fbc039 146 }
Owenmatthewmcgowan 24:93e1474d6d8b 147 void settings() {
mlin 25:ff73360cd038 148 int a_h, a_m, t_h, t_m,t_d,t_mo,t_y = 0;
mlin 16:3cb9b1fbc039 149
mlin 25:ff73360cd038 150 }