Пример #1
0
/**
 * Handler for minute tick
 * Updates the text layer if needed and triggers updating
 * of the minute layer
 */
static void do_update_time(struct tm *current_time) {
  // update the time variables
  set_time(current_time);

  // update the hour layer
  text_layer_set_text(hour_layer, hour_display);
  text_layer_set_text(day_layer, day_string);

  if(has_tapped) {
    // determine wether hours or date should be visible
    layer_set_hidden(text_layer_get_layer(hour_layer), true);
    layer_set_hidden(text_layer_get_layer(day_layer), false);
    layer_set_hidden(text_layer_get_layer(month_layer), false);

  } else {
    layer_set_hidden(text_layer_get_layer(hour_layer), false);
    layer_set_hidden(text_layer_get_layer(day_layer), true);
    layer_set_hidden(text_layer_get_layer(month_layer), true);
  }
  // re-set the bounds. we shouldn't be doing this from
  // .update_proc, change doesn't take effect until next render.
  // but as we're doing this far in advance, it will be ok by 
  // the time it's needed
  set_minute_bounds(minutes);

  // mark the minute layer as dirty so it will be redrawn
  layer_mark_dirty(minute_layer);
  layer_mark_dirty(deco_layer);
}
Пример #2
0
void Message::MergeFrom(const Message& from) {
  GOOGLE_CHECK_NE(&from, this);
  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
    if (from.has_to()) {
      set_to(from.to());
    }
    if (from.has_id()) {
      set_id(from.id());
    }
    if (from.has_time()) {
      set_time(from.time());
    }
    if (from.has_from()) {
      set_from(from.from());
    }
    if (from.has_type()) {
      set_type(from.type());
    }
    if (from.has_sn()) {
      set_sn(from.sn());
    }
    if (from.has_data()) {
      set_data(from.data());
    }
    if (from.has_expire()) {
      set_expire(from.expire());
    }
  }
}
Пример #3
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, i;
  static struct kevent ke[KE_LENGTH];
  struct timespec poll_time;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  /*
   * remember we are doing NANOseconds here, not micro/milli. God knows
   * why jlemon used a timespec, but hey, he wrote the interface, not I
   *   -- Adrian
   */
  poll_time.tv_sec = 0;
  poll_time.tv_nsec = SELECT_DELAY * 1000000;
  num = kevent(kqfd.fd, kq_fdlist, kqoff, ke, KE_LENGTH, &poll_time);
  kqoff = 0;

  set_time();

  if (num < 0)
  {
    const struct timespec req = { .tv_sec = 0, .tv_nsec = 50000000 };
    nanosleep(&req, NULL);  /* Avoid 99% CPU in comm_select */
    return;
  }

  for (i = 0; i < num; i++)
  {
    F = lookup_fd(ke[i].ident);
    if (F == NULL || !F->flags.open || (ke[i].flags & EV_ERROR))
      continue;

    if (ke[i].filter == EVFILT_READ)
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if (ke[i].filter == EVFILT_WRITE)
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Пример #4
0
void device_rtc_interface::set_current_time(running_machine &machine)
{
	system_time systime;
	machine.base_datetime(systime);

	set_time(true, systime.local_time.year, systime.local_time.month + 1, systime.local_time.mday, systime.local_time.weekday + 1,
		systime.local_time.hour, systime.local_time.minute, systime.local_time.second);
}
Пример #5
0
/** Callback to set receiver GPS time estimate. */
static void set_time_callback(u16 sender_id, u8 len, u8 msg[], void* context)
{
  (void)sender_id; (void)len; (void) context;

  gps_time_t *t = (gps_time_t *)msg;

  set_time(TIME_COARSE, *t);
}
Пример #6
0
blargg_err_t Nsf_Emu::run_clocks( blip_time_t& duration, int )
{
	set_time( 0 );
	while ( time() < duration )
	{
		nes_time_t end = min( next_play, duration );
		end = min( end, time() + 32767 ); // allows CPU to use 16-bit time delta
		if ( cpu::run( end ) )
		{
			if ( r.pc != badop_addr )
			{
				set_warning( "Emulation error (illegal instruction)" );
				r.pc++;
			}
			else
			{
				play_ready = 1;
				if ( saved_state.pc != badop_addr )
				{
					cpu::r = saved_state;
					saved_state.pc = badop_addr;
				}
				else
				{
					set_time( end );
				}
			}
		}
		
		if ( time() >= next_play )
		{
			nes_time_t period = (play_period + play_extra) / clock_divisor;
			play_extra = play_period - period * clock_divisor;
			next_play += period;
			if ( play_ready && !--play_ready )
			{
				check( saved_state.pc == badop_addr );
				if ( r.pc != badop_addr )
					saved_state = cpu::r;
				
				r.pc = play_addr;
				low_mem [0x100 + r.sp--] = (badop_addr - 1) >> 8;
				low_mem [0x100 + r.sp--] = (badop_addr - 1) & 0xFF;
				GME_FRAME_HOOK( this );
			}
		}
Пример #7
0
static void tick_handler(struct tm *tick_time, TimeUnits units_changed){
	set_time();
	
	if(mins != 0 && (tick_time->tm_min +(tick_time->tm_hour*60))%mins == 0){
		vibes_double_pulse();
		APP_LOG(APP_LOG_LEVEL_DEBUG, "fmt");
	}
}
Пример #8
0
GameTimedCallback::GameTimedCallback(CallBack *t, void *d, uint32 wait_time, bool repeating)
    : TimedCallback(t, d, wait_time, repeating)
{
    // re-queue timer using game ticks
    dequeue();
    real_time = TIMER_GAMETIME;
    set_time();// change to game time
    queue(); // start
}
Пример #9
0
int Set_time(unsigned char * time_buf)
{
    int ret;
    char rtc_string[40];
    ret = set_time(time_buf[0],time_buf[1],time_buf[2],time_buf[3],time_buf[4],time_buf[5],time_buf[6]);
    sprintf(rtc_string,"date %02d%02d%02d%02d%02d%02d.%02d",time_buf[2],time_buf[3],time_buf[4],time_buf[5],time_buf[0],time_buf[1],time_buf[6]);
    system(rtc_string);
    return ret;
}
Пример #10
0
void
comm_select(unsigned long delay)
{
  int num, i, fd;
  static struct kevent ke[KE_LENGTH];
  struct timespec poll_time;
  PF *hdl;
  fde_t *F;

  /*
   * remember we are doing NANOseconds here, not micro/milli. God knows
   * why jlemon used a timespec, but hey, he wrote the interface, not I
   *   -- Adrian
   */
  poll_time.tv_sec = 0;
  poll_time.tv_nsec = delay * 1000000;

  num = kevent(kq, kqlst, kqoff, ke, KE_LENGTH, &poll_time);
  kqoff = 0;
  while (num < 0 && ignoreErrno(errno))
    num = kevent(kq, kqlst, 0, ke, KE_LENGTH, &poll_time);

  set_time();

  for (i = 0; i < num; i++)
  {
    fd = (int) ke[i].ident;
    hdl = NULL;
    F = &fd_table[fd];

    if (ke[i].flags & EV_ERROR)
    {
      errno = ke[i].data;
      /* XXX error == bad! -- adrian */
      continue; /* XXX! */
    }

    switch (ke[i].filter)
    {
      case EVFILT_READ:
        if ((hdl = F->read_handler) != NULL)
        {
          F->read_handler = NULL;
          hdl(fd, F->read_data);
        }
      case EVFILT_WRITE:
        if ((hdl = F->write_handler) != NULL)
        {
          F->write_handler = NULL;
          hdl(fd, F->write_data);
        }
      default:
        /* Bad! -- adrian */
        break;
    }
  }
}
Пример #11
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, ci;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  num = poll(pollfds, pollnum, SELECT_DELAY);

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);  /* avoid 99% CPU in comm_select */
#endif
    return;
  }

  for (ci = 0; ci < pollnum && num > 0; ci++)
  {
    int revents = pollfds[ci].revents;

    if (revents == 0)
      continue;
    num--;

    F = lookup_fd(pollfds[ci].fd);
    assert(F);
    if (!F->flags.open)
      continue;

    if (revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR))
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if (revents & (POLLWRNORM | POLLOUT | POLLHUP | POLLERR))
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Пример #12
0
acl_int64 event_timer::trigger(void)
{
	// sanity check
	if (tasks_.empty())
		return TIMER_EMPTY;

	acl_assert(length_ > 0);

	set_time();

	std::list<event_task*> tasks;

	// 从定时器中取出到达的定时任务
	for (std::list<event_task*>::iterator it = tasks_.begin();
		it != tasks_.end();)
	{
		if ((*it)->when > present_)
			break;

		tasks.push_back(*it);
		it = tasks_.erase(it);
		length_--;
	}

	if (tasks.empty())
	{
		acl_assert(!tasks_.empty());

		event_task* first = tasks_.front();
		acl_int64 delay = first->when - present_;
		return delay < 0 ? 0 : delay;
	}

	for (std::list<event_task*>::iterator it = tasks.begin();
		it != tasks.end(); ++it)
	{
		set_task(*it);
		// 调用子类虚函数,触发定时器任务过程
		timer_callback((*it)->id);
	}

	tasks.clear();

	// 子类有可能会在 timer_callback 中删除了所有的定时任务
	if (tasks_.empty())
		return TIMER_EMPTY;

	event_task* first = tasks_.front();
	acl_int64 delay = first->when - present_;

	if (delay < 0)
		return 0;
	else if (delay > first->delay)  /* xxx */
		return first->delay;
	else
		return delay;
}
Пример #13
0
void CommandSocket::sendPrintTime()
{
#ifdef ARCUS
    auto message = std::make_shared<cura::proto::ObjectPrintTime>();
    message->set_time(FffProcessor::getInstance()->getTotalPrintTime());
    message->set_material_amount(FffProcessor::getInstance()->getTotalFilamentUsed(0));
    private_data->socket->sendMessage(message);
#endif
}
Пример #14
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  struct timeval to;
  int num, fd;
  fde_t *F;
  PF *hdl;

  /* Copy over the read/write sets so we don't have to rebuild em */
  memcpy(&tmpreadfds, &select_readfds, sizeof(fd_set));
  memcpy(&tmpwritefds, &select_writefds, sizeof(fd_set));

  to.tv_sec = 0;
  to.tv_usec = SELECT_DELAY * 1000;
  num = select(highest_fd + 1, &tmpreadfds, &tmpwritefds, NULL, &to);

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);
#endif
    return;
  }

  for (fd = 0; fd <= highest_fd && num > 0; fd++)
    if (FD_ISSET(fd, &tmpreadfds) || FD_ISSET(fd, &tmpwritefds))
    {
      num--;

      F = lookup_fd(fd);
      if (F == NULL || !F->flags.open)
        continue;

      if (FD_ISSET(fd, &tmpreadfds))
        if ((hdl = F->read_handler) != NULL)
        {
          F->read_handler = NULL;
          hdl(F, F->read_data);
          if (!F->flags.open)
            continue;
        }

      if (FD_ISSET(fd, &tmpwritefds))
        if ((hdl = F->write_handler) != NULL)
        {
          F->write_handler = NULL;
          hdl(F, F->write_data);
          if (!F->flags.open)
            continue;
        }

      comm_setselect(F, 0, NULL, NULL, 0);
    }
}
Пример #15
0
/* option_checker()'s role is ONLY check "short option" */
void option_checker(int argc, char ** argv)
{
    int opt;
    /* long option's define */
    static struct option loption[] = {
        {"help", no_argument, NULL, 'h'},
        {"time", required_argument, NULL, 't'},
        {"file", required_argument, NULL, 'f'}
    };

    /* check the number of argument */
    if(argc == 1) {
        error_procedure("number of argument");
    }

    /* set all modes to OFF */
    set_mode();

    /* check short options */
    while((opt = getopt_long(argc, argv, "mbv:plzt:f:h", loption, NULL)) != -1) {
        switch(opt) {
            case 'b':
                set_tabu2opt_mode();
                break;
            case 'm':
                set_parallel_mode();
                break;
            case 'v':
                set_visual_mode(atoi(optarg));
                break;
            case 'p':
                set_parallel_mode();
                break;
            case 'l':
                set_pole_mode();
                break;
            case 'z':
                set_tozaki_mode();
                break;
            case 't':
                set_time(INIT,atoi(optarg));
                break;
            case 'f':
                read_data_set(optarg);
                break;
            case 'h':
                if(argc == 2) {
                    help_document(argv);
                }
                break;
            case '?':
                error_procedure("comand-line option");
                break;
        }
    }
}
int set_delay_time(alphabet_game_t *alphabet_game, unsigned int usec)
{
	alphabet_game_t *ag=alphabet_game;
	unsigned int us=usec;
	if(NULL==ag){
		return RET_FAILED;
	}

	return set_time(&ag->delay_time,us);
}
gboolean
gst_rtsp_range_convert_units (GstRTSPTimeRange * range, GstRTSPRangeUnit unit)
{
  if (range->unit == unit)
    return TRUE;

  if (range->min.type == GST_RTSP_TIME_NOW ||
      range->max.type == GST_RTSP_TIME_NOW)
    return FALSE;

  set_time (&range->min, &range->min2, unit,
      get_time (range->unit, &range->min, &range->min2));
  set_time (&range->max, &range->max2, unit,
      get_time (range->unit, &range->max, &range->max2));

  range->unit = unit;

  return TRUE;
}
Пример #18
0
WorldClock::WorldClock(string city_name, double hour_diff, Point center,
double radius) : Clock(center, radius) 
{ Point p = center; 
  p.move(0, -radius); 
  city = Message(p, city_name); 
  Time now; 
  const double SECONDS_PER_HOUR = 60 * 60; 
  now.add_seconds(hour_diff * SECONDS_PER_HOUR); 
  set_time(now); 
} 
Пример #19
0
int main() {
    char buffer[32] = {0};
    set_time(CUSTOM_TIME);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
    while(1) {
        time_t seconds = time(NULL);
        strftime(buffer, 32, "%Y-%m-%d %H:%M:%S %p", localtime(&seconds));
        printf("[%ld] [%s]\n", seconds, buffer);
        wait(1);
    }
}
Пример #20
0
void DogStateCart3::read_frame(int nframe)
{
    //DogState::read(nframe, get_outputdir());
    set_time(ReadStateArray(get_outputdir(), "q", *q, nframe));
    if (dogParams.get_maux()>0)
    {
        const double t = ReadStateArray(get_outputdir(), "a", *aux, nframe);
        assert_eq(t, get_time());
    }
}
Пример #21
0
void *POSIX_Init(
  void *argument
)
{
  int               status;
  useconds_t        result;
  struct sigaction  act;
  sigset_t          mask;

  TEST_BEGIN();

  /* set the time of day, and print our buffer in multiple ways */

  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );

  /* get id of this thread */

  Init_id = pthread_self();
  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );

  Signal_occurred = 0;
  Signal_count = 0;

  /* Validate ualarm is ignored if signal not caught */
  act.sa_handler = Signal_handler;
  act.sa_flags   = 0;
  sigaction( SIGALRM, &act, NULL );
  puts( "Init: ualarm in 1 us" );
  sleep(3);
  result = ualarm(1,0);
  rtems_test_assert( result == 0 );
  
  status = sleep(10);
  rtems_test_assert( status == 0 );

  /* unblock Signal and see if it happened */
  status = sigemptyset( &mask );
  rtems_test_assert( !status );
  status = sigaddset( &mask, SIGALRM );
  rtems_test_assert( !status );
  puts( "Init: Unblock SIGALRM" );
  status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
  rtems_test_assert( !status );
  status = sleep(10);

  /* stop ularm */
  puts( "Init: clear ualarm with 0,0" );
  result = ualarm(0,0);
  status = sleep(10);

  TEST_END();
  rtems_test_exit(0);

  return NULL; /* just so the compiler thinks we returned something */
}
Пример #22
0
acl_int64 event_timer::trigger(void)
{
	// sanity check
	if (tasks_.empty())
		return TIMER_EMPTY;

	acl_assert(length_ > 0);

	set_time();

	std::list<event_task*>::iterator it, next;
	std::list<event_task*> tasks;
	event_task* task;

	// 从定时器中取出到达的定时任务
	for (it = tasks_.begin(); it != tasks_.end(); it = next)
	{
		if ((*it)->when > present_)
			break;
		next = it;
		++next;
		task = *it;
		tasks_.erase(it);
		length_--;
		tasks.push_back(task);
	}

	// 有可能这些到达的定时任务已经被用户提前删除了
	if (tasks.empty())
	{
		acl_assert(!tasks_.empty());

		event_task* first = tasks_.front();
		acl_int64 delay = first->when - present_;
		return delay < 0 ? 0 : delay;
	}

	for (it = tasks.begin(); it != tasks.end(); ++it)
	{
		set_task(*it);
		// 调用子类虚函数,触发定时器任务过程
		timer_callback((*it)->id);
	}

	tasks.clear();

	// 子类有可能会在 timer_callback 中删除了所有的定时任务
	if (tasks_.empty())
		return TIMER_EMPTY;

	event_task* first = tasks_.front();
	acl_int64 delay = first->when - present_;

	return delay < 0 ? 0 : delay;
}
Пример #23
0
/*
 * comm_select
 *
 * Called to do the new-style IO, courtesy of squid (like most of this
 * new IO code). This routine handles the stuff we've hidden in
 * comm_setselect and fd_table[] and calls callbacks for IO ready
 * events.
 */
void
comm_select(void)
{
  int num, i;
  struct pollfd pollfds[128];
  struct dvpoll dopoll;
  void (*hdl)(fde_t *, void *);
  fde_t *F;

  dopoll.dp_timeout = SELECT_DELAY;
  dopoll.dp_nfds = 128;
  dopoll.dp_fds = &pollfds[0];
  num = ioctl(dpfd.fd, DP_POLL, &dopoll);

  set_time();

  if (num < 0)
  {
#ifdef HAVE_USLEEP
    usleep(50000);  /* avoid 99% CPU in comm_select */
#endif
    return;
  }

  for (i = 0; i < num; i++)
  {
    F = lookup_fd(dopoll.dp_fds[i].fd);
    if (F == NULL || !F->flags.open)
      continue;

    if ((dopoll.dp_fds[i].revents & POLLIN))
    {
      if ((hdl = F->read_handler) != NULL)
      {
        F->read_handler = NULL;
        hdl(F, F->read_data);
        if (!F->flags.open)
          continue;
      }
    }

    if ((dopoll.dp_fds[i].revents & POLLOUT))
    {
      if ((hdl = F->write_handler) != NULL)
      {
        F->write_handler = NULL;
        hdl(F, F->write_data);
        if (!F->flags.open)
          continue;
      }
    }

    comm_setselect(F, 0, NULL, NULL, 0);
  }
}
Пример #24
0
/*-------------------------------------------------------------------
  SetTimeZone
 -------------------------------------------------------------------*/
 void SetTimeZone( int hour_offset, int isdst )
 {
    time_t RawTime;
    struct tm *TimeInfo;
 
    time( &RawTime );  // Get system time in time_t format
    TimeInfo = localtime( &RawTime );  // Convert to struct tm format
    TimeInfo->tm_hour += hour_offset;
    TimeInfo->tm_isdst = isdst;
    set_time( mktime( TimeInfo ) );
}
Пример #25
0
void main_window_load(){
	Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
	
	layer_set_update_proc(window_layer, update_proc);
	
	B0 = gbitmap_create_with_resource(RESOURCE_ID_RES_0); B1 = gbitmap_create_with_resource(RESOURCE_ID_RES_1);
	B2 = gbitmap_create_with_resource(RESOURCE_ID_RES_2); B3 = gbitmap_create_with_resource(RESOURCE_ID_RES_3);
	B4 = gbitmap_create_with_resource(RESOURCE_ID_RES_4); B5 = gbitmap_create_with_resource(RESOURCE_ID_RES_5);
	B6 = gbitmap_create_with_resource(RESOURCE_ID_RES_6); B7 = gbitmap_create_with_resource(RESOURCE_ID_RES_7);
	B8 = gbitmap_create_with_resource(RESOURCE_ID_RES_8); B9 = gbitmap_create_with_resource(RESOURCE_ID_RES_9);
	
	#ifdef PBL_ROUND
		bool round = true;
	#else
		bool round = false;
	#endif
	
	if(!(center || round)){
		hour1 = bitmap_layer_create(GRect(PADING_X, PADING_Y, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(hour1, B0);
		layer_add_child(window_layer, bitmap_layer_get_layer(hour1));
		
		hour2 = bitmap_layer_create(GRect(PADING_X*2 + IMAGE_W, PADING_Y, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(hour2, B1);
		layer_add_child(window_layer, bitmap_layer_get_layer(hour2));
		
		min1 = bitmap_layer_create(GRect(PADING_X, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(min1, B2);
		layer_add_child(window_layer, bitmap_layer_get_layer(min1));	
		
		min2 = bitmap_layer_create(GRect(PADING_X*2 + IMAGE_W, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(min2, B3);
		layer_add_child(window_layer, bitmap_layer_get_layer(min2));
	}else{
		hour1 = bitmap_layer_create(GRect(PADING_CENTER_X, PADING_Y, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(hour1, B0);
		layer_add_child(window_layer, bitmap_layer_get_layer(hour1));
	
		hour2 = bitmap_layer_create(GRect(bounds.size.w - PADING_CENTER_X - IMAGE_W, PADING_Y, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(hour2, B1);
		layer_add_child(window_layer, bitmap_layer_get_layer(hour2));
	
		min1 = bitmap_layer_create(GRect(PADING_CENTER_X, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(min1, B2);
		layer_add_child(window_layer, bitmap_layer_get_layer(min1));
	
		min2 = bitmap_layer_create(GRect(bounds.size.w - PADING_CENTER_X - IMAGE_W, bounds.size.h - PADING_Y - IMAGE_H, IMAGE_W, IMAGE_H));
		bitmap_layer_set_bitmap(min2, B3);
		layer_add_child(window_layer, bitmap_layer_get_layer(min2));
	}
	
	set_time();
}
Пример #26
0
/* Accepts delay, immediate toggle(false), and realtime switch(true). It must
 * be queued afterwards to start.
 */
TimedEvent::TimedEvent(uint32 reltime, bool immediate, bool realtime)
    : delay(reltime), repeat_count(0), ignore_pause(false),
      real_time(realtime), tq_can_delete(true), defunct(false)
{
    tq = NULL;

    if(immediate) // start now (useful if repeat is true)
        time = 0;
    else
        set_time();
}
Пример #27
0
void sig_handle(int signum)
{
    DEBUG_printf("receive signal :%d\n",signum);
    //SIGUSR1:pause;SIGUSR2:start;
    if(signum == SIGUSR1)
    {
        set_time(6000000,6000000);
        r_connect = 0;
        close(sockfd);
        ClearQueue(&Q_cmd);//clear the comdmand queue.
        ClearQueue(&Q_respond);
    }
    else if(signum == SIGUSR2)
    {
        ClearQueue(&Q_cmd);//clear the comdmand queue.
        ClearQueue(&Q_respond);
        set_time(30,30);
        tcp_state();
    }
}
Пример #28
0
static struct timeval *get_time(void)
{
	if (!_state.s_time_set) {
		struct timeval tv;

		gettimeofday(&tv, NULL);
		set_time(&tv);
	}

	return &_state.s_now;
}
long um_stime(int __user *tptr)
{
	int value;

	if (get_user(value, tptr))
                return -EFAULT;

	set_time((unsigned long long) value * NSEC_PER_SEC);

	return 0;
}
static void main_window_load(Window *window) {
  //Get resources
  ResHandle font_20 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_20);
  ResHandle font_25 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_25);
  ResHandle font_43 = resource_get_handle(RESOURCE_ID_FONT_IMAGINE_43);

  //Bottom frame
  lower_layer = text_layer_create(GRect(0, 84, 144, 84));
  text_layer_set_background_color(lower_layer, fg_color);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(lower_layer));

  //TextLayers
  time_layer = util_init_text_layer(GRect(1, 41, 150, 50), fg_color, GColorClear, font_43, GTextAlignmentLeft);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

  am_pm_layer = util_init_text_layer(GRect(0, 0, 0, 0), fg_color, GColorClear, font_20, GTextAlignmentLeft);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(am_pm_layer));

  day_layer = util_init_text_layer(GRect(1, 75, 150, 50), bg_color, GColorClear, font_25, GTextAlignmentLeft);
  text_layer_set_text(day_layer, "MON");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(day_layer));

  date_layer = util_init_text_layer(GRect(70, 75, 150, 50), bg_color, GColorClear, font_25, GTextAlignmentLeft);
  text_layer_set_text(date_layer, "25");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(date_layer));

  month_layer = util_init_text_layer(GRect(1, 95, 150, 50), bg_color, GColorClear, font_20, GTextAlignmentLeft);
  text_layer_set_text(month_layer, "JANUARY");
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(month_layer));

  //InverterLayers
  top_shade = inverter_layer_compat_func_create(GRect(0, 0, 144, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(top_shade));

  bottom_shade = inverter_layer_compat_func_create(GRect(0, 0, 144, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(bottom_shade));

  q1_shade = inverter_layer_compat_func_create(GRect(0, 0, 35, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(q1_shade));

  q2_shade = inverter_layer_compat_func_create(GRect(36, 0, 35, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(q2_shade));

  q3_shade = inverter_layer_compat_func_create(GRect(72, 0, 35, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(q3_shade));

  q4_shade = inverter_layer_compat_func_create(GRect(108, 0, 35, 0));
  layer_add_child(window_get_root_layer(window), inverter_layer_compat_func_get(q4_shade));

  //Init display not blank
  time_t temp = time(NULL);  
  struct tm *t = localtime(&temp);
  set_time(t);
}