Exemple #1
0
int main(void)
{
    window = window_create();  /* Инициализируем окно */
    window_set_background_color(window, GColorBlack); /* устанавливаем фоновый цвет */
    window_set_fullscreen(window, true); /* включаем полноэкранность */
    window_stack_push(window, true);  /* открываем окно с анимацией */
    srand(time(NULL)); /* инициализируем генератор случайных чисел текущем временем */
    text_layer = text_layer_create(GRect(0 , 30, 144, 168)); /* создаем текстовый массив, указываем размер и координаты */
    text_layer_set_text_color(text_layer, GColorWhite);  /* устанавливаем цвет текста */
    text_layer_set_background_color(text_layer, GColorClear);  /* устанавливаем цвет фона */
    text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); /* устанавливаем шрифт */
    text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); /* устанавливаем выравнивание по центру */
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));  /* подключаем текстовый слой к основному в качестве дочернего */
#if (LANG == ENG)
    text_layer_set_text(text_layer, "Shake to roll \n the dice!");  /* показываем сообщение при запуске */
#endif
#if (LANG == RUS)
    text_layer_set_text(text_layer, "Встряхните часы для броска костей");  /* показываем сообщение при запуске */
#endif
    accel_tap_service_subscribe(accel_int);  /* подписываемся на прерывания от акселерометра */
    app_event_loop();  /* ждем событий */
    if (first_time == true) /* если выходим без запуска перебора... */
    { 
        text_layer_destroy(text_layer); /* ...то удаляем текстовый слой с сообщением */
    }
    else  /* если выходим уже после запуска... */
    {    
        bitmap_layer_destroy(image_layer); /* ...то уничтожаем текстовый слой... */
        gbitmap_destroy(image); /* ... и уничтожаем массив с графикой, текстовый слой уже удален в функции accel_int */
    }
    accel_tap_service_unsubscribe();  /* отписываемся от прерываний акселерометра */
    window_destroy(window);  /* уничтожаем главное окно, освобождаем ресурсы */
}
Exemple #2
0
static void handle_tap(AccelAxisType axis, int32_t direction) {
    persist_write_bool(STYLE_KEY, !persist_read_bool(STYLE_KEY));
    set_style();
    force_update();
    vibes_long_pulse();
    accel_tap_service_unsubscribe();
}
Exemple #3
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context){
	Tuple *minutes = dict_find(iterator, VIBE_TIME);
	if(minutes){
		mins = minutes->value->uint8;
		persist_write_int(KEY_MINUTES, mins);
	}
	
	Tuple *center_t = dict_find(iterator, CENTER);
	if(center_t){
		center = center_t->value->int8;
		persist_write_bool(CENTER, center);
		
		window_stack_pop(false);
		deinit();
		init();
	}
	
	Tuple *date = dict_find(iterator, SHOW_DATE);
	if(date){
		accel_tap_service_unsubscribe();
		if(date->value->int8){
			accel_tap_service_subscribe(accel_tap_handler);
		}
	}
	
}
Exemple #4
0
void handle_deinit(void) {
	tick_timer_service_unsubscribe();
	accel_tap_service_unsubscribe();
  text_layer_destroy(time_layer);
	text_layer_destroy(date_layer);
  window_destroy(my_window);
}
Exemple #5
0
SimplyAccel *simply_accel_create(Simply *simply) {
  if (s_accel) {
    return s_accel;
  }

  SimplyAccel *self = malloc(sizeof(*self));
  *self = (SimplyAccel) {
    .simply = simply,
    .rate = ACCEL_SAMPLING_100HZ,
    .num_samples = 25,
  };
  s_accel = self;

  accel_tap_service_subscribe(handle_accel_tap);

  return self;
}

void simply_accel_destroy(SimplyAccel *self) {
  if (!self) {
    return;
  }

  accel_tap_service_unsubscribe();

  free(self);

  s_accel = NULL;
}
Exemple #6
0
static void deinit(void) {
	tick_timer_service_unsubscribe();
	accel_tap_service_unsubscribe();
	battery_state_service_unsubscribe();
	bitmap_layer_destroy(pow_layer);
	text_layer_destroy(battery_layer);
	window_destroy(my_window);
}
// destroy objects
static void main_window_unload(Window *window) {
  text_layer_destroy(s_time_layer);
  text_layer_destroy(s_text_layer);
  gbitmap_destroy(s_logo_bitmap);
  bitmap_layer_destroy(s_logo_layer);
  inverter_layer_destroy(s_invert_layer);
  accel_tap_service_unsubscribe();
}
Exemple #8
0
static void deinit(void) {
	accel_tap_service_unsubscribe();
	tick_timer_service_unsubscribe();
	text_layer_destroy(textLayer);
	fonts_unload_custom_font(font);
	layer_destroy(layer);
	window_destroy(window);
}
void handle_deinit(void) {
    accel_tap_service_unsubscribe();
	text_layer_destroy(text_time_layer);
	text_layer_destroy(text_date_layer);
	text_layer_destroy(text_countdown_layer);
    bitmap_layer_destroy(text_image_layer);
    bitmap_layer_destroy(logo_image_layer);
	window_destroy(window);
}
/*----------------------------------------------------------------------------*/
int main(void)
{
  APP_LOG(APP_LOG_LEVEL_INFO, "main: entry:  %s %s", __TIME__, __DATE__);

  /*
   *   Commission App
   */
  window = window_create();

  WindowHandlers handlers = {.load = window_load, .unload = window_unload };
  window_set_window_handlers(window, handlers);

  const bool animated = true;
  window_stack_push(window, animated);

  Layer * window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  /* Display the simple splash screen to indicate PebblePointer is running. */
  image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PEBBLEPOINTER);
  image_layer = bitmap_layer_create(bounds);
  bitmap_layer_set_bitmap(image_layer, image);
  bitmap_layer_set_alignment(image_layer, GAlignCenter);
  layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));

  /* Basic accelerometer initialization.  Enable Tap-Tap functionality. */
  accel_service_set_sampling_rate( SAMPLING_RATE );
  accel_tap_service_subscribe( (AccelTapHandler) accel_tap_callback );
  app_message_open(SYNC_BUFFER_SIZE, SYNC_BUFFER_SIZE);

  /* Request notfication on Bluetooth connectivity changes.  */
  bluetooth_connection_service_subscribe( bluetooth_connection_callback );
  isConnected = bluetooth_connection_service_peek();
  APP_LOG(APP_LOG_LEVEL_INFO, "initially %sonnected", (isConnected) ? "c" : "disc");

  /*
   *   Event Processing
   */
  app_event_loop();

  /*
   *   Decommission App
   */
  if (tapSwitchState == true) {
    accel_data_service_unsubscribe();
  }

  /* Remove the Tap-Tap callback */
  accel_tap_service_unsubscribe();

  /* Release splash-screen resources */
  gbitmap_destroy(image);
  bitmap_layer_destroy(image_layer);
  window_destroy(window);

  APP_LOG(APP_LOG_LEVEL_INFO, "main: exit");
}
Exemple #11
0
static void deinit(void) {
	accel_tap_service_unsubscribe();
	accel_data_service_unsubscribe();
	if (timer != NULL) app_timer_cancel(timer);
	tick_timer_service_unsubscribe();
	layer_destroy(layer);
  fonts_unload_custom_font(fontHour);
  fonts_unload_custom_font(fontDate);
	window_destroy(window);
}
Exemple #12
0
void handle_deinit(void) {
    window_destroy(window);
    bitmap_layer_destroy(background);
    gbitmap_destroy(background_bmp);
    
    for(int i = 0; i < 4; i++)
        unload_number(i >> 1, i & 1);
    
    tick_timer_service_unsubscribe();
    accel_tap_service_unsubscribe();
}
Exemple #13
0
static void windows_kodi_unload(Window *window){
  action_bar_layer_destroy(action_bar);
  text_layer_destroy(s_title_info_layer);
  text_layer_destroy(s_album_info_layer);

  if (TAP_NOT_DATA) {
    accel_tap_service_unsubscribe();
  } else {
    accel_data_service_unsubscribe();
  }
}
void handle_deinit() {
	int i;
	
	accel_tap_service_unsubscribe();
	tick_timer_service_unsubscribe();
	
	for (i=0; i<NUMSLOTS; i++) {
		deinitSlot(i);
	}
	
	window_destroy(window);
}
Exemple #15
0
void main_window_deinit(void)
{
	accel_tap_service_unsubscribe();
	tick_timer_service_unsubscribe();
	if (app_timer != NULL) {
		app_timer_cancel(app_timer);
	}

	for (int index = 0; index < 4; index++) {
		text_layer_destroy(text_layers[index]);
	}

	window_destroy(main_window);
}
static void accel_tap_handler(AccelAxisType axis, int32_t direction) {
    accel_data_service_unsubscribe();
    vibes_short_pulse();
    psleep(2000);
    accel_data_service_subscribe(1, accel_handler);
    accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
    pause = 1;
    accel_tap_service_unsubscribe();
    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);
    app_timer_register(10000, endtrial_callback, (void*)start_time);
}
static void back_click_handler(ClickRecognizerRef recognizer, void *context){
    uninvertText();
    inv=0;
    i=0;
    num_cards=0;
    for (int i = 0; i < num_cards*2; ++i){
      free(cdarray[i]);
    }
    free(cdarray);
    accel_tap_service_unsubscribe();
    window_stack_pop(true); 
    return;

}
Exemple #18
0
void refresh_settings(){
	phrases_set_settings(main_settings);

	//Little hack to update the words beforehand
	phrases_get_main_swear(true, true);
	phrases_get_main_swear(false, true);

	text_layer_set_text(second_word_t, phrases_get_main_swear(altWordBuffer, false));
	layer_set_frame(text_layer_get_layer(second_word_t), get_new_frame(second_word_t, phrases_get_main_swear(altWordBuffer, false)));
	adapt_font_size_to_frame(second_word_t);

	layer_set_hidden(inverter_layer_get_layer(theme), !main_settings.invert);
	layer_set_hidden(battery_bar_layer, !main_settings.batteryBar);
	layer_set_hidden(text_layer_get_layer(slot_t), false);
	layer_set_hidden(text_layer_get_layer(seconds_t), !main_settings.seconds);
	switch(main_settings.slotUse){
		case SLOT_USE_NOTHING:
			layer_set_hidden(text_layer_get_layer(slot_t), true);
			break;
		case SLOT_USE_CUSTOM_TEXT:
			text_layer_set_text(slot_t, main_settings.customslottext[0]);
			break;
		case SLOT_USE_BLUETOOTH_STATUS:;
			bool connected = bluetooth_connection_service_peek();
			text_layer_set_text(slot_t, phrases_get_bluetooth(connected));
			break;
	}
	if(main_settings.shakeAction == SHAKE_USE_DISABLED){
		accel_tap_service_unsubscribe();
	}
	else{
		accel_tap_service_unsubscribe();
		accel_tap_service_subscribe(shake_handler);
	}
	notify_bar_set_enabled(main_settings.alerts);
	set_animation_use(main_settings.animation);
}
void window_unload(Window *window)
{
  // Call this before destroying text_layer, because it can change the text
  // and this must only happen while the layer exists.
  accel_data_service_unsubscribe();
  accel_tap_service_unsubscribe();

  text_layer_destroy(text_layer_2);
  text_layer_destroy(text_layer_1);
  text_layer_destroy(text_layer_3);
  text_layer_destroy(text_layer_4);
  gbitmap_destroy(s_icon_reset);
  gbitmap_destroy(s_icon_play);
  gbitmap_destroy(s_icon_pause);
  gbitmap_destroy(s_icon_calib);
}
Exemple #20
0
void update_configuration(void)
{
    bool show_battery = 1;    /* default to true */

    if (persist_exists(CONFIG_KEY_BATTERY))
    {
        show_battery = persist_read_bool(CONFIG_KEY_BATTERY);
    }
	
	if (show_battery) {
		accel_tap_service_unsubscribe();
		qtp_setup();
	} else {
		qtp_app_deinit();
        accel_tap_service_subscribe(&tap_handler);
	}
}
Exemple #21
0
static void handle_deinit(void)
{
   tick_timer_service_unsubscribe();
   accel_tap_service_unsubscribe();

   text_layer_destroy(line1);
   text_layer_destroy(line2);
   text_layer_destroy(line3);

   bitmap_layer_destroy(blockp_layer);
   gbitmap_destroy(blockp_image);

   bitmap_layer_destroy(splash_layer);
   gbitmap_destroy(splash_image);

   window_destroy(window);
}  // handle_deinit()
Exemple #22
0
void handle_deinit(void) {
    tick_timer_service_unsubscribe();
    battery_state_service_unsubscribe();
    bluetooth_connection_service_unsubscribe();
    accel_tap_service_unsubscribe();
    
    bitmap_layer_destroy(bt_layer);
    gbitmap_destroy(bt);
    
    bitmap_layer_destroy(bg_layer);
    gbitmap_destroy(background);
    
    text_layer_destroy(time_layer);
    text_layer_destroy(date_layer);
    text_layer_destroy(battery_layer);
    text_layer_destroy(game_layer);
}
Exemple #23
0
void cierre(void)
{
  //parte accelerometer
  accel_data_service_unsubscribe();
  accel_tap_service_unsubscribe();
 
  text_layer_destroy(text_layer_2);
  text_layer_destroy(text_layer_1);
  //---------------------
  
  tick_timer_service_unsubscribe();
  battery_state_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();
  text_layer_destroy(time_layer);
  text_layer_destroy(connection_layer);
  text_layer_destroy(battery_layer);
  window_destroy(window);
}
Exemple #24
0
static void handle_tick(struct tm *tick_time, TimeUnits units_changed)
{
       APP_LOG(APP_LOG_LEVEL_ERROR, "checking for handshake...");
       if (data_handshake == true && tap_handshake == true)
       {
         vibes_double_pulse();
         
         text_layer_set_text(phone_layer, "");
         text_layer_set_text(name_layer, "");
         APP_LOG(APP_LOG_LEVEL_ERROR, "handshake detected!");
showPopup();
         //send_cmd();
         data_handshake = false;
         tap_handshake = false;
         accel_data_service_unsubscribe();
         accel_tap_service_unsubscribe();
       }
}
Exemple #25
0
void handle_deinit() {
  int i;
  if (timer != NULL) {
    app_timer_cancel(timer);
    timer=NULL;
  }

  bluetooth_connection_service_unsubscribe();
  accel_tap_service_unsubscribe();
  tick_timer_service_unsubscribe();
  
  for (i=0; i<NUMSLOTS; i++) {
    deinitSlot(i);
  }
  
  layer_destroy(mainLayer);
  window_destroy(window);
}
static void window_unload(Window *window)
{
    numOfNotifications = 0;

    nw_ui_unload();

    #ifdef PBL_COLOR
        if (bitmapReceivingBuffer != NULL)
        {
            free(bitmapReceivingBuffer);
            bitmapReceivingBuffer = NULL;
        }

        if (notificationBitmap != NULL)
        {
            gbitmap_destroy(notificationBitmap);
            notificationBitmap = NULL;
        }
    #endif

    #ifdef PBL_MICROPHONE
    if (dictationSession != NULL)
            dictation_session_destroy(dictationSession);
    #endif

    accel_tap_service_unsubscribe();
    bluetooth_connection_service_unsubscribe();
    tick_timer_service_unsubscribe();

    window_destroy(window);

    if (main_noMenu && config_dontClose)
    {
        closeApp();
    }

    if (main_noMenu)
        closingMode = true;

    for (int i = 0; i < NOTIFICATION_SLOTS; i++)
    {
        destroy_notification(notificationData[i]);
    }
}
Exemple #27
0
static void main_window_unload(Window *window) {
  // Unregister services 
  tick_timer_service_unsubscribe();
  battery_state_service_unsubscribe();
  accel_tap_service_unsubscribe();
  bluetooth_connection_service_unsubscribe();

  // Destroy TextLayers
  text_layer_destroy(s_time_layer);
  text_layer_destroy(s_date_layer);
  text_layer_destroy(s_battery_layer);
  
  // Destroy BT resources
  bitmap_layer_destroy(s_bt_layer);
  gbitmap_destroy(s_bt_connected_bitmap);
  gbitmap_destroy(s_bt_disconnected_bitmap);
  inverter_layer_destroy(s_inv_layer);
  
  // Destroy Pi Time
  bitmap_layer_destroy(s_pi_layer);
  gbitmap_destroy(s_pi_bitmap);
}
Exemple #28
0
int main(void) {
  window = window_create();
  window_stack_push(window, true /* Animated */ );
  //accel_data_service_subscribe(0, handle_accel);//subscribe to the accel service
  window_set_click_config_provider(window, click_config_provider);
  psleep(1000);
  
  accel_tap_service_subscribe(&accel_tap_handler);
  
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  text_layer = text_layer_create(bounds);
  char str[30];
  snprintf(str, 30, "Pebble Butt");
  text_layer_set_text(text_layer, str);
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer));
  app_event_loop();  
  //destructor of the main func
  accel_tap_service_unsubscribe();
  text_layer_destroy(text_layer);
  window_destroy(window);
}
Exemple #29
0
static void handle_tap_timeout(void* data) {
    accel_tap_service_unsubscribe();
}
Exemple #30
0
static void handle_window_disappear(Window* window) {
  accel_tap_service_unsubscribe();
}