コード例 #1
0
void setLeftRightBalance(int lefta, int righta)
{
	int volume;
	left = lefta;
	right = righta;
	volume = VsGetVolume();
	setGVolume(volume);
	
}
コード例 #2
0
ファイル: player.c プロジェクト: Tregan/JTI-2.3-A3-IMC
THREAD(FallingAsleep, arg)
{
    printf("falling asleep started\n");
    for(;;)
    {
        int volumeGoal = 254;
        
        //Dont start yet if no sound is playing
        while(VsGetStatus() != VS_STATUS_RUNNING)
            NutSleep(50);

        //Get the amount of seconds from the fallingAsleepTime minutes
        long totalSeconds = (long)fallingAsleepTime * 1000 * 60;
        printf("totalseconds = %lu\n", totalSeconds);
        //Get the time to sleep before "increasing" the volume. Divide the totalSeconds by the volumeGoal to get a smooth transition
        long sleepTime = totalSeconds / volumeGoal;
        printf("sleeptime = %lu\n", sleepTime);
        int currentVolume = VsGetVolume();
        
        //"Increase" the volume until it hits the goal
        while(currentVolume < volumeGoal)
        {
            NutSleep(sleepTime);
            VsSetVolume(currentVolume + 1, currentVolume + 1);
            printf("Falling Asleep Mode tick now. Volume lowered %d", VsGetVolume());
            currentVolume++;
        }
        
        //Call stopStream in network.c
        stopStream();
        //Turn off falling asleep mode
        fallingAsleepMode = 0;
        //Reset volume
        VsSetVolume(0, 0);
        //Exit the thread
        NutThreadExit();
    }
}
コード例 #3
0
ファイル: rtc.c プロジェクト: Jordyderuijter/JTI2.3A4
THREAD(AlarmPollingThread, arg)
{
    static u_int button_cooldown_counter = 0;
    static bool button_cooldown = true;
    u_long alarm_a;
    u_long alarm_b; 
    short snooze_time;
    tm snooze;
    tm alarm_a_backup;
    
    for(;;)
    {      
        X12RtcGetStatus(&alarm_a);
        alarm_b = alarm_a;
        alarm_a &= 0b00100000;

        alarm_b &= 0b01000000;

        if(alarm_a!=0 && alarm_a_on)
        {
            VsBeep((u_char)500, 1000);              //BeepBoop, beeps with (frequency, duration)
            VsSetVolume(0,0);
            puts("Volume on");
        }

        if(alarm_b!=0 && alarm_b_on)
        {
            VsBeep((u_char)1000, 1000);              //BeepBoop, beeps with (frequency, duration)
            VsSetVolume(0,0);
            puts("Volume on");
        }

        if(button_cooldown_counter >= 2)
        {
            button_cooldown = false;
            button_cooldown_counter = 0;
        }
    
        if(kb_button_is_pressed(KEY_ALT) && alarm_a!=0)
        {
            At45dbPageRead(2, &snooze_time, 2);
            X12RtcClearStatus(0b00100000);
            get_alarm_a(&snooze);
            snooze.tm_min+=snooze_time;
            set_alarm_a(&snooze);
        }
        
        if(!button_cooldown)
        {
            switch(kb_button_pressed())
            {
                case KEY_ESC:
                    puts("escape pressed");
                    if(VsGetVolume() != 0)
                    {
                        puts("volume on");
                        VsSetVolume(0, 0);
                    }
                    else if(VsGetVolume() == 0)  
                    {
                        puts("volume off");
                        VsSetVolume(100, 100);
                    } 
                    if(alarm_a != 0)
                    {
                        X12RtcClearStatus(0b00100000);
                        At45dbPageRead(3, &alarm_a_backup, sizeof(tm));
                        set_alarm_a(&alarm_a_backup);
                    }
                    if(alarm_b != 0)
                    {
                        X12RtcClearStatus(0b01000000);
                        disable_alarm_b();
                        alarm_b_on = false;
                    }
                    break;

                case KEY_01:
                    alarm_a_on = !alarm_a_on;
                    alarmstatus_changed = true;
                    break;

                case KEY_02:
                    alarm_b_on = !alarm_b_on;
                    alarmstatus_changed = true;
                    break;

                default:
                    break;
            }
            button_cooldown = true;
        }
        if(button_cooldown)
                button_cooldown_counter++; 
        NutSleep(100);
    }
}