Esempio n. 1
0
void read_rtc(void)
{
	if(rtc_is_ds3231()) {
		int8_t t;
		uint8_t f;
		ds3231_get_temp_int(&t, &f);
	}
	else {
		uint8_t hour, min, sec;
		rtc_get_time_s(&hour, &min, &sec);	
	}
}
Esempio n. 2
0
void read_rtc(bool show_extra_info)
{
    static uint16_t counter = 0;

    if(g_show_temp && rtc_is_ds3231() && counter > 125) {
        int8_t t;
        uint8_t f;
        ds3231_get_temp_int(&t, &f);
        show_temp(t, f);
    }
    else {
        t = rtc_get_time();
        if (t == NULL) return;
        show_time(t, g_24h_clock, show_extra_info);
    }

    counter++;
    if (counter == 250) counter = 0;
}
Esempio n. 3
0
void display_time(display_mode_t mode)  // (wm)  runs approx every 100 ms
{
    static uint16_t counter = 0;
#ifdef FEATURE_AUTO_DATE
    if (mode == MODE_DATE) {
        show_date(tm_, g_Region, (scroll_ctr++) * 10 / 38);  // show date from last rtc_get_time() call
    }
    else
#endif
        if (mode == MODE_ALARM_TEXT) {
            show_alarm_text();
        }
        else if (mode == MODE_ALARM_TIME) {
            if (g_alarm_switch) {
                rtc_get_alarm_s(&alarm_hour, &alarm_min, &alarm_sec);
                show_alarm_time(alarm_hour, alarm_min, 0);
            }
            else {
                show_alarm_off();
            }
        }
// alternate temp and time every 2.5 seconds
        else if (g_show_temp && rtc_is_ds3231() && counter > 250) {
            int8_t t;
            uint8_t f;
            ds3231_get_temp_int(&t, &f);
            show_temp(t, f);
        }
        else {
            tm_ = rtc_get_time();
            if (tm_ == NULL) return;
#ifdef FEATURE_SET_DATE
            g_dateyear = tm_->Year;  // save year for Menu
            g_datemonth = tm_->Month;  // save month for Menu
            g_dateday = tm_->Day;  // save day for Menu
#endif
#ifdef FEATURE_AUTO_DST
            if (tm_->Second%10 == 0)  // check DST Offset every 10 seconds (60?)
                setDSToffset(g_DST_mode);
            if ((tm_->Hour == 0) && (tm_->Minute == 0) && (tm_->Second == 0)) {  // MIDNIGHT!
                g_DST_updated = false;
                if (g_DST_mode)
                    DSTinit(tm_, g_DST_Rules);  // re-compute DST start, end
            }
#endif
#ifdef FEATURE_AUTO_DATE
            if (g_AutoDate && (tm_->Second == g_autotime) ) {
                save_mode = clock_mode;  // save current mode
                clock_mode = MODE_DATE;  // display date now
                g_show_special_cnt = g_autodisp;  // show date for g_autodisp ms
                scroll_ctr = 0;  // reset scroll position
            }
            else
#endif
#ifdef FEATURE_FLW
                if (mode == MODE_FLW) {
                    if ((tm_->Second >= g_autotime - 3) && (tm_->Second < g_autotime))
                        show_time(tm_, g_24h_clock, 0); // show time briefly each minute
                    else
                        show_flw(tm_); // otherwise show FLW
                }
                else
#endif
                    show_time(tm_, g_24h_clock, mode);
        }
    counter++;
    if (counter == 500) counter = 0;
}