Ejemplo n.º 1
0
void winner_blink(__u8 player, int time)
{
    printf("winner time: %d\n",time);
    // turn on
    if (blink)
    {
        printf(" blink on");
        blink = 0;
        draw_time(time, GREEN);
        redraw();
        if (player == P1)
            draw_score_p1(5);
        else
            draw_score_p2(5);
    }
    //turn off
    else
    {
        printf("blink off");
        blink = 1;
        clear_time();
        redraw();
        if (player == P1)
            clear_score_p1();
        else
            clear_score_p2();
    }
    redraw();
}
Ejemplo n.º 2
0
void clear_all()
{
	clear_fonts();
	clear_gbitmap();
	clear_marvin();
	clear_time();
	clear_date();
	clear_bolt();
	clear_explosion();
	clear_animations();
	clear_background();
}
static void cpuidle_profile_main_start(void)
{
	if (profile_ongoing) {
		pr_err("cpuidle profile is ongoing\n");
		return;
	}

	clear_time();
	profile_start_time = ktime_get();

	profile_ongoing = 1;

	/* Wakeup all cpus and clear own profile data to start profile */
	preempt_disable();
	clear_profile_info(&per_cpu(profile_info, smp_processor_id()), state_count);
	smp_call_function(call_cpu_start_profile, NULL, 1);
	preempt_enable();

	pr_info("cpuidle profile start\n");
}
Ejemplo n.º 4
0
/**
 *  @brief Timer Thread - used to aid time specific tasks.
 *
 *    Continuously updates the time information on the 7 Seg display
 *    and checks for the closest Wifi beacon (every 10 seconds).
 *
 *  @param Void.
 *  @return Void.
 */
void * timer(void){
  struct timespec timeToWait;
  struct timeval now;
  int err, init = FALSE;
  int paused_blink = FALSE;


  //extern char closest_mac[];

  gettimeofday(&now,NULL);
  timeToWait.tv_sec = now.tv_sec+1;
  timeToWait.tv_nsec = 0;


  while(alive && logged_in)
  {

    long long int time = 0, prev_time = 0;

    pthread_mutex_lock(&timer_Mutex);
    err = pthread_cond_timedwait(&timer_Signal, &timer_Mutex, &timeToWait);
/*    if (err == ETIMEDOUT) {
      printd("timer timed out\n");
    }
    else
    {
      printd("timer called\n");
    }
*/
    pthread_mutex_unlock(&timer_Mutex);

    gettimeofday(&now,NULL);

    if (time = getTimeGst()) //nanoseconds into current stream
    {
      if (init == FALSE)
      {
        long long int nano_offset = (1000000000UL - time);
        timeToWait.tv_sec = now.tv_sec + (nano_offset / 1000000000UL);
        timeToWait.tv_nsec = nano_offset % 1000000000UL;
        init = TRUE;
      }
      else
      {
        timeToWait.tv_sec = now.tv_sec + TIMEOUT;
        timeToWait.tv_nsec = 0;
      }
      count = time / (1000000000UL);
      show_time();
      paused_blink = FALSE;
      
      if (time == prev_time)
      {
        killGst();
        init = FALSE;
        clear_time();        
      }
    }
    else
    {
      if (!paused && init == TRUE)
      {
        killGst();
        init = FALSE;
        clear_time();
      }

      timeToWait.tv_sec = now.tv_sec;//+1;
      timeToWait.tv_nsec = 500000000UL;//0;
      //display_time("    ");
      paused_blink = TRUE;
      init = FALSE;
    }

    /*
    if (strlen(closest_mac) != 0)
    {
      printd("timer seeing mac: %s\n",closest_mac);
    }
    */
  }
  pthread_exit(0);
}
Ejemplo n.º 5
0
int main(void){
    volatile uint8_t limit=10;
    uint32_t counter=0;
    uint8_t flag=0;
    initialize();

    limit=eeprom_read_byte((uint8_t *)EE_LIMIT);
    
    sei();
    
    //limit=eeprom_read_byte((uint8_t *)EE_LIMIT);
    //eeprom_write_byte((uint8_t *)EE_LIMIT, limit);
    
    while (1) {

        if (timer_on==0) {
            clear_time();
        }else{
            //Turn reached limit turn relay off
            if (t.minute==limit) {
                timer_on=0;
                PORT_RELAY  &=  ~(1<<RELAY);
                to_display_0=0;
                to_display_1=0;
                beep(1000);
                beep(1000);
                _delay_ms(500);
                beep(1000);
                beep(1000);
                _delay_ms(500);
                beep(1000);
                beep(1000);
            }
        }
        //Start Timer
        if (((PIN_SW1 & (1<<SW1))==0) && timer_on==0) {
            _delay_ms(20);
            beep(100);
            to_display_0= limit / 10;
            to_display_1= limit % 10;
            _delay_ms(1000);
            timer_on=1;
            clear_time();
            PORT_RELAY  |=  (1<<RELAY);
        }
        //Stop Timer
        if (((PIN_SW2 & (1<<SW2))==0) && timer_on==1) {
            _delay_ms(20);
            //Wait for button release
            while ((PIN_SW2 & (1<<SW2))==0);              
            timer_on=0;
            clear_time();
            beep(100);
            PORT_RELAY  &=  ~(1<<RELAY);
        }
        //Configure timer
        if (((PIN_SW2 & (1<<SW2))==0) && timer_on==0) {
            _delay_ms(20);
            beep(100);
            while (1) {
                
                if (((PIN_SW1 & (1<<SW1))==0)) {
                    _delay_ms(20);
                    beep(100);
                    if (limit>0) {
                        limit--;
                    }
                }
                if (((PIN_SW2 & (1<<SW2))==0)) {
                    _delay_ms(20);
                    beep(100);
                    while ((PIN_SW2 & (1<<SW2))==0) {
                        counter++;
                        _delay_ms(1);
                        if (counter==1000UL) {
                            beep(100);
                        }
                    }
                    if (counter>1000UL) {
                        counter=0;
                        goto    LABEL1;
                    }else{
                        counter=0;   
                        if (limit<99) {
                            limit++;
                        }
                    }
                }
                if (flag==0) {
                    to_display_0=0xFF;
                    to_display_1=0xFF;
                    flag=1;
                }else{
                    to_display_0= limit / 10;
                    to_display_1= limit % 10;                    
                    flag=0;
                }
                _delay_ms(100);
            }
LABEL1:           
            eeprom_write_byte((uint8_t *)EE_LIMIT, limit);
        }
    }


    return 0;
}