Ejemplo n.º 1
0
static void main_window_load(Window *window) {
  
  //APP_LOG(APP_LOG_LEVEL_ERROR, "In Main_window_load");
  // Use system font, apply it and add to Window
  s_3_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_64));
  s_2_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_59));
  s_4_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_50));
  s_6_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_PTN_47));
 
  
  s_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  s_large_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_medium_title_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

  inverter = inverter_layer_create(GRect(0,0,144,168));
  layer_set_bounds(inverter_layer_get_layer(inverter),GRectZero);
  
  flash = inverter_layer_create(GRect(2,7,7,7));
  
  int jj;
  for (jj = 0; jj < 6; jj++) {
  dataInverter[jj] = inverter_layer_create(GRect(0,0,144,168));
  layer_set_bounds(inverter_layer_get_layer(dataInverter[jj]),GRectZero);  
  }
  
  // Create Display RectAngles
  
  // Six data fields & their titles
  #define SIX_FIELD_INDEX 0
  #define SIX_FIELD_MAX 5
  s_data_layer[0] = text_layer_create(GRect(0, 2, 71, 49));
  s_data_title[0] = text_layer_create(GRect(0, 49, 71, 15));

  s_data_layer[1] = text_layer_create(GRect(73, 2, 71, 49));
  s_data_title[1] = text_layer_create(GRect(73, 49, 71, 15));
  
  s_data_layer[2] = text_layer_create(GRect(0, 53, 71, 49));
  s_data_title[2] = text_layer_create(GRect(0, 102, 71, 14));
  
  s_data_layer[3] = text_layer_create(GRect(73, 53, 71, 49));
  s_data_title[3] = text_layer_create(GRect(73, 102, 71, 14));
  
  s_data_layer[4] = text_layer_create(GRect(0, 105, 71, 49));
  s_data_title[4] = text_layer_create(GRect(0, 154, 71, 15));
  
  s_data_layer[5] = text_layer_create(GRect(73, 105, 71, 49));
  s_data_title[5] = text_layer_create(GRect(73, 154, 71, 15));
  
  // Two data fields & their titles
  #define TWO_FIELD_INDEX 6
  #define TWO_FIELD_MAX 7
  s_data_layer[6] = text_layer_create(GRect(0, 2, 288, 60));
  layer_set_frame((Layer *) s_data_layer[6], GRect(0, 2, 144, 60));
  s_data_title[6] = text_layer_create(GRect(0, 64, 144, 28));
  
  s_data_layer[7] = text_layer_create(GRect(0, 79, 288, 60));
  layer_set_frame((Layer *) s_data_layer[7], GRect(0, 79, 144, 60));
  s_data_title[7] = text_layer_create(GRect(0, 140, 144, 28));

  
  // Four data fields & their titles
  #define FOUR_FIELD_INDEX 8
  #define FOUR_FIELD_MAX 11
  s_data_layer[8] = text_layer_create(GRect(0, 12, 142, 51));
  layer_set_frame((Layer *) s_data_layer[8], GRect(0, 12, 71, 51));
  s_data_title[8] = text_layer_create(GRect(0, 65, 71, 24));
  
  s_data_layer[9] = text_layer_create(GRect(73, 12, 71, 51));
  s_data_title[9] = text_layer_create(GRect(73, 65, 71, 24));
  
  s_data_layer[10] = text_layer_create(GRect(0, 91, 142, 51));
  layer_set_frame((Layer *) s_data_layer[10], GRect(0, 91, 71, 51));
  s_data_title[10] = text_layer_create(GRect(0, 144, 71, 24));
  
  s_data_layer[11] = text_layer_create(GRect(73, 91,  71, 51));
  s_data_title[11] = text_layer_create(GRect(73, 144, 71, 24));
  
  // Three fields - One big, two small
  //#define THREE_FIELD_INDEX 12
  #define THREE_FIELD_MAX 14
  s_data_layer[12] = text_layer_create(GRect(0, 10, 432, 65));
  layer_set_frame((Layer *) s_data_layer[12], GRect(0, 10, 144, 65));
  s_data_title[12] = text_layer_create(GRect(0, 75, 144, 28));

  s_data_layer[13] = text_layer_create(GRect(0, 91, 150, 51));
  layer_set_frame((Layer *) s_data_layer[13], GRect(0, 91, 71, 51));
  s_data_title[13] = text_layer_create(GRect(0, 144, 71, 24));
  
  
  //s_data_layer[14] = text_layer_create(GRect(73, 91, 142, 51));
  //layer_set_frame((Layer *) s_data_layer[14], GRect(73, 91, 71, 51));
  s_data_layer[14] = text_layer_create(GRect(73, 91,  71, 51));
  s_data_title[14] = text_layer_create(GRect(73, 144, 71, 24));
  
  
  // Top title
  s_data_layer[TITLE_INDEX] = text_layer_create(GRect(0, 0, 144, 16));
  
  

  // Set up top title area
    text_layer_set_background_color(s_data_layer[TITLE_INDEX], GColorBlack);
    text_layer_set_text_color(s_data_layer[TITLE_INDEX], GColorWhite);
    text_layer_set_text_alignment(s_data_layer[TITLE_INDEX], GTextAlignmentCenter);
    text_layer_set_text(s_data_layer[TITLE_INDEX], "StartLine");
    text_layer_set_font(s_data_layer[TITLE_INDEX], s_title_font);
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_data_layer[TITLE_INDEX])); 
 
  window_set_background_color(window, GColorBlack);
  // Set up the messgage layer
  messageLayer = text_layer_create(GRect(10,30,124,120));
  text_layer_set_background_color(messageLayer, GColorClear);
  text_layer_set_text_color(messageLayer, GColorWhite);
  text_layer_set_text_alignment(messageLayer, GTextAlignmentCenter);
  text_layer_set_font(messageLayer, s_large_title_font);
  
  

  
  titleLayer = layer_create(GRect(0, 0, 144, 168));
  layer_insert_below_sibling(titleLayer, (Layer *)s_data_layer[TITLE_INDEX]);
  
  
  dataLayer = layer_create(GRect(0, 0, 144, 168));
  layer_insert_below_sibling(dataLayer, titleLayer); 
 
  
  int i;
  for (i =0; i < TITLE_INDEX; i++)
    {
    //Data

    text_layer_set_background_color(s_data_layer[i], GColorClear);
    text_layer_set_text_color(s_data_layer[i], GColorWhite);
    text_layer_set_text_alignment(s_data_layer[i], GTextAlignmentCenter);
    text_layer_set_overflow_mode(s_data_layer[i], GTextOverflowModeWordWrap);
    layer_add_child(dataLayer, text_layer_get_layer(s_data_layer[i]));
    
    //Title

    text_layer_set_background_color(s_data_title[i], GColorClear);
    text_layer_set_text_color(s_data_title[i], GColorWhite);
    text_layer_set_text_alignment(s_data_title[i], GTextAlignmentCenter);
    
    if (i >= SIX_FIELD_INDEX && i <= SIX_FIELD_MAX) // Small title fonts on the 6 field layout
      {
      text_layer_set_font(s_data_layer[i], s_6_font);    
      text_layer_set_font(s_data_title[i], s_title_font);
    }
    else if (i >= TWO_FIELD_INDEX && i <= TWO_FIELD_MAX) // This is 2 fields
      {
      text_layer_set_font(s_data_layer[i], s_2_font); 
      text_layer_set_font(s_data_title[i], s_large_title_font);
    }

    else if (i >= FOUR_FIELD_INDEX && i <= FOUR_FIELD_MAX) // 4 field layout
      {
      text_layer_set_font(s_data_layer[i], s_4_font); 
      text_layer_set_font(s_data_title[i], s_medium_title_font);
    }
    else if (i >= THREE_FIELD_INDEX && i <= THREE_FIELD_MAX)
      {
      if (i == THREE_FIELD_INDEX) // First field is big
        {
        text_layer_set_font(s_data_layer[i], s_3_font); 
        text_layer_set_font(s_data_title[i], s_large_title_font);
      } else
        {
        text_layer_set_font(s_data_layer[i], s_4_font);    
        text_layer_set_font(s_data_title[i], s_medium_title_font);        
      }
    }      
   
    layer_add_child(titleLayer, text_layer_get_layer(s_data_title[i]));
    
  }
  
 layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(inverter));


  int ii;
  for (ii = 0; ii < 6; ii++) {
     layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(dataInverter[ii]));
  }
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(messageLayer)); 

   layer_add_child(window_get_root_layer(window), inverter_layer_get_layer(flash));

  
  // Go find a screen with some fields in use
  for (currentScreen = 0; screens[currentScreen].num_fields == 0; currentScreen++)
    ;

  // Add the padlock icon - steals the rest of my heap!!
  s_padlockLayer = bitmap_layer_create(GRect(133, 3, 8, 11));
  s_res_padlock = gbitmap_create_with_resource(RESOURCE_ID_PADLOCK);
  bitmap_layer_set_bitmap(s_padlockLayer, s_res_padlock);
  layer_add_child(window_get_root_layer(window), (Layer *)s_padlockLayer);
  layer_set_hidden((Layer *)s_padlockLayer, configLock == 1);
  
  // And make it the current screen
  updatescreen(currentScreen,"00");
}
Ejemplo n.º 2
0
void handle_timer(void *data)
{
    text_layer_set_text(statusTextLayer, STATUS_READY);
}
Ejemplo n.º 3
0
static void update_unit(TextLayer *text_layer, Layer *bar_layer, struct tm *tick_time, char *buffer, const char *format) {
  strftime(buffer, sizeof("00"), format, tick_time);
  text_layer_set_text(text_layer, buffer); 
  
  layer_mark_dirty(bar_layer);
}
Ejemplo n.º 4
0
void up_single_click_handler(ClickRecognizerRef recognizer, void *context)
{
    text_layer_set_text(statusTextLayer, STATUS_RINGING);
    send_cmd( CMD_START );
}
Ejemplo n.º 5
0
// App message callbacks
static void app_send_failed(DictionaryIterator *iterator, AppMessageResult reason, void *context)
{
    text_layer_set_text(statusTextLayer, STATUS_FAILED);
    start_reset_timer();
}
Ejemplo n.º 6
0
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "Up");
}
Ejemplo n.º 7
0
static void back_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "Back");
  window_stack_pop(true);
}
Ejemplo n.º 8
0
static void update_time(struct tm *t) {
  fuzzy_time_to_words(t->tm_hour, t->tm_min, s_buffer, BUFFER_SIZE);
  text_layer_set_text(s_text_layer, s_buffer);
}
Ejemplo n.º 9
0
// Updates the time text
static void update_time(void *data)
{
	clock_copy_time_string(buffer, 12);
	text_layer_set_text(time_layer, buffer);
	time_timer = app_timer_register(TIME_TIMEOUT, update_time, 0);
}
static void reset_status_timer_callback(void *data) {
    text_layer_set_text(status_text_layer, "Active");
    layer_mark_dirty(text_layer_get_layer(status_text_layer));
}
Ejemplo n.º 11
0
static void handle_bluetooth(bool connected) {
  text_layer_set_text(s_connection_layer, connected ? "connected" : "disconnected");
}
Ejemplo n.º 12
0
DateTimeLayer* date_time_layer_create(Watchface* watchface) {
    DateTimeLayer* date_time_layer = malloc(sizeof(DateTimeLayer));
    date_time_layer->watchface = watchface;
    
    GRect frame = layer_get_frame(watchface_get_layer(watchface));
    
    date_time_layer->layer = layer_create(frame);
    
    default_time_frame = GRect(0, 2, frame.size.w, frame.size.h-6);
    default_date_frame = GRect(1, 74, frame.size.w, frame.size.h-62);
    nudged_up_date_frame = GRect(
        default_date_frame.origin.x, default_date_frame.origin.y - 8,
        default_date_frame.size.w,   default_date_frame.size.h
    );
    if(HAS_LIGHT_WEATHER) {
        default_date_frame = nudged_up_date_frame;
    }
    
    date_time_layer->time_layer = text_layer_create(default_time_frame);
    date_time_layer->date_layer = text_layer_create(default_date_frame);
    
    text_layer_set_text_alignment(
        date_time_layer->time_layer, GTextAlignmentCenter
    );
    text_layer_set_background_color(
        date_time_layer->time_layer, GColorClear
    );
    text_layer_set_text_color(
        date_time_layer->time_layer, GColorWhite
    );
    text_layer_set_font(
        date_time_layer->time_layer, watchface_get_fonts(watchface)->futura_53
    );
    text_layer_set_text(date_time_layer->time_layer, "(null)");
    
    text_layer_set_text_alignment(
        date_time_layer->date_layer, GTextAlignmentCenter
    );
    text_layer_set_background_color(
        date_time_layer->date_layer, GColorClear
    );
    text_layer_set_text_color(
        date_time_layer->date_layer, GColorWhite
    );
    text_layer_set_font(
        date_time_layer->date_layer, watchface_get_fonts(watchface)->futura_18
    );
    
    layer_add_child(
        date_time_layer->layer,
        text_layer_get_layer(date_time_layer->time_layer)
    );
    layer_add_child(
        date_time_layer->layer,
        text_layer_get_layer(date_time_layer->date_layer)
    );
    
    date_time_layer_update_frame(date_time_layer);
    
    return date_time_layer;
}
Ejemplo n.º 13
0
void last_bg_text_layer_update(TextLayer *text_layer, DataMessage *data) {
  static char last_bg_buffer[8];
  format_bg(last_bg_buffer, sizeof(last_bg_buffer), data->last_sgv, false, get_prefs()->mmol);
  text_layer_set_text(text_layer, last_bg_buffer);
}
Ejemplo n.º 14
0
void setField(int i /* Field Index */,  bool negNum, char* value)
  {
  static PropertyAnimation *pa1[6] = {NULL}, *pa2[6] = {NULL}; //Arrays to cope with 6 fields
    {
    static GSize textContent;
    static GRect gfrom, gto, gframe;
    TextLayer *flm = s_data_layer[screens[currentScreen].field_layer_map[i]];
    text_layer_set_text_alignment(flm, GTextAlignmentLeft);
    text_layer_set_text(flm, value); // This line only
    textContent = text_layer_get_content_size(flm);
    gfrom = layer_get_bounds((Layer *)flm);
    gframe = layer_get_frame((Layer *)flm);
    
    // APP_LOG(APP_LOG_LEVEL_INFO, "gframe.size.w=%d textContent.w=%d i=%d", gframe.size.w, textContent.w, i);
    if (textContent.w > gframe.size.w) // Overflowed
      {
      // APP_LOG(APP_LOG_LEVEL_INFO, "setfield11 value=%s", value);
      if ( (pa1[i] == NULL || !animation_is_scheduled((Animation*)pa1[i])) 
          && (pa2[i] == NULL || !animation_is_scheduled((Animation*) pa2[i]))) // We are not already animating
        {
        // APP_LOG(APP_LOG_LEVEL_INFO, "setField 10");
        gto = gfrom;
        gfrom.origin.x = 0;
        gto.origin.x = (gframe.size.w - textContent.w)/2; //Work out har far left to move animate the text
        // APP_LOG(APP_LOG_LEVEL_INFO, "setField11 gfrom.x=%d gfrom.y=%d", gfrom.origin.x, gfrom.origin.y);
        // APP_LOG(APP_LOG_LEVEL_INFO, "setField11 gto.x=%d gto.y=%d", gto.origin.x, gto.origin.y);
        int tim = (int)(-2000.0 * ((float)gto.origin.x) / 20.0);
        animate_layer_bounds(&pa1[i], (Layer *)flm, &gfrom, &gto, tim, 0);
        animate_layer_bounds(&pa2[i], (Layer *)flm, &gto, &gfrom, tim, tim);
        }
      else
        {
        //APP_LOG(APP_LOG_LEVEL_INFO, "Already scheduled screen=%d i=%d %d %d %d %d", currentScreen, i, (int)pa1[i], animation_is_scheduled((Animation*)pa1[i]), (int)pa2[i], animation_is_scheduled((Animation*)pa2[i]) );
        text_layer_set_text(flm, value); // Animation running - just set the text
      }
    }
    else // We need to redraw the text centred in the reset bounds
      {
      // APP_LOG(APP_LOG_LEVEL_INFO, "setfield11 value=%s", value);
      GRect bF = layer_get_bounds((Layer *)flm);
      GRect fF = layer_get_frame((Layer *)flm);
      if (bF.size.w != fF.size.w) // is there extra space?
        {
        bF.origin.x = -(bF.size.w / 2 - fF.size.w / 2) /2;
        // APP_LOG(APP_LOG_LEVEL_INFO, "origin.x =%d", bF.origin.x);
        layer_set_bounds((Layer *)flm, bF); // Centre the Bounds below the Frame
      }
      text_layer_set_text_alignment(flm, GTextAlignmentCenter); //Should be Center but need to work out how!
      text_layer_set_text(flm, value); // This line only
    }
    
  }
  if (negNum) // Did we get a negative number
  {
    doDataInvert(i);
  } 
  else // No, positive number
  {
    doDataRevert(i);
  }
}
Ejemplo n.º 15
0
static void set_battery() {
    BatteryChargeState state = battery_state_service_peek();

    gbitmap_destroy(batt_bitmap);

    switch (state.charge_percent) {
    case 90:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt90);
        text_layer_set_text(batt_txt_layer, "90");
        break;
    case 80:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt80);
        text_layer_set_text(batt_txt_layer, "80");
        break;
    case 70:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt70);
        text_layer_set_text(batt_txt_layer, "70");
        break;
    case 60:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt60);
        text_layer_set_text(batt_txt_layer, "60");
        break;
    case 50:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt50);
        text_layer_set_text(batt_txt_layer, "50");
        break;
    case 40:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt40);
        text_layer_set_text(batt_txt_layer, "40");
        break;
    case 30:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt30);
        text_layer_set_text(batt_txt_layer, "30");
        break;
    case 20:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt20);
        text_layer_set_text(batt_txt_layer, "20");
        break;
    case 10:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt10);
        text_layer_set_text(batt_txt_layer, "10");
        break;
    case 00:
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt00);
        text_layer_set_text(batt_txt_layer, "0");
        break;
    default:
        text_layer_set_text(batt_txt_layer, "100");
        batt_bitmap = gbitmap_create_with_resource(RESOURCE_ID_batt100);
        break;
    }
    bitmap_layer_set_bitmap(batt_layer, batt_bitmap);
}
Ejemplo n.º 16
0
static void main_window_load(Window *window) {
  GRect bounds = layer_get_bounds(window_get_root_layer(window));
  
  action_bar = action_bar_layer_create();
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider);
  bool topbutton_dismiss = load_persistent_storage_bool(TOP_BUTTON_DISMISS_KEY, true);

  action_bar_layer_set_icon_animated(action_bar,topbutton_dismiss?BUTTON_ID_UP:BUTTON_ID_DOWN,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_CROSS_INV),true);
  action_bar_layer_set_icon_animated(action_bar,topbutton_dismiss?BUTTON_ID_DOWN:BUTTON_ID_UP,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_ICON_ZZ_INV),true);

  action_bar_layer_add_to_window(action_bar,window);
  
  // Create output TextLayer
  
  s_output_layer = text_layer_create(GRect(0, bounds.size.h/2-(is_24h()?0:4), bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h));
  text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter);
  text_layer_set_font(s_output_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));

  //snprintf(output_text, sizeof(output_text), "00:00");
  text_layer_set_text(s_output_layer, output_text);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_output_layer));
  
  //snprintf(output_text, sizeof(output_text), "00:00");
  if(alarm_has_description(s_alarm))
  {
    // Create Description
    s_description_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(20,0), PBL_IF_ROUND_ELSE(20,6), bounds.size.w-ACTION_BAR_WIDTH-PBL_IF_ROUND_ELSE(20,0), bounds.size.h/2-10));
    text_layer_set_text_alignment(s_description_layer, GTextAlignmentCenter);
    text_layer_set_font(s_description_layer,fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    text_layer_set_text(s_description_layer, s_alarm->description);
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_description_layer));
  }
  else
  {
#ifndef PBL_PLATFORM_APLITE
    s_command_seq = gdraw_command_sequence_create_with_resource(RESOURCE_ID_CLOCK_SEQUENCE);
    // Create the canvas Layer
    s_canvas_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(60,30)-ACTION_BAR_WIDTH/2, 0, bounds.size.w, bounds.size.h));
    // Set the LayerUpdateProc
    layer_set_update_proc(s_canvas_layer, update_proc);

    // Add to parent Window
    layer_add_child(window_get_root_layer(window), s_canvas_layer);
    
#else
    // Create Bitmap
    s_bitmap_layer = bitmap_layer_create(GRect(0,10,bounds.size.w-ACTION_BAR_WIDTH, bounds.size.h));
    s_logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO);
    bitmap_layer_set_bitmap(s_bitmap_layer,s_logo);
    bitmap_layer_set_alignment(s_bitmap_layer,GAlignTop);
    layer_add_child(window_get_root_layer(window),bitmap_layer_get_layer(s_bitmap_layer));
    s_pat.durations = s_segments;
    s_pat.num_segments = 2;

#endif
  }
  s_vibration_pattern = load_persistent_storage_int(VIBRATION_PATTERN_KEY,0);
  s_vibration_duration = load_persistent_storage_int(VIBRATION_DURATION_KEY, 2);
  s_konami_dismiss = load_persistent_storage_bool(KONAMI_DISMISS_KEY,false);

  s_auto_snooze = load_persistent_storage_bool(AUTO_SNOOZE_KEY, true);
  // do smart-alarmy stuff here
#ifdef PBL_HEALTH
  if(s_alarm->smart_alarm_minutes>0)
  {
    // Attempt to subscribe
    if(!health_service_events_subscribe(health_handler, NULL)) {
      APP_LOG(APP_LOG_LEVEL_ERROR, "Health not available!");
      start_vibration(NULL);
    }
    else {
      // Check which activities are available
      HealthServiceAccessibilityMask activity_mask = health_service_any_activity_accessible(HealthActivityMaskAll,time(NULL)-SECONDS_PER_HOUR,time(NULL));
      
      if(activity_mask & HealthServiceAccessibilityMaskAvailable){
        APP_LOG(APP_LOG_LEVEL_INFO, "We can read activities!");
        // Get an activities mask
        HealthActivityMask activities = health_service_peek_current_activities();
        
        // Determine if the user is sleeping
        if(activities & HealthActivitySleep) { // give him time to wake
          APP_LOG(APP_LOG_LEVEL_INFO, "User is sleeping!");
          s_start_smart_alarm_timer = app_timer_register(1000*60*s_alarm->smart_alarm_minutes,start_vibration,NULL);
        } else { // just vibrate
          start_vibration(NULL);
        }
      }
      else { // we don't get the current activity, so just vibrate
        start_vibration(NULL);
      }
    }
  }
  else {
    start_vibration(NULL);
  }
  
#else
  start_vibration(NULL);
#endif
  // test snoozing with the accelerometer
  /*if(s_flip_to_snooze)
  {
    accel_tap_service_subscribe(&accel_tap_handler);
  }*/
}
Ejemplo n.º 17
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "Select");
  _drum = DigitDrumWindowCreate(5, 1);
  window_stack_push(_drum->window, true);
}
Ejemplo n.º 18
0
static void update(int select) {
	// Get a tm structure
	time_t temp = time(NULL); 
	struct tm *tick_time = localtime(&temp);

	if (select == 1) {
		// Write the current hours and minutes into a buffer
		static char s_buffer[8];
		strftime(s_buffer, sizeof(s_buffer), clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
		// Drop the first char of s_buffer if needed
	    if (!clock_is_24h_style() && (s_buffer[0] == '0')) 
	    {
	      memmove(s_buffer, &s_buffer[1], sizeof(s_buffer) - 1);
	    }
		// Display this time on the TextLayer
		text_layer_set_text(s_time_textLayer, s_buffer);
	} else if (select == 2) {
		// Start with all tick time functions relating to date.
		strftime(dayOfWeekNumber_tickTime, sizeof(dayOfWeekNumber_tickTime), "%w", tick_time);
		strftime(engDayOfWeek_tickTime, sizeof(engDayOfWeek_tickTime), "%a", tick_time);
		strftime(month_tickTime, sizeof(month_tickTime), "%m", tick_time);
	    strftime(day_tickTime, sizeof(day_tickTime), "%d", tick_time);
	    strftime(year_tickTime, sizeof(year_tickTime), ".%y", tick_time);

		// Date
		if( persist_read_int(KEY_LANGUAGE) == 0 ) {
			// English
			text_layer_set_text(s_dayOfWeek_textLayer, engDayOfWeek_tickTime);
    	} else {
    		// Time to convert this to spanish
    		int dayOfWeekInt = atoi(dayOfWeekNumber_tickTime);
    		static char temporary_day_of_week_holder_update[8];
    		switch(dayOfWeekInt) {
    			case 0:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Dom");
    			break;
    			case 1:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Lun");
    			break;
    			case 2:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Mar");
    			break;
    			case 3:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Mie");
    			break;
    			case 4:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Jue");
    			break;
    			case 5:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Vie");
    			break;
    			case 6:
    				snprintf(temporary_day_of_week_holder_update, sizeof(temporary_day_of_week_holder_update), "%s", "Sab");
    			break;
    			default:
					text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_update);
				break;
    		}
    		text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_update);
    		APP_LOG(APP_LOG_LEVEL_INFO, "Update: Loaded Language as Spanish\n");
		}
    	// Date
	    // Get rid of Pesky 0's
	    if( month_tickTime[0] == '0' ) 
	    {
	      memmove(month_tickTime, &month_tickTime[1], sizeof(month_tickTime) - 1);
	    }
	    if( day_tickTime[0] == '0' ) 
	    {
	      memmove(day_tickTime, &day_tickTime[1], sizeof(day_tickTime) - 1);
	    }
	    static char temporary_date_holder_update[8];
	    // Combine
	    if( persist_read_int(KEY_DATE_FORMAT) == 0 ) {
	    	snprintf(temporary_date_holder_update, sizeof(temporary_date_holder_update), "%s.%s", month_tickTime, day_tickTime);
	    	snprintf(dateWithoutYear, sizeof(dateWithoutYear), "%s", temporary_date_holder_update);
	    	text_layer_set_text(s_date_textLayer, dateWithoutYear);
	    	APP_LOG(APP_LOG_LEVEL_INFO, "Update: Date was loaded as MM-DD\n");
		} else if( persist_read_int(KEY_DATE_FORMAT) == 1 ) {
			snprintf(temporary_date_holder_update, sizeof(temporary_date_holder_update), "%s.%s", day_tickTime, month_tickTime);
			snprintf(ddmm_dateWithoutYear, sizeof(ddmm_dateWithoutYear), "%s", temporary_date_holder_update);
			text_layer_set_text(s_date_textLayer, ddmm_dateWithoutYear);
			APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date was loaded as DD-MM\n");
		}
		// year
		if( persist_read_bool(KEY_DATE_ADD_YEAR) == true ) {
			strcat(temporary_date_holder_update, year_tickTime);
			text_layer_set_text(s_date_textLayer, temporary_date_holder_update);
		}
    }
}
Ejemplo n.º 19
0
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "Down");
}
Ejemplo n.º 20
0
static void main_window_load(Window *window) {
	// Get information about the Window
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);

	// Create Layers
	s_time_textLayer = text_layer_create(
	    GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50));
	s_weather_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(65, 5), PBL_IF_ROUND_ELSE(0, 2), PBL_IF_ROUND_ELSE(70, bounds.size.w), 50));
	s_dayOfWeek_textLayer = text_layer_create(
		GRect(PBL_IF_ROUND_ELSE(30, -5), PBL_IF_ROUND_ELSE(25, 2), bounds.size.w, 50));
	s_date_textLayer = text_layer_create(
		GRect(0, PBL_IF_ROUND_ELSE(105, 115), PBL_IF_ROUND_ELSE(bounds.size.w-31, bounds.size.w-3), 50));
	// UI Layers
	s_ui_top = text_layer_create(
		GRect(0,0,bounds.size.w,PBL_IF_ROUND_ELSE(70,52)));
	s_ui_bottom = text_layer_create(
		GRect(0,PBL_IF_ROUND_ELSE(110,117),bounds.size.w,100));

	// Setup Background colors
	text_layer_set_background_color(s_time_textLayer, 		GColorClear);
	text_layer_set_background_color(s_weather_textLayer, 	GColorClear);
	text_layer_set_background_color(s_dayOfWeek_textLayer,	GColorClear);
	text_layer_set_background_color(s_date_textLayer,		GColorClear);

	// Setup Text Colors
	text_layer_set_text_color(s_time_textLayer, 			GColorBlack);
	text_layer_set_text_color(s_weather_textLayer,			GColorWhite);
	text_layer_set_text_color(s_dayOfWeek_textLayer,		GColorWhite);
	text_layer_set_text_color(s_date_textLayer,				GColorWhite);

	// Setup Font Styles
	time_font = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
	nonTime_font = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);
	text_layer_set_font(s_time_textLayer, time_font);
	// text_layer_set_font(s_time_textLayer, s_time_gfont);
	text_layer_set_font(s_weather_textLayer, nonTime_font);
	text_layer_set_font(s_dayOfWeek_textLayer, nonTime_font);
	text_layer_set_font(s_date_textLayer, nonTime_font);

	// Format Text alignments
	text_layer_set_text_alignment(s_time_textLayer, 		GTextAlignmentCenter);
	text_layer_set_text_alignment(s_weather_textLayer,		GTextAlignmentRight);
	text_layer_set_text_alignment(s_dayOfWeek_textLayer,	GTextAlignmentLeft);
	text_layer_set_text_alignment(s_date_textLayer,			GTextAlignmentRight);

	// Optionally, Add Text to the layer as a placeholder
	text_layer_set_text(s_weather_textLayer, "...");
		
	// Perform Color Changes!
	#if defined(PBL_BW)
		text_layer_set_background_color(s_ui_top,				GColorBlack);
		text_layer_set_background_color(s_ui_bottom,			GColorBlack);
  	#elif defined(PBL_COLOR)
	    // Accent Color Setting
	    int red_accent = persist_read_int(KEY_COLOR_RED_ACCENT);
	    int green_accent = persist_read_int(KEY_COLOR_GREEN_ACCENT);
	    int blue_accent = persist_read_int(KEY_COLOR_BLUE_ACCENT);

	    // APP_LOG(APP_LOG_LEVEL_INFO, "color is %d". bg_color_accent);
		// APP_LOG(APP_LOG_LEVEL_INFO, "accent color is rgb %d %d %d", red_accent, green_accent,blue_accent);
	    if(red_accent >= 0 && green_accent >= 0 && blue_accent >= 0) {
	    	GColor bg_color_accent = GColorFromRGB(red_accent, green_accent, blue_accent);
	    	
	    	text_layer_set_background_color(s_ui_top, bg_color_accent);
	    	text_layer_set_background_color(s_ui_bottom, bg_color_accent);
	    	text_layer_set_text_color(s_dayOfWeek_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_date_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    	text_layer_set_text_color(s_weather_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    }
	    // Time Color Setting
	    int red_time = persist_read_int(KEY_COLOR_RED_TIME);
	    int green_time = persist_read_int(KEY_COLOR_GREEN_TIME);
	    int blue_time = persist_read_int(KEY_COLOR_BLUE_TIME);

	    if(red_time >= 0 && green_time >= 0 && blue_time >= 0) {
	    	GColor bg_color_time = GColorFromRGB(red_time, green_time, blue_time);
	    	
	    	window_set_background_color(s_main_window, bg_color_time);
	    	text_layer_set_text_color(s_time_textLayer, gcolor_is_dark(bg_color_time) ? GColorWhite : GColorBlack);
	    }
    #endif

	// UI
	layer_add_child(window_layer, text_layer_get_layer(s_ui_top));
	layer_add_child(window_layer, text_layer_get_layer(s_ui_bottom));
	// Add Layers as Children to window.
	layer_add_child(window_layer, text_layer_get_layer(s_time_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_weather_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_dayOfWeek_textLayer));
	layer_add_child(window_layer, text_layer_get_layer(s_date_textLayer));
	// Don't forget to destroy all layers below.
}
Ejemplo n.º 21
0
void handle_init(AppContextRef ctx) { 
  if (clock_is_24h_style()) {
    format_time = "%H:%M";
    format_date = "%d-%m-%Y";
  }
  else {
    format_time = "%I:%M";
    format_date = "%m/%d/%Y";
  }
  
  update_time();

  resource_init_current_app(&APP_RESOURCES);
  ubuntu_time = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_BOLD_50));
  ubuntu_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_16));
  ubuntu_text = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UBUNTU_10));

  window_init(&window, MY_NAME);
  window_stack_push(&window, true);

  text_layer_init(&layer_time, GRect(0, 20, 144, 54));
  text_layer_set_font(&layer_time, ubuntu_time);
  text_layer_set_text(&layer_time, (const char*)&string_time);
  text_layer_set_text_alignment(&layer_time, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(&window), &layer_time.layer);

  text_layer_init(&layer_date, GRect(0, 74, 144, 20));
  text_layer_set_font(&layer_date, ubuntu_date);
  text_layer_set_text(&layer_date, (const char*)&string_date);
  text_layer_set_text_alignment(&layer_date, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(&window), &layer_date.layer);
    
  bitmap_layer_init(&layer_battery, GRect(8, 140, 14, 8));
  bitmap_layer_set_bitmap(&layer_battery, &bitmap_battery.bmp);
  layer_add_child(window_get_root_layer(&window), &layer_battery.layer);

  bitmap_layer_init(&layer_signal, GRect(8, 150, 14, 8));
  bitmap_layer_set_bitmap(&layer_signal, &bitmap_signal.bmp);
  layer_add_child(window_get_root_layer(&window), &layer_signal.layer);
  
  bmp_init_container(RESOURCE_ID_PNG_CALL, &layer_call);
  layer_call.layer.layer.frame.origin.x = 142 - 8 - 9;
  layer_call.layer.layer.frame.origin.y = 140;
  layer_add_child(window_get_root_layer(&window), &layer_call.layer.layer);

  bmp_init_container(RESOURCE_ID_PNG_MESSAGE, &layer_message);
  layer_message.layer.layer.frame.origin.x = 142 - 8 - 9;
  layer_message.layer.layer.frame.origin.y = 150;
  layer_add_child(window_get_root_layer(&window), &layer_message.layer.layer);
  
  text_layer_init(&layer_numbercall, GRect(101, 138, 22, 10));
  text_layer_set_font(&layer_numbercall, ubuntu_text);
  text_layer_set_text(&layer_numbercall, (const char*)&string_call);
  text_layer_set_text_alignment(&layer_numbercall, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(&window), &layer_numbercall.layer);

  text_layer_init(&layer_numbermessage, GRect(101, 148, 22, 10));
  text_layer_set_font(&layer_numbermessage, ubuntu_text);
  text_layer_set_text(&layer_numbermessage, (const char*)&string_message);
  text_layer_set_text_alignment(&layer_numbermessage, GTextAlignmentRight);
  layer_add_child(window_get_root_layer(&window), &layer_numbermessage.layer);  
  
  update_stats();
 
  request_command(REACTOR_COMMAND_REFRESH);
}
Ejemplo n.º 22
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
	// Weather -------------------------------------------------------------------
	static char temperature_buffer[8];
	static char weather_layer_buffer[8];
	int temperature = 0;
	Tuple *temp_tuple = dict_find(iterator, KEY_TEMPERATURE);
	static int temp_in_c;
	if( temp_tuple ) {
		temp_in_c = (int)temp_tuple->value->int32;
		if( persist_read_bool(KEY_WEATHER_UNIT) == true ) {
			temperature = convert_to_fahrenheit(temp_in_c);
		} else {
			temperature = temp_in_c;
		}
	}
	Tuple *unit_tuple = dict_find(iterator, KEY_WEATHER_UNIT);
	if( unit_tuple && unit_tuple->value->int8 > 0 ) {
		// USE CELCIOUS UNITS
		persist_write_bool(KEY_WEATHER_UNIT, false);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Units are C\n");
		temperature = temp_in_c;
	} else if( unit_tuple && unit_tuple->value->int8 <= 0 ) {
		// USEFARIENHEIT
		persist_write_bool(KEY_WEATHER_UNIT, true);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Units are F\n");
		temperature = convert_to_fahrenheit(temp_in_c);
	}
	snprintf(temperature_buffer, sizeof(temperature_buffer), "%d", temperature);
	snprintf(weather_layer_buffer, sizeof(weather_layer_buffer), "%s°", temperature_buffer);
	text_layer_set_text(s_weather_textLayer, weather_layer_buffer);
	// End Weather ---------------------------------------------------------------

	// Configuration -------------------------------------------------------------
	// Color ===================
	#if defined(PBL_COLOR)
	  Tuple *color_red_accent = dict_find(iterator, KEY_COLOR_RED_ACCENT);
	  Tuple *color_green_accent = dict_find(iterator, KEY_COLOR_GREEN_ACCENT);
	  Tuple *color_blue_accent = dict_find(iterator, KEY_COLOR_BLUE_ACCENT);
	  Tuple *color_red_time = dict_find(iterator, KEY_COLOR_RED_TIME);
	  Tuple *color_green_time = dict_find(iterator, KEY_COLOR_GREEN_TIME);
	  Tuple *color_blue_time = dict_find(iterator, KEY_COLOR_BLUE_TIME);
	  if(color_red_accent && color_green_accent && color_blue_accent) {
	    // Apply the color if available
	  
	    int red_accent = color_red_accent->value->int32;
	    int green_accent = color_green_accent->value->int32;
	    int blue_accent = color_blue_accent->value->int32;

	    // Persist values
	    persist_write_int(KEY_COLOR_RED_ACCENT, red_accent);
	    persist_write_int(KEY_COLOR_GREEN_ACCENT, green_accent);
	    persist_write_int(KEY_COLOR_BLUE_ACCENT, blue_accent);

	    GColor bg_color_accent = GColorFromRGB(red_accent, green_accent, blue_accent);
	    text_layer_set_background_color(s_ui_top, bg_color_accent);
	    text_layer_set_background_color(s_ui_bottom, bg_color_accent);

	    text_layer_set_text_color(s_dayOfWeek_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    text_layer_set_text_color(s_date_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	    text_layer_set_text_color(s_weather_textLayer, gcolor_is_dark(bg_color_accent) ? GColorWhite : GColorBlack);
	  }
	  
	  if(color_red_time && color_green_time && color_blue_time) {
	    // Apply the color if available
	    int red_time = color_red_time->value->int32;
	    int green_time = color_green_time->value->int32;
	    int blue_time = color_blue_time->value->int32;

	    // Persist values
	    persist_write_int(KEY_COLOR_RED_TIME, red_time);
	    persist_write_int(KEY_COLOR_GREEN_TIME, green_time);
	    persist_write_int(KEY_COLOR_BLUE_TIME, blue_time);

	    GColor bg_color_time = GColorFromRGB(red_time, green_time, blue_time);
	    window_set_background_color(s_main_window, bg_color_time);

	    text_layer_set_text_color(s_time_textLayer, gcolor_is_dark(bg_color_time) ? GColorWhite : GColorBlack);
	  }
	 #endif
	// End Color ===============

	// Date Format
	static char temporary_date_holder_callback[32];
	Tuple *date_format_tuple = dict_find(iterator, KEY_DATE_FORMAT);
	if( date_format_tuple ) {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date Tuple Worked!\n");
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Value Recieved from Date Tuple: %d\n", (int)date_format_tuple->value->int8);
	} else {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date Tuple Failed\n");
	}
	if( date_format_tuple && date_format_tuple->value->int8 == 49 ) {
		snprintf(temporary_date_holder_callback, sizeof(temporary_date_holder_callback), "%s.%s", day_tickTime, month_tickTime);
		// snprintf(dateWithoutYear, sizeof(dateWithoutYear), "\0");
		snprintf(ddmm_dateWithoutYear, sizeof(ddmm_dateWithoutYear), "%s", temporary_date_holder_callback);
		persist_write_int(KEY_DATE_FORMAT, 1);
		text_layer_set_text(s_date_textLayer, temporary_date_holder_callback);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date was updated as DD-MM 1\n");
	} else if( date_format_tuple && date_format_tuple->value->int8 == 48 ){
		snprintf(temporary_date_holder_callback, sizeof(temporary_date_holder_callback), "%s.%s", month_tickTime, day_tickTime);
		// snprintf(dateWithoutYear, sizeof(dateWithoutYear), "\0");
		snprintf(dateWithoutYear, sizeof(dateWithoutYear), "%s", temporary_date_holder_callback);
		persist_write_int(KEY_DATE_FORMAT, 0);
		text_layer_set_text(s_date_textLayer, temporary_date_holder_callback);
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Date was updated as MM-DD 1\n");
	}

	// Add year or not
	static char temporary_dateWithoutYear_holder_update[32];
	Tuple *year_is_displayed_tuple = dict_find(iterator, KEY_DATE_ADD_YEAR);
	if( year_is_displayed_tuple && year_is_displayed_tuple->value->int8 > 0 ) {
		if( persist_read_int(KEY_DATE_FORMAT) == 1 ) {
			strcpy(temporary_dateWithoutYear_holder_update, ddmm_dateWithoutYear);
		}
		else if( persist_read_int(KEY_DATE_FORMAT) == 0 ) {
			strcpy(temporary_dateWithoutYear_holder_update, dateWithoutYear);
		}
		strcat(temporary_dateWithoutYear_holder_update, year_tickTime);
		persist_write_bool(KEY_DATE_ADD_YEAR, true);
		text_layer_set_text(s_date_textLayer, temporary_dateWithoutYear_holder_update);
	} else if( year_is_displayed_tuple && year_is_displayed_tuple->value->int8 <= 0 ) {
		persist_write_bool(KEY_DATE_ADD_YEAR, false);
		if( persist_read_int(KEY_DATE_FORMAT) == 1 )
			text_layer_set_text(s_date_textLayer, ddmm_dateWithoutYear);
		else
			text_layer_set_text(s_date_textLayer, dateWithoutYear);
	}

	// Language Handing On Callback			
	Tuple *lang_is_eng_tuple = dict_find(iterator, KEY_LANGUAGE);
	if( lang_is_eng_tuple ) {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: lang Tuple Worked!\n");
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: Value Recieved from lang Tuple: %d\n", (int)lang_is_eng_tuple->value->int8);
	} else {
		APP_LOG(APP_LOG_LEVEL_INFO, "Callback: lang Tuple Failed\n");
	}
	if( lang_is_eng_tuple && lang_is_eng_tuple->value->int8 == 49 ) {
		// Time to convert this to spanish
		int dayOfWeekInt = atoi(dayOfWeekNumber_tickTime);
		static char temporary_day_of_week_holder_callback[8];
		switch(dayOfWeekInt) {
			case 0:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Dom");
			break;
			case 1:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Lun");
			break;
			case 2:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Mar");
			break;
			case 3:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Mie");
			break;
			case 4:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Jue");
			break;
			case 5:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Vie");
			break;
			case 6:
				snprintf(temporary_day_of_week_holder_callback, sizeof(temporary_day_of_week_holder_callback), "%s", "Sab");
			break;
			default:
				text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_callback);
			break;
		}
		persist_write_int(KEY_LANGUAGE, 1);
		text_layer_set_text(s_dayOfWeek_textLayer, temporary_day_of_week_holder_callback);
	} else if( lang_is_eng_tuple && lang_is_eng_tuple->value->int8 == 48 ) {
		persist_write_int(KEY_LANGUAGE, 0);
		// English
		text_layer_set_text(s_dayOfWeek_textLayer, engDayOfWeek_tickTime);
	}
	// End Configuration ---------------------------------------------------------
}
Ejemplo n.º 23
0
void down_single_click_handler(ClickRecognizerRef recognizer, void *context)
{
    text_layer_set_text(statusTextLayer, STATUS_SILENCING);
    send_cmd( CMD_STOP );
}
Ejemplo n.º 24
0
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "First Line\n Second Line \n Third Line \n Fourth Line \n Fifth Line");
}
Ejemplo n.º 25
0
static void app_received_msg(DictionaryIterator* received, void* context)
{
    vibes_short_pulse();
    text_layer_set_text(statusTextLayer, STATUS_DONE);
    start_reset_timer();
}
Ejemplo n.º 26
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, true);
  
  s_res_background_image = gbitmap_create_with_resource(RESOURCE_ID_BACKGROUND_IMAGE);
  // s_bitmaplayer_1
  s_bitmaplayer_1 = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_bitmaplayer_1, s_res_background_image);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_1);
  
  //background_layer
  background_layer = layer_create(GRect(0,0,144,168));
  layer_set_update_proc(background_layer, background_update);
  layer_add_child(window_get_root_layer(s_window), (Layer*)background_layer);
  
  // s_layer_1
  s_layer_1 = layer_create(GRect(0, 0, 144, 168));
  layer_set_update_proc(s_layer_1, levels_update);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_layer_1);
  
  time_layer = text_layer_create(GRect(40,90,100,40));
  text_layer_set_text(time_layer, "141.12");
  #ifdef PBL_COLOR
    text_layer_set_text_color(time_layer, GColorElectricBlue);
  #else
    text_layer_set_text_color(time_layer, GColorWhite);
  #endif
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_text_alignment(time_layer, GTextAlignmentRight);
  text_layer_set_font(time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_17)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)time_layer);
  
  charge_layer = text_layer_create(GRect(52,115,88,21));
  text_layer_set_text(charge_layer, "CHRG");
  #ifdef PBL_COLOR
    text_layer_set_background_color(charge_layer, GColorRed);
    text_layer_set_text_color(charge_layer, GColorBlack);
  #else
    text_layer_set_background_color(charge_layer, GColorWhite);
    text_layer_set_text_color(charge_layer, GColorBlack);
  #endif
  text_layer_set_text_alignment(charge_layer, GTextAlignmentCenter);
  text_layer_set_font(charge_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_16)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)charge_layer);
  layer_set_hidden((Layer*)charge_layer, true);
  
  bluetooth_layer = text_layer_create(GRect(16,10,100,40));
  text_layer_set_text(bluetooth_layer, "PTT");
  #ifdef PBL_COLOR
    text_layer_set_text_color(bluetooth_layer, GColorElectricBlue);
  #else
    text_layer_set_text_color(bluetooth_layer, GColorWhite);
  #endif
  text_layer_set_background_color(bluetooth_layer, GColorClear);
  text_layer_set_font(bluetooth_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_METAL_GEAR_13)));
  layer_add_child(window_get_root_layer(s_window), (Layer*)bluetooth_layer);
  
  level1 = gpath_create(&LEVEL_1_POINTS);
  level2 = gpath_create(&LEVEL_2_POINTS);
  level3 = gpath_create(&LEVEL_3_POINTS);
  level4 = gpath_create(&LEVEL_4_POINTS);
  level5 = gpath_create(&LEVEL_5_POINTS);
  level6 = gpath_create(&LEVEL_6_POINTS);
  
  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());
}
Ejemplo n.º 27
0
void show_message(char *msg){
	text_layer_set_text(s_textlayer_message, msg);
}
Ejemplo n.º 28
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Brains Watch");
  window_stack_push(&window, true);

  resource_init_current_app(&APP_RESOURCES);

//    rotbmp_pair_init_container(RESOURCE_ID_IMAGE_PANDA_WHITE, RESOURCE_ID_IMAGE_PANDA_BLACK, &bitmap_container);


  // Set up a layer for the static watch face background
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
  layer_add_child(&window.layer, &background_image_container.layer.layer);


dice = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_VISITOR_16));

  text_layer_init(&date_layer, GRect(53, 105, 40, 40));
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_text_color(&date_layer, GColorBlack);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, dice);
  layer_add_child(&window.layer, &date_layer.layer);

 PblTm ti;
 get_time(&ti);
  
 string_format_time(date_text, sizeof(date_text), "%d", &ti);
 text_layer_set_text(&date_layer, date_text);




  // Set up a layer for the hour hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_HOUR_HAND, &hour_hand_image_container);

    //  hour_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&hour_hand_image_container.layer, GPoint(3, 42));

  layer_add_child(&window.layer, &hour_hand_image_container.layer.layer);


  // Set up a layer for the minute hand
  rotbmp_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND, &minute_hand_image_container);

 // minute_hand_image_container.layer.compositing_mode = GCompOpClear;

  rot_bitmap_set_src_ic(&minute_hand_image_container.layer, GPoint(3, 58));

  layer_add_child(&window.layer, &minute_hand_image_container.layer.layer);






  update_hand_positions();


  // Setup the black and white circle in the centre of the watch face
  // (We use a bitmap rather than just drawing it because it means not having
  // to stuff around with working out the circle center etc.)
  rotbmp_pair_init_container(RESOURCE_ID_IMAGE_CENTER_CIRCLE_WHITE, RESOURCE_ID_IMAGE_CENTER_CIRCLE_BLACK,
			     &center_circle_image_container);

  // TODO: Do this properly with a GRect().
  // (144 = screen width, 168 = screen height)
  center_circle_image_container.layer.layer.frame.origin.x = (144/2) - (center_circle_image_container.layer.layer.frame.size.w/2);
  center_circle_image_container.layer.layer.frame.origin.y = (168/2) - (center_circle_image_container.layer.layer.frame.size.h/2);


  layer_add_child(&window.layer, &center_circle_image_container.layer.layer);

  layer_init(&second_display_layer, window.layer.frame);
  second_display_layer.update_proc = &second_display_layer_update_callback;
  layer_add_child(&window.layer, &second_display_layer);

}
Ejemplo n.º 29
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  // refresh
  text_layer_set_text(price_layer, "Loading...");
  send_to_phone(QUOTE_KEY_FETCH);
}
Ejemplo n.º 30
0
// Redraw time when it's changed (every second)
void handle_timechanges(struct tm *tick_time, TimeUnits units_changed){
  // TimeUnits to redraw just part of screen
  // Buffer where we write time
  static char time_buffer[17];
  
  if (militaryTime) {
    strftime(time_buffer, sizeof(time_buffer), "%H:%M:%S %d.%m %w", tick_time);
  } else {
    strftime(time_buffer, sizeof(time_buffer), "%I:%M:%S %d.%m %w", tick_time);
  }
  
  // Separate digits
  static char hours_1st_digit[2];
  hours_1st_digit[0] = time_buffer[0];
  hours_1st_digit[1] = '\0';
  
  static char hours_2nd_digit[2];
  hours_2nd_digit[0] = time_buffer[1];
  hours_2nd_digit[1] = '\0';
  
  static char minutes_1st_digit[2];
  minutes_1st_digit[0] = time_buffer[3];
  minutes_1st_digit[1] = '\0';
  
  static char minutes_2nd_digit[2];
  minutes_2nd_digit[0] = time_buffer[4];
  minutes_2nd_digit[1] = '\0';
  
  static char seconds_1st_digit[2];
  seconds_1st_digit[0] = time_buffer[6];
  //seconds_1st_digit[0] = '8'; // debug line
  seconds_1st_digit[1] = '\0';
  
  static char seconds_2nd_digit[2];
  seconds_2nd_digit[0] = time_buffer[7];
  //seconds_2nd_digit[0] = '8';
  seconds_2nd_digit[1] = '\0';
  
  static char day_1st_digit[2];
  day_1st_digit[0] = time_buffer[9];
  //day_1st_digit[0] = '0';
  day_1st_digit[1] = '\0';
  
  static char day_2nd_digit[2];
  day_2nd_digit[0] = time_buffer[10];
  //day_2nd_digit[0] = '0';
  day_2nd_digit[1] = '\0';
  
  static char date_delimiter[2];
  date_delimiter[0] = '/';
  date_delimiter[1] = '\0';
  
  static char month_1st_digit[2];
  month_1st_digit[0] = time_buffer[12];
  //month_1st_digit[0] = '0';
  month_1st_digit[1] = '\0';
  
  static char month_2nd_digit[2];
  month_2nd_digit[0] = time_buffer[13];
  //month_2nd_digit[0] = '8';
  month_2nd_digit[1] = '\0';
  
  static char day_of_week_id[2];
  day_of_week_id[0] = time_buffer[15];
  static char day_of_week[3];
    
  switch (day_of_week_id[0]){
    case '0':
    {
      strcpy(day_of_week, "SU");
      break;
    }
    case '1':
    {
      strcpy(day_of_week, "MO");
      break;
    }
    case '2':
    {
      strcpy(day_of_week, "TU");
      break;
    }
    case '3':
    {
      strcpy(day_of_week, "WE");
      break;
    }
    case '4':
    {
      strcpy(day_of_week, "TH");
      break;
    }
    case '5':
    {
      strcpy(day_of_week, "FR");
      break;
    }
    case '6':
    {
      strcpy(day_of_week, "SA");
      break;
    }
    default:
     strcpy(day_of_week, "NA");    
  }
  
  // Draw time
  text_layer_set_text(hours_1st_layer, hours_1st_digit);
  text_layer_set_text(hours_2nd_layer, hours_2nd_digit);
  text_layer_set_text(minutes_1st_layer, minutes_1st_digit);
  text_layer_set_text(minutes_2nd_layer, minutes_2nd_digit);
  text_layer_set_text(seconds_1st_layer, seconds_1st_digit);
  text_layer_set_text(seconds_2nd_layer, seconds_2nd_digit);
  
  // Drawing date according format.
  if (dateDDMM){
    text_layer_set_text(date_1st_layer, day_1st_digit);
    text_layer_set_text(date_2nd_layer, day_2nd_digit);
    text_layer_set_text(date_3rd_layer, month_1st_digit);
    text_layer_set_text(date_4th_layer, month_2nd_digit);
  } else {
    text_layer_set_text(date_1st_layer, month_1st_digit);
    text_layer_set_text(date_2nd_layer, month_2nd_digit);
    text_layer_set_text(date_3rd_layer, day_1st_digit);
    text_layer_set_text(date_4th_layer, day_2nd_digit);
  }

  text_layer_set_text(date_delimiter_layer, date_delimiter);
  text_layer_set_text(day_of_week_layer, day_of_week);
  
  // Get weather update
  if (weatherCountdown > 0) {
    weatherCountdown -= 1;
  } else {
    get_weather();
    weatherCountdown = weatherCountdownInit;
  }
  
  // Draw battery state
  static char battery_buffer[5];
  snprintf(battery_buffer, sizeof(battery_buffer), "%02d%%", s_battery_level);
  text_layer_set_text(s_battery_info_layer, battery_buffer);
}