Exemple #1
0
void Sched::resetAlarm(int i, int &cur, int &nxt){
	//int cur =0;
	Serial.println("in resetAlarm");
	int idx = senrels[i];
	printSched(idx);
	char senrel[10];
	strcpy(senrel,schedArr[i]);
	//make cur the 
	for(int j=0; j<events[idx];j++){
		if (hour() == progs[idx][j][0]){
			if (minute() < progs[idx][j][1]){
				cur = j-1;
				break;
			}
		}
		if (hour() < progs[idx][j][0]){
			Serial.print("should breat at: ");
			Serial.println(j);
			Serial.println(progs[idx][j][0]);
			cur= j-1;
			break;
		}
		cur =j;
	}
	nxt = cur+1;
	if (nxt>=events[idx]){
		nxt=0;
	}
	Serial.println(cur);
	Serial.println(senrel);
	Serial.print(hour());
	Serial.print(":");
	Serial.print(minute());
	Serial.println();
}
Exemple #2
0
boolean Cooling::Start()
{
	totTime = now();

	if(second() % 2 == 0) //Updates the temp every two seconds
	{
		sensors.requestTemperatures();
		CurrentTemp = sensors.getTempCByIndex(0) + Calibrator;
	}

	lcd.cooling(totTime, CurrentTemp, _temp);

	digitalWrite(COOLINGPUMP,HIGH);

	if(second() == 1)
	{
		int check = _id+minute(totTime)+hour(totTime)*60+CurrentTemp;
		Serial.print("cooling,"+String(_id)+",0,"+String(minute(totTime)+hour(totTime)*60)+","+CurrentTemp+","+String(check)+"/");
	}

	if(CurrentTemp <= _temp)
	{
		relay.AllLow();
		digitalWrite(BUZZER, HIGH);
		delay(500);
		digitalWrite(BUZZER, LOW);
		int check = _id+minute(totTime)+hour(totTime)*60+CurrentTemp;
		Serial.print("cooling,"+String(_id)+",0,"+String(minute(totTime)+hour(totTime)*60)+","+CurrentTemp+","+String(check)+"/");
		return false;
	}

	return true;
}
Exemple #3
0
logincheck()
{
    if ( thisAccount.special[ hour() ] )  /* Is is free time?     */
    {
        specialTime = TRUE;
    } else {
        specialTime = FALSE;
    }

    /* Local and bad calls get no accounting.   */
    if (!gotCarrier() || (whichIO == CONSOLE)) return(TRUE);

    if (  !thisAccount.days[ dayofweek() ]
    ||    !thisAccount.hours[ hour() ]
    ||     logBuf.credits <= 0 )
    {
        tutorial("nologin.blb");

        loggedIn = FALSE;

        terminate(TRUE, FALSE);

        return (FALSE);
    }

    if ( thisAccount.special[ hour() ] )  /* Is is free time?     */
    {
        specialTime = TRUE;
    }

    return (TRUE);
}
Exemple #4
0
function plotDay(var value,int type)
{
	int periods = 2*24;
	LookBack = max(LookBack,periods);
	int h = 2*hour() + minute()/30;
	if(h > periods) return;
	plotSeason(h,hour(),dow(),value,type);
}
Exemple #5
0
function plotWeek(var value,int type)
{
	int periods = (4*24 + 22);
	LookBack = max(LookBack,periods);
	int h = hour() + 24*(dow()-1);
	if(h > periods) return;
	plotSeason(h,hour(),week(),value,type);
}
void Time::printOn( ostream& outputStream ) const
{
    char temp[BufSize];
    ostrstream os( temp, BufSize );
    os << ((hour()%12 == 0) ? 12 : hour()%12) << ":"
       << setfill( '0' )
       << setw( 2 ) << minute() << ":"
       << setw( 2 ) << second() << "."
       << setw( 2 ) << hundredths() << " "
       << ((hour() > 11) ? "p" : "a") << "m" << ends;
    outputStream << temp;
}
void LedCycle::saveEepromDatas()
{
  EEPROM.write(eepromAddress + 0, (uint8_t)hour(startTime));
  EEPROM.write(eepromAddress + 1, (uint8_t)minute(startTime));

  EEPROM.write(eepromAddress + 2, (uint8_t)hour(fadeInTime));
  EEPROM.write(eepromAddress + 3, (uint8_t)minute(fadeInTime));

  EEPROM.write(eepromAddress + 4, (uint8_t)hour(stopTime));
  EEPROM.write(eepromAddress + 5, (uint8_t)minute(stopTime));

  EEPROM.write(eepromAddress + 6, (uint8_t)hour(fadeOutTime));
  EEPROM.write(eepromAddress + 7, (uint8_t)minute(fadeOutTime));
}
Exemple #8
0
void AgentClock::drawagentclock(uint8_t agents_here[], CRGB leds[], boolean stealth, CRGBPalette16 bgpalette, uint16_t start_index)
{
 /* uint8_t seconds = second() >> 1;
  uint8_t minutes = minute() >> 1;
  uint8_t hours = hour(); //don't divide hour by 2
*/
 uint8_t seconds = (second() * SECLEDS) / 60;
  uint8_t minutes = (minute() * MINLEDS) / 60 ;
  if(minute() > 0 && minutes < 1)
    minutes = 1;
  uint8_t hours = (hour()+1) >> 2; // hour is 1-12
   if(hour() > 0  && hours < 1)
    hours = 1;
  //update agent colorings and move them as required 
  updateagents(seconds, sec_agents,agents_here, sec_palette,SECMIN);
  updateagents(minutes, min_agents,agents_here, min_palette,SECMIN);
  updateagents(hours, hour_agents,agents_here, hour_palette,12);

  //draw the agents.
  drawagents(leds, sec_agents, SECMIN);
  drawagents(leds, min_agents, SECMIN);
  drawagents(leds, hour_agents, 12);

  
  //draw the background
 for (int i = 0; i < num_leds; i++)
  {
    if (agents_here[i] == 0)
    {
      if (stealth)
      {
        if(start_index >= 0 )
        {
        leds[i] = ColorFromPalette( bgpalette, start_index, brightness, blending);
        start_index += 2; 
        }
        else 
        leds[i] = ColorFromPalette( bgpalette, i, brightness, blending);
      }
      else
        leds[i] = CRGB::Black;

    }

  } 


}
Exemple #9
0
void l_vault(void)
{
    print1("You come to a thick vault door with a complex time lock.");
    if ((hour()==23)) {
        print2("The door is open.");
        Level->site[12][56].locchar = FLOOR;
    }
    else {
        print2("The door is closed.");
        Level->site[12][56].locchar = WALL;
        morewait();
        clearmsg();
        if (cinema_confirm("You're about to try to crack the safe.")=='y') {
            if (random_range(100) < Player.rank[THIEVES]*Player.rank[THIEVES]) {
                print2("The lock clicks open!!!");
                gain_experience(5000);
                Level->site[12][56].locchar = FLOOR;
            }
            else {
                print2("Uh, oh, set off the alarm.... The castle guard arrives....");
                morewait();
                if (Player.rank[NOBILITY] == DUKE) {
                    clearmsg();
                    print1("\"Ah, just testing us, your Grace?  I hope we're up to scratch.\"");
                    morewait();
                }
                else
                    send_to_jail();
            }
        }
        else print2("Good move.");
    }
}
Exemple #10
0
/**
 * Disaply complete time with 'hh:mm:ss' format
 */
void timeComplete_Display(){
  Serial.print(hour());
  Serial.print(":");
  printDigits(minute());
  Serial.print(":");
  printDigits(second());
}
Exemple #11
0
String getTimeString(time_t t = now())
{
  // String holder to return
  String dateStr;
  byte _day = weekday(t);
  byte sub1 = _day * 3;
  byte sub2 = sub1 + 3;
  dateStr = dayShortNames_P.substring(sub1, sub2);
  
  //Example "Sun "
  dateStr.concat(" ");

  int _hour = hour(t);
  if(_hour < 10) {
    dateStr.concat(" ");
  }
  dateStr.concat(_hour); // EX: "Sun 10"
  dateStr.concat(":");  // EX: "Sun 10:"
  
  int _minute = minute(t);
  if(_minute < 10) {
    dateStr.concat("0");
  }
  dateStr.concat(_minute); // EX: "Sun 10:1"
  dateStr.concat(":"); // EX: "Sun 10:1:"
  
  int _second = second(t);
  if(_second < 10) {
    dateStr.concat("0");
  }
  dateStr.concat(_second); // EX: "Sun 10:1:20"
  
  return dateStr;
}
uint8_t LedCycle::getOutputPercent(time_t currentTime)
{
  double brightnessPercent;
  time_t timeInDay;
  timeInDay = hoursToTime_t(hour(currentTime)) + 
      minutesToTime_t(minute(currentTime)) + 
      second(currentTime);

  // If we are fading in the led
  if ((timeInDay >= startTime) && (timeInDay <= (startTime + fadeInTime))) {
    brightnessPercent = ((timeInDay - startTime) * 100) / (fadeInTime);
    if (brightnessPercent >= 100) {
        brightnessPercent = 100;
    }
    return (uint8_t)brightnessPercent;
  }
  // If we are fading out the led
  if ((timeInDay >= (stopTime - fadeOutTime)) && (timeInDay <= stopTime)) {
    brightnessPercent = 100 - (((timeInDay - (stopTime - fadeOutTime))
                         * 100 / fadeOutTime));
    if (brightnessPercent <= 0) {
      brightnessPercent = 0;
    }
    return (uint8_t)brightnessPercent;
  }
  // If it is day time
  if ((timeInDay >= startTime) && (timeInDay < stopTime)) {
    brightnessPercent = 100;
    return (uint8_t)brightnessPercent;
  }
  // If it is night time
  brightnessPercent = 0;
  return (uint8_t)brightnessPercent;
}
void digitalClockDisplay(time_t time)
{
    // digital clock display of the time
    printDigits(hour(time), NULL);
    printDigits(minute(time), ':');
    // printDigits(second(time), ':');
}
Exemple #14
0
void loop() {
    char str[256];
    snprintf(str, 256, "%04u-%02u-%02uT%02u:%02u:%02u", year(), month(),
           day(), hour(), minute(), second());
    Serial.println(str);
    delay(5000);
}
bool CDVDSubtitleParserVplayer::Open(CDVDStreamInfo &hints)
{
  if (!CDVDSubtitleParserText::Open())
    return false;

  // Vplayer subtitles have 1-second resolution
  m_framerate = DVD_TIME_BASE;

  // Vplayer subtitles don't have StopTime, so we use following subtitle's StartTime
  // for that, unless gap was more than 4 seconds. Then we set subtitle duration
  // for 4 seconds, to not have text hanging around in silent scenes...
  int iDefaultDuration = 4 * (int)m_framerate;

  char line[1024];

  CRegExp reg;
  if (!reg.RegComp("([0-9]+):([0-9]+):([0-9]+):([^|]*?)(\\|([^|]*?))?$"))
    return false;

  CDVDOverlayText* pPrevOverlay = NULL;

  while (m_pStream->ReadLine(line, sizeof(line)))
  {
    if (reg.RegFind(line) > -1)
    {
      std::string hour(reg.GetMatch(1));
      std::string min (reg.GetMatch(2));
      std::string sec (reg.GetMatch(3));
      std::string lines[3];
      lines[0] = reg.GetMatch(4);
      lines[1] = reg.GetMatch(6);
      lines[2] = reg.GetMatch(8);

      CDVDOverlayText* pOverlay = new CDVDOverlayText();
      pOverlay->Acquire(); // increase ref count with one so that we can hold a handle to this overlay

      pOverlay->iPTSStartTime = m_framerate * (3600*atoi(hour.c_str()) + 60*atoi(min.c_str()) + atoi(sec.c_str()));

      // set StopTime for previous overlay
      if (pPrevOverlay)
      {
        if ( (pOverlay->iPTSStartTime - pPrevOverlay->iPTSStartTime) < iDefaultDuration)
          pPrevOverlay->iPTSStopTime = pOverlay->iPTSStartTime;
        else
          pPrevOverlay->iPTSStopTime = pPrevOverlay->iPTSStartTime + iDefaultDuration;
      }
      pPrevOverlay = pOverlay;
      for (int i = 0; i < 3 && !lines[i].empty(); i++)
          pOverlay->AddElement(new CDVDOverlayText::CElementText(lines[i].c_str()));

      m_collection.Add(pOverlay);
    }

    // set StopTime for the last subtitle
    if (pPrevOverlay)
      pPrevOverlay->iPTSStopTime = pPrevOverlay->iPTSStartTime + iDefaultDuration;
  }

  return true;
}
Exemple #16
0
void timeprint(void)
{
  static char * old_month = 0;

  /* WSS * HACK * This shouldn't be here at all but time is so screwed up */
  /* WSS * HACK * I don't know where else I can check for a new month reliably */
  if (!old_month)
    old_month = month();
  else
    {
      /* WSS * HACK * ptr comparision... works cause they're static */
      if (old_month != month() && Player.rank[LEGION] > 0)
        {
          bank_account * account;
          account = bank_index_number(SalaryAccount);
          if (account) account->balance += SalaryAmount;
          old_month = month();
        }
    }

  wclear(Timew);
  wprintw(Timew,"%d:%d",showhour(),showminute());
  if (showminute()==0) waddch(Timew,'0');
  wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
  wprintw(Timew,month());
  wprintw(Timew," the %d",day());
  wprintw(Timew,ordinal(day()));
  wrefresh(Timew);
}
Exemple #17
0
string VSTime::toString() const
{
	string result = "";
	char   buf1[10] = {0,};
	char   buf2[10] = {0,};
	char   buf3[10] = {0,};
	char   buf4[10] = {0,};

	sprintf(buf1, "%d", hour());
	sprintf(buf2, "%d", minute());
	sprintf(buf3, "%d", second());
	sprintf(buf4, "%d", msec());

	string hour   = string(buf1);
	string minute = string(buf2);
	string second = string(buf3);
	string msec   = string(buf4);

	if (hour.size() == 1)   hour   = "0"  + hour;
	if (minute.size() == 1) minute = "0"  + minute;
	if (second.size() == 1) second = "0"  + second;
	if (msec.size() == 1)   msec   = "00" + msec;
	if (msec.size() == 2)   msec   = "0"  + msec;

	result += hour   + ":"; // hour
	result += minute + ":"; // minute
	result += second + ":"; // second
	result += msec;         // msec

	return result;
}
void TimerDialog::on_timeEdit_timeChanged()
{
    auto time = ui->timeEdit->time();
    ui->horizontalSliderHours->setValue(time.hour());
    ui->horizontalSliderMinutes->setValue(time.minute());
    ui->horizontalSliderSeconds->setValue(time.second());
}
Exemple #19
0
inline void page_addSchedule() {
  static schedule s; //Schedule to be added
  static int value = 0;
  if(pre_page != ADD_SCHEDULE) {
    PTLS("Page Add Schedule");
    pre_page = ADD_SCHEDULE; 
    lcd.cursor();
  
    //Need to reintialize everytime we enter the page but not every refresh
    s.day = weekday();
    s.hour = hour();
    s.minute = minute();
    s.temperature = temperature_sensor;
    value = 0;
  }
  String t = getTimeString(s);
  lcd.print(F("Add: "));
  lcd.print(t);
  lcd.setCursor(0,1);
  lcd.print(F("Temp: "));
  lcd.print(s.temperature);
  if (button_input == PLUS_UP || button_input == PLUS_HOLD) {
    if (value == 0) {
      s.day++;
      if (s.day >= 8) s.day = 1;
    } else if (value == 1) {
      s.hour++;
      if (s.hour >= 24) s.hour = 0;
    } else if (value == 2) {
      s.minute++;
      if (s.minute >= 60) s.minute = 0;
    } else if (value == 3) {
      s.temperature++;
      if (s.temperature >= 99) 
        s.temperature = 99;
    }
  }
  else if (button_input == MINUS_UP || button_input == MINUS_HOLD) {
    if (value == 0) {
      s.day--;
      if (s.day <= 0) s.day = 7;
    } else if (value == 1) {
      s.hour--;
      if (s.hour >= 24) s.hour = 23;
    } else if (value == 2) {
      s.minute--;
      if (s.minute >= 60) s.minute = 59;
    } else if (value == 3) {
      s.temperature--;
      if (s.temperature <= 32 || s.temperature >= 99) 
        s.temperature = 32;
    }
  } else if (button_input == MODE_UP)  {
    value += 1;
    value = value % 4;
  } else if (button_input == SET_UP) {
    node_add(s);
    switchPage(LIST_MODE);
  }
}
void digitalClockDisplay() {
    if (sync) {
        Serial.println("DCF sync good");
        sync = false;
    }

    Serial.print(day());
    Serial.print('.');
    Serial.print(month());
    Serial.print('.');
    Serial.print(year());
    Serial.print(' ');
    Serial.print(' ');


    const uint8_t minutes = minute();
    const uint8_t hours = hour();

    print_2_digits(hours);
    Serial.print(':');
    print_2_digits(minutes);
    Serial.print(':');
    print_2_digits(second());

    display_digit(minutes % 10, bit0_pin + 0, 4);
    display_digit(minutes / 10, bit0_pin + 5, 3);

    display_digit(hours % 10, bit0_pin +  9, 4);
    display_digit(hours / 10, bit0_pin + 14, 2);

    Serial.println();
}
Exemple #21
0
LITESQL_String Time::asString(LITESQL_String format) const {
    if (format ==  LITESQL_L("%u")) {
        LITESQL_Char buf[32];
        snprintf(buf, 32,  LITESQL_L("%d"), value);
        return buf;
    }
    Split data(format,  LITESQL_L("%"));
    LITESQL_String res = data[0];
    for (size_t i = 1; i < data.size(); i++) {
        LITESQL_String rest = data[i].substr(1, data[i].size());
        switch(data[i][0]) {
        case 'h':
            res += toString(hour()) + rest;
            break;
        case 'M':
            if (min() < 10)
                res +=  LITESQL_L("0");
            res += toString(min()) + rest;
            break;
        case 's':
            if (sec() < 10)
                res +=  LITESQL_L("0");
            res += toString(sec()) + rest;
        }
    }
    return res;
}
Exemple #22
0
uint8_t Timer::isSummerTime()
{
	time_t t = mRtc.get() + TIMEZONE_SHIFT_SECONDS;
	
	uint8_t m = month(t);
	
	if(m > 10 || m < 3)
	{
		return 0;
	}
	else if(m > 3 && m < 10)
	{
		return 1;
	}
	else
	{
		uint8_t w = weekday(t);
		
		// otestovat posledni nedeli v mesici
		if(day(t) + 7 - w < 31)
		{
			return m == 3 ? 0 : 1;
		}
		else
		{
			// nedele - otestovat cas
			if(w == 1)
			{
				if(m == 3)
				{
					// brezen po druhe hodine
					return ( hour(t) > 2 ? 1 : 0);
				}
				else
				{
					// rijen po treti hodine
					return ( hour(t) > 2 ? 0 : 1);
					
				}
			}
			else
			{
				return m == 3 ? 1 : 0;
			}
		}
	}
}
time_t computeUserInput(uint8_t index, uint8_t number)
{
  static time_t time;
  uint8_t numberPosition = index;
  uint8_t nextPosition = index + 1;

  switch (index)
  {
    case 0:
      if (number > 2)
        number = 0;
      time = 0;
      time = hoursToTime_t(number * 10);
      break;
    case 1:
      nextPosition = 3;
      if (hour(time) >= 20 && number > 3)
        number = 0;
      time += hoursToTime_t(number);
      break;
    case 2:
      numberPosition = 3;
      nextPosition = 4;
      if (number > 5)
        number = 0;
      time += minutesToTime_t(number * 10);
      break;
    case 3:
      numberPosition = 4;
      nextPosition = 6;
      time += minutesToTime_t(number);
      break;
    case 4:
      numberPosition = 6;
      nextPosition = 7;
      if (number > 5)
        number = 0;
      time += number * 10;
      break;
    case 5:
      time += number;
      numberPosition = 7;
      nextPosition = 0;
      lcd.setCursor(10,3);
      lcd.print("OK : *");
      break;
    default:
      return time;
  }

  lcd.setCursor(numberPosition,1);
  lcd.print(number);
  lcd.setCursor(numberPosition,2);
  lcd.print(" ");
  lcd.setCursor(nextPosition,2);
  lcd.print("^");

  return time;
}
DateTime DateTime::start_of_minute() const
{
    g_assert(is_set());

    int year=0, month=0, day=0;
    ymd(year, month, day);
    return DateTime(m_tz.get(), year, month, day, hour(), minute(), 0);
}
Exemple #25
0
String SparkTime::AMPMString(uint32_t tnow) {
  uint8_t tempHour = hour(tnow);
  if (tempHour<12) {
    return String("AM");
  } else {
    return String("PM");
  }
}
int Alarms::check_alarm() {
	int i;
	for (i=0;i<MAX_ALARMS;i++) {
		if ((alarm_list[i].activate)&&(alarm_list[i].hr==hour())&&(alarm_list[i].mnt==minute())&&((alarm_list[i].day==weekday())||alarm_list[i].day==0)) {
			return alarm_list[i].id;
		}
	}
	return 255;
}
Exemple #27
0
int jwd::parseData(char *line, struct timeval *l_tData, double *sensorValue){
	int yday, mod;
	char date[7] = {0}, time[5] = {0};
	struct tm timestamp;
	std::string profile_data;
	
	
	// TODO/FIXME: are data timestamps in UTC or local time?
	
	if (sensorGroup == "dd") {
		// read date, time and sensor values of one line of data
		sscanf(line, "%s %i %s %i %lf %lf %lf %lf %lf %lf %lf %lf",
			date, &yday, time, &mod,
			&sensorValue[0], &sensorValue[1], &sensorValue[2], &sensorValue[3],
			&sensorValue[4], &sensorValue[5], &sensorValue[6], &sensorValue[7]);
	} else if (sensorGroup == "rd") {
		// read date and time of one line of data
		sscanf(line, "%s %i %s", date, &yday, time);
		
		profile_data.assign(line + 21, 3);
		mod = atoi(profile_data.c_str());
		
		// read sensor values of one line of data
		for (int i = 0; i < profile_length; i++) {
			profile_data.assign(line + 24 + i * 3, 3);
			sensorValue[i] = atoi(profile_data.c_str());
		}
	}
	
	// calculate timestamp in seconds:
	
	// evaluate date...
	std::string year(date, 2);
	std::string month(date + 2, 2);
	std::string day(date + 4, 2);
	
	// ...and fill tm structure
	timestamp.tm_mday = atoi(day.c_str());
	timestamp.tm_mon = atoi(month.c_str()) - 1;
	timestamp.tm_year = atoi(year.c_str()) + 100;
	
	// evaluate time...
	std::string hour(time, 2);
	std::string min(time + 2, 2);
	std::string sec("0");
	
	// ...and fill tm structure
	timestamp.tm_hour = atoi(hour.c_str());
	timestamp.tm_min = atoi(min.c_str());
	timestamp.tm_sec = atoi(sec.c_str());
	
	// get seconds since the Epoch
	l_tData->tv_sec = timegm(&timestamp);	// FIXME: function is non-standard GNU extension
	
	return 0;
}
boolean isDaytimeNow(int dhr, int dmin, int dsec, int mhr, int mmin, int msec) {
    // startup lamp status checks
    time_t startOfDay = timeToSeconds(dhr, dmin, dsec); // Hour,Min,Secs for start of day;
    time_t startOfNight = timeToSeconds(mhr, mmin, msec); // Hour,Min,Secs for start of Night;

    // Change the current timestamp to secs
    time_t t = timeToSeconds(hour(), minute(), second());
    // If its between startOfDay & StartOfNight return true
    return (t >= startOfDay && t < startOfNight);
}
Exemple #29
0
		// time := hour colon minute [ colon second ] .
		void time()
		{
			hour();
			colon();
			minute();
			if (is_colon(scan.get())) {
				colon();
				second();
			}
		}
Exemple #30
0
String SparkTime::hour12String(uint32_t tnow) {
  uint8_t tempHour = hour(tnow);
  if (tempHour>12) {
    tempHour -= 12;
  }
  if (tempHour == 0) {
    tempHour = 12;
  }
  return String(_digits[tempHour]);
}