Ejemplo n.º 1
0
static void update_triangle_proc(Layer *layer, GContext *ctx) {
  if(!s_spinning) {
    return;
  }
  
  // Move
  int32_t move_x = (int32_t)(sin_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO);
  int32_t move_y = (int32_t)(-cos_lookup(angle) * (RADIUS - 4) / TRIG_MAX_RATIO);
  gpath_move_to(s_spin_arrow_path, GPoint(s_spin_circle_center.x - move_x, s_spin_circle_center.y + move_y));
  
  if(TESTING){
    APP_LOG(APP_LOG_LEVEL_DEBUG, "move_x: %d", (int)move_x);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "move_y: %d", (int)move_y);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "angle: %d", (int)TRIGANGLE_TO_DEG(angle));
  }
  
  // Rotate
  gpath_rotate_to(s_spin_triangle_path, -angle);
  gpath_rotate_to(s_spin_arrow_path, -angle);
  
  // Fill the path:
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, s_spin_triangle_path);
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_draw_filled(ctx, s_spin_arrow_path);
}
Ejemplo n.º 2
0
static void hands_layer_update_callback(Layer *layer, GContext* ctx) {

  GPoint center = GPoint(CENTER_X, CENTER_Y);

// hours and minutes
//  int32_t hour_angle = TRIG_MAX_ANGLE * (now->tm_hour * 5 + now->tm_min / 12) / 60;
  int32_t hour_angle = (TRIG_MAX_ANGLE * (((hour % 12) * 6) + (min / 10))) / (12 * 6);
  int32_t min_angle = TRIG_MAX_ANGLE * min / 60;
  gpath_rotate_to(hour_path, hour_angle);
  gpath_rotate_to(hour_in_path, hour_angle);
  gpath_rotate_to(min_path, min_angle);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, hour_path);
  gpath_draw_outline(ctx, hour_path);
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, hour_in_path);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_draw_circle(ctx, center, DOTS_SIZE+4);
  gpath_draw_filled(ctx, min_path);
  gpath_draw_outline(ctx, min_path);
  graphics_fill_circle(ctx, center, DOTS_SIZE+3);

  // center dot
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_circle(ctx, center, DOTS_SIZE);
}
Ejemplo n.º 3
0
static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  const int16_t second_hand_length = PBL_IF_ROUND_ELSE((bounds.size.w / 2) - 19, bounds.size.w / 2);

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  // minute/hour hand
  // 時
  graphics_context_set_stroke_color(ctx, s_backColor);

  graphics_context_set_fill_color(ctx, s_hourHandColor);
  gpath_rotate_to(s_hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, s_hour_arrow);
  // 分
  graphics_context_set_fill_color(ctx, s_backColor);
  gpath_rotate_to(s_minute_arrow, (TRIG_MAX_ANGLE * (t->tm_min * 10 + (t->tm_sec/6)) / (60 * 10)));
  graphics_context_set_stroke_width(ctx, 2);
  graphics_context_set_stroke_color(ctx, s_minuteHandColor);
  gpath_draw_outline(ctx, s_minute_arrow);

  // 秒
  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  GPoint second_hand = {
    .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y,
  };
if (s_show_seconds_hand){
    // second hand
    graphics_context_set_stroke_width(ctx, 3);
    graphics_context_set_stroke_color(ctx, s_secondHandColor);
    graphics_draw_line(ctx, second_hand, center);
    graphics_context_set_stroke_width(ctx, 1);
    graphics_context_set_stroke_color(ctx, s_backColor);
    graphics_draw_line(ctx, second_hand, center);
  }
  // dot in the middle
  // 黒に設定
  graphics_context_set_fill_color(ctx, s_backColor);
  // 円を塗り潰し
  graphics_fill_circle(ctx, center, 7);
  // 線の色を白に設定
  graphics_context_set_stroke_color(ctx, s_secondHandColor);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, center, 7);
  graphics_draw_circle(ctx, center, 1);
  
}

static void date_update_proc(Layer *layer, GContext *ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  strftime(s_day_buffer, sizeof(s_day_buffer), "%a", t);
  text_layer_set_text(s_day_label, s_day_buffer);

  strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t);
  text_layer_set_text(s_num_label, s_num_buffer);
}
Ejemplo n.º 4
0
static void hands_update_proc(Layer *layer, GContext *hands_ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  
  graphics_context_set_fill_color(hands_ctx, GColorDukeBlue);

  gpath_rotate_to(minute_arrow_path, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_draw_filled(hands_ctx, minute_arrow_path);
  gpath_draw_outline(hands_ctx, minute_arrow_path);

  gpath_rotate_to(hour_arrow_path, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(hands_ctx, hour_arrow_path);
  gpath_draw_outline(hands_ctx, hour_arrow_path);

  // dot in the middle
  GRect hands_bounds = layer_get_bounds(s_hands_layer);

    if (BTConnected == 1) {
       graphics_context_set_text_color(hands_ctx, GColorDukeBlue);
       graphics_context_set_fill_color(hands_ctx, GColorYellow);
    } else {
       graphics_context_set_text_color(hands_ctx, GColorWhite);
       graphics_context_set_fill_color(hands_ctx, GColorRed);
    }  

  graphics_fill_circle(hands_ctx, GPoint(hands_bounds.size.w / 2, hands_bounds.size.h / 2), 13);
  #ifdef PBL_PLATFORM_BASALT
      graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(61, 72, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
  #else   //  PEBBLE_PLATFORM_CHALK
      graphics_draw_text(hands_ctx, day_text, fontRobotoCondensed19, GRect(78, 78, 24, 24), GTextOverflowModeWordWrap, GTextAlignmentCenter, NULL);
  #endif

}
Ejemplo n.º 5
0
static void hands_update_proc(Layer* me, GContext* ctx) {
  const GPoint center = grect_center_point(&me->bounds);
  const int16_t secondHandLength = me->bounds.size.w / 2;

  GPoint secondHand;

  PblTm t;
  get_time(&t);

  int32_t second_angle = TRIG_MAX_ANGLE * t.tm_sec / 60;
  secondHand.y = (int16_t)(-cos_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.y;
  secondHand.x = (int16_t)(sin_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.x;

  // second hand
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_draw_line(ctx, secondHand, center);

  // minute/hour hand
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorBlack);

  gpath_rotate_to(&s_data.minute_arrow, TRIG_MAX_ANGLE * t.tm_min / 60);
  gpath_draw_filled(ctx, &s_data.minute_arrow);
  gpath_draw_outline(ctx, &s_data.minute_arrow);

  gpath_rotate_to(&s_data.hour_arrow, (TRIG_MAX_ANGLE * (((t.tm_hour % 12) * 6) + (t.tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, &s_data.hour_arrow);
  gpath_draw_outline(ctx, &s_data.hour_arrow);

  // dot in the middle
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, GRect(me->bounds.size.w / 2-1, me->bounds.size.h / 2-1, 3, 3), 0, GCornerNone);
}
Ejemplo n.º 6
0
static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  const GPoint center = grect_center_point(&bounds);
  const int16_t secondHandLength = bounds.size.w / 2;

  GPoint secondHand;

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  secondHand.y = (int16_t)(-cos_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.y;
  secondHand.x = (int16_t)(sin_lookup(second_angle) * (int32_t)secondHandLength / TRIG_MAX_RATIO) + center.x;

  // second hand
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_draw_line(ctx, secondHand, center);

  // minute/hour hand
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_color(ctx, GColorBlack);

  gpath_rotate_to(minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_draw_filled(ctx, minute_arrow);
  gpath_draw_outline(ctx, minute_arrow);

  gpath_rotate_to(hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, hour_arrow);
  gpath_draw_outline(ctx, hour_arrow);

  // dot in the middle
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, GRect(bounds.size.w / 2 - 1, bounds.size.h / 2 - 1, 3, 3), 0, GCornerNone);
}
Ejemplo n.º 7
0
void minute_display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;
  get_time(&t);
  unsigned int angle = t.tm_min * 6;
  unsigned int hr_angle = (t.tm_min / 5) *30;	
  GPoint center = grect_center_point(&me->frame);

  // minute background white
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_circle(ctx, center, 72);

  // five minute sector black 
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_rotate_to(&minute5_segment_path, (TRIG_MAX_ANGLE / 360) * hr_angle);  
  gpath_draw_filled(ctx, &minute5_segment_path);
	
  // minute sector white	
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_rotate_to(&minute_segment_path, (TRIG_MAX_ANGLE / 360) * angle);	
  gpath_draw_filled(ctx, &minute_segment_path);
  
  // minute markers black	
  graphics_context_set_stroke_color(ctx, GColorBlack);	  
  for (unsigned int i = 0; i < 360; i+=30) {
      gpath_rotate_to(&minute_marker_path, (TRIG_MAX_ANGLE / 360) * i);
      gpath_draw_outline(ctx, &minute_marker_path);
  }

  // black out outer ring	
  graphics_context_set_stroke_color(ctx, GColorBlack);	
  graphics_draw_circle(ctx, center, 73); 	
  graphics_draw_circle(ctx, center, 74); 	
}
Ejemplo n.º 8
0
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
                       );
}
Ejemplo n.º 9
0
static void tick_minute_handler(struct tm *tick_time, TimeUnits units_changed) {
	// Write the current hours and minutes into a buffer
    static char time_buffer[2];
    time_buffer[1] = '\0';
    time_buffer[0] = chinese_numbers[tick_time->tm_hour % 12];
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Hour is: %s", time_buffer);
    
    gpath_rotate_to(hand_path_hr, TRIG_MAX_ANGLE * ((tick_time->tm_hour % 12)*60 + tick_time->tm_min) / (12 * 60));
    gpath_rotate_to(hand_path_min, TRIG_MAX_ANGLE * tick_time->tm_min / 60);
    layer_mark_dirty(hand_layer);
}
Ejemplo n.º 10
0
void tick_handler(struct tm *tick_time, TimeUnits units_changed){
	//update digital clock
	strftime(buffer, sizeof("00:00"), "%H:%M", tick_time);
	strftime(date_buffer, sizeof("00"), "%d", tick_time);
	text_layer_set_text(text_layer, buffer);
	text_layer_set_text(date_layer, date_buffer);

	//update analog clock
	gpath_rotate_to(hour_path, (TRIG_MAX_ANGLE/360)*(((tick_time->tm_hour)*30)+((tick_time->tm_min)*0.5)));
	gpath_move_to(hour_path, (GPoint){72, 84});
	gpath_rotate_to(minute_path, (TRIG_MAX_ANGLE/360)*((tick_time->tm_min)*6));
	gpath_move_to(minute_path, (GPoint){72, 84});
}
static void analog_update_proc(Layer *layer, GContext *ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  // Draw ticks behind
  draw_ticks(layer, ctx);

  // minute/hour hand
  graphics_context_set_compositing_mode(ctx, GCompOpSet);
  graphics_context_set_antialiased(ctx, true);

  gpath_rotate_to(minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_rotate_to(minute_fill, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_rotate_to(hour_arrow, 
      (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6));
  gpath_rotate_to(hour_fill, 
      (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10)))/(12 * 6));

  // Draw minute hand background
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 6);
  gpath_draw_outline(ctx, minute_arrow);

  // Draw minute hand foreground
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_width(ctx, 3);
  gpath_draw_outline(ctx, minute_arrow);
  gpath_draw_filled(ctx, minute_fill);

  // Draw hour hand background
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 6);
  gpath_draw_outline(ctx, hour_arrow);

  // Draw hour hand foreground
  graphics_context_set_stroke_color(ctx, GColorWhite);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_stroke_width(ctx, 3);
  gpath_draw_outline(ctx, hour_arrow);
  gpath_draw_filled(ctx, hour_fill);

  // Draw a black peg in the center
  graphics_context_set_antialiased(ctx, false);
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 1);
  gpath_draw_filled(ctx, peg_fill);
}
Ejemplo n.º 12
0
Archivo: plain.c Proyecto: 7bp/pebble
void hour_display_layer_update_callback(Layer *me, GContext* ctx) {
  (void)me;

  PblTm t;

  get_time(&t);

  unsigned int angle = t.tm_hour * 30 + t.tm_min / 2;
  gpath_rotate_to(&hour_hand_path, (TRIG_MAX_ANGLE / 360) * angle);
  gpath_rotate_to(&hour_hand_outline_path, (TRIG_MAX_ANGLE / 360) * angle);

  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_draw_filled(ctx, &hour_hand_outline_path);
  gpath_draw_filled(ctx, &hour_hand_path);
}
Ejemplo n.º 13
0
static void hour_display_update_proc(Layer *layer, GContext* ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  unsigned int angle = (t->tm_hour % 12) * 30;
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);

  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_circle(ctx, center, 48);

  for (unsigned int i = 0; i < 360; i += 15) {
    if ((i != angle) && (i != (angle + 15)) && (i != ((angle - 15 + 360) % 360)) ) {
      gpath_rotate_to(s_hour_segment_path, (TRIG_MAX_ANGLE / 360) * i);
      graphics_context_set_fill_color(ctx, GColorBlack);
      gpath_draw_filled(ctx, s_hour_segment_path);
    }
  }

  // Stray pixels
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_circle(ctx, center, 5);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  if ((angle != 0) && (angle != 330)) {
    graphics_draw_pixel(ctx, GPoint(71, 77));
    graphics_draw_pixel(ctx, GPoint(71, 78));
  }
}
Ejemplo n.º 14
0
// Draws a given hand on the face, using the vector structures.
void draw_vector_hand(struct VectorHandTable *hand, int hand_index, int num_steps,
                      int place_x, int place_y, GContext *ctx) {
  GPoint center = { place_x, place_y };
  int32_t angle = TRIG_MAX_ANGLE * hand_index / num_steps;
  int gi;

  for (gi = 0; gi < hand->num_groups; ++gi) {
    struct VectorHandGroup *group = &hand->group[gi];

    GPath path;
    gpath_init(&path, &group->path_info);

    gpath_rotate_to(&path, angle);
    gpath_move_to(&path, center);

    if (group->fill != GColorClear) {
      graphics_context_set_fill_color(ctx, group->fill);
      gpath_draw_filled(ctx, &path);
    }
    if (group->outline != GColorClear) {
      graphics_context_set_stroke_color(ctx, group->outline);
      gpath_draw_outline(ctx, &path);
    }
  }
}
Ejemplo n.º 15
0
static void minute_display_layer_update_callback(Layer *layer, GContext* ctx) {

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  unsigned int angle = t->tm_min * 6;

  gpath_rotate_to(minute_segment_path, (TRIG_MAX_ANGLE / 360) * angle);

  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);

  graphics_context_set_fill_color(ctx, GColorWhite);

  graphics_fill_circle(ctx, center, 77);

  graphics_context_set_fill_color(ctx, GColorBlack);

  // Note: I had intended to use the `GCompOpAssignInverted` mode here
  //       but it appears it's ignored for path/shape drawing.

  gpath_draw_filled(ctx, minute_segment_path);

  graphics_fill_circle(ctx, center, 52);
}
Ejemplo n.º 16
0
void hour_display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;
  get_time(&t);
  unsigned int angle = (t.tm_hour % 12) * 30;
  GPoint center = grect_center_point(&me->frame);
	
  // hour background black
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_fill_circle(ctx, center, 52);
	
  // hour sector white
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_rotate_to(&hour_segment_path, (TRIG_MAX_ANGLE / 360) * angle);
  gpath_draw_filled(ctx, &hour_segment_path);

  // rounding hour "sector"	
  graphics_context_set_stroke_color(ctx, GColorBlack);	
  graphics_draw_circle(ctx, center, 50); 	
  graphics_draw_circle(ctx, center, 49); 	
  graphics_draw_circle(ctx, center, 48); 	
  graphics_draw_circle(ctx, center, 47); 	

/*	
 	graphics_context_set_fill_color(ctx, GColorBlack);
 	graphics_fill_circle(ctx, center, 25);	
*/
}
Ejemplo n.º 17
0
void layer_ring_update_callback(Layer *layer, GContext* ctx) {	
	time_t tt = time(NULL);
	struct tm *t = localtime(&tt);
	
	unsigned int angle = 0;
	if (t->tm_min != 0) {
		angle = ( t->tm_min + 1 ) * 6;
	}
	
	GRect bounds = layer_get_bounds(layer);
	GPoint center = grect_center_point(&bounds);
	
	graphics_context_set_fill_color(ctx, s_color_ring_1);
	graphics_fill_circle(ctx, center, 73);
	
	graphics_context_set_fill_color(ctx, s_color_ring_2);
	for(; angle < 355; angle += 6) {
		gpath_rotate_to(s_path_ring_segment, (TRIG_MAX_ANGLE / 360) * angle);
		gpath_draw_filled(ctx, s_path_ring_segment);
	}
	
	graphics_context_set_stroke_color(ctx, s_color_bg_out);
	graphics_context_set_stroke_width(ctx, 4);
	graphics_draw_circle(ctx, center, 73);
}
Ejemplo n.º 18
0
//added by gac and is probably wrong
void month_display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;

  get_time(&t);
  
  unsigned int angle;
  
  //angle = (( t.tm_mon % 12 ) * 30) + (t.tm_mday / 2);
  angle = (( ( t.tm_mon + 1 ) % 12 ) * 30);
  
  angle = angle - (angle % 2);  //use modulo 2 for smaller black overlaps

  GPoint center = grect_center_point(&me->frame);

  graphics_context_set_fill_color(ctx, GColorWhite);

  graphics_fill_circle(ctx, center, 25);

  graphics_context_set_fill_color(ctx, GColorBlack);

  for(; angle < 355; angle += 2) {  //has to be same increment as the modulo in line 231

    gpath_rotate_to(&month_segment_path, (TRIG_MAX_ANGLE / 360) * angle);

    gpath_draw_filled(ctx, &month_segment_path);
  }

  graphics_fill_circle(ctx, center, 20);
}
Ejemplo n.º 19
0
void second_display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;

  get_time(&t);

  unsigned int angle = t.tm_sec * 6;

  GPoint center = grect_center_point(&me->frame);

  graphics_context_set_fill_color(ctx, GColorWhite);

  graphics_fill_circle(ctx, center, 65);

  graphics_context_set_fill_color(ctx, GColorBlack);

  for(; angle < 355; angle += 6) {

    gpath_rotate_to(&second_segment_path, (TRIG_MAX_ANGLE / 360) * angle);

    gpath_draw_filled(ctx, &second_segment_path);

  }

  graphics_fill_circle(ctx, center, 60);

}
Ejemplo n.º 20
0
void hour_display_layer_update_callback(Layer *me, GContext* ctx) {

  PblTm t;

  get_time(&t);

  unsigned int angle;

  #if TWENTY_FOUR_HOUR_DIAL
    angle = (t.tm_hour * 15) + (t.tm_min / 4);
  #else
    angle = (( t.tm_hour % 12 ) * 30) + (t.tm_min / 2);
  #endif

  angle = angle - (angle % 6);

  GPoint center = grect_center_point(&me->frame);

  graphics_context_set_fill_color(ctx, GColorWhite);

  graphics_fill_circle(ctx, center, 45);

  graphics_context_set_fill_color(ctx, GColorBlack);

  for(; angle < 355; angle += 6) {

    gpath_rotate_to(&hour_segment_path, (TRIG_MAX_ANGLE / 360) * angle);

    gpath_draw_filled(ctx, &hour_segment_path);
  }

  graphics_fill_circle(ctx, center, 40);
}
Ejemplo n.º 21
0
/**
 * Redraw handler for the minute layer
 * Draws the minute dial
 */
static void minute_layer_draw(Layer *layer, GContext *ctx) {

  // rotate the black quadrant that we use to mask the white circle
  gpath_rotate_to(minute_path, (TRIG_MAX_ANGLE * minutes / 60));
  gpath_move_to(minute_path, GPoint(144/2,168/2));
  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, minute_path);

  // draw the other overlays
  if(minutes < 45){
    // hide the last quadrant (45-60)
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(0,0,144/2,168/2), 0, 0);
  }

  if(minutes < 30) {
    // hide third quadrant (30-45)
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(0,168/2,144/2,168/2), 0, 0);
  }

  if(minutes <= 15) {
    // hide second quadrant (15-30)
    graphics_context_set_fill_color(ctx, GColorBlack);
    graphics_fill_rect(ctx, GRect(144/2,168/2,144/2,168/2), 0, 0);
  }

}
Ejemplo n.º 22
0
void minute_display_layer_update_callback(Layer *me, GContext* ctx) {
	(void) me;

	time_t now = time(NULL);
	struct tm *t = localtime(&now);

	unsigned int angle = t->tm_min * 6 + t->tm_sec / 10;

	if (init_anim < ANIM_MINUTES) {
		angle = 0;
	} else if (init_anim == ANIM_MINUTES) {
		minute_angle_anim += 6;
		if (minute_angle_anim >= angle) {
			init_anim = ANIM_SECONDS;
		} else {
			angle = minute_angle_anim;
		}
	}

	gpath_rotate_to(minute_hand_path, (TRIG_MAX_ANGLE / 360) * angle);

	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_context_set_stroke_color(ctx, GColorBlack);

	gpath_draw_filled(ctx, minute_hand_path);
	gpath_draw_outline(ctx, minute_hand_path);
}
Ejemplo n.º 23
0
void hour_display_layer_update_callback(Layer *me, GContext* ctx) {
	(void) me;

	time_t now = time(NULL);
	struct tm *t = localtime(&now);

	unsigned int angle = t->tm_hour * 30 + t->tm_min / 2;

	if (init_anim < ANIM_HOURS) {
		angle = 0;
	} else if (init_anim == ANIM_HOURS) {
		if (hour_angle_anim == 0 && t->tm_hour >= 12) {
			hour_angle_anim = 360;
		}
		hour_angle_anim += 6;
		if (hour_angle_anim >= angle) {
			init_anim = ANIM_MINUTES;
		} else {
			angle = hour_angle_anim;
		}
	}

	gpath_rotate_to(hour_hand_path, (TRIG_MAX_ANGLE / 360) * angle);

	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_context_set_stroke_color(ctx, GColorBlack);

	gpath_draw_filled(ctx, hour_hand_path);
	gpath_draw_outline(ctx, hour_hand_path);
}
Ejemplo n.º 24
0
void updateGenericHand(GPath* path, GContext* ctx, float circleFrac) {
	gpath_rotate_to(path, TRIG_MAX_ANGLE * circleFrac);
	
	graphics_context_set_fill_color(ctx, GColorWhite);
	graphics_context_set_stroke_color(ctx, GColorBlack);
	gpath_draw_filled(ctx, path);
	gpath_draw_outline(ctx, path);
}
Ejemplo n.º 25
0
static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);

  const int16_t second_hand_length = PBL_IF_ROUND_ELSE((bounds.size.w / 2) - 19, bounds.size.w / 2);

  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  GPoint second_hand = {
    .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y,
  };

  // second hand
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_draw_line(ctx, second_hand, center);

  // minute/hour hand
  graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_context_set_stroke_color(ctx, GColorLightGray);

  gpath_rotate_to(s_minute_arrow, TRIG_MAX_ANGLE * t->tm_min / 60);
  gpath_draw_filled(ctx, s_minute_arrow);
  gpath_draw_outline(ctx, s_minute_arrow);

  gpath_rotate_to(s_hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, s_hour_arrow);
  gpath_draw_outline(ctx, s_hour_arrow);

  // dot in the middle
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_fill_rect(ctx, GRect(bounds.size.w / 2 - 1, bounds.size.h / 2 - 1, 3, 3), 0, GCornerNone);
}

static void date_update_proc(Layer *layer, GContext *ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  strftime(s_day_buffer, sizeof(s_day_buffer), "%a", t);  //%b for month
  text_layer_set_text(s_day_label, s_day_buffer);

  strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t);
  text_layer_set_text(s_num_label, s_num_buffer);
}
Ejemplo n.º 26
0
static void draw_clock_layer_inner(Layer *layer, GContext *ctx) {
	uint16_t offset = 1 + (THICKNESS * 2) + (OFFSET * 2);

	graphics_context_set_fill_color(ctx, GColorBlack);
	graphics_fill_circle(ctx, s_clock_center, s_clock_center.x - offset);
	graphics_context_set_fill_color(ctx, GColorWhite);
	gpath_rotate_to(s_hand_path_inner, s_hand_angle[2]);
	gpath_draw_filled(ctx, s_hand_path_inner);
	graphics_fill_circle(ctx, s_clock_center, s_clock_center.x - offset - THICKNESS);
}
Ejemplo n.º 27
0
void minute_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    gpath_rotate_to(&minute_hand, (TRIG_MAX_ANGLE / 360) * curMin * 6);

    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorBlack);
    gpath_draw_filled(ctx, &minute_hand);
    gpath_draw_outline(ctx, &minute_hand);
}
Ejemplo n.º 28
0
void hour_layer_update_callback(Layer *me, GContext* ctx) {
    (void)me;
    
    gpath_rotate_to(&hour_hand, (TRIG_MAX_ANGLE / 360) * (curHour * 30 + curMin / 2));

    graphics_context_set_stroke_color(ctx, GColorWhite);
    graphics_context_set_fill_color(ctx, GColorBlack);
    gpath_draw_filled(ctx, &hour_hand);
    gpath_draw_outline(ctx, &hour_hand);
}
Ejemplo n.º 29
0
static void redraw_direction_arrow(Layer *layer, GContext *ctx) {
  Arrow* arrow = (Arrow*) layer_get_data(layer);
  if (!arrow->direction) {
    return;
  }
  gpath_rotate_to(arrow_path, TRIG_MAX_ANGLE / 360 * arrow->direction);

  graphics_context_set_fill_color(ctx, GColorBlack);
  gpath_draw_filled(ctx, arrow_path);
}
Ejemplo n.º 30
0
static void draw_shape(GContext* ctx, int shape, int32_t angle, bool hour) {
  if (shape < 3) {
    graphics_draw_circle(ctx, center_point, hour ? HOUR_RADIUS : MINUTE_RADIUS);
  } else {
    GPathInfo* path_info = (hour ? HOUR_SHAPES : MINUTE_SHAPES) + shape - 3;
    GPath* path = gpath_create(path_info);
    gpath_rotate_to(path, angle);
    gpath_move_to(path, center_point);
    gpath_draw_outline(ctx, path);
  }
}