Esempio n. 1
0
void time_sleep()
{
//	TCCR2B = _BV(CS22)|_BV(CS20);
//	while(ASSR & (_BV(OCR2BUB)|_BV(TCR2AUB)|_BV(TCR2BUB)));

#if RTC_SRC != RTC_SRC_INTERNAL
	// Turn off square wave
	rtc_sqw(RTC_SQW_OFF);

	alarm_s alarm;

	// Set next alarm
	if(alarm_getNext(&alarm))
	{
		alarm.days = alarm_getNextDay() + 1;
		rtc_setUserAlarmWake(&alarm);
	}
	else
		rtc_setUserAlarmWake(NULL);

	// 
	if(appConfig.volHour)
	{
		alarm.min = 0;
		alarm.hour = 0;
		alarm.days = 0;
		rtc_setSystemAlarmWake(&alarm);
	}
	else // Hour beep volume set to minimum, so don't bother with the system alarm
		rtc_setSystemAlarmWake(NULL);
#endif

	update = false;
}
Esempio n. 2
0
void time_sleep()
{
//	TCCR2B = (1<<CS22)|(1<<CS20);
//	while(ASSR & 0x07);

	// Turn off square wave
	ds1337_sqw(DS1337_SQW_OFF);

	// Set next alarm
	s_alarm* nextAlarm = alarm_getNext();
	if(nextAlarm != NULL)
	{
		s_alarm alarm;
		alarm.min = dec2bcd(nextAlarm->min);
		alarm.hour = dec2bcd(nextAlarm->hour);
		alarm.days = timeData.day;
		ds1337_setUserAlarmWake(&alarm);
	}
	else
		ds1337_setUserAlarmWake(NULL);

	/*shao
	if(watchConfig.volHour)
	{
		s_alarm alarm;
		alarm.min = 0;
		ds1337_setSystemAlarmWake(&alarm);
	}
	else // Hour beep volume set to minimum, so don't bother with the system alarm
		ds1337_setSystemAlarmWake(NULL);*/

	update = false;
}
Esempio n. 3
0
static display_t draw()
{
#if COMPILE_ANIMATIONS
	static byte usbImagePos = FRAME_HEIGHT;
	static byte chargeImagePos = FRAME_HEIGHT;
#endif

	// Draw date
	drawDate();

	// Draw time animated
	display_t busy = ticker();

	// Draw battery icon
	drawBattery();

	byte fix = 20;

	// Draw USB icon
	image_s icon = newImage(fix, FRAME_HEIGHT - 9, usbIcon, 16, 8, WHITE, NOINVERT, 0);
	draw_bitmap_set(&icon);

#if COMPILE_ANIMATIONS
	if(animateIcon(USB_CONNECTED(), &usbImagePos))
	{
		icon.y = usbImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#else
	if(USB_CONNECTED())
	{
		draw_bitmap_s2(NULL);
		icon.x += 20;
	}
#endif
	
	// Draw charging icon
	icon.width = 8;
#if COMPILE_ANIMATIONS
	if(animateIcon(CHARGING(), &chargeImagePos))
	{
		icon.bitmap = chargeIcon;
		icon.y = chargeImagePos;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}	
#else
	if(CHARGING())
	{
		icon.bitmap = chargeIcon;
		draw_bitmap_s2(NULL);
		icon.x += 12;
	}
#endif

	icon.y = FRAME_HEIGHT - 8;

#if COMPILE_STOPWATCH
	// Stopwatch icon
	if(stopwatch_active())
	{
		icon.bitmap = stopwatch;
		draw_bitmap_s2(&icon);
		icon.x += 12;
	}
#endif	

	// Draw next alarm
	alarm_s nextAlarm;
	if(alarm_getNext(&nextAlarm))
	{
		time_s alarmTime;
		alarmTime.hour = nextAlarm.hour;
		alarmTime.mins = nextAlarm.min;
		alarmTime.ampm = CHAR_24;
		time_timeMode(&alarmTime, appConfig.timeMode);
		
		char buff[9];
		sprintf_P(buff, PSTR("%02hhu:%02hhu%c"), alarmTime.hour, alarmTime.mins, alarmTime.ampm);
		draw_string(buff, false, icon.x, FRAME_HEIGHT - 8);
		icon.x += (alarmTime.ampm == CHAR_24) ? 35 : 42;

		icon.bitmap = dowImg[alarm_getNextDay()];
		draw_bitmap_s2(&icon);

//		icon.x += 9;
	}

	return busy;
}