int RTClockClass::getUnit(int unit) { DS3231_get(&t); // Get updated time switch (unit) { case UNIT_HOUR: return t.hour; break; case UNIT_MINUTE: return t.min; break; case UNIT_SECOND: return t.sec; break; case UNIT_DAY: return t.mday; break; case UNIT_MONTH: return t.mon; break; case UNIT_YEAR: return t.year; break; case UNIT_YEAR_SHORT: return t.year_s; break; } }
void Clock::update() { if (millis() - this->lastUpdate > this->updateTime) { this->lastUpdate = millis(); DS3231_get(&date); date12h = date;//Copy date 24h and set to 12 if (date12h.hour > 12) { date12h.hour -= 12; } else if (date12h.hour == 0) {//Simulate 12 hours while is the 00 date12h.hour = 12; } } }