void display_value(unsigned short value, unsigned short row_number, bool show_first_leading_zero)
{
  /*

     Displays a numeric value between 0 and 99 on screen.

     Rows are ordered on screen as:

       Row 0
       Row 1

     Includes optional blanking of first leading zero,
     i.e. displays ' 0' rather than '00'.

   */
  value = value % 100; // Maximum of two digits per row.
  // Column order is: | Column 0 | Column 1 |
  // (We process the columns in reverse order because that makes
  // extracting the digits from the value easier.)
  
    for (int column_number = 1; column_number >= 0; column_number--) {
    int slot_number = (row_number * 2) + column_number;
    unload_digit_image_from_slot(slot_number);
    if (!((value == 0) && (column_number == 0) && !show_first_leading_zero)) {
      load_digit_image_into_slot(slot_number, value % 10);
    }
    value = value / 10;
  }
}
Beispiel #2
0
void display_value(unsigned short value, unsigned short row_number, bool show_first_leading_zero, bool isReversed, int startNum, int endNum) {

  value = value % 100;
  
  for (int column_number = startNum; column_number >= endNum; column_number--) {
    int slot_number = (row_number * 4) + column_number;
    if(isReversed){
    	if(slot_number == 0){
    		slot_number = 1;
    	}else if(slot_number == 1){
    		slot_number = 0;
    	}
    	if(slot_number == 6){
    		slot_number = 7;
    	}else if(slot_number == 7){
    		slot_number = 6;
    	}
    }
    unload_digit_image_from_slot(slot_number);
    if (!((value == 0) && (column_number == 0) && !show_first_leading_zero)) {
      load_digit_image_into_slot(slot_number, value % 10, isReversed);
    }
    value = value / 10;
  }
}
Beispiel #3
0
static void do_init(void) {
  window = window_create();

  window_stack_push(window, true);
  window_layer = window_get_root_layer(window);
  
  date_layer = text_layer_create(GRect(layers[0][0][0],layers[0][0][1],layers[0][1][0],layers[0][1][1]));
  text_layer_set_text_alignment(date_layer, GTextAlignmentCenter);
  text_layer_set_text(date_layer, "");
  
  ampm_layer = text_layer_create(GRect(layers[3][0][0],layers[3][0][1],layers[3][1][0],layers[3][1][1]));
  text_layer_set_text_alignment(ampm_layer, GTextAlignmentCenter);
  text_layer_set_text(ampm_layer, "");
  text_layer_set_text_color(date_layer, GColorBlack);
  text_layer_set_background_color(date_layer, GColorWhite);
  text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16)));
  
  conn_layer = bitmap_layer_create(
    GRect(layers[1][0][0],layers[1][0][1],layers[1][1][0],layers[1][1][1]));
  load_icon_into_layer(0, bitmap_layer_get_layer(conn_layer));
  
  battery_layer = bitmap_layer_create(
    GRect(layers[2][0][0],layers[2][0][1],layers[2][1][0],layers[2][1][1]));
  load_icon_into_layer(0, bitmap_layer_get_layer(battery_layer));
  
  int adj = 0;
  for (int slot_number = 0; slot_number < TOTAL_IMAGE_SLOTS; slot_number++) {
    digit_slot[slot_number] = bitmap_layer_create(
        GRect(position[slot_number][0][0], position[slot_number][0][1], position[slot_number][1][0], position[slot_number][1][1]));
    
    load_digit_image_into_slot(slot_number, slot_number);
    layer_add_child(window_layer, bitmap_layer_get_layer(digit_slot[slot_number]));
  }
  
    time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  
  handle_second_tick(current_time, SECOND_UNIT);
  handle_bluetooth(bluetooth_connection_service_peek());
  handle_battery(battery_state_service_peek());
  
  tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);
  
  layer_add_child(window_layer, text_layer_get_layer(date_layer));
  
  window_set_background_color(window, GColorWhite);
  text_layer_set_text_color(date_layer, GColorBlack);
  text_layer_set_background_color(date_layer, GColorWhite);
  text_layer_set_font(date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_BOLD_16)));

  layer_add_child(window_layer, bitmap_layer_get_layer(conn_layer));
  layer_add_child(window_layer, bitmap_layer_get_layer(battery_layer));
  
  layer_add_child(window_layer, text_layer_get_layer(ampm_layer));
}
Beispiel #4
0
void display_value(unsigned short value, unsigned short row_number, bool show_first_leading_zero) {
  value = value % 100; 
  
  for (int column_number = 1; column_number >= 0; column_number--) {
    int slot_number = (row_number * 2) + column_number;
    if (!((value == 0) && (column_number == 0) && !show_first_leading_zero)) {
      load_digit_image_into_slot(slot_number, value % 10);
    }
    value = value / 10;
  }
}
Beispiel #5
0
static void display_value(unsigned short value, unsigned short row_number) {
    value = value % 100; // Maximum of two digits per row.

    // Slot Order is: 0 | 1 | 2 | 3
    // (We process the slots in reverse order because that makes
    // extracting the digits from the value easier.)
    for (int column_number = 1; column_number >= 0; column_number--) {
        int slot_number = (row_number * 2) + column_number;
        unload_digit_image_from_slot(slot_number);
        load_digit_image_into_slot(slot_number, value % 10);
        value = value / 10;
    }
}
static void display_value(unsigned short value, unsigned short row_number, bool show_first_leading_zero) {
  value = value % 100; // Maximum of two digits per row.

  // Column order is: | Column 0 | Column 1 |
  // (We process the columns in reverse order because that makes
  // extracting the digits from the value easier.)
  for (int column_number = 1; column_number >= 0; column_number--) {
    int slot_number = (row_number * 2) + column_number;
    unload_digit_image_from_slot(slot_number);
    if (!((value == 0) && (column_number == 0) && !show_first_leading_zero)) {
      load_digit_image_into_slot(slot_number, value % 10);
    }
    value = value / 10;
  }
}