Ejemplo n.º 1
0
 uint8_t TimeAlarmsClass::getDigitsNow( dtUnits_t Units)
 {
   time_t time = now();
   if(Units == dtSecond) return numberOfSeconds(time);
   if(Units == dtMinute) return numberOfMinutes(time); 
   if(Units == dtHour) return numberOfHours(time);
   if(Units == dtDay) return dayOfWeek(time);
   return 255;  // This should never happen 
 }
Ejemplo n.º 2
0
void getCronometragem() {

  Serial.println("pegando a cronometragem...");
  long result = (long) millis() - inicial;
  
  int days = elapsedDays(result);
  int hours = numberOfHours(result);
  int minutes = numberOfMinutes(result);
  int seconds = numberOfSeconds(result);

  // digital clock display of current time
  Serial.print(days,DEC);  
  printDigits(hours);  
  printDigits(minutes);
  printDigits(seconds);
  Serial.println();  
  
  printHeader();
  printChaveValorJson("TEMPO TOTAL", (String) result);
  printFooter();
  
}
Ejemplo n.º 3
0
    void TimeAlarmsClass::captureLastNextTriggerData()
    {
      time_t timeNow = now();
      // Serial.println("timeNow      : " + String(numberOfHours  (timeNow)));
      // Serial.println("timeNow      : " + String(numberOfMinutes(timeNow)));
      // Serial.println("timeNow      : " + String(numberOfSeconds(timeNow)));
      // Serial.println("timeNow      : " + String(dayOfWeek      (timeNow)));

      time_t  lastTrigger = 0x00000000;
      uint8_t lastTriggerId = 0;
      for(uint8_t id = 0; id < dtNBR_ALARMS; id++)
      {
        if(isAllocated(id) )
        {
          time_t testValue = Alarm[id].nextTrigger;
          // Serial.println("-- testValue  : " + String(numberOfHours  (testValue)));
          // Serial.println("-- testValue  : " + String(numberOfMinutes(testValue)));
          // Serial.println("-- testValue  : " + String(numberOfSeconds(testValue)));
          // Serial.println("-- testValue  : " + String(dayOfWeek      (testValue)));
          if(uint32_t(Alarm[id].nextTrigger) > uint32_t(lastTrigger)) {
            lastTrigger = Alarm[id].nextTrigger;
            lastTriggerId = id;
          }
        }
      }
      // Serial.println("lastTriggerId: " + String(lastTriggerId));
      // Serial.println("lastTrigger  : " + String(numberOfHours  (lastTrigger)));
      // Serial.println("lastTrigger  : " + String(numberOfMinutes(lastTrigger)));
      // Serial.println("lastTrigger  : " + String(numberOfSeconds(lastTrigger)));
      // Serial.println("lastTrigger  : " + String(dayOfWeek      (lastTrigger)));

      time_t nextTrigger = 0xffffffff;  // the max time value
      uint8_t nextTriggerId = 0;
      for(uint8_t id = 0; id < dtNBR_ALARMS; id++)
      {
        if(isAllocated(id) )
        {
          // if(Alarm[id].nextTrigger <  nextTrigger) {
          if(uint32_t(Alarm[id].nextTrigger) <  uint32_t(nextTrigger)) {
            nextTrigger = Alarm[id].nextTrigger;
            nextTriggerId = id;
          }
        }      
      }
      // Serial.println("nextTriggerId: " + String(nextTriggerId));
      // Serial.println("nextTrigger  : " + String(numberOfHours  (nextTrigger)));
      // Serial.println("nextTrigger  : " + String(numberOfMinutes(nextTrigger)));
      // Serial.println("nextTrigger  : " + String(numberOfSeconds(nextTrigger)));
      // Serial.println("nextTrigger  : " + String(dayOfWeek      (nextTrigger)));

      uint32_t lastTriggerSeconds = uint8_t(numberOfHours(lastTrigger))*3600 + uint8_t(numberOfMinutes(lastTrigger))*60 + uint8_t(numberOfSeconds(lastTrigger));
      uint32_t nextTriggerSeconds = uint8_t(numberOfHours(nextTrigger))*3600 + uint8_t(numberOfMinutes(nextTrigger))*60 + uint8_t(numberOfSeconds(nextTrigger));
      uint32_t timeNowSeconds     = uint8_t(numberOfHours(timeNow    ))*3600 + uint8_t(numberOfMinutes(timeNow    ))*60 + uint8_t(numberOfSeconds(timeNow    ));

      this->ltId = lastTriggerId;
      this->ntId = nextTriggerId;
      this->ltOnTickArgs = Alarm[lastTriggerId].onTickArgs;
      this->ntOnTickArgs = Alarm[nextTriggerId].onTickArgs;
      this->ltTimeSeconds = lastTriggerSeconds;
      this->ntTimeSeconds = nextTriggerSeconds;
      this->nowTimeSeconds = timeNowSeconds;

      // Serial.println("");
    }
Ejemplo n.º 4
0
 return create( value, onTickHandler, IS_ONESHOT, dtTimer );