Пример #1
0
void sta_info_init(void)
{
	int i;

     	stainfo_g.mode = STATION_MODE_INFRA;
	stainfo_g.chan = 1;
	strcpy(stainfo_g.ssid, "WirelessHD");
	stainfo_g.rate = 0;
	stainfo_g.wep = 0;
	stainfo_g.wepkeylen = 0;
	stainfo_g.wepkeyactive = 0;
	stainfo_g.sharedkeyauth = 0;
	stainfo_g.brgmacclone = 0;
	stainfo_g.preamble = 0;	
	stainfo_g.profileCount = 0;

	// initial sites info
	wl_read_profile();
	stainfo_g.profileCount = profiles_g_count;

	/* Check if client mode is disabled */
	if (nvram_invmatch("wlp_clientmode_x", "0") && profiles_g_count!=0)
	{	
		//int pref = atoi(nvram_safe_get("wlp_pref_x"));
		//if (pref < profiles_g_count)
		//	sta_start_connecting_one(&profiles_g[pref]);
		//else sta_start_connecting_profile(0);
		if (nvram_match("wlp_clientmode_x", "2")) 
			nvram_set("wl0_mode", "wet");
		else nvram_set("wl0_mode", "sta");
		eval("wlconfig", "eth2");
		sta_start_scanning_profile(0);
	}
	else if (nvram_match("wlp_beap_x", "1")) sta_start_being_ap();
	else sta_stop();
}	
Пример #2
0
void GUI_Thread (void const *argument)
{
    /**
        This GUI makes the assumes that, during operation, the SD card will not be removed and
        the contects of the SD card will not be changed. It also assumes that all of mp3 files
        are on the top dir and there's subdirs are not supported.
    */

    osEvent sig;
    uint32_t spin_delay = 0, lcd_timeout = 0;

    // get the list of mp3s
    len = get_files("", &cur_fp);

    // see if there's at least one song
    if (cur_fp != NULL)
    {
        // if so, display the song
        display_stats();
    }
    else
    {
        // otherwise display an error msg and quit
        LCD_write_str("<No Songs Found>", LCD_DDRAM_LINE1_ADDR);
        LCD_write_str("MP3 Halted :(   ", LCD_DDRAM_LINE2_ADDR);
        return;
    }

    while(1)
    {
        // check if the player is done playing
        sig = osSignalWait(GUI_SIG_NEXT, 0);
        if ( (sig.status == osEventSignal) && (sig.value.signals & GUI_SIG_NEXT) )
        {
            if (cur_fp->next != NULL)
            {
                ++count;
                cur_fp = cur_fp->next;
                display_stats();

                if (GUI_Status == GUI_STATUS_PLAYING)
                {
                    PLAYER_PLAY(cur_fp->fname);
                    cur_song = cur_fp->fname;
                }
            }
            else
            {
                sta_stop();
                GUI_Status = GUI_STATUS_STOPPED;
            }

            // emulate a button press so the screen would light up
            btn_pressed = 1;
        }

        /* light up the screen if any of the buttons were pressed */
        if (btn_pressed)
        {
            // light up the screen
            PWM1->_2_CMPB = LCD_PWM_HIGH;
            // reset timeout
            lcd_timeout = 0;
            btn_pressed = 0;
            if(vol_btn_pressed){
                display_volume(); 
                vol_displayed = 1;  
                vol_btn_pressed = 0;
            }else{
                display_stats();
                vol_displayed = 0;
            }
        }
        // assume lcd_timeout is longer than vol_timeout
        else if (lcd_timeout == VOL_DELAY)
        {
            // switch to song screen
            // Also default display to song
            if(vol_displayed){
                display_stats();
                vol_displayed = 0;
            }
        }
        else if (lcd_timeout == DELAY_MUL)
        {
            // timeout, so we dimm the screen
            PWM1->_2_CMPB = LCD_PWM_LOW;            
        }
        ++lcd_timeout;  // will take a while before uint32_t rolls over

        /* spin animation */
        if (GUI_Status == GUI_STATUS_PLAYING)
        {
            if (spin_delay == SPIN_SPD)
            {
                spin_index = (spin_index + 1) % 4;
                spin_delay = 0;
            }
            else
            {
                ++spin_delay;
            }
        }
        if(!vol_displayed){
            display_song();
            LCD_write_nstr_f((char*)&spin_str[spin_index], 1, LCD_DDRAM_LINE1_ADDR+LCD_MAX_WIDTH-1);
        }

        osDelay(GUI_DELAY);
    }
}
Пример #3
0
void GPIOE_Handler()
{

    // check if the delay has passed
    if (TIMER0->RIS & TIMER_RIS_TATORIS)
    {
        // assume a button was pressed
        btn_pressed = 1;

        if (GPIOE->MIS & (1<<4))
        {
            /* Play/Pause (SW4) */
            if (GUI_Status == GUI_STATUS_STOPPED)
            {
                // if the player is waiting for a song
                if (Player_State == PLAYER_STATE_WAITING)
                {
                    PLAYER_PLAY(cur_fp->fname);
                    cur_song = cur_fp->fname;
                }
                // if a new song is selected
                else if (cur_song != cur_fp->fname)
                {
                    // skip the current song and queue the next song
                    osSignalSet(PlayerThreadId, PLAYER_SIG_SKIP);
                    PLAYER_PLAY(cur_fp->fname);
                    cur_song = cur_fp->fname;
                }
                // otherwise resume playing
                sta_play();
                GUI_Status = GUI_STATUS_PLAYING;
            }
            else if (GUI_Status == GUI_STATUS_PLAYING)
            {
                sta_stop();
                GUI_Status = GUI_STATUS_STOPPED;
            }
        }
        else if (GPIOE->MIS & (1<<5))
        {
            /* Prev (SW5) */
            if (cur_fp->prev != NULL)
            {
                --count;
                cur_fp = cur_fp->prev;
                display_stats();

                if (GUI_Status == GUI_STATUS_PLAYING)
                {
                    osSignalSet(PlayerThreadId, PLAYER_SIG_SKIP);
                    PLAYER_PLAY(cur_fp->fname);
                    cur_song = cur_fp->fname;
                }
            }

            // clear int
            GPIOE->ICR |= 1<<5;
        }
        // no buttons were pressed therefore...
        else
        {
            btn_pressed = 0;
        }

        // reset the timer
        TIMER0->ICR |= TIMER_ICR_TATOCINT;
        TIMER0->CTL |= TIMER_CTL_TAEN;
    }

    // clear int
    GPIOE->ICR |= 1<<4 | 1<<5;
}