示例#1
0
void minuteElapsed()
{
	if (addMinute(1))
		addHour(1);
	// checa se o alarme está ativo e o dispara
	if (alarmActived)
		checkAlarm();
}
示例#2
0
uint8_t compareTime(time *time1, time *time2, uint8_t offset){
	for(uint8_t of = 0; of <= offset; of++){
		addMinute(time1);
	}
	
	if(time1->hours == time2->hours && time1->hours == time2->hours){
		return 1;
	}else{
		return 0;
	}
}
示例#3
0
// Parses a timezone part, and adjust year, month, monthDay, hour, minute,
// second, millisecond.
bool DateComponents::parseTimeZone(const String& src,
                                   unsigned start,
                                   unsigned& end) {
  if (start >= src.length())
    return false;
  unsigned index = start;
  if (src[index] == 'Z') {
    end = index + 1;
    return true;
  }

  bool minus;
  if (src[index] == '+')
    minus = false;
  else if (src[index] == '-')
    minus = true;
  else
    return false;
  ++index;

  int hour;
  int minute;
  if (!toInt(src, index, 2, hour) || hour < 0 || hour > 23)
    return false;
  index += 2;

  if (index >= src.length() || src[index] != ':')
    return false;
  ++index;

  if (!toInt(src, index, 2, minute) || minute < 0 || minute > 59)
    return false;
  index += 2;

  if (minus) {
    hour = -hour;
    minute = -minute;
  }

  // Subtract the timezone offset.
  if (!addMinute(-(hour * 60 + minute)))
    return false;
  end = index;
  return true;
}
示例#4
0
void decClick()
{
	switch (state)
	{
		case ModeTimeMin:
			addMinute(-1);
			break;
		case ModeTimeHour:
			addHour(-1);
			break;
		case ModeAlarmMin:
			addMinuteAlarm(-1);
			break;
		case ModeAlarmHour:
			addHourAlarm(-1);
			break;
		case ModeAlarmActived:
			alarmActived = !alarmActived;
			break;
	}
}
示例#5
0
//sauvegarde les données provenants du fichier json des horaires de bus dans notre tableau
void modelTan::saveHoraires(json_value *value, string name)
{
    if(value->name != NULL){
        name = value->name;
    }
    switch(value->type)
    {
    case JSON_OBJECT:
    case JSON_ARRAY:
        for (json_value *it = value->first_child; it; it = it->next_sibling)
        {
                saveHoraires(it, name);
        }
        break;
    case JSON_STRING:
        if(name.compare("heure")==0){
            addHeure(value->string_value);
        }
        else if(name.compare("passages")==0){
            addMinute(value->string_value);
        }
    }
}
示例#6
0
void handleBit(){
	
	if(onCounter > 7 && onCounter < 14){
		errorInHandle = handleDCF(0, secondCounter);
	}else if(onCounter > 17 && onCounter < 24){
		errorInHandle = handleDCF(1, secondCounter);
	}else if(onCounter != 0){
		//Error bit!
		//SETFLAG(FLAG_ERROR);
		if(secondCounter > 20 && secondCounter < 36){
			errorInHandle = 1;
		} //The rest isn't needed		
	}
	
	secondCounter++;
	if(offCounter >= 93 && secondCounter < 59 && secondCounter > 2){
		//It CAN read the clock, just not handle it yet
		SETFLAG(FLAG_SYNCED);
		RESETFLAG(FLAG_STARTUP);
		RESETFLAG(FLAG_ERROR);
		secondCounter = 0;
		//This probably means it just started up..
	}else if(offCounter >= 93 && secondCounter >= 59){
		if(errorInHandle){
			SETFLAG(FLAG_ERROR);
			errorInHandle = 0;
		}else{
			RESETFLAG(FLAG_ERROR);
		}
		//Oh, new minute! :O
		secondCounter = 0;
		SETFLAG(FLAG_SYNCED);
		//Display the new time
		if(dcfTime.hours > 24 || dcfTime.minutes > 59){		
			//ERROR!
			SETFLAG(FLAG_ERROR);
			dcfTime.hours = 0;
			dcfTime.minutes = 0;
		}
		//if(!checkTime(dcfTime)){
		//	SETFLAG(FLAG_ERROR);
		//}
		/*if(dcfHours > currentHour && dcfHours - currentHour >= 2 && currentHour != 0 && currentHour != 23){
			SETFLAG(FLAG_ERROR);
			addMinute();
		}else if(dcfHours < currentHour && currentHour - dcfHours >= 2 && currentHour != 0 && currentHour != 23){
			SETFLAG(FLAG_ERROR);
			addMinute();
		}
		
		if(dcfMinutes > currentMinutes && dcfMinutes - currentMinutes >= 9 && currentMinutes != 0 && currentMinutes != 59){
			SETFLAG(FLAG_ERROR);
			addMinute();
		}else if(dcfMinutes < currentMinutes && currentMinutes - dcfMinutes >= 9 && currentMinutes != 0 && currentMinutes != 59){
			SETFLAG(FLAG_ERROR);
			addMinute();
		}*/
		if(!CHECKFLAG(FLAG_ERROR)){
			currentTime.hours = dcfTime.hours;
			currentTime.minutes = dcfTime.minutes;
			RESETFLAG(FLAG_STARTUP);
		}else{
			//RESETFLAG(FLAG_ERROR);
			RESETFLAG(FLAG_SYNCED);
			if(currentTime.hours == 0 && currentTime.minutes == 0){
				currentTime.hours = dcfTime.hours;
				currentTime.minutes = dcfTime.minutes;
			}else{
				addMinute(&currentTime);
			}
		}
	}
	onCounter = 0;
	offCounter = 0;
}