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 36:ed374dec24c0, committed 2017-05-25
- Comitter:
- tunagonen
- Date:
- Thu May 25 15:58:41 2017 +0000
- Parent:
- 35:138b7d7cc3a1
- Commit message:
- added draw hands
Changed in this revision
movinghands.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/movinghands.h Thu May 25 13:45:45 2017 +0000 +++ b/movinghands.h Thu May 25 15:58:41 2017 +0000 @@ -1,43 +1,20 @@ #include "libs.h" -void draw_hands ( int x0 , int y0 , int r , float seconds , float minutes , float hours) - for ( int n = seconds ; n < 60; n++) { - int x1, y1 , x1F , x2F = 0; - double angle = n * M_PI / 30; - double angleF = (n-1) * M_PI / 30 ; - x1 = r * cos(angle) + x0; - y1 = r * sin(angle) + y0; - x1F = r * cos(angleF) + x0; - y1F = r * sin(angleF) + y0; - TFT.line(x0, y0, x1, y1, Red); - wait(1) ; - TFT.line(x0, y0, x1F, y1F, Black); - } - for ( int m = minutes ; m < 60; m++) { - int x2, y2 , x2F , y2F = 0; - double angle2 = m * M_PI / 360 ; - double angle2F = (m-1) * M_PI / 360 ; +void draw_hands ( int x0 , int y0 , int r , float minutes , float hours , int color) + { + + int rs = 0.8 * r ; // shorter moving hand + int m = minutes ; + int k = hours % 12; + int angle2 = k * M_PI / 6 ; + int angle = m * M_PI / 30 ; + x1 = rs * cos(angle) + x0; + y1 = rs * sin(angle) + y0; x2 = r * cos(angle2) + x0; y2 = r * sin(angle2) + y0; - x2F = r * cos(angle2F) + x0; - y2F = r * sin(angle2F) + y0; - TFT.line(x0, y0, x2, y2, White); - wait(60) ; - TFT.line(x0, y0, x2F, y2F, Black); - } - - for ( int k = hours ; k < 12; m++) { - int x3, y3 , x3F , y3F = 0; - double angle - double angle3 = k * M_PI / 6 ; - double angle3F = (k-1) * M_PI / 6 ; - x3 = r * cos(angle3) + x0; - y3 = r * sin(angle3) + y0; - x3F = r * cos(angle3F) + x0; - y3F = r * sin(angle3F) + y0; - TFT.line(x0, y0, x3, y3, White); - wait(60) ; - TFT.line(x0, y0, x3F, y3F, Black); - } + TFT.line(x0, y0, x2, y2, color); + TFT.line(x0, y0, x1, y1, color); + } + \ No newline at end of file