bool Clock::AlarmIsUp(){ if(!GetAlarmIsRunning()){ return false; } return rtc.now().unixtime() > _alarm.unixtime(); }
void loop () { DateTime now = RTC.now(); //this is running a test cycle that lights up both parts for a few minutes every hour. //to change it to birthdays just add now.day and now.month conditions like below if (now.minute() >= 11 && (now.minute() <= 13)){ rainbowCycle_A(20); } else if (now.minute() >= 22 && (now.minute() <= 25)){ rainbowCycle_B(20); } else{ for(q=0; q< 13; q++) { strip_h.setPixelColor(q,0,0,0); strip_d.setPixelColor(q,0,0,0); strip_s.setPixelColor(q,0,0,0); strip_h.show(); strip_d.show(); strip_s.show(); } } }
/** Return minutes left of the alarm timer if it is set. */ int Clock::GetAlarmMinute(){ if(!GetAlarmIsRunning()){ return 0; } TimeSpan timeBetweenNowAndAlarm = _alarm - rtc.now(); if(timeBetweenNowAndAlarm.minutes() >= 0){ return timeBetweenNowAndAlarm.minutes(); } return 0; }
/** Return seconds left of the alarm timer if it is set. */ int Clock::GetAlarmSecond(){ if(!GetAlarmIsRunning()){ return 0; } TimeSpan timeBetweenNowAndAlarm = _alarm - rtc.now(); if(timeBetweenNowAndAlarm.seconds() >= 0){ return timeBetweenNowAndAlarm.seconds(); } return 0; }
/* * @brief Helper function to get current time from RTC & Arduino. * * @return 0 on success, -1 on failure */ int _getCurrentTime( DateTime *now, unsigned long *curr_millis ) { // Try to get the current time from the RTC, if available. This will be prepended to the log file // to be used to convert relative timestamps to real time values. Wire.begin(); RTC.begin(); if (RTC.isrunning()) { *now = RTC.now(); *curr_millis = millis(); return 0; } return -1; }
void showTime() { DateTime now = rtc.now(); String timeStr = String( "" ) + int( now.hour() ) + String( ":" ) + int( now.minute() ) + ':' + now.second(); Serial.println( timeStr ); lcd.setCursor( 0, 0 ); lcd.print( timeStr ); // Serial.println( "Hello" ); // lcd.setCursor( 0, 0 ); // lcd.print( "H E L L O" ); }
void AgroShield::setDateTime(){ Wire.begin(); RTC.begin(); if (! RTC.isrunning()) { Serial.println("RTC is NOT running..."); } // This section grabs the current datetime and compares it to // the compilation time. If necessary, the RTC is updated. DateTime now = RTC.now(); DateTime compiled = DateTime(__DATE__, __TIME__); if (now.unixtime() < compiled.unixtime() || now.unixtime() > compiled.unixtime()) { Serial.println("RTC is older than compile time! Updating"); RTC.adjust(DateTime(__DATE__, __TIME__)); } Serial.println("Setup complete."); delay(100); }
void loop () { DateTime now = rtc.now(); Serial.print(now.year(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); Serial.print(" since midnight 1/1/1970 = "); Serial.print(now.unixtime()); Serial.print("s = "); Serial.print(now.unixtime() / 86400L); Serial.println("d"); // calculate a date which is 7 days and 30 seconds into the future DateTime future (now.unixtime() + 7 * 86400L + 30); Serial.print(" now + 7d + 30s: "); Serial.print(future.year(), DEC); Serial.print('/'); Serial.print(future.month(), DEC); Serial.print('/'); Serial.print(future.day(), DEC); Serial.print(' '); Serial.print(future.hour(), DEC); Serial.print(':'); Serial.print(future.minute(), DEC); Serial.print(':'); Serial.print(future.second(), DEC); Serial.println(); Serial.println(); delay(3000); }
// Get current clock second. int Clock::GetSecond(){ return rtc.now().second(); }
// Get current clock hour. int Clock::GetHour(){ return rtc.now().hour(); }
void setup(void) { status.reset(); /// Discrete & Analog IO pinMode(13, OUTPUT); // Arduino on-board LED pinMode(A0, OUTPUT); // Buzzer /// Comm. Channels // UART Serial.begin(115200); Serial.flush(); Serial.println("Starting up greenOmatic Duemilanove Testbed..."); Serial.print("Program compiled on "); Serial.print(__DATE__); Serial.print(" at "); Serial.println(__TIME__); Serial.println(); // RF #ifdef INTERFACE_ASK_RX pinMode(RF_RX_PIN, INPUT); vw_set_rx_pin(RF_RX_PIN); vw_setup(RF_BAUD); vw_rx_start (); Serial.print ("ASK RF Receiver configured on PIN "); Serial.print (RF_RX_PIN); Serial.print (" @ "); Serial.print (RF_BAUD, DEC); Serial.println(" baud."); #endif //INTERFACE_ASK_RX // Ethernet #ifdef INTERFACE_ETHERNET Serial.print("Starting Ethernet... "); #ifdef ETHERNET_DYNAMIC_IP int eth_stat = Ethernet.begin(mac); if (0 == eth_stat) { Serial.println(" Problem starting ethernet !"); status.ethernet_valid = status.ERROR; } else { Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; } #else Ethernet.begin(mac, IPaddr); Serial.print("Ethernet started, IP = "); Serial.println( Ethernet.localIP() ); status.ethernet_valid = status.VALID; #endif //ETHERNET_DYNAMIC_IP #ifdef ETHERNET_WEBSERVER server.begin(); #endif //ETHERNET_WEBSERVER #ifdef ETHERNET_UDPCLIENT Udp.begin(localPort); #endif //ETHERNET_UDPCLIENT #endif /// Peripherals // I2C RTC #ifdef PERIPHERAL_RTCC Wire.begin(); rtc.begin(); if (rtc.isrunning()) { status.time_valid = status.VALID; GetDatetimeString(rtc.now()); Serial.print("RTCC configured on I2C. Time is currently "); Serial.println(currentTime); #ifdef ETHERNET_UDPCLIENT //TODO: Get NTP Time #else // Compare RTC time to this programs compile time DateTime rtcTime = rtc.now(); DateTime compileTime(F(__DATE__), F(__TIME__)); // If the compile-time is later (more recent) than the current RTC time, update the RTC if (compileTime.secondstime() > rtcTime.secondstime()) { Serial.println("Program compile-time is later than RTC time; updating RTC."); rtc.adjust( DateTime(F(__DATE__), F(__TIME__)) ); } #endif //ETHERNET_UDPCLIENT } else { status.time_valid = status.ERROR; // TODO, can we narrow this down further like with the DS1307RTC library? } #endif Serial.println("\nInitialization complete!\n\n"); }
uint32_t Clock::ClockUnixtime(){ return rtc.now().unixtime(); }
// The loop function is called in an endless loop void loop() { switch(b.getState()) { case Button::pressed: // if press and hold is allowed, the pressed state should not be used break; case Button::released: Serial1.println("Released condition"); b.resetState(); Store.Advance(); break; case Button::press_hold: Serial1.println("Press and hold condition"); ForceADCReadout = true; switch( Store.getItemState(Store.mIndex) ) { case Item::normal: Serial1.println("normal->forced_off"); Store.setItemState(Store.mIndex, Item::forced_off); break; case Item::forced_off: Serial1.println("forced_off->forced_on"); Store.setItemState(Store.mIndex, Item::forced_on); break; case Item::forced_on: Serial1.println("forced_on->normal"); Store.setItemState(Store.mIndex, Item::normal); break; } b.resetState(); break; default:; } // ADC sampling for(int i = 0; i < CHANNEL_COUNT; i++ ) { AdcChannel * ch = &ADCs[i]; if( ch->isActive() && ( ForceADCReadout || ch->isDue() )) { Store.temperatureReading(i, ch->getTemperature()); } } ForceADCReadout = false; // update LCD display if necessary if( Store.isAnyActiveChannel() == true ) { if(CurrentIndex != Store.mIndex || Store.getDirty(Store.mIndex)) { CurrentIndex = Store.mIndex; lcd.home (); // set cursor to 0,0 char buf[32]; float t = Store.getTemperature(Store.mIndex); int intPart = t; unsigned int fractPart = abs((t - (float)intPart)*10.0); sprintf( buf, "CH%d %d.%01dC %s", CurrentIndex + 1, intPart, fractPart, Store.getIsOn(Store.mIndex) ? "ON " : "OFF "); Store.setDirty(Store.mIndex, false); lcd.print( buf ); lcd.setCursor (0,1); // go to start of 2nd line if( Store.getItemState(Store.mIndex) == Item::forced_off || Store.getItemState(Store.mIndex) == Item::forced_on ) { lcd.print( "FORCED " ); } else { lcd.print( Store.getLow(Store.mIndex) ); lcd.print(".."); lcd.print( Store.getHigh(Store.mIndex) ); lcd.print("C "); } // list controlled actuators lcd.print("A:"); for( int i = 0; i < CHANNEL_COUNT; i++ ) { if( Store.getActuators(Store.mIndex) & (1 << i) ) { lcd.print((char)(i + '1')); } } lcd.print(" "); } } else { lcd.home (); // set cursor to 0,0 lcd.print("ALL CHANNELS"); lcd.setCursor (0,1); // go to start of 2nd line lcd.print("INACTIVE"); } // log the data if time comes. Protect against wrap around unsigned long ms = millis(); if( ms < notTooOftenCounter || notTooOftenCounter + 60000 < ms ) { notTooOftenCounter = millis(); DateTime now = rtc.now(); if( !Store.LogIfDue( now ) ) { Serial1.println("No logging. The write attempt failed. Is the SD inserted? Insert and reset!"); digitalWrite( ALARM_LED_PIN, HIGH ); } } }
void setup() { // debugging channel Serial1.begin(57600); while (!Serial1) { delay(100); } Serial1.print( "RAM at setup " ); Serial1.println( freeRam() ); // ALRAM pinMode(ALARM_LED_PIN, OUTPUT); digitalWrite( ALARM_LED_PIN, LOW ); // must "begin" the button to get proper pin assignment/muxing b.begin(); // initializing ADC channels. The channels 0...7 are assigned to the // pins A0...A7. Note that the display and the config.txt files, as well as // the shield's silk layer use enumeration 1 to 8 ADCs[0] = AdcChannel(A0); ADCs[1] = AdcChannel(A1); ADCs[2] = AdcChannel(A2); ADCs[3] = AdcChannel(A3); ADCs[4] = AdcChannel(A4); ADCs[5] = AdcChannel(A5); ADCs[6] = AdcChannel(A6); ADCs[7] = AdcChannel(A7); // initializing actuators. The Id is 0 to 7, a bit number in // actuator byte of the ADC channel. The mapping to the pin is // pin = A8 + Id Actuators[0] = Actuator(0, true); Actuators[1] = Actuator(1, true); Actuators[2] = Actuator(2, true); Actuators[3] = Actuator(3, true); Actuators[4] = Actuator(4, true); Actuators[5] = Actuator(5, true); Actuators[6] = Actuator(6, true); Actuators[7] = Actuator(7, false); // the last actuator is not connected through ULN2003 but directly // The Real Time Clock rtc.begin(); // returns bool, but is never false Serial1.print( "RAM after rtc.begin " ); Serial1.println( freeRam() ); if(rtc.isrunning()) Serial1.println("RTC is running"); else { Serial1.println("RTC is NOT running"); rtc.adjust(DateTime(__DATE__, __TIME__)); // setup the current date and time initially } DateTime now = rtc.now(); Serial1.print(now.year(), DEC); Serial1.print('/'); Serial1.print(now.month(), DEC); Serial1.print('/'); Serial1.print(now.day(), DEC); Serial1.print(" ("); Serial1.print(daysOfTheWeek[now.dayOfTheWeek()]); Serial1.print(") "); Serial1.print(now.hour(), DEC); Serial1.print(':'); Serial1.print(now.minute(), DEC); Serial1.print(':'); Serial1.print(now.second(), DEC); Serial1.println(); // activate LCD module lcd.begin (16,2); // for 16 x 2 LCD module lcd.setBacklightPin(3,POSITIVE); lcd.setBacklight(HIGH); Serial1.print( "RAM after lcd.begin " ); Serial1.println( freeRam() ); if(!Store.begin()) { Serial1.println("Error initializing the storage"); digitalWrite( ALARM_LED_PIN, HIGH ); } Serial1.print( "RAM after Storage.begin " ); Serial1.println( freeRam() ); // the below makes sure the 1st active item is displayed upon start up. Otherwise // the item 0 is displayed, even if inactive Store.mIndex = CHANNEL_COUNT-1; Store.Advance(); }
DateTime Cron::getTime(){ DateTime now = RTC.now(); return now; }
String getCurrentDate() { DateTime now = RTC.now(); char tbs[8]; sprintf(tbs, "%02d:%02d:%02d", now.hour(), now.minute(), now.second()); return tbs; }
uint8_t ScheduleEntry::ActivateEntry(RTC_DS1307 RTC) { // only work with enabled schedules static int devices[7] = {1, 0, 13, 12, 11, 10, 9}; static uint8_t pins = 7; time = RTC.now(); // Serial.println("Contents of entry:"); // for (int i = 0 ; i < 24; i++) { // Serial.println(analogValue, DEC); // } // sprintf(serial_buffer, "ssl: %d timesecond: %d", ssl, time.second()); // Serial.println(serial_buffer); if (en == 1) { if (ssc == DASH) { if (time.second() > ssu && time.second() < ssl) { // sprintf(serial_buffer, "time.second()<%d> > ssu<%d> && time.second()<%d> < ssl<%d>", time.second(), ssu, time.second(), ssl); // Serial.println(serial_buffer); return 0; } } if (ssl != time.second() && ssl != ASTERISK) { // sprintf(serial_buffer, "(ssl<%d> != time.second()<%d> && ssl<%d> != ASTERISK)", ssl, time.second(), ssl); // Serial.println(serial_buffer); return 0; } if (mnc == DASH) { if (time.minute() > mnu && time.minute() < mnl) { // Serial.println("minute1"); return 0; } } if (mnl != time.minute() && mnl != ASTERISK) { // Serial.println("minute2"); return 0; } if (hhc == DASH) { if (time.hour() > hhu && time.hour() < hhl) { // Serial.println("hour"); return 0; } } if (hhl != time.hour() && hhl != ASTERISK) { // Serial.println("hour2"); return 0; } if (mdc == DASH) { if (time.day() > mdu && time.day() < mdl) { // Serial.println("mdu"); return 0; } } if (mdl != time.day() && mdl != ASTERISK) { // Serial.println("mdu2"); return 0; } if (wdc == DASH) { if (time.dayOfWeek() > wdu && time.dayOfWeek() < wdl) { // Serial.println("dayOfWeek"); return 0; } } if (wdl != time.dayOfWeek() && wdl != ASTERISK) { // Serial.println("dayOfWeek2"); return 0; } if (moc == DASH) { if (time.month() > mou && time.month() < mol) { // Serial.println("month"); return 0; } } if (mol != time.month() && mol != ASTERISK) { // Serial.println("month2"); return 0; } if (yyc == DASH) { if (time.year()-2000 > yyu && time.year()-2000 < yyl) { // Serial.println("year"); return 0; } } if (yyl != time.year()-2000 && yyl != ASTERISK) { // Serial.println("year2"); return 0; } switch (id) { case ASTERISK: if (ScheduleEntry::GetDeviseFinalState(ds)) { for (uint8_t i = 0; i<pins; i++ ) { digitalWrite(devices[i], 1); } } else { for (uint8_t i = 0; i<pins; i++ ) { digitalWrite(devices[i], 0); } } break; default: if (ScheduleEntry::GetDeviseFinalState(ds)) { digitalWrite(devices[id], 1); } else { digitalWrite(devices[id], 0); } break; } return 1; } else { return 0; } };
void ClockTime::update(){ Clock = RTC.now(); // get the RTC time currentsecond = Clock.second(); currenthour = Clock.hour() % 12; currentminute = Clock.minute() % 60; }
int main(void) { /// setup init(); setup(); /// loop control for(frame=0; ; ++frame) { digitalWrite(13, HIGH); status.reset(); String new_msg = "Loop #"; new_msg.concat(frame); #ifdef PERIPHERAL_RTCC /// check time if (status.VALID == status.time_valid) { GetDatetimeString(rtc.now()); } /* TODO: port RTC.chipPresent() functionality over to RTClib if ( RTC.read(tm) ) { status.time_valid = status.VALID; } else { if ( RTC.chipPresent() ) { status.time_valid = status.INVALID; Serial.println("The DS1307 is stopped. Please set the RTC time."); Serial.println(); } else { status.time_valid = status.UNINSTALLED; Serial.println("DS1307 read error! Please check the circuitry."); Serial.println(); } } */ #endif /// Check interfaces for received messages // Serial, direct to the Command Line Interface (CLI) if(Serial.available() > 0) { char buff_console [8]; for(uint8_t len_console = 0x00; Serial.available() > 0; len_console++) { buff_console[len_console] = Serial.read(); CLI(buff_console, len_console); } } #ifdef INTERFACE_ASK_RX // RF (1-wire ASK, aka VirtualWire), print to console uint8_t buff_rf [VW_MAX_MESSAGE_LEN]; uint8_t len_rf = VW_MAX_MESSAGE_LEN; if(vw_get_message(buff_rf, &len_rf)) { #ifdef PERIPHERAL_RTCC // Prefix received messages with current date-time on console if (status.VALID == status.time_valid) { Serial.print(currentTime); Serial.write(" | "); } #endif //PERIPHERAL_RTCC Serial.print("RF Received : "); for(uint8_t i = 0; i < len_rf; i++) { Serial.print((char)buff_rf[i]); } Serial.println(); } #endif //INTERFACE_ASK_RX #ifdef ETHERNET_WEBSERVER EthernetClient client = server.available(); if (client) { Serial.println("new http client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connection: close"); // the connection will be closed after completion of the response client.println("Refresh: 60"); // refresh the page automatically every 60 sec client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); #ifdef PERIPHERAL_RTCC client.print("green-O-matic RTC Time : "); client.println(currentTime); #endif //PERIPHERAL_RTCC #ifdef INTERFACE_ASK_RX client.println("Most recently received 433MHz ASK Transmission : "); #endif //INTERFACE_ASK_RX client.println("</html>"); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(5); // close the connection client.stop(); Serial.println("client disconnected"); } #endif //ETHERNET_WEBSERVER digitalWrite(13, LOW); delay (LOOP_DELAY); }; return 0; }
void AgroShield::getDateTime(){ boolean run = true; Wire.begin(); RTC.begin(); if (! RTC.isrunning()) { Serial.print("RTC is NOT running | "); run = false; } if(run){ // This section grabs the current datetime and compares it to // the compilation time. If necessary, the RTC is updated. DateTime now = RTC.now(); DateTime compiled = DateTime(__DATE__, __TIME__); //if (now.unixtime() < compiled.unixtime() || now.unixtime() > compiled.unixtime()) { if (now.unixtime() < compiled.unixtime() ) { //Serial.println("RTC is older than compile time! Updating"); RTC.adjust(DateTime(__DATE__, __TIME__)); } //Serial.println("Setup complete."); delay(100); // Get the current time now = RTC.now(); // Display the current time //Serial.print("Current time: "); if (now.day() <= 9) { Serial.print("0"); Serial.print(now.day(), DEC); } else{ Serial.print(now.day(), DEC); } Serial.print('/'); if (now.month() <= 9) { Serial.print("0"); Serial.print(now.month(), DEC); } else{ Serial.print(now.month(), DEC); } Serial.print('/'); Serial.print(now.year(), DEC); Serial.print(' '); if (now.hour() <= 9) { Serial.print("0"); Serial.print(now.hour(), DEC); } else{ Serial.print(now.hour(), DEC); } Serial.print(':'); if (now.minute() <= 9) { Serial.print("0"); Serial.print(now.minute(), DEC); } else{ Serial.print(now.minute(), DEC); } Serial.print(':'); if (now.second() <= 9) { Serial.print("0"); Serial.print(now.second(), DEC); Serial.print(" | "); } else{ Serial.print(now.second(), DEC); Serial.print(" | "); } delay(100); } }
long getCurrentDateTimeInUnixTime() { return RTC.now().unixtime(); }
// Get current clock minute. int Clock::GetMinute(){ return rtc.now().minute(); }
void loop() { File dataFile; //String dataString; //char dataToSD[40]; //String timeString; char tempstring[10]; // create string arrays //float temp; static int WaitingForTemp = 0; //int readCount; DateTime now; // = rtc.now(); static int nowriting = 0; delay(1000); switch(system_FSM) { case S_IDLE: //Read time from RTC now = rtc.now(); if(now.minute() % 11 == 0) nowriting = 0; //Trigger state change if(WaitingForTemp == 1){ if (millis() - lastTempRequest >= delayInMillis) // waited long enough?? system_FSM = S_READ_SENS; } if(WaitingForTemp == 0) { system_FSM = S_TRIG_TEMP; if(now.minute() % 10 == 0 || nowriting == 0) system_FSM = S_WRITE_SD; nowriting = 1; } break; case S_TRIG_TEMP: // Trig async reading of DS1820 temp sensor sensors.requestTemperatures(); // remember time of trigger lastTempRequest = millis(); WaitingForTemp = 1; system_FSM = S_IDLE; break; case S_READ_SENS: //read value of sensors SensorData.sensor1 = sensors.getTempC(Sensor1); SensorData.sensor2 = sensors.getTempC(Sensor2); //SensorData.sensor1 = sensors.getTempC(Sensor1); //SensorData.sensor1 = sensors.getTempC(Sensor1); //SensorData.sensor1 = sensors.getTempC(Sensor1); WaitingForTemp = 0; system_FSM = S_IDLE; /* if(readCount == 0) system_FSM = S_WRITE_SD; else system_FSM = S_IDLE; readCount++; */ break; case S_WRITE_SD: // Read time and date from RTC TimeDate(rtc.now(),dateTimeString,1); // Open datafile dataFile = SD.open("templog.txt", FILE_WRITE); // Write values to SD card if (dataFile) { dataFile.print(dateTimeString); dataFile.print(";"); dataFile.print(SensorData.sensor1); dataFile.print(";"); dataFile.println(SensorData.sensor2); dataFile.close(); } // state change to IDLE system_FSM = S_IDLE; break; default: system_FSM = S_IDLE; } switch(menu_FSM) { case M_PAGE1: if(menu_FSM !=menu_last_state) { DisplayClear(); mySerial.write("Time"); // clear display + legends MenuShowTime = millis(); } now = rtc.now(); DisplayGoto(1,0); mySerial.write("Time"); // clear display + legends DisplayGoto(1,8); TimeDate(now,dateTimeString,2); mySerial.print(dateTimeString); DisplayGoto(2,6); TimeDate(now,dateTimeString,3); mySerial.print(dateTimeString); //reserved for showing time and SD card status menu_last_state = M_PAGE1; if(millis() - MenuShowTime >= MenuDelayInMillis) menu_FSM = M_PAGE2; break; case M_PAGE2: if(menu_FSM !=menu_last_state) { DisplayClear(); mySerial.write("Sens 1: C"); mySerial.write("Sens 2: C"); DisplayGoto(1,14); mySerial.write(223); DisplayGoto(2,14); mySerial.write(223); MenuShowTime = millis(); } DisplayGoto(1,10); mySerial.write(dtostrf(SensorData.sensor1,4,1,tempstring)); // write out the RPM value DisplayGoto(2,10); mySerial.write(dtostrf(SensorData.sensor2,4,1,tempstring)); // write out the TEMP value //mySerial.write(dtostrf(system_FSM,4,1,tempstring)); DEBUG menu_last_state = M_PAGE2; if(millis() - MenuShowTime >= MenuDelayInMillis) menu_FSM = M_PAGE3; break; case M_PAGE3: if(menu_FSM !=menu_last_state) { DisplayClear(); mySerial.write("Sens 3: N/A C"); // clear display + legends mySerial.write("Sens 4: N/A C"); DisplayGoto(1,14); mySerial.write(223); DisplayGoto(2,14); mySerial.write(223); MenuShowTime = millis(); } DisplayGoto(1,7); // mySerial.write(dtostrf(SensorData.sensor1,4,1,tempstring)); // write out the RPM value DisplayGoto(2,7); //mySerial.write(dtostrf(MenuShowTime,4,1,tempstring)); // write out the TEMP value menu_last_state = M_PAGE3; if(millis() - MenuShowTime >= MenuDelayInMillis) menu_FSM = M_PAGE1; break; case M_PAGE4: break; default: menu_FSM = M_PAGE1; } }
DateTime OpenGardenClass::getTime(void){ return RTC.now(); }
String getCurrentTime() { DateTime now = RTC.now(); char tbs[10]; sprintf(tbs, "%02d/%02d/%4d", now.day(), now.month(), now.year()); return tbs; }
/** Set a new alarm with given hours, minutes and seconds from current time. */ void Clock::SetAlarm(int hoursFromNow, int minutesFromNow, int secondsFromNow){ _alarm = DateTime(rtc.now() + TimeSpan(0, hoursFromNow, minutesFromNow, secondsFromNow)); _alarmIsRunning = true; }
// Return ajusted time that ~ match now DateTime ClockMaster::getTime(){ return rtc.now() + TimeSpan(0, 0, 21, 16);//timeDifference; }