コード例 #1
0
//
// ticks every minute, updating the time and date.
//
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t)
{
    //
    // this seems pointless.
    // Glenn: Left this in because I don't know what it does.
    //
    (void)ctx;

    PblTm *tickTime = t->tick_time;
   
    //
    // set the date - only changing it when the day changes
    // format strings here: http://www.gnu.org/software/emacs/manual/html_node/elisp/Time-Parsing.html
    //
    static char dateText[] = "Sun 01 September 00";
    static int lastShownDate = -1;
    int theDay = tickTime->tm_yday;
    if (theDay != lastShownDate)
    {
        lastShownDate = theDay;
        string_format_time(dateText, sizeof(dateText), "%a %B %e", tickTime );
        text_layer_set_text(&_currentDate, dateText);
    }
    
    //
    // set the time
    //
    static char timeText[] = "00:00";
    const char *timeFormat = clock_is_24h_style() ? "%R" : "%l:%M";
    string_format_time(timeText, sizeof(timeText), timeFormat, tickTime);
    text_layer_set_text(&_currentTime, timeText);
}
コード例 #2
0
ファイル: orbit.c プロジェクト: juliengrenier/pebble
void update_rings() {
  PblTm t;

  get_time(&t);

  int hourAngle = ((t.tm_hour % 12) * 30) + (t.tm_min / 2);
  int minAngle = t.tm_min * 6;

  static char hour_str[] = "00";
  static char minute_str[] = "00";

  char *hour_format;
  if (clock_is_24h_style()) {
    hour_format = "%k";
  } else {
    hour_format = "%l";
  }

  string_format_time(hour_str, sizeof(hour_str), hour_format, &t);
  string_format_time(minute_str, sizeof(minute_str), "%M", &t);

  set_hand_text(&hourText, hourAngle, hour_str, GPoint(0,-55), GSize(26,26));
  set_hand_text(&minuteText, minAngle, minute_str, GPoint(0,-24), GSize(18,18));

  set_hand_angle(&hourImage, hourAngle, GPoint(0, -55));
  set_hand_angle(&minuteImage, minAngle, GPoint(0, -24));
}
コード例 #3
0
ファイル: bmo_watch.c プロジェクト: remixz/pebble-bmo
void update_display(PblTm *tick_time) {
  static char date_text[] = "Xxxxxxxxx, Xxxxxxxxx 00";
  static char new_date_text[] = "Xxxxxxxxx, Xxxxxxxxx 00";
  static char time_text[] = "00:00   ";
  char *time_format;

  // Date layer
  string_format_time(new_date_text, sizeof(date_text), "%A, %B %d", tick_time);
  if (strncmp(new_date_text, date_text, sizeof(date_text)) != 0) {
      strncpy(date_text, new_date_text, sizeof(date_text));
      text_layer_set_text(&text_date_layer, date_text);
  }

  // Time layer
  if (clock_is_24h_style()) {
    time_format = "%R";
  } else {
    time_format = "%I:%M %p";
  }
  string_format_time(time_text, sizeof(time_text), time_format, tick_time);
  if (!clock_is_24h_style() && (time_text[0] == '0')) {
    memmove(time_text, &time_text[1], sizeof(time_text) - 1);
  }

  text_layer_set_text(&text_time_layer, time_text);
}
コード例 #4
0
ファイル: WinPebble01.c プロジェクト: hal1729/WinPebble01
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {

  // Need to be static because they're used by the system later.
  static char time_text[] = "00:00";
  static char date_text[] = "Xxxxxxxxx 00";

  char *time_format;


  // TODO: Only update the date when it's changed.
  string_format_time(date_text, sizeof(date_text), "%B %e", t->tick_time);
  text_layer_set_text(&text_date_layer, date_text);


  if (clock_is_24h_style()) {
    time_format = "%R";
  } else {
    time_format = "%I:%M";
  }

  string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

  // Kludge to handle lack of non-padded hour format string
  // for twelve hour clock.
  if (!clock_is_24h_style() && (time_text[0] == '0')) {
    memmove(time_text, &time_text[1], sizeof(time_text) - 1);
  }

  text_layer_set_text(&text_time_layer, time_text);

}
コード例 #5
0
ファイル: main.c プロジェクト: SheepWillPrevail/pebble
void update_time() {
  PblTm time;
  
  get_time(&time);
  string_format_time(string_time, sizeof(string_time), format_time, &time);
  string_format_time(string_date, sizeof(string_date), format_date, &time);
}
コード例 #6
0
void updateDayAndNightInfo(bool update_everything)
{
  static char sunrise_text[] = "00:00";
  static char sunset_text[] = "00:00";

  PblTm pblTime;
  get_time(&pblTime);

  if(update_everything || currentData != pblTime.tm_hour) 
  {
    char *time_format;

    if (clock_is_24h_style()) 
    {
      time_format = "%R";
    } 
    else 
    {
      time_format = "%I:%M";
    }

    float sunriseTime = calcSunRise(pblTime.tm_year, pblTime.tm_mon+1, pblTime.tm_mday, realLatitude, realLongitude, 91.0f);
    float sunsetTime = calcSunSet(pblTime.tm_year, pblTime.tm_mon+1, pblTime.tm_mday, realLatitude, realLongitude, 91.0f);
    adjustTimezone(&sunriseTime);
    adjustTimezone(&sunsetTime);
    
    if (!pblTime.tm_isdst) 
    {
      sunriseTime+=1;
      sunsetTime+=1;
    } 
    
    pblTime.tm_min = (int)(60*(sunriseTime-((int)(sunriseTime))));
    pblTime.tm_hour = (int)sunriseTime;
    string_format_time(sunrise_text, sizeof(sunrise_text), time_format, &pblTime);
    text_layer_set_text(&text_sunrise_layer, sunrise_text);
    
    pblTime.tm_min = (int)(60*(sunsetTime-((int)(sunsetTime))));
    pblTime.tm_hour = (int)sunsetTime;
    string_format_time(sunset_text, sizeof(sunset_text), time_format, &pblTime);
    text_layer_set_text(&text_sunset_layer, sunset_text);
    text_layer_set_text_alignment(&text_sunset_layer, GTextAlignmentRight);

    sunriseTime+=12.0f;
    sun_path_info.points[1].x = (int16_t)(my_sin(sunriseTime/24 * M_PI * 2) * 120);
    sun_path_info.points[1].y = -(int16_t)(my_cos(sunriseTime/24 * M_PI * 2) * 120);

    sunsetTime+=12.0f;
    sun_path_info.points[4].x = (int16_t)(my_sin(sunsetTime/24 * M_PI * 2) * 120);
    sun_path_info.points[4].y = -(int16_t)(my_cos(sunsetTime/24 * M_PI * 2) * 120);

    currentData = pblTime.tm_hour;
    
    //Update location unless being called from location update
    if (!update_everything) {
      http_time_request();
    }
  }
}
コード例 #7
0
ファイル: arrivals.c プロジェクト: chrissmall22/pebbus
void arrivals_success(int32_t cookie, int http_status, DictionaryIterator* received, void* context)
{
    Tuple *t = dict_find(received, 1);
    char *v = t->value->cstring;
    uint16_t index = 0;
    uint16_t len = t->length;
    arrivalsCount = 0;
    int16_t time = 0;
    MenuIndex top = { 0, 0 };
    

    PblTm now;
    get_time(&now);
    if (clock_is_24h_style()) {
        string_format_time(arrival_time_str, sizeof(arrival_time_str), "Updated: %H:%M", &now);
    }
    else {
        string_format_time(arrival_time_str, sizeof(arrival_time_str), "Updated: %l:%M %p", &now);
    }

    for(unsigned char i=0;i<MAX_ARRIVALS && index < len;i++) {
        //stokenize(char *source, uint16_t index, char delimiter, char *target, uint16_t max_length)
        index = stokenize(v, index, ':', ARRIVALS[i].route, ARRIVAL_ROUTE_LENGTH, len);
        index = stokenize(v, index, ':', ARRIVALS[i].actual, sizeof(ARRIVALS[i].actual), len);
        index = stokenize(v, index, ':', ARRIVALS[i].scheduled, sizeof(ARRIVALS[i].scheduled), len);

        //TODO: DRY

        time = satoi(ARRIVALS[i].actual, strlen(ARRIVALS[i].actual));

        if(abs(time) > 99*60 + 59) //Maximum displayable value.
        	time = (99*60 + 59) * (time < 0 ? -1 : 1);

        if(time > 60 || time < -60) {
	        snprintf(ARRIVALS[i].actual, ARRIVAL_TIME_LENGTH, "%d:%02d", time / 60, abs(time % 60));
	    } else {
	    	snprintf(ARRIVALS[i].actual, ARRIVAL_TIME_LENGTH, "%d", time % 60);
	    }

	    time = satoi(ARRIVALS[i].scheduled, strlen(ARRIVALS[i].scheduled));

        if(abs(time) > 99*60 + 59) //Maximum displayable value.
        	time = (99*60 + 59) * (time < 0 ? -1 : 1);

        if(time > 60 || time < -60) {
	        snprintf(ARRIVALS[i].scheduled, ARRIVAL_TIME_LENGTH, "%d:%02d", time / 60, abs(time % 60));
	    } else {
	    	snprintf(ARRIVALS[i].scheduled, ARRIVAL_TIME_LENGTH, "%d", time % 60);
	    }

        APP_LOG(APP_LOG_LEVEL_INFO, "Received route:%s actual:%s scheduled:%s (index:%d/%d)", ARRIVALS[i].route, ARRIVALS[i].actual, ARRIVALS[i].scheduled, index, len);
        ++arrivalsCount;
    }

    menu_layer_reload_data(&_arrivalsMenu);
    menu_layer_set_selected_index(&_arrivalsMenu, top, MenuRowAlignBottom, false);

}
コード例 #8
0
ファイル: T10_SW.c プロジェクト: swoiwode/pebble-t10
static void hand_layer_update( Layer * const me, GContext * ctx )
{
    ( void ) me;
    
    // Draw the hour hand outline in black and filled with white
    int hour_angle = ( ( now.tm_hour * 60 + now.tm_min ) * TRIG_MAX_ANGLE ) / ( 60 * 24 );    
    
    gpath_rotate_to(&hour_path, hour_angle);
    graphics_context_set_fill_color(ctx, GColorWhite);
    gpath_draw_filled(ctx, &hour_path);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    gpath_draw_outline(ctx, &hour_path);

    // Draw the minute hand outline in black and filled with white
    int minute_angle = ( now.tm_min * TRIG_MAX_ANGLE ) / 60;
    
    gpath_rotate_to(&minute_path, minute_angle);
    graphics_context_set_fill_color(ctx, GColorWhite);
    gpath_draw_filled(ctx, &minute_path);
    graphics_context_set_stroke_color(ctx, GColorBlack);
    gpath_draw_outline(ctx, &minute_path);
    
    // Draw the second hand outline in black and filled with white
    int second_angle = ( now.tm_sec * TRIG_MAX_ANGLE ) / 60;
    
    gpath_rotate_to( &second_path, second_angle );
    graphics_context_set_fill_color( ctx, GColorWhite );
    gpath_draw_filled( ctx, &second_path );
    graphics_context_set_stroke_color( ctx, GColorBlack );
    gpath_draw_outline(ctx, &second_path);

    // Black circle over the hands.  Looks nice.
    graphics_context_set_fill_color( ctx, GColorBlack );
    graphics_fill_circle( ctx, GPoint( W / 2, H / 2 ), 30);

    // Put some date info in the center space.
    graphics_context_set_text_color( ctx, GColorWhite );
    string_format_time( buffer, sizeof( buffer ), "%a", &now );
    graphics_text_draw( ctx,
                        buffer,
                        font_date,
                        GRect( W / 2 - 30, H / 2 - 30, 60, 24 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );

    string_format_time( buffer, sizeof( buffer ), "%m/%d", &now );
    graphics_text_draw( ctx,
                        buffer,
                        font_date,
                        GRect( W / 2 - 30 , H / 2 - 8, 60, 24 ),
                        GTextOverflowModeTrailingEllipsis,
                        GTextAlignmentCenter,
                        NULL
                       );
}
コード例 #9
0
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) 
{
  (void)t;
  (void)ctx;

  // Need to be static because they're used by the system later.
  static char time_text[] = "00:00";
  static char dom_text[] = "00";
	string_format_time(dom_text, sizeof(dom_text), "%e", t->tick_time);	
  static char dow_text[] = "xxx";
	string_format_time(dow_text, sizeof(dow_text), "%a", t->tick_time);	
  static char yon_text[] = "00";
	string_format_time(yon_text, sizeof(yon_text), "%y", t->tick_time);	
  static char mon_text[] = "xxx";
	string_format_time(mon_text, sizeof(mon_text), "%b", t->tick_time);	

  char *time_format;

  if (clock_is_24h_style()) 
  {
    time_format = "%R";
  } 
  else 
  {
    time_format = "%I:%M";
  }

  string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

  if (!clock_is_24h_style() && (time_text[0] == '0')) 
  {
    memmove(time_text, &time_text[1], sizeof(time_text) - 1);
  }

  text_layer_set_text(&dow_layer, dow_text);
  text_layer_set_text(&dom_layer, dom_text);
  text_layer_set_text(&yon_layer, yon_text);
  text_layer_set_text(&mon_layer, mon_text);
  
  text_layer_set_text(&text_time_layer, time_text);
  text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter);

  rotbmp_pair_layer_set_angle(&bitmap_container.layer, TRIG_MAX_ANGLE * get24HourAngle(t->tick_time->tm_hour, t->tick_time->tm_min));
  bitmap_container.layer.layer.frame.origin.x = (144/2) - (bitmap_container.layer.layer.frame.size.w/2);
  bitmap_container.layer.layer.frame.origin.y = (168/2) - (bitmap_container.layer.layer.frame.size.h/2);

// Vibrate Every Hour
  #if HOUR_VIBRATION
	 
    if ((t->tick_time->tm_min==0) && (t->tick_time->tm_sec==0))
	{
	vibes_enqueue_custom_pattern(hour_pattern);
    }
  #endif
  
  updateDayAndNightInfo(false);
}
コード例 #10
0
void updateDayAndNightInfo()
{
  static char sunrise_text[] = "00:00";
  static char sunset_text[] = "00:00";
  

  PblTm pblTime;
  get_time(&pblTime);

  if(currentData != pblTime.tm_hour) 
  {
    moonphase_text[0] = 'a' + 26.0f * moon_phase(1900 + pblTime.tm_year,  1 + pblTime.tm_mon, pblTime.tm_mday);
  
    char *time_format;

    if (clock_is_24h_style()) 
    {
      time_format = "%R";
    } 
    else 
    {
      time_format = "%I:%M";
    }

    float sunriseTime = calcSunRise(pblTime.tm_year, pblTime.tm_mon+1, pblTime.tm_mday, LATITUDE, LONGITUDE, 91.0f);
    float sunsetTime = calcSunSet(pblTime.tm_year, pblTime.tm_mon+1, pblTime.tm_mday, LATITUDE, LONGITUDE, 91.0f);
    adjustTimezone(&sunriseTime);
    adjustTimezone(&sunsetTime);
    
    if (!pblTime.tm_isdst) 
    {
      sunriseTime+=1;
      sunsetTime+=1;
    } 
    
    pblTime.tm_min = (int)(60*(sunriseTime-((int)(sunriseTime))));
    pblTime.tm_hour = (int)sunriseTime;
    string_format_time(sunrise_text, sizeof(sunrise_text), time_format, &pblTime);
    text_layer_set_text(&text_sunrise_layer, sunrise_text);
    
    pblTime.tm_min = (int)(60*(sunsetTime-((int)(sunsetTime))));
    pblTime.tm_hour = (int)sunsetTime;
    string_format_time(sunset_text, sizeof(sunset_text), time_format, &pblTime);
    text_layer_set_text(&text_sunset_layer, sunset_text);
    text_layer_set_text_alignment(&text_sunset_layer, GTextAlignmentRight);

    sunriseTime+=12.0f;
    sun_path_info.points[1].x = (int16_t)(my_sin(sunriseTime/24 * M_PI * 2) * 120);
    sun_path_info.points[1].y = -(int16_t)(my_cos(sunriseTime/24 * M_PI * 2) * 120);

    sunsetTime+=12.0f;
    sun_path_info.points[4].x = (int16_t)(my_sin(sunsetTime/24 * M_PI * 2) * 120);
    sun_path_info.points[4].y = -(int16_t)(my_cos(sunsetTime/24 * M_PI * 2) * 120);
  
    currentData = pblTime.tm_hour;
  }
}
コード例 #11
0
void update_time_text(PblTm *current_time) {
  static char time_text[] = "00:00";
  if(clock_is_24h_style())
    string_format_time(time_text, sizeof(time_text), "%R", current_time);
  else
    string_format_time(time_text, sizeof(time_text), "%I:%M", current_time);
  text_layer_set_text(&time_layer, time_text);
  display_time.tm_min = current_time->tm_min;
}
コード例 #12
0
void handle_tick(AppContextRef ctx, PebbleTickEvent *t)
{
    (void)ctx;

    // If we were passed an event, then we should already have the current
    // time. If not, then we're probably being called from handle_init, so
    // we need to get it.
    if(t)
        pebble_time = *t->tick_time;
    else
        get_time(&pebble_time);

    // If digital readout is on, then print the time:
    if(digital_time) {

        // Format the time with the chosed time format
        string_format_time(time_text, sizeof(time_text), time_format, &pebble_time);

        // Replace the leading zero with blank if we're in 12h mode.
        if ((!is_24h) && (time_text[0] == '0')) {
            time_text[0] = ' ';
        }

        // And set it for display. This should automatically mark the
        // layer as dirty.
        text_layer_set_text(&time_layer, time_text);
    }

    // If we're displaying the date (ie. !big), update the date string
    // every hour, and also on initialisation.
    if(!big) {
        if(!t || (pebble_time.tm_sec == 0 && pebble_time.tm_min == 0)) {
            string_format_time(date_text, sizeof(date_text), "%a %e %b", &pebble_time);
            text_layer_set_text(&date_layer, date_text);
        }
    }

    // If we're displaying a second-hand, then mark the second-hand layer
    // as dirty for redrawing.
    if(seconds) {
        layer_mark_dirty(&sechand_layer);
    }

    // Update the hour/minute hands, if:
    //
    //   a) !t, in which case, we're being called from handle_init, so
    //      need to do the initial update;
    //
    //   b) Current seconds = 0 (ie. we're on the minute); or
    //
    //   c) Display of seconds is not enabled, which implies this event
    //      handler is running every minute anyway.
    if (!seconds || (pebble_time.tm_sec == 0)) {
        layer_mark_dirty(&hmhands_layer);
    }
}
コード例 #13
0
void update_date_text(PblTm *current_time) {
  static char date_text[] = "Xxxxxxxxx 00";
  if(current_time->tm_wday == 3)
    // "Wednesday" doesn't fit on the screen so just show "Wed"
    string_format_time(date_text, sizeof(date_text), "%a %e", current_time);
  else
    string_format_time(date_text, sizeof(date_text), "%A %e", current_time);
  text_layer_set_text(&date_layer, date_text);
  display_time.tm_mday = current_time->tm_mday;
}
コード例 #14
0
ファイル: polar_clock.c プロジェクト: culverg/polar5arc
void handle_second_tick(AppContextRef ctx, PebbleTickEvent *t) {

  (void)ctx;

  layer_mark_dirty(&second_display_layer);
  layer_mark_dirty(&minute_display_layer);
  layer_mark_dirty(&hour_display_layer);
	
  #if SHOW_DAY_ARC
	  layer_mark_dirty(&day_display_layer);
  #endif
	  
  #if SHOW_MONTH_ARC
	  layer_mark_dirty(&month_display_layer);
  #endif
	  
  #if SHOW_TEXT_TIME

  // Need to be static because it's used by the system later.
  static char time_text[] = "00:00";

  char *time_format;

  if (clock_is_24h_style()) {
    time_format = "%R";
  } else {
    time_format = "%I:%M";
  }

  string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

  text_layer_set_text(&text_time_layer, time_text);

  #endif

  #if SHOW_TEXT_DATE
  
    /*
	#if ROW_DATE
    static char date_text[] = "00 Xxx";
    string_format_time(date_text, sizeof(date_text), "%e %b", t->tick_time);
    #else
    static char date_text[] = "Xxx 00";
    string_format_time(date_text, sizeof(date_text), "%b %e", t->tick_time);
    #endif
	*/
    static char date_text[] = "00";
    string_format_time(date_text, sizeof(date_text), "%e", t->tick_time);
      
  text_layer_set_text(&text_date_layer, date_text);

  #endif

}
コード例 #15
0
ファイル: main.c プロジェクト: Niknam/futura-time
/* Called by the OS once per minute. Update the time and date.
*/
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t)
{
    /* Need to be static because pointers to them are stored in the text
    * layers.
    */
    static char date_text[] = "XXX 00";
    static char hour_text[] = "00";
    static char minute_text[] = ":00";

    (void)ctx;  /* prevent "unused parameter" warning */

    if (t->units_changed & DAY_UNIT)
    {		
	    string_format_time(date_text,
                           sizeof(date_text),
                           "%a %d",
                           t->tick_time);

		if (date_text[4] == '0') /* is day of month < 10? */
		{
		    /* This is a hack to get rid of the leading zero of the
			   day of month
            */
            memmove(&date_text[4], &date_text[5], sizeof(date_text) - 1);
		}
        text_layer_set_text(&date_layer, date_text);
    }

    if (clock_is_24h_style())
    {
        string_format_time(hour_text, sizeof(hour_text), "%H", t->tick_time);
		if (hour_text[0] == '0')
        {
            /* This is a hack to get rid of the leading zero of the hour.
            */
            memmove(&hour_text[0], &hour_text[1], sizeof(hour_text) - 1);
        }
    }
    else
    {
        string_format_time(hour_text, sizeof(hour_text), "%I", t->tick_time);
        if (hour_text[0] == '0')
        {
            /* This is a hack to get rid of the leading zero of the hour.
            */
            memmove(&hour_text[0], &hour_text[1], sizeof(hour_text) - 1);
        }
    }

    string_format_time(minute_text, sizeof(minute_text), ":%M", t->tick_time);
    time_layer_set_text(&time_layer, hour_text, minute_text);
	
}
コード例 #16
0
// --------------------------------------------------------
//           date_update_proc()
//
//   callback handler supplied to system during init
// --------------------------------------------------------
void date_update_proc(Layer* me, GContext* ctx) {

  PblTm t;
  get_time(&t);

  string_format_time(s_data.day_buffer, sizeof(s_data.day_buffer), "%a", &t);
  text_layer_set_text(&s_data.day_label, s_data.day_buffer);

  string_format_time(s_data.num_buffer, sizeof(s_data.num_buffer), "%d", &t);
  text_layer_set_text(&s_data.num_label, s_data.num_buffer);

}  // date_update_proc()
コード例 #17
0
ファイル: BN0046.c プロジェクト: ryck/BN0046_SDK1.0
void update_display_month(PblTm *tick_time) {
  // Month or Weekday
  static char month_text[] = "AAA";

  #if (WEEKDAY_US_MM_DD || WEEKDAY_NON_US_DD_MM) // Show Weekday (3 letter abbrev)
      string_format_time(month_text, sizeof(month_text), "%a", tick_time);
  #else // Show Month (3 letter abbrev)
      string_format_time(month_text, sizeof(month_text), "%b", tick_time);
  #endif

  text_layer_set_text(&month, month_text);
}
コード例 #18
0
ファイル: main.c プロジェクト: wisnij/isochron
void update_display( PblTm* current_time )
{
    static char time_text[] = "HH:MM";
    static char date_text[] = "AAAAAAAAA\nbbb dd, YYYY";
    static char iso_text[]  = "YYYY-mm-dd\nYYYY-WVV-u\nYYYY-jjj";
    
    string_format_time( time_text, sizeof time_text, "%H:%M", current_time );
    string_format_time( date_text, sizeof date_text, "%A\n%b %d, %Y", current_time );
    string_format_time( iso_text,  sizeof iso_text,  "%Y-%m-%d\n%Y-W%V-%u\n%Y-%j", current_time );
    
    text_layer_set_text( &text_time_layer, time_text );
    text_layer_set_text( &text_date_layer, date_text );
    text_layer_set_text( &text_iso_layer,  iso_text );
}
コード例 #19
0
ファイル: roboto.c プロジェクト: sdl2147/pebble-robotoweather
/* Called by the OS once per minute. Update the time and date.
*/
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t)
{
    /* Need to be static because pointers to them are stored in the text
    * layers.
    */
    static char date_text[] = "XXX, XXX 00";
    static char hour_text[] = "00";
    static char minute_text[] = ":00";

    (void)ctx;  /* prevent "unused parameter" warning */

    if (t->units_changed & DAY_UNIT)
    {
        string_format_time(date_text,
                           sizeof(date_text),
                           "%a, %b %d",
                           t->tick_time);
        text_layer_set_text(&date_layer, date_text);
    }

    if (clock_is_24h_style())
    {
        string_format_time(hour_text, sizeof(hour_text), "%H", t->tick_time);
    }
    else
    {
        string_format_time(hour_text, sizeof(hour_text), "%I", t->tick_time);
        if (hour_text[0] == '0')
        {
            /* This is a hack to get rid of the leading zero.
            */
            memmove(&hour_text[0], &hour_text[1], sizeof(hour_text) - 1);
        }
    }

    string_format_time(minute_text, sizeof(minute_text), ":%M", t->tick_time);
    time_layer_set_text(&time_layer, hour_text, minute_text);
	
	if(!located || !(t->tick_time->tm_min % 15))
	{
		//Every 15 minutes, request updated weather
		http_location_request();
	}
	else
	{
		//Every minute, ping the phone
		link_monitor_ping();
	}
}
コード例 #20
0
ファイル: lively.c プロジェクト: edwardhotchkiss/Lively
// handles setting time updates
void update_time(AppContextRef ctx, PblTm *current_time) {
  char *time_format;
  // set date
  string_format_time(date_text, sizeof(date_text), "%b %d", current_time);
  text_layer_set_text(&date_text_layer, date_text);
  // check military time
  if (clock_is_24h_style()) {
    time_format = "%R";
  } else {
    time_format = "%I:%M";
  }
  // set time
  string_format_time(time_text, sizeof(time_text), time_format, current_time);
  text_layer_set_text(&time_text_layer, time_text);
}
コード例 #21
0
ファイル: main.c プロジェクト: savagejen/MoogleTime
//Draws the hours and minutes
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {

    (void)ctx;

    static char hours_text[] = "    00 00";
    static char minutes_text[] = "    00 00";

    char *minutes_format;
    char *hours_format;

    minutes_format = "MP  %M/59";
    if (clock_is_24h_style()) {
        hours_format = "HP  %H/23";
    } else {
        hours_format = "HP  %I/12";
    }

    string_format_time(hours_text, sizeof(hours_text), hours_format, t->tick_time);
    string_format_time(minutes_text, sizeof(minutes_text), minutes_format, t->tick_time);

    if (t->tick_time->tm_hour>0&&t->tick_time->tm_hour<6&&current_background!=2) {
        //Moogle is asleep
        set_background_image(&image_container,RESOURCE_ID_IMAGE_MOG_DEAD_WHITE);
        current_background=2;

    }
    if (t->tick_time->tm_hour>6&&t->tick_time->tm_hour<9&&current_background!=1) {
        //Moogle is groggy
        set_background_image(&image_container,RESOURCE_ID_IMAGE_MOG_HURT_WHITE);
        current_background=1;

    }
    if (t->tick_time->tm_hour>9&&t->tick_time->tm_hour<21&&current_background!=0) {
        //Moogle is awake
        set_background_image(&image_container,RESOURCE_ID_IMAGE_MOG_OK_WHITE);
        current_background=0;

    }
    if (t->tick_time->tm_hour>21&&t->tick_time->tm_hour<24&&current_background!=1) {
        //Moogle is tired
        set_background_image(&image_container,RESOURCE_ID_IMAGE_MOG_HURT_WHITE);
        current_background=1;
    }

    text_layer_set_text(&text_hours_layer, hours_text);
    text_layer_set_text(&text_minutes_layer, minutes_text);

}
コード例 #22
0
ファイル: hebwatch.c プロジェクト: rosenbergj/pebble_hebwatch
void handle_tick(AppContextRef app_ctx, PebbleTickEvent *event) {
    float fracthour = event->tick_time->tm_hour + (event->tick_time->tm_min * 1.0 / 60) + (event->tick_time->tm_sec * 1.0 / 3600) - 1;
    double jc = julian_century(event->tick_time->tm_year + 1900, event->tick_time->tm_mon+1, event->tick_time->tm_mday, fracthour);
  /*  h_m_chelek_string(jc, hour_count_start, hour_count_end, s_time_str_buffer);*/
  string_format_time(s_time_str_buffer, 32, "%I:%M:%S %p", event->tick_time);
  text_layer_set_text(&normaltime, s_time_str_buffer);
}
コード例 #23
0
ファイル: modern.c プロジェクト: BUSHA/pebble
void draw_date(){
  PblTm t;
  get_time(&t);
  
  string_format_time(date_text, sizeof(date_text), "%d", &t);
  text_layer_set_text(&date_layer, date_text);
}
コード例 #24
0
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
    
    (void)ctx;
    
    // Need to be static because they're used by the system later.
    static char time_text[] = "00:00";
    
    char *time_format;
    
    if (clock_is_24h_style()) {
        time_format = "%R";
    } else {
        time_format = "%I:%M";
    }
    
    string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);
    
    // Kludge to handle lack of non-padded hour format string
    // for twelve hour clock.
    if (!clock_is_24h_style() && (time_text[0] == '0')) {
        memmove(time_text, &time_text[1], sizeof(time_text) - 1);
    }
    
    text_layer_set_text(&text_time_layer, time_text);
    layer_mark_dirty(&text_time_layer.layer);
}
コード例 #25
0
ファイル: tic_tock_toe.c プロジェクト: 343max/pebblekit
void update_time_display() {
  static char timeText[] = "00:00";

  char *timeFormat;

  PblTm currentTime;

  GContext* ctx = app_get_current_graphics_context();
#ifdef INVERT_COLORS
  graphics_context_set_compositing_mode(ctx, GCompOpAssignInverted);
#endif

  if (clock_is_24h_style()) {
    timeFormat = "%R";
  } else {
    timeFormat = "%I:%M";
  }

  get_time(&currentTime);

  string_format_time(timeText, sizeof(timeText), timeFormat, &currentTime);

  // Kludge to handle lack of non-padded hour format string
  // for twelve hour clock.
  if (!clock_is_24h_style() && (timeText[0] == '0')) {
    memmove(timeText, &timeText[1], sizeof(timeText) - 1);
  }

  text_layer_set_text(&timeLayer, timeText);
}
コード例 #26
0
void update_watch(PblTm* t) {

    static char date_text[] = "XXXXXXXX, XXX 00";

    //rotbmp_pair_layer_set_angle(&hour_hand_image_container.layer, ((t->tm_hour % 12) * 30) + (t->tm_min/2));
    hour_hand_image_container.layer.white_layer.rotation = TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 30) + (t->tm_min/2)) / 360;
    hour_hand_image_container.layer.black_layer.rotation = TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 30) + (t->tm_min/2)) / 360;
    hour_hand_image_container.layer.layer.frame.origin.x = (144/2) - (hour_hand_image_container.layer.layer.frame.size.w/2);
    hour_hand_image_container.layer.layer.frame.origin.y = (168/2) - (hour_hand_image_container.layer.layer.frame.size.h/2);
    layer_mark_dirty(&hour_hand_image_container.layer.layer);

    //rotbmp_pair_layer_set_angle(&minute_hand_image_container.layer, t->tm_min * 6);
    minute_hand_image_container.layer.white_layer.rotation = TRIG_MAX_ANGLE * (t->tm_min * 6) / 360;
    minute_hand_image_container.layer.black_layer.rotation = TRIG_MAX_ANGLE * (t->tm_min * 6) / 360;
    minute_hand_image_container.layer.layer.frame.origin.x = (144/2) - (minute_hand_image_container.layer.layer.frame.size.w/2);
    minute_hand_image_container.layer.layer.frame.origin.y = (168/2) - (minute_hand_image_container.layer.layer.frame.size.h/2);
    layer_mark_dirty(&minute_hand_image_container.layer.layer);

    //Set Date text
    if (t->tm_wday != last_wday)
    {
        string_format_time(date_text, sizeof(date_text), "%A, %b %e", t);
        text_layer_set_text(&text_date_layer, date_text);

        last_wday = t->tm_wday;
    }

}
コード例 #27
0
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
	(void)ctx;

	static char time_text[] = "00:00";
	char *time_format;

	//Time
	if (clock_is_24h_style()) {
		time_format = "%R";
	} else {
		time_format = "%I:%M";
	}

	string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

	if (!clock_is_24h_style() && (time_text[0] == '0')) {
		memmove(time_text, &time_text[1], sizeof(time_text) - 1);
	}

	text_layer_set_text(&text_time_layer, time_text);

	//Redraw layer
	layer_mark_dirty(&main_layer);
	
	Minutes_Open++;
}
コード例 #28
0
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) 
{
  (void)t;
  (void)ctx;

  // Need to be static because they're used by the system later.
  static char time_text[] = "00:00";

  char *time_format;

  if (clock_is_24h_style()) 
  {
    time_format = "%R";
  } 
  else 
  {
    time_format = "%I:%M";
  }

  string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

  if (!clock_is_24h_style() && (time_text[0] == '0')) 
  {
    memmove(time_text, &time_text[1], sizeof(time_text) - 1);
  }

  text_layer_set_text(&text_time_layer, time_text);
  text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter);

  rotbmp_pair_layer_set_angle(&bitmap_hour_container.layer, TRIG_MAX_ANGLE * get24HourAngle(t->tick_time->tm_hour, t->tick_time->tm_min));
  bitmap_hour_container.layer.layer.frame.origin.x = (144/2) - (bitmap_hour_container.layer.layer.frame.size.w/2);
  bitmap_hour_container.layer.layer.frame.origin.y = (168/2) - (bitmap_hour_container.layer.layer.frame.size.h/2);

  updateDayAndNightInfo();
}
コード例 #29
0
void handle_minute_tick(AppContextRef ctx, PebbleTickEvent *t) {
	(void)t;
  (void)ctx;

  // Need to be static because they're used by the system later.
  static char time_text[] = "00:00";
  static char date_text[] = "00 Xxxxxxxxx";

  char *time_format;


  // TODO: Only update the date when it's changed.
  string_format_time(date_text, sizeof(date_text), "%e %B", t->tick_time);
  text_layer_set_text(&text_date_layer, date_text);


  if (clock_is_24h_style()) {
    time_format = "%R";
  } else {
    time_format = "%I:%M";
  }

  string_format_time(time_text, sizeof(time_text), time_format, t->tick_time);

  // Kludge to handle lack of non-padded hour format string
  // for twelve hour clock.
  if (!clock_is_24h_style() && (time_text[0] == '0')) {
    memmove(time_text, &time_text[1], sizeof(time_text) - 1);
  }

  text_layer_set_text(&text_time_layer, time_text);
	if(t->tick_time->tm_min%2==0) {
		layer_mark_dirty(&hour_display_layer);
	}
	layer_mark_dirty(&minute_display_layer);
	
	// Vibrate Every Five Minutes
  //#if HOUR_VIBRATION
         
    if ((t->tick_time->tm_min % 5 == 0 ) && (t->tick_time->tm_sec==0))
    {
        //vibes_enqueue_custom_pattern(hour_pattern);
		vibes_double_pulse();	
    }

  //#endif
}
コード例 #30
0
ファイル: ppf.c プロジェクト: saulricardo/PPF
void update_time_display() {
  static char timePast[] = "00:00";
  static char timePresent[] = "00:00";
  static char timeFuture[] = "00:00";
  char *timeFormat;

  PblTm currentTime;
  PblTm pastTime;
  PblTm futureTime;
  
    timeFormat = "%I:%M";
  //get pebble Time
  get_time(&currentTime);
  get_time(&pastTime);
  get_time(&futureTime);
  
  if(currentTime.tm_min == 0){
 	 pastTime.tm_min = 59;
 	 pastTime.tm_hour = pastTime.tm_hour - 1;
  } else{
    pastTime.tm_min = pastTime.tm_min - 1;
  }
  if(currentTime.tm_min == 59){
 	 futureTime.tm_min = 0;
 	 futureTime.tm_hour = futureTime.tm_hour + 1;
  } else {
    futureTime.tm_min = futureTime.tm_min + 1;
  }
  string_format_time(timePast, sizeof(timePast), timeFormat, &pastTime);
  string_format_time(timePresent, sizeof(timePresent), timeFormat, &currentTime);
  string_format_time(timeFuture, sizeof(timeFuture), timeFormat, &futureTime);

  if (!clock_is_24h_style() && (timePast[0] == '0')) {
    memmove(timePast, &timePast[1], sizeof(timePast) - 1);
  }
  if (!clock_is_24h_style() && (timePresent[0] == '0')) {
    memmove(timePresent, &timePresent[1], sizeof(timePresent) - 1);
  }
  if (!clock_is_24h_style() && (timeFuture[0] == '0')) {
    memmove(timeFuture, &timeFuture[1], sizeof(timeFuture) - 1);
  }

  text_layer_set_text(&timePastLayer, timePast);
  text_layer_set_text(&timePresentLayer, timePresent);
  text_layer_set_text(&timeFutureLayer, timeFuture);

}