コード例 #1
0
ファイル: my_alarm.c プロジェクト: CoreyGao/Software_Timer
MYALARM *alarm_declare(int tm,MYALARM *t){
     if(tm<0 || tm>MAXTIME){
	  printf("error time in alarm_declare\n");
	  return NULL;
     }
     MYALARM *temp;

     interrupt_disable();
     for(t=alarms;t<&alarms[MAXALARM];t++){
	  if(t->inuse == FALSE)
	       break;
     }
     
     if(t == &alarms[MAXALARM]){
	  printf("alarms is full now,please try later\n");
	  return NULL;
     }

     t->inuse=TRUE;
     t->time = (time_t)tm;
     time(&t->declare_time);
     
     alarm_update();
     interrupt_enable();
     return t;
}
コード例 #2
0
ファイル: my_alarm.c プロジェクト: CoreyGao/Software_Timer
int alarm_cancle(MYALARM *t){
     interrupt_disable();
     TIME now;
     time(&now);
     if(!t->inuse){
	  printf("alarm not in use,can't disable\n");
	  return -1;
     }
     t->inuse=FALSE;
     

     if(t == next_timer){
	  alarm_update();
     }
//     printf("success cancel\n");
     interrupt_enable();
     return 0;
}
コード例 #3
0
ファイル: my_alarm.c プロジェクト: CoreyGao/Software_Timer
void alarm_interrupt_handler(int sig){
     printf("%d bingo\n",next_timer->time);
     next_timer->inuse = FALSE;
     alarm_update();
}
コード例 #4
0
ファイル: main.c プロジェクト: Genoil/smartwatch
int main(void)
{
	init();

	sei();

	if(wdt_wasReset())
		resetError();

	buzzer_buzz(200, TONE_4KHZ, VOL_UI);
	led_flash(LED_GREEN, 50, 255);

	watchface_setFace(watchface_normal);
	watchface_loadFace();
/*
	while(1)
	{
		buzzer_buzzb(200,TONE_5KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_4KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_2_5KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_2KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_4KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_5KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_2_5KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_2KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_3_5KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_4KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_3KHZ, VOL_UI);
		buzzer_buzzb(250,TONE_2KHZ, VOL_UI);
		buzzer_buzzb(250,TONE_2KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_4KHZ, VOL_UI);
		buzzer_buzzb(200,TONE_4KHZ, VOL_UI);
	}
*/
	while(1)
	{
		bool timeUpt = time_update();
		if(pwrmgr_userActive())
		{
			if(timeUpt && timeData.secs == 0)
				battery_update();
			buttons_update();
		}

		buzzer_update();
		led_update();
		stopwatch_update();

		if(pwrmgr_userActive())
		{
			alarm_update();
			display_update();
		}

//		freeRAM();

		wdt_update();

		pwrmgr_update();
	}
}