int main(void)
{
	tm gmt;
	WatchDogDisable();
	NutDelay(100);
	SysInitIO();
	SPIinit();
	LedInit();
	LcdLowLevelInit();
	Uart0DriverInit();
	Uart0DriverStart();
	LogInit();
	LogMsg_P(LOG_INFO, PSTR("-----------------------------------------------------------------------------------------------"));
	CardInit();
	X12Init();
	if (X12RtcGetClock(&gmt) == 0)
	{
		LogMsg_P(LOG_INFO, PSTR("RTC time [%02d:%02d:%02d]\n"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
	}
	if (At45dbInit() == AT45DB041B)
	{
		
	}
	RcInit();
	KbInit();
	SysControlMainBeat(ON);             // enable 4.4 msecs hartbeat interrupt
	initMenu();
	sei();
	NutTimerInit();
	NutThreadSetPriority(1);
	int keyvalue = KbGetKey();
	int old;
	LcdBackLight(LCD_BACKLIGHT_ON);
	if(NutRegisterDevice(&DEV_ETHER, 0x8300, 5))printf("Error: No LAN device\n");
	else printf("Lan device initialized\n");
	
	for (;;)
	{
		keyvalue = KbGetKey();
		if(old != keyvalue){
			stateMenu(keyvalue);
			old = keyvalue;
		}		
		NutSleep(100);
		WatchDogRestart();
	}

	return(0);      // never reached, but 'main()' returns a non-void, so.....
}
Beispiel #2
0
	THREAD(ButtonHandlerThread, arg)
	{
		for (;;) {
			NutSleep(100);
			buttonHandler(KbGetKey());
		}
	}
Beispiel #3
0
THREAD(Thread1, arg)
{
	LcdSetCursorPosition(0,4);
	PrintStr("Ingedrukt");
	int licht = 1;

    for (;;) {
		LcdSetCursorPosition(1,11);
		PrintStr("\1");
		LcdSetCursorPosition(1,12);
		PrintStr("\2");
		LcdSetCursorPosition(1,13);
		PrintStr("\3");
		LcdSetCursorPosition(0,15);
		PrintStr("\4");
		LcdSetCursorPosition(1,15);
		PrintStr("\5");
        NutSleep(100);
		LcdSetCursorPosition(0,0);
		PrintStr("000");		

    	char buffer [16];
		int n;
		char kb = KbGetKey();
		if(kb < 125 && kb > 0){
			n = sprintf(buffer,"%d",kb);
			LcdSetCursorPosition(0,(3-n));
			PrintStr(buffer);
		}
		if(kb == 13){
			if(licht == 1){
				licht = 0;
			}else{
				licht = 1;
			}
			LcdBackLight(licht);
			
		}
		//PrintStr(sprintf("%s",KbGetKey()));
		NutSleep(100);

    }
}
Beispiel #4
0
int main(void)
{
    struct _tm timeCheck;

    WatchDogDisable();

    NutDelay(100);

    SysInitIO();

	SPIinit();

	LedInit();

	LcdLowLevelInit();

    Uart0DriverInit();
    Uart0DriverStart();
	LogInit();

    X12Init();

    VsPlayerInit();

    NtpInit();

    NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
    NutThreadCreate("BackgroundThread", AlarmSync, NULL, 2500);
    NutThreadCreate("BackgroundThread", AlarmCheck, NULL, 256);

	KbInit();

    SysControlMainBeat(ON);             // enable 4.4 msecs heartbeat interrupt

    /*
     * Increase our priority so we can feed the watchdog.
     */
    NutThreadSetPriority(1);

	/* Enable global interrupts */
	sei();
	
	LcdBackLight(LCD_BACKLIGHT_ON);
    setCurrentDisplay(DISPLAY_DateTime, 5);

    X12RtcGetClock(&timeCheck);
    int hours;
    int mins;
    int secs;
    if(!NutNvMemLoad(100, &hours, sizeof(hours)))
    {
        printf("uren: %d", hours);
    }
    if(!NutNvMemLoad(105, &mins, sizeof(mins)))
    {
        printf(" minuten: %d", mins);
    }
    if(!NutNvMemLoad(110, &secs, sizeof(secs)))
    {
        printf(" seconden %d", secs);
    }
    printf("Welcome to Saltyradio.\nI'm using mac address:  %s\n\n\n", getMacAdress());

    for (;;)
    {
        //Key detecten
        if(KbGetKey() == KEY_01){
            setCurrentDisplay(DISPLAY_DateTime, 5);
        }
        else if(KbGetKey() == KEY_OK)
        {
            if(getCurrentDisplay() == DISPLAY_MainMenu)
            {
                clickOk();
            }
            else if(getCurrentDisplay() == DISPLAY_SettingsMenu)
            {
                clickOkSettings();
            }
            else if(getCurrentDisplay() == DISPLAY_Play || getCurrentDisplay() == DISPLAY_Song)
            {
                clickOkPlay();
            }
            else
            {
                setCurrentDisplay(DISPLAY_MainMenu, 10000);
            }
        }
        else if(KbGetKey() == KEY_LEFT)
        {
            switchLeft();
        }
        else if(KbGetKey() == KEY_RIGHT)
        {
            switchItem();
        }
        else if(KbGetKey() == KEY_DOWN){
            setCurrentDisplay(DISPLAY_Volume, 5);
            volumeDown();
        }else if(KbGetKey() == KEY_UP) {
            setCurrentDisplay(DISPLAY_Volume, 5);
            volumeUp();
        }
        refreshScreen();
        WatchDogRestart();
        NutSleep(100);
    }
    return(0);
}