Update for latest ctrulib

Now the example compiles using the latest ctrulib. It also uses
standard C Time library to get date and time
This commit is contained in:
Aurelio Mannara 2015-05-25 10:29:06 +02:00
parent eb1d6013cf
commit 1f375c0a75
2 changed files with 22 additions and 22 deletions

View File

@ -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)
#---------------------------------------------------------------------------------

View File

@ -14,18 +14,12 @@
#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);
printf("\x1b[0;0H%02d:%02d:%02d", hour, min, seconds);
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();
@ -62,8 +61,6 @@ int main(int argc, char **argv)
// Exit services
gfxExit();
hidExit();
aptExit();
srvExit();
return 0;
}