Beispiel #1
0
static void main_window_load(Window *window) {

  #ifdef PBL_ROUND
    GPoint digitPoints[4] = {GPoint(40, 17), GPoint(90, 17), GPoint(40, 92), GPoint(90, 92)};
  #else
    GPoint digitPoints[4] = {GPoint(7, 7), GPoint(60, 7), GPoint(7, 90), GPoint(60, 90)};
  #endif

  ClockDigit_construct(&clockDigits[0], digitPoints[0]);
  ClockDigit_construct(&clockDigits[1], digitPoints[1]);
  ClockDigit_construct(&clockDigits[2], digitPoints[2]);
  ClockDigit_construct(&clockDigits[3], digitPoints[3]);

  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(clockDigits[i].imageLayer));
  }

  window_set_background_color(window, globalSettings.timeBgColor);

  // create the sidebar
  Sidebar_init(window);

  // Make sure the time is displayed from the start
  redrawScreen();
  update_clock();
}
Beispiel #2
0
/* forces everything on screen to be redrawn -- perfect for keeping track of settings! */
void forceScreenRedraw() {
  // maybe the colors changed!
  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
  }

  window_set_background_color(mainWindow, globalSettings.timeBgColor);

  // or maybe the sidebar position changed!
  if(globalSettings.sidebarOnRight) {
    layer_set_frame(sidebarLayer, GRect(114, 0, 30, 168));

    for(int i = 0; i < 4; i++) {
      ClockDigit_offsetPosition(&clockDigits[i], 0);
    }
  } else {
    layer_set_frame(sidebarLayer, GRect(0, 0, 30, 168));

    for(int i = 0; i < 4; i++) {
      ClockDigit_offsetPosition(&clockDigits[i], 30);
    }
  }

  // maybe the language changed!
  update_clock();
}
Beispiel #3
0
static void main_window_load(Window *window) {
//   APP_LOG(APP_LOG_LEVEL_DEBUG, "trying to construct");
  ClockDigit_construct(&clockDigits[0], GPoint(7, 7));
  ClockDigit_construct(&clockDigits[1], GPoint(60, 7));
  ClockDigit_construct(&clockDigits[2], GPoint(7, 90));
  ClockDigit_construct(&clockDigits[3], GPoint(60, 90));

//   APP_LOG(APP_LOG_LEVEL_DEBUG, "Made it past construction");

  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
    layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(clockDigits[i].imageLayer));
  }

//   APP_LOG(APP_LOG_LEVEL_DEBUG, "Made it past color setting");

  // load font
  sidebarFont = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  dateFont = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);

  // init the sidebar layer
  if(globalSettings.sidebarOnRight) {
    sidebarLayer = layer_create(GRect(114, 0, 30, 168));
  } else {
    sidebarLayer = layer_create(GRect(0, 0, 30, 168));
  }
  layer_add_child(window_get_root_layer(window), sidebarLayer);
  layer_set_update_proc(sidebarLayer, sidebarLayerUpdateProc);

  // load the sidebar graphics
  #ifdef PBL_COLOR
    dateImage = gdraw_command_image_create_with_resource(RESOURCE_ID_DATE_BG);
    disconnectImage = gdraw_command_image_create_with_resource(RESOURCE_ID_DISCONNECTED);
    batteryImage = gdraw_command_image_create_with_resource(RESOURCE_ID_BATTERY_BG);
  #else
    dateImage = gbitmap_create_with_resource(RESOURCE_ID_DATE_BG);
    disconnectImage = gbitmap_create_with_resource(RESOURCE_ID_DISCONNECTED);
    batteryImage = gbitmap_create_with_resource(RESOURCE_ID_BATTERY_BG);
  #endif

  if (!dateImage || !disconnectImage) {
    APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to load a PDC image.");
  }

  window_set_background_color(window, globalSettings.timeBgColor);

  // Make sure the time is displayed from the start
  forceScreenRedraw();
  update_clock();
}
Beispiel #4
0
/* forces everything on screen to be redrawn -- perfect for keeping track of settings! */
void redrawScreen() {

  // check if the tick handler frequency should be changed
  if(globalSettings.updateScreenEverySecond != updatingEverySecond) {
    tick_timer_service_unsubscribe();

    if(globalSettings.updateScreenEverySecond) {
      tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
      updatingEverySecond = true;
    } else {
      tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
      updatingEverySecond = false;
    }
  }

  // maybe the colors changed!
  for(int i = 0; i < 4; i++) {
    ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, globalSettings.timeBgColor);
    // ClockDigit_setColor(&clockDigits[i], globalSettings.timeColor, GColorWhite);
  }

  window_set_background_color(mainWindow, globalSettings.timeBgColor);

  // or maybe the sidebar position changed!
  int digitOffset = (globalSettings.sidebarOnLeft) ? 30 : 0;

  for(int i = 0; i < 4; i++) {
    ClockDigit_offsetPosition(&clockDigits[i], digitOffset);
  }

  // maybe the language changed!
  update_clock();

  // update the sidebar
  Sidebar_redraw();
}