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
Revision 18:02667782b06f, committed 2017-05-25
- Comitter:
- mlin
- Date:
- Thu May 25 10:17:45 2017 +0000
- Parent:
- 17:356a299d3224
- Parent:
- 14:e0fb408647cf
- Child:
- 19:4c30c3182e04
- Commit message:
- .
Changed in this revision
settings.h | Show annotated file Show diff for this revision Revisions of this file |
settings.h.orig | Show annotated file Show diff for this revision Revisions of this file |
--- a/poll.h Thu May 25 10:13:13 2017 +0000 +++ b/poll.h Thu May 25 10:17:45 2017 +0000 @@ -31,7 +31,7 @@ -int readX() +int readY() { int delta = 0, xv1 = 0, xv2 = 0, k = 0; int temp1 = 0, temp2 = 0; @@ -67,7 +67,7 @@ //return(xv2/10); //maybe better to return the average of both.... } // subroutine to read y values - has different pin functions .. -int readY() +int readX() { DigitalOut yp(PTB3); DigitalOut ym(PTB2);
--- a/settings.h Thu May 25 10:13:13 2017 +0000 +++ b/settings.h Thu May 25 10:17:45 2017 +0000 @@ -13,13 +13,17 @@ //set New button (used to set new alarm/time/date) TFT.set_font((unsigned char*) Arial12x12); - TFT.locate(0,40); - TFT.printf("Set New"); + TFT.locate(71,25); + TFT.set_orientation(0); + + TFT.printf("Cancel"); + TFT.set_orientation(1); //Full reset button - TFT.locate(0,140); - TFT.printf("Full reset"); - + TFT.locate(170,25); + TFT.set_orientation(0); + TFT.printf("Set New"); + TFT.set_orientation(1); //home button TFT.locate(0,210); TFT.printf("Home"); @@ -31,18 +35,20 @@ TFT.rect(50,0,320,100,Blue); //set alarm box TFT.rect(50,100,320,200,White); //set time box TFT.rect(50,200,320,240,White); //set date box - + TFT.set_font((unsigned char*) Arial12x12); //set alarm title TFT.locate(105,0); TFT.printf("Set Alarm"); - TFT.set_font((unsigned char*) Arial24x23); //set alarm hour + + TFT.set_font((unsigned char*) Arial28x28); //set alarm hour + TFT.locate(50,30); - TFT.printf("Alarm_Hour"); + TFT.printf("AH");//Alarm_Hour //set alarm mins TFT.locate(230,30); - TFT.printf("Alarm_Min"); + TFT.printf("Am");//Alarm_Min TFT.set_font((unsigned char*) Arial12x12); //set time title TFT.locate(105,100); @@ -50,11 +56,11 @@ TFT.set_font((unsigned char*) Arial24x23); //set time hour TFT.locate(50,130); - TFT.printf("Time_Hour"); + TFT.printf("TH"); // Time_hour //set time mins TFT.locate(230,130); - TFT.printf("Alarm_Min"); + TFT.printf("TM");//Time Min TFT.set_font((unsigned char*) Arial12x12);//set date day TFT.locate(50,200);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/settings.h.orig Thu May 25 10:17:45 2017 +0000 @@ -0,0 +1,75 @@ + + +void drawsettingsbuttons() //Navigation Buttons +{ + TFT.fillrect(0,0,50,100,Blue); //ste alarm button + TFT.fillrect(0,100,50,200,White); //set time button + TFT.fillrect(0,200,50,240,Green); //home button + + + TFT.rect(0,0,50,100,Blue); //outlines + TFT.rect(0,100,50,200,White); //outlines + TFT.rect(0,200,50,240,White); //outlines + + //set New button (used to set new alarm/time/date) + TFT.set_font((unsigned char*) Arial12x12); + TFT.locate(0,40); + TFT.printf("Set New"); + + //Full reset button + TFT.locate(0,140); + TFT.printf("Full reset"); + + //home button + TFT.locate(0,210); + TFT.printf("Home"); + +} + +void drawoutlines() //draw alarm, time, date +{ + TFT.rect(50,0,320,100,Blue); //set alarm box + TFT.rect(50,100,320,200,White); //set time box + TFT.rect(50,200,320,240,White); //set date box + + TFT.set_font((unsigned char*) Arial12x12); //set alarm title + TFT.locate(105,0); + TFT.printf("Set Alarm"); + + TFT.set_font((unsigned char*) Arial24x23); //set alarm hour + TFT.locate(50,30); + TFT.printf("Alarm_Hour"); + + //set alarm mins + TFT.locate(230,30); + TFT.printf("Alarm_Min"); + + TFT.set_font((unsigned char*) Arial12x12); //set time title + TFT.locate(105,100); + TFT.printf("Set Time"); + + TFT.set_font((unsigned char*) Arial24x23); //set time hour + TFT.locate(50,130); + TFT.printf("Time_Hour"); + + //set time mins + TFT.locate(230,130); + TFT.printf("Alarm_Min"); + + TFT.set_font((unsigned char*) Arial12x12);//set date day + TFT.locate(50,200); + TFT.printf("day"); + + //set date month + TFT.locate(120,200); + TFT.printf("month"); + + //set date year + TFT.locate(190,200); + TFT.printf("year"); + + +} +void settingslogic() { + + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/singlepong.cpp Thu May 25 10:17:45 2017 +0000 @@ -0,0 +1,28 @@ + +#include "libs.h" +#include "singlepong.h" + +int main() { + + float location_player = 120 - ( 120 * tsi_d() ); //reading analog inputs from the potentiometers + int SCREENH = 239 ; //screen height + int SCREENW = 319 ; //screen width + int PADDLEW = 10 ; // paddle width + int PADDLEH = 40 ; // paddle height + int PADDLEG = 10 ; // paddle gap from the touchscreen + int ABALL = 10 ; // ball size + int PADDLE_A = 0 ; // location paddle A + int PADDLE_AF = 0 ; // final location paddle A + float XBALL = 0 ; // ball's x location + float YBALL = 0 ; // ball's y location + + float VXball = 3 ; // velocity in x-direction + float VYball = 2 ; // velocity in y-direction + + while(1) { + draw(); + move(); + wait(0.01) ; + } +} + \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/singlepong.h Thu May 25 10:17:45 2017 +0000 @@ -0,0 +1,81 @@ +#include "libs.h" + +float map(float in, float inMin, float inMax, float outMin, float outMax) { + // check it's within the range + if (inMin<inMax) { + if (in <= inMin) + return outMin; + if (in >= inMax) + return outMax; + } + else { // cope with input range being backwards. + if (in >= inMin) + return outMin; + if (in <= inMax) + return outMax; + } + // calculate how far into the range we are + float scale = (in-inMin)/(inMax-inMin); + // calculate the output. + return outMin + scale*(outMax-outMin); +} + + +void move() { + + int player = location_player ; ; + PADDLE_A = map(player , 0 , 1023 , 0 , SCREENH - PADDLEH) ; + int VPADDLE_A = PADDLE_AF - PADDLE_A ; // speed of paddle A + + + XBALL += VXBALL ; //x location of the ball + YBALL += VYBALL ; //y location of the ball + + //bounce from the top and bottom + + if (YBALL >= SCREENH - ABALL || YBALL <=0) + { + VYBALL *= -1 ; + } + + //bounce from Paddle A + if (XBALL >= PADDLEG && XBALL <= PADDLEG + ABALL && VXBALL < 0) + { + if (YBALL > PADDLE_A - ABALL && YBALL < PADDLE_A + PADDLEH) + { + VXBALL *= -1 ; + } + } + + //bounce from the opposite wall + + if ( XBALL >= SCREENW ) + { + VXBALL *= -1 ; + } + + + // if the the wall scores + + if (XBALL <= 0 ) { + + // reset function // + + } + + } + + void draw() +{ + + + fillcircle(XBALL , YBALL , ABALL , 1 ) ; //draw ball + + fillrect( PADDLEG , PADDLE_A , PADDLEW , PADDLEH , 1) ; //draw paddle A + + + } + + + + \ No newline at end of file