static void pause_click_handler(ClickRecognizerRef recognizer, void *context) { int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT; if (calib_stored != 0 && calibrating == 0) { pause++; pause = pause % 2; if (pause == 0) { end_time = time(NULL); double elapsed = difftime(end_time, start_time); result = (int)floor(sum_x/elapsed); display(text_layer_3, "Score: %d", result); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play); int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT; display(text_layer_4, "Calib: %d", calib_stored); text_layer_set_text(text_layer_2, ""); if (result > 2*calib_stored) { send(0, 1); text_layer_set_text(text_layer_1, "YOU'RE DRUNK"); dialog_message_window_push(); } else { send(0, 0); text_layer_set_text(text_layer_1, "YOU'RE FINE"); } } else { sum_x = 0; text_layer_set_text(text_layer_2, "RUNNING"); text_layer_set_text(text_layer_3, ""); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause); start_time = time(NULL); } } }
static void endtrial_callback() { pause++; vibes_short_pulse(); end_time = time(NULL); double elapsed = difftime(end_time, start_time); result = (int)floor(sum_x/elapsed); display(text_layer_3, "Final: %d", result); action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play); int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT; if (result > 2*calib_stored) { send(0,1); text_layer_set_text(text_layer_1, "YOU'RE DRUNK"); text_layer_set_text(text_layer_4, ""); dialog_message_window_push(); } else { send(0,0); text_layer_set_text(text_layer_1, "YOU'RE FINE"); text_layer_set_text(text_layer_2, ""); text_layer_set_text(text_layer_4, ""); } }
void select_click_handler(ClickRecognizerRef recognizer, void *context) { if (cargando==1) return; switch(posicion) { case 0: posicion=1; break; case 1: posicion=2; action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, buscar_bitmap); break; case 2: if (strcmp(devuelve_datos_parada(numero_parada(),0),"Parada inexistente")==0) { posicion =0; } else { posicion=0; layer_mark_dirty(marcador); //envia_peticion(); dialog_message_window_push(numero_parada()); } break; } layer_mark_dirty(marcador); }
static void select_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, void *context) { switch(cell_index->row) { case 0: checkbox_window_push(); break; case 1: dialog_choice_window_push(); break; case 2: dialog_message_window_push(); break; case 3: list_message_window_push(); break; case 4: radio_button_window_push(); break; case 5: { PinWindow *pin_window = pin_window_create((PinWindowCallbacks) { .pin_complete = pin_complete_callback }); pin_window_push(pin_window, true); } break; case 6: text_animation_window_push(); break; case 7: progress_bar_window_push(); break; case 8: progress_layer_window_push(); break; case 9: dialog_config_window_push(); break; default: break; }
void window_load(Window *window) { //Capa para mostrar el marcador bajo los números marcador = layer_create(layer_get_bounds(window_get_root_layer(window))); layer_set_update_proc(marcador, marcador_update_callback); layer_add_child(window_get_root_layer(window), marcador); //Barra de opciones de la derecha action_bar = action_bar_layer_create(); action_bar_layer_add_to_window(action_bar, window); action_bar_layer_set_click_config_provider(action_bar, click_config_provider); //Asignación de recursos gráficos #ifdef PBL_COLOR arriba_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_ARRIBA_BLACK); abajo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_ABAJO_BLACK); pulsar_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_PULSAR_BLACK); play_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_PLAY_BLACK); buscar_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_BUSCAR_BLACK); #else arriba_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_ARRIBA_WHITE); abajo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_ABAJO_WHITE); pulsar_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_PULSAR_WHITE); play_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_PLAY_WHITE); buscar_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONO_BUSCAR_WHITE); #endif //Asignación de iconos a la barra de opciones action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, arriba_bitmap ); action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, abajo_bitmap); if (posicion==2) action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, buscar_bitmap); else action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, play_bitmap); //Capas principales del programa textoparada_layer = init_text_layer(GRect(5, 5, 120, 35), GColorBlack, GColorClear, FONT_KEY_GOTHIC_28_BOLD, GTextAlignmentLeft); text_layer_set_text(textoparada_layer, "Parada"); layer_add_child(window_get_root_layer(window), (Layer*) textoparada_layer); mensaje_layer = init_text_layer(GRect(5, 90, 100, 80), GColorBlack, GColorClear, FONT_KEY_GOTHIC_24_BOLD, GTextAlignmentLeft); text_layer_set_text(mensaje_layer, "Introduce parada"); layer_add_child(window_get_root_layer(window), (Layer*) mensaje_layer); dig1_layer = init_text_layer(GRect(10, 30, 30, 50), GColorBlack, GColorClear, FONT_KEY_ROBOTO_BOLD_SUBSET_49, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), (Layer*) dig1_layer); dig2_layer = init_text_layer(GRect(40, 30, 30, 50), GColorBlack, GColorClear, FONT_KEY_ROBOTO_BOLD_SUBSET_49, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), (Layer*) dig2_layer); dig3_layer = init_text_layer(GRect(70, 30, 30, 50), GColorBlack, GColorClear, FONT_KEY_ROBOTO_BOLD_SUBSET_49, GTextAlignmentCenter); layer_add_child(window_get_root_layer(window), (Layer*) dig3_layer); pinta_datos(); pinta_nombredeparada(); if (i_buscar==1) busca_parada(); if (posicion==2) { dialog_message_window_push(numero_parada()); } }