]> Chaos Git - corbenik/ctrulib.git/commitdiff
Update for latest ctrulib
authorAurelio Mannara <aurelio.mannara@gmail.com>
Mon, 25 May 2015 08:29:06 +0000 (10:29 +0200)
committerAurelio Mannara <aurelio.mannara@gmail.com>
Mon, 25 May 2015 08:29:06 +0000 (10:29 +0200)
Now the example compiles using the latest ctrulib. It also uses
standard C Time library to get date and time

examples/time/rtc/Makefile
examples/time/rtc/source/main.c

index 27830f8a726eacdc6253f9b3279b717a61922682..d75f5482ead557cbc72a0e2aea60e01bbebfb590 100755 (executable)
@@ -32,11 +32,10 @@ SOURCES             :=      source
 DATA           :=      data
 INCLUDES       :=      include
 
-
 #---------------------------------------------------------------------------------
 # options for code generation
 #---------------------------------------------------------------------------------
-ARCH   :=      -march=armv6k -mtune=mpcore -mfloat-abi=softfp
+ARCH   :=      -march=armv6k -mtune=mpcore -mfloat-abi=hard
 
 CFLAGS :=      -g -Wall -O2 -mword-relocations \
                        -fomit-frame-pointer -ffast-math \
@@ -114,6 +113,10 @@ else
        export APP_ICON := $(TOPDIR)/$(ICON)
 endif
 
+ifeq ($(strip $(NO_SMDH)),)
+       export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
+endif
+
 .PHONY: $(BUILD) clean all
 
 #---------------------------------------------------------------------------------
@@ -138,10 +141,10 @@ DEPENDS   :=      $(OFILES:.o=.d)
 # main targets
 #---------------------------------------------------------------------------------
 ifeq ($(strip $(NO_SMDH)),)
-.PHONY: all
-all    :       $(OUTPUT).3dsx $(OUTPUT).smdh
-endif
+$(OUTPUT).3dsx :       $(OUTPUT).elf $(OUTPUT).smdh
+else
 $(OUTPUT).3dsx :       $(OUTPUT).elf
+endif
 $(OUTPUT).elf  :       $(OFILES)
 
 #---------------------------------------------------------------------------------
index a766898dca119e7d87044811c3dce6ee13b3cdf6..613918502d1a997f14d933fd974d16765e774096 100644 (file)
 
 #include <3ds.h>
 #include <stdio.h>
-
-#define SECONDS_IN_DAY 86400
-#define SECONDS_IN_HOUR 3600
-#define SECONDS_IN_MINUTE 60
+#include <time.h>
 
 int main(int argc, char **argv)
 {
        // Initialize services
-       srvInit();
-       aptInit();
-       gfxInit();
-       hidInit(NULL);
+       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);
@@ -44,13 +38,18 @@ int main(int argc, char **argv)
                if (kDown & KEY_START) break; // break in order to return to hbmenu
 
                //Print current time
-               u64 timeInSeconds = osGetTime() / 1000;
-               u64 dayTime = timeInSeconds % SECONDS_IN_DAY;
-               u8 hour = dayTime / SECONDS_IN_HOUR;
-               u8 min = (dayTime % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE;
-               u8 seconds = dayTime % SECONDS_IN_MINUTE;
+               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%02d:%02d:%02d", hour, min, seconds);
+               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();
@@ -62,8 +61,6 @@ int main(int argc, char **argv)
 
        // Exit services
        gfxExit();
-       hidExit();
-       aptExit();
-       srvExit();
+
        return 0;
 }