pong game added to the main sketch
Dependencies: RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor
Fork of MainSketch by
Diff: RTC.h
- Revision:
- 9:eee503060d69
- Child:
- 11:1da15361a35b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RTC.h Wed May 24 03:11:29 2017 +0000 @@ -0,0 +1,59 @@ + #include "Rtc_Ds1307.h" +Rtc_Ds1307 rtc(I2C_SDA, I2C_SCL); +Rtc_Ds1307::Time_rtc tm_c = {}; +Rtc_Ds1307::Time_rtc tm_a = {}; +char buffer[128]; +int readptr = 0; + + +void read_time(){ + // perform read + pc.printf("Performing read operation\n\r"); + int n = 0; + do { + n++; + } while(!rtc.getTime(tm_c)); +pc.printf("The current time is : %02d:%02d:%02d\n\r", tm_c.hour, tm_c.min, tm_c.sec); +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); +pc.printf("Tried to read %d times\n\r",n); +} + +void write(){ +// perform write + pc.printf("Enter the date (date 0..31)"); + pc.scanf("%d", &tm_c.date); + pc.printf("Enter the date (month 1..12)"); + pc.scanf("%d", &tm_c.mon); + pc.printf("Enter the date (year)"); + pc.scanf("%d", &tm_c.year); + pc.printf("Enter the time (hours 0..23)"); + pc.scanf("%d", &tm_c.hour); + pc.printf("Enter the time (minutes 0..59)"); + pc.scanf("%d", &tm_c.min); + pc.printf("Enter the time (seconds 0..59)"); + pc.scanf("%d", &tm_c.sec); + pc.printf("Performing write operation\n\r"); + + while(pc.readable()) + + pc.getc(); + int n = 0; + while (!rtc.setTime(tm_c, true, false)){ //set the Time in RTC Param : ( Time container, Start Clock, Twelve Hour Clock) + n++; + } + pc.printf("Tried to write %d times\n\r",n); +} + +//other RTC functions: +//rtc.startClock(); +//rtc.stopClock(); +//square wave +// int rs; +// pc.printf("Please specify the frequency : [0 = 1Hz, 1 = 4.096kHz, 2 = 8.192kHz, 3 = 32.768kHz] "); +// scanf("%d", &rs); +// pc.printf("Enabling the output with %d option\n", rs); +// rtc.setSquareWaveOutput(true, (Rtc_Ds1307::SqwRateSelect_t)rs); + + +//square wave off +//rtc.setSquareWaveOutput(false, Rtc_Ds1307::RS1Hz); \ No newline at end of file