void setBackLight(int state)
{
	switch (state)
	{
	case 0:
		LcdBackLight(LCD_BACKLIGHT_OFF);
		lcdBackLightStatus = state;
		break;
	case 1:
		LcdBackLight(LCD_BACKLIGHT_ON);
		lcdBackLightStatus = state;
		break;
	}
}
Beispiel #2
0
void displayTwitch(char name[], char title[], char game[]) {

    if (timerStruct(lastDisplayTime) % 10 < 5) {
        ClearLcd();
        if(strlen(name) < 16) {
            LcdArrayLineOne(name, strlen(name));
        }else {
            LcdArrayLineOne(name, 16);
        }
        LcdArrayLineTwo("is streaming    ", 16);
    }
    else {
        ClearLcd();
        if(strlen(title) > 16) {
            LcdArrayLineOne(title, 16);
        }else {
            LcdArrayLineOne(title, strlen(title));
        }if(strlen(game) > 16) {
            LcdArrayLineTwo(game, 16);
        }else{
            LcdArrayLineTwo(game, strlen(game));
        }
    }
    LcdBackLight(LCD_BACKLIGHT_ON);
}
Beispiel #3
0
void displayStreamInfo(){
    LcdBackLight(LCD_BACKLIGHT_ON);
    char offset = getScrollOffset();


    if (offset == 0)
        (*write_display_ptr[1])("                ", 17);

    (*write_display_ptr[0])("  Station Info  ", 17);

    //char* streamInfo = getStreamInfo();

    // I have to copy the StreamInfo buffer, I kept overwriting it.
    char streamInfo[48] = "    No  info    ";
    char* streamInfoPtr = &streamInfo[0];
    strncpy(streamInfo, getStreamInfo(), 48); // copy the streamInfo buffer.
    streamInfo[48] = '\0'; // To be sure...

    if (offset >= 0)
        streamInfoPtr += offset;
    streamInfoPtr[16] = '\0';

    (*write_display_ptr[1])(streamInfoPtr, 17);

    incrementScrollOffset();

    NutDelay(500);
}
Beispiel #4
0
void displayTwitter(char* text)
{
    ClearLcd();
    LcdBackLight(LCD_BACKLIGHT_ON);
    LcdArrayLineOne("     Twitter    ", 16);
    int j = 0;
    int i;
    char text1[16];
    for(i = 0; i<140;i++){
        if (text[i] != 0){
            j++;
        }
    }

        for(i = 0; i < 16; i++){
            if (text[Scroller+i]!= 0) {
                text1[i] = text[Scroller + i];
            } else {
                text1[i] = ' ';
            }
        }
        LcdArrayLineTwo(text1,16);
        Scroller++;
        if (Scroller > j){
            Scroller = 0;
        }
}
Beispiel #5
0
/**
 * Temporarily light up the display.
 * @param time  time in ~500ms/half seconds
 */
void lcd_backlight_on(int time)
{
    if(time > 0)
    {
        LcdBackLight(LCD_BACKLIGHT_ON);
        lcd_backlight_time = time;
    }
}
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 #7
0
/**
 * Starting point of the thread that handles everything on the LCD screen except the information.
 * @param arg
 */
THREAD(DisplayThread, arg)
{
    for(;;)
    {
        lcd_display_main_screen(); //Shows time, date and alarm status. Only shows alarm status again if it changed.  
        
        // Turn off the backlight if it was temporarily enabled.
        if(lcd_backlight_time == 0)
            LcdBackLight(LCD_BACKLIGHT_OFF);
        else
            lcd_backlight_time--;   // Decrease the backlight 'timer'.  
        
        NutSleep(500);
    }
}
void updateScreenBackLight()
{
	if (alarmStatus == 2)
	{
		LedControl(LED_TOGGLE);
	}
	if (lcdBackLightStatus > 0)
	{
		backlightTimer++;
		if (backlightTimer >= onTimer)
		{
			backlightTimer = 0;
			lcdBackLightStatus = 0;
			LcdBackLight(LCD_BACKLIGHT_OFF);
		}
	}

}
Beispiel #9
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 #10
0
void refreshScreen(){
    if(timerStruct(lastDisplayTime) > displayTime && currentViewDisplay != DISPLAY_Alarm){
        currentViewDisplay = DISPLAY_DateTime;
        LcdBackLight(LCD_BACKLIGHT_OFF);
    }

    if(currentViewDisplay == DISPLAY_DateTime){
        displayDateTime();
    } else if(currentViewDisplay == DISPLAY_Volume){
        displayVolume();
    } else if(currentViewDisplay == DISPLAY_Alarm){
        displayAlarm(getRunningAlarmID());
    } else if(currentViewDisplay == DISPLAY_Twitch){
        displayTwitch(data.name, data.title, data.game);
    } else if(currentViewDisplay == DISPLAY_Twitter){
        displayTwitter(TweetFeed.tweet);
    } else if(currentViewDisplay == DISPLAY_StreamInfo){
        displayStreamInfo();
    }
}
Beispiel #11
0
void setCurrentDisplay(viewDisplays d, u_long dt){
    X12RtcGetClock(&lastDisplayTime);
    LcdBackLight(LCD_BACKLIGHT_ON);
    currentViewDisplay = d;
    displayTime = dt;
}
Beispiel #12
0
	int main(void) {
		//audioInit();
		//setVolume(254);
		WatchDogDisable();		//disable watchdog
		NutDelay(100);			//wait for it to disable
		SysInitIO();			//initialise input and output
		SPIinit();				//initialise SPI-registers (speed, mode)
		LedInit();				//initialise led
		initLCD();				//initialise lcd
		Uart0DriverInit();		//initialise Universal asynchronous receiver/transmitter  
		Uart0DriverStart();		//start Uart
		printf("\n\n\n\nHardware initialization done\n\n");
		LogInit();				//initialise ability to log
		CardInit();				//initialise cardreader
		printf("\n----------------------------------------------START OF PROGRAM------------------------------------------------------------\n");

		if (NutSegBufInit(8192) == 0) {
			puts("NutSegBufInit: Fatal error");
		}
		
		/*
		* Initialize the MP3 decoder hardware.
		*/
		if (VsPlayerInit() || VsPlayerReset(0)) {
			puts("VsPlayer: Fatal error");
		}
		
		if(X12Init() == -1){
			printf("error initializing RTC");	//initialise X12RTC 
		}				
		tm gmt;
		if (X12RtcGetClock(&gmt) == 0) {
			LogMsg_P(LOG_INFO, PSTR("local storage time [%02d:%02d:%02d] (in RTC)\n"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec);
		}

		if (At45dbInit() == AT45DB041B) {
			// ......
		}

		RcInit();					//Initialise the Remote Control module
		KbInit();					//Initialise keyboard
		initMenu();					//Initialise menu
		NutThreadCreate("Bh", ButtonHandlerThread, NULL, 512);	//create thread to handle button presses
		printf("\nInitialization done.\n");
		initAlarms();
		SysControlMainBeat(ON); 	//enable 4.4 msecs heartbeat interrupt
		printf("Heartbeat on.\n");
		NutThreadSetPriority(1);	//Increase our priority so we can feed the watchdog.
		sei();						//enable global interrupts
		NutThreadCreate("Bg", TimeSyncThread, NULL, 512);
		NutThreadCreate("Bq", RefreshSceenThread, NULL, 512);
		NutThreadCreate("Bl", AlarmCheckerThread, NULL, 512);
		printf("\nEntering main loop.\n");
		LcdBackLight(LCD_BACKLIGHT_ON);
		for(;;){
			NutSleep(100);
			WatchDogRestart();			//restart watchdog
		}
		
		return(0);
	}
Beispiel #13
0
int main(void)
{
	
    WatchDogDisable();

    NutDelay(100);

    SysInitIO();
	
	SPIinit();
    
	LedInit();
	
	LcdLowLevelInit();
	LcdBackLight(1);
	PrintStr("Starting System");
    Uart0DriverInit();
    Uart0DriverStart();
	LogInit();

    CardInit();

	char custom[48] = ALL;
	
	LoadCustomChars(custom, 6);
	
    X12Init();
    if (X12RtcGetClock(&gmt) == 0)
    {
		LogMsg_P(LOG_INFO, PSTR("RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );
    }

    if (At45dbInit()==AT45DB041B)
    {
        // ......
    }


    RcInit();
    
	KbInit();

    SysControlMainBeat(ON);             // enable 4.4 msecs hartbeat interrupt
	
	ClearLcdScreen();

	//Nieuwe threads aanmaken
    NutThreadCreate("t01", Thread1, NULL, 512);
	NutThreadCreate("time", TimeUpdater, NULL, 512);
	
	//Start netwerk
	int i = initNetworkDHCP();
	LogMsg_P(LOG_INFO, PSTR("Ethernet Startup Message: [%d]"),i);

	//Haal Internet tijd op
	pgmt = getNTPTime();
	X12RtcSetClock(&pgmt);
	//LogMsg_P(LOG_INFO, PSTR("New RTC time [%02d:%02d:%02d]"), gmt.tm_hour, gmt.tm_min, gmt.tm_sec );

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

	/* Enable global interrupts */
	sei();

	/******************NETWERK**TEST*****************************************************/

	//Maak nieuwe socket
	TCPSOCKET *sock;
	sock = NutTcpCreateSocket();
	//Connect met google.nl
	LogMsg_P(LOG_INFO, PSTR("Connecting client"));
	clientConnect(sock);
	//Zend http req
	clientSend(sock,buffer,sizeof(buffer));

	//Ontvang response in buffer --> grotere buffer (1500)= crash-->heapsize??(8k ram)
	char rcvbuffer [500];
	int rec;
	rec = clientReceive(sock,rcvbuffer,sizeof(rcvbuffer));
	LogMsg_P(LOG_INFO, PSTR("received [%d]"),rec);

	//0 terminate buffer(string)
	//rcvbuffer[499] = 0;

	//Print buffer(http response enz)
	LogMsg_P(LOG_INFO, PSTR("received [%s]"),rcvbuffer);
	
	//Sluit connectie
	clientClose(sock);
	/***********************************************************************************/

	//Main gui besturing??
    for (;;)
    {
        NutSleep(100);
        WatchDogRestart();
    }

    return(0);      
}
Beispiel #14
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);
}