pong game added to the main sketch

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of MainSketch by IoT Ox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RTC.h Source File

RTC.h

00001 #include "Rtc_Ds1307.h"
00002 Rtc_Ds1307 rtc(I2C_SDA, I2C_SCL);
00003 Rtc_Ds1307::Time_rtc tm_c = {};
00004 Rtc_Ds1307::Time_rtc tm_a = {};
00005 char buffer[128];
00006 int readptr = 0;
00007 
00008 
00009 void read_time()
00010 {
00011 //  perform read
00012     pc.printf("Performing read operation\n\r");
00013     int n = 0;
00014     do   {
00015         n++;
00016     } while(!rtc.getTime(tm_c));
00017     pc.printf("The current time is : %02d:%02d:%02d\n\r", tm_c.hour, tm_c.min, tm_c.sec);
00018     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);
00019     pc.printf("Tried to read %d times\n\r",n);
00020 }
00021 
00022 void write()
00023 {
00024 //  perform write
00025     pc.printf("Enter the date (date 0..31)");
00026     pc.scanf("%d", &tm_c.date);
00027     pc.printf("Enter the date (month 1..12)");
00028     pc.scanf("%d", &tm_c.mon);
00029     pc.printf("Enter the date (year)");
00030     pc.scanf("%d", &tm_c.year);
00031     pc.printf("Enter the time (hours 0..23)");
00032     pc.scanf("%d", &tm_c.hour);
00033     pc.printf("Enter the time (minutes 0..59)");
00034     pc.scanf("%d", &tm_c.min);
00035     pc.printf("Enter the time (seconds 0..59)");
00036     pc.scanf("%d", &tm_c.sec);
00037     pc.printf("Performing write operation\n\r");
00038 
00039     while(pc.readable())
00040 
00041         pc.getc();
00042     int n = 0;
00043     while (!rtc.setTime(tm_c, true, false)) { //set the Time in RTC Param : ( Time container, Start Clock, Twelve Hour Clock)
00044         n++;
00045     }
00046     pc.printf("Tried to write %d times\n\r",n);
00047 }
00048 
00049 //other RTC functions:
00050 //rtc.startClock();
00051 //rtc.stopClock();
00052 //square wave
00053 //            int rs;
00054 //            pc.printf("Please specify the frequency : [0 = 1Hz, 1 = 4.096kHz, 2 = 8.192kHz, 3 = 32.768kHz] ");
00055 //            scanf("%d", &rs);
00056 //            pc.printf("Enabling the output with %d option\n", rs);
00057 //            rtc.setSquareWaveOutput(true, (Rtc_Ds1307::SqwRateSelect_t)rs);
00058 
00059 
00060 //square wave off
00061 //rtc.setSquareWaveOutput(false, Rtc_Ds1307::RS1Hz);