Esempio n. 1
0
/************************ menu callbacks **********************************/
static void clock_activated()
{
	sys_messagebus_register(&clock_event, SYS_MSG_RTC_MINUTE
						| SYS_MSG_RTC_HOUR
						| SYS_MSG_RTC_DAY
						| SYS_MSG_RTC_MONTH
#ifdef CONFIG_MOD_CLOCK_BLINKCOL
						| SYS_MSG_RTC_SECOND
#endif
	);

	/* create two screens, the first is always the active one */
	lcd_screens_create(2);

	/* display stuff that won't change with time */
	display_symbol(0, LCD_SEG_L1_COL, SEG_ON);
	display_char(0, LCD_SEG_L2_2, '-', SEG_SET);

	/* update screens with fake event */
	clock_event(SYS_MSG_RTC_YEAR
					| SYS_MSG_RTC_MONTH
					| SYS_MSG_RTC_DAY
					| SYS_MSG_RTC_HOUR
					| SYS_MSG_RTC_MINUTE);
}
Esempio n. 2
0
static void clock_event(enum sys_message msg)
{
#ifdef CONFIG_MOD_CLOCK_BLINKCOL
	display_symbol(0, LCD_SEG_L1_COL,
	     ((rtca_time.sec & 0x01) ? SEG_ON : SEG_OFF));
#endif

	if (msg & SYS_MSG_RTC_YEAR)
		_printf(1, LCD_SEG_L1_3_0, "%04u", rtca_time.year);
#ifdef CONFIG_MOD_CLOCK_MONTH_FIRST
	if (msg & SYS_MSG_RTC_MONTH)
		_printf(0, LCD_SEG_L2_4_3, "%02u", rtca_time.mon);
	if (msg & SYS_MSG_RTC_DAY) {
		_printf(0, LCD_SEG_L2_1_0, "%02u", rtca_time.day);
#else
	if (msg & SYS_MSG_RTC_MONTH)
		_printf(0, LCD_SEG_L2_1_0, "%02u", rtca_time.mon);
	if (msg & SYS_MSG_RTC_DAY) {
		_printf(0, LCD_SEG_L2_4_3, "%02u", rtca_time.day);

#endif
		_printf(1, LCD_SEG_L2_2_0, rtca_dow_str[rtca_time.dow],
								SEG_SET);
	}
	if (msg & SYS_MSG_RTC_HOUR) {
#ifdef CONFIG_MOD_CLOCK_AMPM
		uint8_t tmp_hh = rtca_time.hour;
		if (tmp_hh > 12) {
			tmp_hh -= 12;
			display_symbol(0, LCD_SYMB_AM, SEG_OFF);
			display_symbol(0, LCD_SYMB_PM, SEG_SET);
		} else {
			if (tmp_hh == 12) {
				display_symbol(0, LCD_SYMB_AM, SEG_OFF);
				display_symbol(0, LCD_SYMB_PM, SEG_SET);
			} else {
				display_symbol(0, LCD_SYMB_PM, SEG_OFF);
				display_symbol(0, LCD_SYMB_AM, SEG_SET);
			}
			if (tmp_hh == 0)
				tmp_hh = 12;
		}
		_printf(0, LCD_SEG_L1_3_2, "%2u", tmp_hh);
#else
		_printf(0, LCD_SEG_L1_3_2, "%02u", rtca_time.hour);
#endif
	}
	if (msg & SYS_MSG_RTC_MINUTE)
		_printf(0, LCD_SEG_L1_1_0, "%02u", rtca_time.min);
}

/* update screens with fake event */
static inline void update_screen()
{
	clock_event(SYS_MSG_RTC_YEAR | SYS_MSG_RTC_MONTH | SYS_MSG_RTC_DAY
				| SYS_MSG_RTC_HOUR  | SYS_MSG_RTC_MINUTE);
}