Library to calculate movement and to draw the objects in the pong game

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed

Fork of MainSketch by IoT Ox

Committer:
tunagonen
Date:
Wed May 24 15:18:13 2017 +0000
Revision:
11:d812de0e5136
Parent:
9:eee503060d69
l

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mlin 9:eee503060d69 1 #include "Rtc_Ds1307.h"
mlin 9:eee503060d69 2 Rtc_Ds1307 rtc(I2C_SDA, I2C_SCL);
mlin 9:eee503060d69 3 Rtc_Ds1307::Time_rtc tm_c = {};
mlin 9:eee503060d69 4 Rtc_Ds1307::Time_rtc tm_a = {};
mlin 9:eee503060d69 5 char buffer[128];
mlin 9:eee503060d69 6 int readptr = 0;
mlin 9:eee503060d69 7
mlin 9:eee503060d69 8
mlin 9:eee503060d69 9 void read_time(){
mlin 9:eee503060d69 10 // perform read
mlin 9:eee503060d69 11 pc.printf("Performing read operation\n\r");
mlin 9:eee503060d69 12 int n = 0;
mlin 9:eee503060d69 13 do {
mlin 9:eee503060d69 14 n++;
mlin 9:eee503060d69 15 } while(!rtc.getTime(tm_c));
mlin 9:eee503060d69 16 pc.printf("The current time is : %02d:%02d:%02d\n\r", tm_c.hour, tm_c.min, tm_c.sec);
mlin 9:eee503060d69 17 pc.printf("The current date is : %s, %02d/%02d/%04d\n\r", rtc.weekdayToString(tm_c.wday), tm_c.mon, tm_c.date, tm_c.year);
mlin 9:eee503060d69 18 pc.printf("Tried to read %d times\n\r",n);
mlin 9:eee503060d69 19 }
mlin 9:eee503060d69 20
mlin 9:eee503060d69 21 void write(){
mlin 9:eee503060d69 22 // perform write
mlin 9:eee503060d69 23 pc.printf("Enter the date (date 0..31)");
mlin 9:eee503060d69 24 pc.scanf("%d", &tm_c.date);
mlin 9:eee503060d69 25 pc.printf("Enter the date (month 1..12)");
mlin 9:eee503060d69 26 pc.scanf("%d", &tm_c.mon);
mlin 9:eee503060d69 27 pc.printf("Enter the date (year)");
mlin 9:eee503060d69 28 pc.scanf("%d", &tm_c.year);
mlin 9:eee503060d69 29 pc.printf("Enter the time (hours 0..23)");
mlin 9:eee503060d69 30 pc.scanf("%d", &tm_c.hour);
mlin 9:eee503060d69 31 pc.printf("Enter the time (minutes 0..59)");
mlin 9:eee503060d69 32 pc.scanf("%d", &tm_c.min);
mlin 9:eee503060d69 33 pc.printf("Enter the time (seconds 0..59)");
mlin 9:eee503060d69 34 pc.scanf("%d", &tm_c.sec);
mlin 9:eee503060d69 35 pc.printf("Performing write operation\n\r");
mlin 9:eee503060d69 36
mlin 9:eee503060d69 37 while(pc.readable())
mlin 9:eee503060d69 38
mlin 9:eee503060d69 39 pc.getc();
mlin 9:eee503060d69 40 int n = 0;
mlin 9:eee503060d69 41 while (!rtc.setTime(tm_c, true, false)){ //set the Time in RTC Param : ( Time container, Start Clock, Twelve Hour Clock)
mlin 9:eee503060d69 42 n++;
mlin 9:eee503060d69 43 }
mlin 9:eee503060d69 44 pc.printf("Tried to write %d times\n\r",n);
mlin 9:eee503060d69 45 }
mlin 9:eee503060d69 46
mlin 9:eee503060d69 47 //other RTC functions:
mlin 9:eee503060d69 48 //rtc.startClock();
mlin 9:eee503060d69 49 //rtc.stopClock();
mlin 9:eee503060d69 50 //square wave
mlin 9:eee503060d69 51 // int rs;
mlin 9:eee503060d69 52 // pc.printf("Please specify the frequency : [0 = 1Hz, 1 = 4.096kHz, 2 = 8.192kHz, 3 = 32.768kHz] ");
mlin 9:eee503060d69 53 // scanf("%d", &rs);
mlin 9:eee503060d69 54 // pc.printf("Enabling the output with %d option\n", rs);
mlin 9:eee503060d69 55 // rtc.setSquareWaveOutput(true, (Rtc_Ds1307::SqwRateSelect_t)rs);
mlin 9:eee503060d69 56
mlin 9:eee503060d69 57
mlin 9:eee503060d69 58 //square wave off
mlin 9:eee503060d69 59 //rtc.setSquareWaveOutput(false, Rtc_Ds1307::RS1Hz);