static void toggleorienttoheading(ClickRecognizerRef recognizer, void *context) {
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  } else {
    orientToHeading = !orientToHeading;
    if (orientToHeading) {
      compass_service_unsubscribe();
      text_layer_set_text(direction_layer, "---");
      if (heading >= 0) { 
        text_layer_set_text(star_layer, "^");
        orientation = -TRIG_MAX_ANGLE * heading / 360;
        draw_compass_face();
      } else 
        text_layer_set_text(star_layer, "?");
    } else {
      compass_service_subscribe(&compass_direction_handler);
      text_layer_set_text(direction_layer, "!!!");
      if (heading >= 0) {
        text_layer_set_text(star_layer, "*");
      } else 
        text_layer_set_text(star_layer, "");
    }
  }
}
static void main_window_unload(Window *window) {
  bitmap_layer_destroy(s_layer);
  text_layer_destroy(s_text_layer);
  gbitmap_destroy(s_bitmap);
  
  // eliminar la suscripcion del servicio del compas
  compass_service_unsubscribe();
}
Example #3
0
void init_compass_service(Window * watchface) {
    if (is_module_enabled(MODULE_COMPASS)) {
        compass_service_subscribe((CompassHeadingHandler)compass_handler);
        compass_service_set_heading_filter(TRIG_MAX_ANGLE/64);
    } else {
        compass_service_unsubscribe();
    }
}