Ejemplo n.º 1
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  // Check to see if the worker is currently active
  bool running = app_worker_is_running();

  // Toggle running state
  AppWorkerResult result;
  if(running) {
    result = app_worker_kill();

    if(result == APP_WORKER_RESULT_SUCCESS) {
      text_layer_set_text(s_ticks_layer, "Worker stopped!");
    } else {
      text_layer_set_text(s_ticks_layer, "Error killing worker!");
    }
  } else {
    result = app_worker_launch();

    if(result == APP_WORKER_RESULT_SUCCESS) {
      text_layer_set_text(s_ticks_layer, "Worker launched!");
    } else {
      text_layer_set_text(s_ticks_layer, "Error launching worker!");
    }
  }

  APP_LOG(APP_LOG_LEVEL_INFO, "Result: %d", result);
}
Ejemplo n.º 2
0
static void init(void) {
  app_worker_launch();
  app_worker_message_subscribe(worker_message_handler);

  s_window = window_create();
  window_set_background_color(s_window, PBL_IF_COLOR_ELSE(GColorChromeYellow, GColorBlack));
  window_set_click_config_provider(s_window, click_config_provider);
  window_set_window_handlers(s_window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
Ejemplo n.º 3
0
static void init() {

  app_worker_launch();
  app_worker_message_subscribe(worker_message_handler);
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());

  // Create main Window
  s_main_window = window_create();
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
Ejemplo n.º 4
0
// worker functions
static void launch_background_worker(void) {
    if (app_worker_is_running()) return; // already running
    switch (app_worker_launch()) {
        case APP_WORKER_RESULT_SUCCESS: break;
        case APP_WORKER_RESULT_NO_WORKER: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: APP_WORKER_RESULT_NO_WORKER"); break;
        case APP_WORKER_RESULT_NOT_RUNNING: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: APP_WORKER_RESULT_NOT_RUNNING"); break;
        case APP_WORKER_RESULT_ALREADY_RUNNING: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: APP_WORKER_RESULT_ALREADY_RUNNING"); break;
        case APP_WORKER_RESULT_DIFFERENT_APP: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: APP_WORKER_RESULT_DIFFERENT_APP"); break;
        case APP_WORKER_RESULT_ASKING_CONFIRMATION: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: APP_WORKER_RESULT_ASKING_CONFIRMATION"); break;
        default: APP_LOG(APP_LOG_LEVEL_ERROR, "launch_background_worker: UNKNOWN ERROR WHILE LAUNCHING BACKGROUND WORKER"); break;
    }
}
void process_tuple(Tuple *t){
    int key = t->key;
    int value = t->value->int32;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Loaded key %d with value %d.", key, value);
    switch (key) {
        case APP_KEY_INVERT:
            data_framework_local_settings.lightTheme = value;
            break;
        case APP_KEY_WEATHER_FORMAT:
            data_framework_local_settings.fahrenheit = value;
            if(data_framework_local_settings.fahrenheit){
                data_framework_local_settings.previousTemp = (1.8*(data_framework_local_settings.previousTempRaw-273)+32);
            }
            else{
                data_framework_local_settings.previousTemp = data_framework_local_settings.previousTempRaw-273;
            }
            break;
        case APP_KEY_ANIMATIONS:
            data_framework_local_settings.animations = value;
            break;
        case APP_KEY_AUTO_OPEN:
            data_framework_local_settings.autoOpen = value;
            if(data_framework_local_settings.autoOpen){
                app_worker_launch();
            }
            else{
                app_worker_kill();
            }
            break;
        case APP_KEY_DATE_FORMAT:
            data_framework_local_settings.altDateFormat = value;
            break;
        case APP_KEY_TEMPERATURE:
            data_framework_local_settings.previousTemp = value;
            data_framework_local_settings.previousTempRaw = value;
            if(data_framework_local_settings.fahrenheit){
                data_framework_local_settings.previousTemp = (1.8*(value-273)+32);
            }
            else{
                data_framework_local_settings.previousTemp = value-273;
            }
            break;
        case APP_KEY_CONDITION:
            data_framework_local_settings.previousCondition = value;
            break;
        case APP_KEY_REDUCE_ANIMATIONS:
            data_framework_local_settings.reduceAnimations = value;
            break;
    }
}
Ejemplo n.º 6
0
static void window_appear(Window *window){
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  handle_minute_tick(NULL, MINUTE_UNIT);
  
   bool running = app_worker_is_running();
 
  if (running) {
     APP_LOG(APP_LOG_LEVEL_DEBUG, "Worker Running do nothing");
   //result= app_worker_kill();
  } else {
     APP_LOG(APP_LOG_LEVEL_DEBUG, "Worker stopped");
     app_worker_launch();
  }

}
Ejemplo n.º 7
0
//---------------------------------------------------------------------------------
// Click Handlers
//---------------------------------------------------------------------------------
//------- Select Click Handlers ----------
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
    // Toggle running state
    if (app_worker_is_running()) {
        if (app_worker_kill() == APP_WORKER_RESULT_SUCCESS) {
            text_layer_set_text(text_layer, "Worker stopped!");
            APP_LOG(APP_LOG_LEVEL_INFO, "Worker Stopped");
        } else {
            text_layer_set_text(text_layer, "Error killing worker!");
            APP_LOG(APP_LOG_LEVEL_INFO, "Error Killing Worker");
        }
    } else {
        if (app_worker_launch() == APP_WORKER_RESULT_SUCCESS) {
            text_layer_set_text(text_layer, "Worker launched!");
            APP_LOG(APP_LOG_LEVEL_INFO, "Worker Launched");
        } else {
            text_layer_set_text(text_layer, "Error launching worker!");
            APP_LOG(APP_LOG_LEVEL_INFO, "Error Launching Worker");
        }
    }
}
Ejemplo n.º 8
0
void start_motion_capturing() {
    AppWorkerResult result = app_worker_launch();
}
Ejemplo n.º 9
0
void handle_init(void) {
  // show main
  show_w_master();
  // start worker
  app_worker_launch();
}
Ejemplo n.º 10
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  app_worker_launch();
}