
Now the example compiles using the latest ctrulib. It also uses standard C Time library to get date and time
67 lines
1.6 KiB
C
67 lines
1.6 KiB
C
/*
|
|
RTC example made by Aurelio Mannara for ctrulib
|
|
This code was modified for the last time on: 12/13/2014 2:45 UTC+1
|
|
|
|
This wouldn't be possible without the amazing work done by:
|
|
-Smealum
|
|
-fincs
|
|
-WinterMute
|
|
-yellows8
|
|
-plutoo
|
|
-mtheall
|
|
-Many others who worked on 3DS and I'm surely forgetting about
|
|
*/
|
|
|
|
#include <3ds.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
// Initialize services
|
|
gfxInitDefault();
|
|
|
|
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
|
|
consoleInit(GFX_TOP, NULL);
|
|
|
|
printf("\x1b[29;15HPress Start to exit.");
|
|
|
|
// Main loop
|
|
while (aptMainLoop())
|
|
{
|
|
//Scan all the inputs. This should be done once for each frame
|
|
hidScanInput();
|
|
|
|
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
|
u32 kDown = hidKeysDown();
|
|
|
|
if (kDown & KEY_START) break; // break in order to return to hbmenu
|
|
|
|
//Print current time
|
|
time_t unixTime = time(NULL);
|
|
struct tm* timeStruct = gmtime((const time_t *)&unixTime);
|
|
|
|
int hours = timeStruct->tm_hour;
|
|
int minutes = timeStruct->tm_min;
|
|
int seconds = timeStruct->tm_sec;
|
|
int day = timeStruct->tm_mday;
|
|
int month = timeStruct->tm_mon;
|
|
int year = timeStruct->tm_year +1900;
|
|
|
|
printf("\x1b[0;0H%02i:%02i:%02i", hours, minutes, seconds);
|
|
printf("\x1b[1;0H%02i/%02i/%04i", day, month, year);
|
|
|
|
// Flush and swap framebuffers
|
|
gfxFlushBuffers();
|
|
gfxSwapBuffers();
|
|
|
|
//Wait for VBlank
|
|
gspWaitForVBlank();
|
|
}
|
|
|
|
// Exit services
|
|
gfxExit();
|
|
|
|
return 0;
|
|
}
|