コード例 #1
0
ファイル: iv.c プロジェクト: daveparker/icetubeclock_dimmer
// This turns on/off the alarm when the switch has been
// set. It also displays the alarm time
void setalarmstate(void) {
  if (ALARM_PIN & _BV(ALARM)) { 
    // Don't display the alarm/beep if we already have
    if  (!alarm_on) {
      // alarm on!
      alarm_on = 1;
      // reset snoozing
      snoozetimer = 0;
      // show the status on the VFD tube
      display_str("alarm on");
      // its not actually SHOW_SNOOZE but just anything but SHOW_TIME
      displaymode = SHOW_SNOOZE;
      delayms(1000);
      // show the current alarm time set
      display_alarm(alarm_h, alarm_m);
      delayms(1000);
      // after a second, go back to clock mode
      displaymode = SHOW_TIME;
    }
  } else {
    if (alarm_on) {
      // turn off the alarm
      alarm_on = 0;
      snoozetimer = 0;
      if (alarming) {
	// if the alarm is going off, we should turn it off
	// and quiet the speaker
	DEBUGP("alarm off");
	alarming = 0;
	TCCR1B &= ~_BV(CS11); // turn it off!
	PORTB |= _BV(SPK1) | _BV(SPK2);
      } 
    }
  }
}
コード例 #2
0
ファイル: eClock.c プロジェクト: ZhengzhenZhang/course-design
int main()    
{	
	InitData();	 					
	
	while(1) {

		ReadTimeAndJudgeAlarmArrival();

		switch (mainLoop) {
		case 0:
			display_time();
			break;
		case 1:
			display_data();
			break;
		case 2:
			display_alarm();
			break;
		case 3:
			display_sWatch();
			break;
		}
		KeyScan();
	}

	return 0;
}
コード例 #3
0
ファイル: etAlarm.c プロジェクト: liuyuanbin/ET-smart-band
unsigned char clock_alarm_check(void)
{
	unsigned int curSec = 0;
//	unsigned int dalSec = 0,minSec = 30;
  unsigned int minSec = 30;
	unsigned char i = 0, alarm_open_flag = 0;
	//alarm_info_struct *pClockItem;
	//alarm_str *pClockItem;
	s_tm curTime = {0};
  //  unsigned int alarmSecond  = 0;
	system_time_get(&curTime);
	
	//QPRINTF("aa\r\n");
    curSec = system_sec_get();
	if(curSec >= todayEndSec)
	{	
		//DateChangeFlg=1;
		system_day_sec_init();
		for (i = 0; i < ALARM_ITEM_NUMBER_MAX; ++i)
		{
			g_RamAlarmBlock.pdata[i].alarm_work_today=ALARM_NO_WORKED_TODAY;
		}		
		#if WALK_STEP_RECORD_ARITHMETIC
		SaveEveryDayHistySport_Data_info2_datamanger();
		//app_arthmetic_clear_steps(0);
		#endif

		#if SLEEP_RECORD_ARITHMETIC
		sleep_data_clear();
		#endif
	}
	
  for (i = 0; i < ALARM_ITEM_NUMBER_MAX; ++i)
  {
    	//pClockItem = (alarm_info_struct *)(g_RamAlarmBlock.pdata + i*ALARM_ITEM_MAX_SIZE) ;
		//pClockItem = (alarm_str *)(g_RamAlarmBlock.pdata + i*ALARM_ITEM_MAX_SIZE) ;
		//pClockItem = (alarm_str *)&(g_RamAlarmBlock.pdata[i]) ;
		//QPRINTF("alarm info %d: week=%d, hour=%d,min=%d\r\n", i,pClockItem->week_repeat, pClockItem->hour,pClockItem->min);
		//if(pClockItem->week_repeat & (1 << curTime.weekdays))
		//if((pClockItem->alarm_week & (1 << curTime.weekdays))&&(pClockItem->alarm_enable))
		if((g_RamAlarmBlock.pdata[i].alarm_week & (1 << curTime.weekdays))&&(g_RamAlarmBlock.pdata[i].alarm_enable))
		{
	     if((g_RamAlarmBlock.pdata[i].alarm_work_today==ALARM_NO_WORKED_TODAY)&&(g_RamAlarmBlock.pdata[i].alarm_hour==curTime.hour)&&(g_RamAlarmBlock.pdata[i].alarm_minute==curTime.minute))
	     {
					alarm_open_flag = 1;
				  g_RamAlarmBlock.pdata[i].alarm_work_today=ALARM_WORKED_TODAY;
					if(0 == (g_RamAlarmBlock.pdata[i].alarm_week & 0x80))
					{
						g_RamAlarmBlock.pdata[i].alarm_week &= ~(1 << curTime.weekdays);						
					}					
	    }	
		}
		if(alarm_open_flag)
		{
						alarm_open_flag=0;
						display_alarm(curTime.hour,curTime.minute);
						break;
		}    
  }
	
	//if(alarm_open_flag)
	//{
	//	display_alarm(curTime.hour,curTime.minute);
	//}
	return minSec;
}
コード例 #4
0
ファイル: iv.c プロジェクト: daveparker/icetubeclock_dimmer
void set_alarm(void) 
{
  uint8_t mode;
  uint8_t hour, min, sec;
    
  hour = min = sec = 0;
  mode = SHOW_MENU;

  hour = alarm_h;
  min = alarm_m;
  sec = 0;
  
  timeoutcounter = INACTIVITYTIMEOUT;
  
  while (1) {
    if (just_pressed & 0x1) { // mode change
      return;
    }
    if (just_pressed || pressed) {
      timeoutcounter = INACTIVITYTIMEOUT;  
      // timeout w/no buttons pressed after 3 seconds?
    } else if (!timeoutcounter) {
      //timed out!
      displaymode = SHOW_TIME;     
      alarm_h = hour;
      alarm_m = min;
      eeprom_write_byte((uint8_t *)EE_ALARM_HOUR, alarm_h);    
      eeprom_write_byte((uint8_t *)EE_ALARM_MIN, alarm_m);    
      return;
    }
    if (just_pressed & 0x2) {
      just_pressed = 0;
      if (mode == SHOW_MENU) {
	// ok now its selected
	mode = SET_HOUR;
	display_alarm(hour, min);
	display[1] |= 0x1;
	display[2] |= 0x1;	
      } else if (mode == SET_HOUR) {
	mode = SET_MIN;
	display_alarm(hour, min);
	display[4] |= 0x1;
	display[5] |= 0x1;
      } else {
	// done!
	alarm_h = hour;
	alarm_m = min;
	eeprom_write_byte((uint8_t *)EE_ALARM_HOUR, alarm_h);    
	eeprom_write_byte((uint8_t *)EE_ALARM_MIN, alarm_m);    
	displaymode = SHOW_TIME;
	return;
      }
    }
    if ((just_pressed & 0x4) || (pressed & 0x4)) {
      just_pressed = 0;

      if (mode == SET_HOUR) {
	hour = (hour+1) % 24;
	display_alarm(hour, min);
	display[1] |= 0x1;
	display[2] |= 0x1;
      }
      if (mode == SET_MIN) {
	min = (min+1) % 60;
	display_alarm(hour, min);
	display[4] |= 0x1;
	display[5] |= 0x1;
      }

      if (pressed & 0x4)
	delayms(75);
    }
  }
}