IoT Ox / Mbed 2 deprecated MainSketch Featured

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

Committer:
Owenmatthewmcgowan
Date:
Thu May 25 11:57:26 2017 +0000
Revision:
24:93e1474d6d8b
Parent:
20:e4572fc1b10d
Child:
25:ff73360cd038
Settings Page Button response

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);
Owenmatthewmcgowan 13:e74e09de81e4 71
Owenmatthewmcgowan 12:50289d0ac834 72
Owenmatthewmcgowan 12:50289d0ac834 73 }
Owenmatthewmcgowan 12:50289d0ac834 74
Owenmatthewmcgowan 15:796e17680825 75 void drawsettinganimate() //draw alarm, time, date
Owenmatthewmcgowan 12:50289d0ac834 76 {
Owenmatthewmcgowan 12:50289d0ac834 77 TFT.rect(50,0,320,100,Blue); //set alarm box
Owenmatthewmcgowan 12:50289d0ac834 78 TFT.rect(50,100,320,200,White); //set time box
Owenmatthewmcgowan 12:50289d0ac834 79 TFT.rect(50,200,320,240,White); //set date box
Owenmatthewmcgowan 13:e74e09de81e4 80
Owenmatthewmcgowan 12:50289d0ac834 81 TFT.set_font((unsigned char*) Arial12x12); //set alarm title
Owenmatthewmcgowan 15:796e17680825 82 TFT.locate(157,8);
Owenmatthewmcgowan 12:50289d0ac834 83 TFT.printf("Set Alarm");
Owenmatthewmcgowan 12:50289d0ac834 84
mlin 18:02667782b06f 85
Owenmatthewmcgowan 12:50289d0ac834 86 TFT.set_font((unsigned char*) Arial28x28); //set alarm hour
mlin 18:02667782b06f 87
Owenmatthewmcgowan 15:796e17680825 88 TFT.locate(90,40);
Owenmatthewmcgowan 20:e4572fc1b10d 89
Owenmatthewmcgowan 13:e74e09de81e4 90 TFT.printf("AH");//Alarm_Hour
Owenmatthewmcgowan 12:50289d0ac834 91
Owenmatthewmcgowan 12:50289d0ac834 92 //set alarm mins
Owenmatthewmcgowan 15:796e17680825 93 TFT.locate(230,40);
Owenmatthewmcgowan 15:796e17680825 94 TFT.printf("AM");//Alarm_Min
Owenmatthewmcgowan 12:50289d0ac834 95 TFT.set_font((unsigned char*) Arial12x12); //set time title
Owenmatthewmcgowan 15:796e17680825 96 TFT.locate(157,108);
Owenmatthewmcgowan 12:50289d0ac834 97 TFT.printf("Set Time");
Owenmatthewmcgowan 12:50289d0ac834 98
Owenmatthewmcgowan 12:50289d0ac834 99 TFT.set_font((unsigned char*) Arial28x28); //set time hour
Owenmatthewmcgowan 15:796e17680825 100 TFT.locate(90,140);
Owenmatthewmcgowan 13:e74e09de81e4 101 TFT.printf("TH"); // Time_hour
Owenmatthewmcgowan 12:50289d0ac834 102
Owenmatthewmcgowan 12:50289d0ac834 103 //set time mins
Owenmatthewmcgowan 15:796e17680825 104 TFT.locate(230,140);
Owenmatthewmcgowan 13:e74e09de81e4 105 TFT.printf("TM");//Time Min
Owenmatthewmcgowan 12:50289d0ac834 106
Owenmatthewmcgowan 15:796e17680825 107 //set date day
Owenmatthewmcgowan 15:796e17680825 108 TFT.set_font((unsigned char*) Arial12x12);
Owenmatthewmcgowan 15:796e17680825 109 TFT.locate(60,215);
Owenmatthewmcgowan 12:50289d0ac834 110 TFT.printf("day");
Owenmatthewmcgowan 12:50289d0ac834 111
Owenmatthewmcgowan 12:50289d0ac834 112 //set date month
Owenmatthewmcgowan 15:796e17680825 113 TFT.locate(150,215);
Owenmatthewmcgowan 12:50289d0ac834 114 TFT.printf("month");
Owenmatthewmcgowan 12:50289d0ac834 115
Owenmatthewmcgowan 12:50289d0ac834 116 //set date year
Owenmatthewmcgowan 15:796e17680825 117 TFT.locate(265,215);
Owenmatthewmcgowan 12:50289d0ac834 118 TFT.printf("year");
Owenmatthewmcgowan 12:50289d0ac834 119
Owenmatthewmcgowan 15:796e17680825 120 //Cancel button
Owenmatthewmcgowan 15:796e17680825 121 TFT.set_font((unsigned char*) Arial12x12);
Owenmatthewmcgowan 15:796e17680825 122 TFT.locate(62,20);
Owenmatthewmcgowan 15:796e17680825 123 TFT.set_orientation(0);
Owenmatthewmcgowan 15:796e17680825 124 TFT.background(White);
Owenmatthewmcgowan 15:796e17680825 125 TFT.foreground(Black);
Owenmatthewmcgowan 15:796e17680825 126 TFT.printf("Cancel");
Owenmatthewmcgowan 15:796e17680825 127 TFT.background(Black);
Owenmatthewmcgowan 15:796e17680825 128 TFT.foreground(White);
Owenmatthewmcgowan 15:796e17680825 129 TFT.set_orientation(1);
Owenmatthewmcgowan 15:796e17680825 130
Owenmatthewmcgowan 15:796e17680825 131 //Set New button (used to set new alarm/time/date)
Owenmatthewmcgowan 15:796e17680825 132
Owenmatthewmcgowan 15:796e17680825 133 TFT.locate(161,20);
Owenmatthewmcgowan 15:796e17680825 134 TFT.set_orientation(0);
Owenmatthewmcgowan 15:796e17680825 135 TFT.background(Blue);
Owenmatthewmcgowan 15:796e17680825 136 TFT.printf("Set New");
Owenmatthewmcgowan 15:796e17680825 137 TFT.background(Black);
Owenmatthewmcgowan 15:796e17680825 138 TFT.set_orientation(1);
Owenmatthewmcgowan 15:796e17680825 139 //home button
Owenmatthewmcgowan 15:796e17680825 140 TFT.locate(5,217);
Owenmatthewmcgowan 15:796e17680825 141 TFT.foreground(Blue);
Owenmatthewmcgowan 15:796e17680825 142 TFT.printf("Home");
Owenmatthewmcgowan 15:796e17680825 143 TFT.foreground(White);
Owenmatthewmcgowan 15:796e17680825 144
Owenmatthewmcgowan 12:50289d0ac834 145
mlin 16:3cb9b1fbc039 146 }
Owenmatthewmcgowan 24:93e1474d6d8b 147 void settings() {
mlin 16:3cb9b1fbc039 148
mlin 16:3cb9b1fbc039 149 }