Beispiel #1
0
void in_received_handler(DictionaryIterator *iter, void *context) {
#ifdef ENABLE_LOGS
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Watch: Message received");
#endif
    
    int x = 0;
    
    //processing usernames
    for (x=0;x<MAX_NUM_USERS;x++){
        Tuple *tuple = dict_find(iter, CONST_FRIEND1+x);
        if (tuple){
            set_username_for_friend_at_index(tuple->value->cstring,x);
        }
    }
    //processing ids
    for (x=0;x<MAX_NUM_USERS;x++){
        Tuple *tuple = dict_find(iter, CONST_FRIEND1+x+100);
        if (tuple){
            set_id_for_friend_at_index(tuple->value->cstring,x);
        }
    }
    
    //processing number of friends received, this message should be the last one done in JS
    Tuple *tuple = dict_find(iter, CONST_FRIENDS_COUNT);
    if (tuple){
        set_num_friends(tuple->value->int32);
        save_cache();
    }
    
    //Confirmation of Sending Message
    Tuple *tuple2 = dict_find(iter, CONST_STATUS);
    if (tuple2){
        int error = tuple2->value->int32;
        if (error == STYLE_ERROR) {
            vibes_long_pulse();
            show_message_window(_("Message|Failed"),STYLE_ERROR);
        }
        else {
            vibes_short_pulse();
            show_message_window(_("Message|Sent"),STYLE_SUCCESS);
        }
    }
    
    //Confirmation of Sending Message
    Tuple *tuple3 = dict_find(iter, CONST_ERROR_UPDATING_TOKEN);
    if (tuple3){
        int error = tuple3->value->int32;
        if (error == STYLE_ERROR) {
            vibes_long_pulse();
            show_message_window(_("Failed|to Sync"),STYLE_ERROR);
        }
        else {
            vibes_short_pulse();
            show_message_window(_("Sync|Succeed"),STYLE_SUCCESS);
        }
    }
}
Beispiel #2
0
static void handle_vibe(DictionaryIterator *iter, SimplyData *simply) {
  Tuple *tuple;
  if ((tuple = dict_find(iter, 1))) {
    switch ((VibeType) tuple->value->int32) {
      case VibeShort: vibes_short_pulse(); break;
      case VibeLong: vibes_short_pulse(); break;
      case VibeDouble: vibes_double_pulse(); break;
    }
  }
}
Beispiel #3
0
static void vibrate_quarterly_pattern(int minutes) {
  if(minutes % 15 == 0) {
    vibes_short_pulse();
  }
  
  if(minutes % 30 == 0) {
    vibes_short_pulse();
  }
  
  if(minutes % 45 == 0) {
    vibes_short_pulse();
  }
}
Beispiel #4
0
void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
  switch (cell_index->section) {
    case 0:
      switch (cell_index->row) {
      case 0:
        if (loading==0) carga_calendario();
        break;
      case 1:
        if (loading==0) carga_fpp();
        break;
      }
      break;
    
    case 1:
      switch (cell_index->row) {
      case 0:
         if (loading==0){
           send_int(5,5);
           char version[20];
           time_t now = time(NULL);
           struct tm *tick_time = localtime(&now); 
           snprintf(version, 20, "Versión: %i-%i-%i",tick_time->tm_mday,(tick_time->tm_mon)+1,(tick_time->tm_year)-100); 
           vibes_short_pulse();
           loading = 0;
           layer_mark_dirty(menu_layer_get_layer(menu_layer));
         }
         break;
      }
      break;    
  }
}
Beispiel #5
0
static void update_hours(struct tm *tick_time) {

  if(appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
  }
  
  unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&time_digits_images[0], time_digits_layers[0], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(0, 14)); //n3v3r original 5-> je zahl nun 4 breiter
  set_container_image(&time_digits_images[1], time_digits_layers[1], BIG_DIGIT_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(32, 14)); //n3v3r original 33

  if (!clock_is_24h_style()) {
    if (tick_time->tm_hour >= 12) {
      set_container_image(&time_format_image, time_format_layer, RESOURCE_ID_IMAGE_PM_MODE, GPoint(60, 2));
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), false);
    } 
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_format_layer), true);
    }
    
    if (display_hour/10 == 0) {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), true);
    }
    else {
      layer_set_hidden(bitmap_layer_get_layer(time_digits_layers[0]), false);
    }

  }
}
Beispiel #6
0
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, "");
  }

}
Beispiel #7
0
/*
 * Handle an up or down button press and validate results
 */
static void up_down_handler(int8_t delta) {
  switch (current_field) {
    case F_FROM_HOUR:
    case F_TO_HOUR:
      alter_time(current_field, delta, 23, 0);
      break;
    case F_FROM_MINUTE:
    case F_TO_MINUTE:
      alter_time(current_field, 5 * delta, 55, 0);
      break;
    case F_SMART_ALARM:
      alter_time(current_field, 1, 1, 0);
      break;
    case F_DONE:
      if (values[F_DONE] == 1)
        hide_set_alarm();
      else
        vibes_short_pulse();
      break;
  }
  uint32_t from = to_mins(values[F_FROM_HOUR], values[F_FROM_MINUTE]);
  uint32_t to = to_mins(values[F_TO_HOUR], values[F_TO_MINUTE]);
  values[F_DONE] = (from <= to);
  write_values_to_fields();
}
Beispiel #8
0
void inbox(DictionaryIterator *iter, void *context){
  Tuple *t = dict_read_first(iter);
  if(t) process_tuple(t);
  while(t != NULL){
	t = dict_read_next(iter);
	if(t) process_tuple(t);
  }
	
  if(current == INIT){
	  current = SPLASH;
  }
  else if(current == SPLASH){
	current = HOME;
	window_stack_push(home_window, true);
	window_stack_remove(splash_window, false);
  }
  else if(current == LOADING){
	push_appropriate_window();
  }
  else if(current == MATCHUP){
	//APP_LOG(APP_LOG_LEVEL_INFO, "Old Ally: %d, Old Enemy: %d. Ally: %d, Enemy: %d.", old_matchup_ally_score_int,old_matchup_enemy_score_int,matchup_ally_score_int,matchup_enemy_score_int);
	if( (old_matchup_ally_score_int > old_matchup_enemy_score_int && matchup_ally_score_int < matchup_enemy_score_int)
	 || (old_matchup_ally_score_int < old_matchup_enemy_score_int && matchup_ally_score_int > matchup_enemy_score_int)
	 || (old_matchup_ally_score_int == 0 && old_matchup_enemy_score_int == 0 && (matchup_ally_score_int != 0 || matchup_enemy_score_int != 0)))
	{
		vibes_short_pulse();
	}
	old_matchup_ally_score_int = matchup_ally_score_int;
	old_matchup_enemy_score_int = matchup_enemy_score_int;
	   	  
	layer_mark_dirty(matchup_custom_layer);
  }
}
Beispiel #9
0
static void timer_callback(struct tm *tick_time, TimeUnits units_changed) {
	if (state.round_time == 0) {
		if (state.stretch && stretch_settings.prepare != 0) {
			state.round++;
			state.round_time = stretch_settings.prepare;      
			vibes_long_pulse();
			text_layer_set_text(ui.top_text, "Prepare");
			state.stretch = 0;
		} else {
			if (stretch_settings.prepare == 0) {
				state.round++;
			}

			state.round_time = stretch_settings.time;
			vibes_short_pulse();
			text_layer_set_text(ui.top_text, "Stretch");
			state.stretch = 1;
		}

		update_ui();
	}

	if (state.running) {
		update_time_ui();
	}
}
Beispiel #10
0
bool ComputeRandomEvent(bool fastMode)
{
	uint16_t chanceOfEvent = EVENT_CHANCE_BASE;
#if EVENT_CHANCE_SCALING
	if(ticksSinceLastEvent > 3) {
		chanceOfEvent += (ticksSinceLastEvent - 2) * 4;
	}
#endif
	if(!fastMode) {
		uint16_t result = Random(100) + 1;
		if(result > chanceOfEvent) {
			if(Random(4) == 1) {
				HealStamina(1);
			}
			return false;
		}
	}
	
	if(GetVibration())
		vibes_short_pulse();
		
	ComputeAdventure();
	
#if EVENT_CHANCE_SCALING
		ticksSinceLastEvent = 0;
#endif
	return true;
}
Beispiel #11
0
static void update_hours(struct tm *tick_time) {

	if (appStarted && hourlyvibe) {
    //vibe!
    vibes_short_pulse();
	}
	
  unsigned short display_hour = get_display_hour(tick_time->tm_hour);

  set_container_image(&normal_time_digits_images[0], normal_time_digits_layers[0], NORMAL_IMAGE_RESOURCE_IDS[display_hour/10], GPoint(0, 40));
  set_container_image(&normal_time_digits_images[1], normal_time_digits_layers[1], NORMAL_IMAGE_RESOURCE_IDS[display_hour%10], GPoint(34, 40));

	
	if (!clock_is_24h_style()) {
	
	if (display_hour/10 == 0) {		
		 	layer_set_hidden(bitmap_layer_get_layer(normal_time_digits_layers[0]), true); 
		  } else  if (flip == 0) {
		    layer_set_hidden(bitmap_layer_get_layer(normal_time_digits_layers[0]), false);
            	}
	}		
	
				 static char ampm_text[] = "am";

		     if (!clock_is_24h_style()) {


		strftime(ampm_text, sizeof(ampm_text), "%P", tick_time);
        text_layer_set_text(layer_ampm_text, ampm_text);
			 }
}
Beispiel #12
0
static void toggle_bluetooth_icon(bool connected) {
  if(appStarted && !connected && bluetoothvibe) {
    //vibe!
    vibes_short_pulse();
  }
  layer_set_hidden(bitmap_layer_get_layer(bluetooth_layer), connected);
}
Beispiel #13
0
static void handle_tick(struct tm *t, TimeUnits units_changed) {
  if (strcmp(configs.secondhandoption, "stop2go") == 0) {
    for (int i=0; i<STOP2GO_TICK_RESOLUTION; i++) {
  		app_timer_register(1000 / STOP2GO_TICK_RESOLUTION * i, (void*)layer_mark_dirty, window_get_root_layer(s_window));
    }
  }
  else {
    layer_mark_dirty(window_get_root_layer(s_window));
  }
  
    
  // Hourly vibration
  if (t->tm_min == 0 && t->tm_sec == 0) {
    if (strcmp(configs.hourlyvibration, "short") == 0) {
      vibes_short_pulse();
    }
    else if (strcmp(configs.hourlyvibration, "long") == 0) {
      vibes_long_pulse();
    }
    else if (strcmp(configs.hourlyvibration, "double") == 0) {
      vibes_double_pulse();
    }
  }

}
Beispiel #14
0
static void tick(struct tm *tick_time, TimeUnits units_changed)
{
    if (s_second_rate < 2)
    {
        layer_mark_dirty(s_date_layer);
        layer_mark_dirty(s_time_layer);
    }

    if (tick_time->tm_min == 0 && tick_time->tm_sec == 0 && s_vibe_hourly != SETTING_VIBE_DISABLED)
    {
        switch (s_vibe_hourly)
        {
        case SETTING_VIBE_LONG:
            vibes_long_pulse();
            break;
        case SETTING_VIBE_SHORT:
            vibes_short_pulse();
            break;
        case SETTING_VIBE_DOUBLE:
            vibes_double_pulse();
            break;
        }
    }

    // Get weather update every 2 hours
    if (s_weather_icon == -1 || s_weather_temp == -100 || tick_time->tm_mday*100+tick_time->tm_hour > s_last_update_time + 1)
    {
        request_weather();
    }
    if(tick_time->tm_hour % 2 == 0 && tick_time->tm_min == 0 && tick_time->tm_sec == 0)
    {
        request_weather();
    }
}
Beispiel #15
0
void bluetoothHandler(bool connected) 
{
  APP_LOG(DebugLevel, "bluetoothHandler: start connected :%s:",connected ? "true" : "false");
  bool prevConnected=false;
  if(persist_exists(BT_STATUS)){
    prevConnected = persist_read_bool(BT_STATUS);
	APP_LOG(DebugLevel, "bluetoothHandler: initial key");
  }
	APP_LOG(DebugLevel, "bluetoothHandler: prevConnected :%s:",prevConnected ? "true" : "false");

  if(connected && prevConnected) {
     bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOn);
	  APP_LOG(DebugLevel, "bluetoothHandler: both true turned on connection");
  }
  if(!connected && !prevConnected) {
     bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOff);
	  APP_LOG(DebugLevel, "bluetoothHandler: both false turned off connection");
  }

  if(connected && !prevConnected) {
     bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOn);
	  APP_LOG(DebugLevel, "bluetoothHandler: turned on connection");
     vibes_short_pulse();
  }

  if(!connected && prevConnected) {
  	  bitmap_layer_set_bitmap(GET_LAYER(BLUETOOTH_LAYER), bluetoothImageOff);
	  APP_LOG(DebugLevel, "bluetoothHandler: turned off connection");
     vibes_long_pulse();
     btBuzzerTimer = app_timer_register(BUZZER_INTERVAL, buzzer2,NULL);
  }
  persist_write_bool(BT_STATUS, connected);
  APP_LOG(DebugLevel, "bluetoothHandler: done saved :%s:",connected ? "true" : "false");
} // bluetoothHandler
Beispiel #16
0
void vibrate_quarterly() {
  // load settings
  ElCidSettings *settings = settings_load();
    
  // don't vibrate if not set
  if(!settings->QuarterHourlyVibrate) {
    return;
  }
    
  // get hour from local time  
  time_t temp = time(NULL);
  struct tm *tick_time = localtime(&temp);
  
  // create pattern for vibration
  int minutes = tick_time->tm_min;
  
  // abort if not on the quarter hour
  if(minutes == 0 || minutes % 15 != 0) {
    return;
  }
  
  // get settings value after we know we need it
  u_short vibration_type = settings->QuarterHourVibrationType;
    
  // do pattern as configured
  if(1 == vibration_type) {
    vibes_short_pulse();
  } else if(2 == vibration_type) {
    vibes_long_pulse();
  } else if(3 == vibration_type) {
    vibes_double_pulse();
  } else if(4 == vibration_type) {
    vibrate_quarterly_pattern(minutes);
  }
}
void handle_timer(AppContextRef ctx, AppTimerHandle handle, uint32_t cookie) {
  (void)handle;
  if(cookie == TIMER_UPDATE) {
    if(started) {
      remaining_time -= 1;
      if (remaining_time == 0){
        if (working_mode){
          vibes_short_pulse();
        }
        else{
          vibes_double_pulse();
        }
        start_timer(SHORT_TIMER_DELAY);
      }else{
        if (remaining_time < 0){
          if (working_mode){
            reset_relax_count_down();
          }
          else{
            reset_work_count_down();
          }
        }else{
          display_time();
        }
        start_timer(TIMER_DELAY);
      }
    }
  }
}
Beispiel #18
0
void check_vibration(char *mode) {
	if (strcmp(mode, MODE_LONG) == 0) {
		vibes_long_pulse();
	} else if (strcmp(mode, MODE_SHORT) == 0) {
		vibes_short_pulse();
	}
}
Beispiel #19
0
void calibrate_accel_end( bool keepData) {
    int tries = 0;

    vibes_short_pulse();
    accel_data_service_unsubscribe();

    if (keepData) {
          thresholdUp -= (thresholdUp>>2);
          // threshold set to 75% of max value: x - x/4, down = x'/2
          while ((periodsSki != 3) && (tries < MAXCALIBTRY)) {
               tries++;
	 // threshold set to 75% of max value: x - x/4, down = x'/2
         //    thresholdDown = thresholdUp>>1;
	       periodsLift = calibrationCount;
	       periodsSki = strokesDetected( calibrationSamples, calibrationCount);    
               periodsStatic = thresholdUp;
               lastAccel.timestamp = 0;
               app_log(APP_LOG_LEVEL_INFO, __FILE__ , __LINE__, "Calib detected: %i", (int)periodsSki);
               if (periodsSki > 3) thresholdUp += thresholdUp>>3;
               if (periodsSki < 3) thresholdUp -= thresholdUp>>3;
           }
       if (periodsSki != 3) {
           thresholdUp = MOVINGTHRESHOLD;
           thresholdDown = STATICTHRESHOLD;
       }
       persist_write_int(THUPKEY, thresholdUp);
       persist_write_int(THDOWNKEY, thresholdUp>>1);
    }
    else 
static void pin_set_handler(ClickRecognizerRef recognizer, void *context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Pin set");
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  } 
  else {
    app_timer_reschedule(locationtimer, 1000 * (nextcall + 10));
    strcpy(command, "pin");
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
      vibes_short_pulse();
      APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send command %s to phone!", command);
      return;
    }
    dict_write_cstring(iter, CMD_KEY, command);
    const uint32_t final_size = dict_write_end(iter);
    app_message_outbox_send();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent command '%s' to phone! (%d bytes)", command, (int) final_size);
    if (!hint_layer) {
      Layer *window_layer = window_get_root_layer(window);
      hint_layer = text_layer_create(hint_layer_size);
      text_layer_set_font(hint_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
      text_layer_set_text_alignment(hint_layer, GTextAlignmentCenter);
      layer_add_child(window_layer, text_layer_get_layer(hint_layer));
    }
    text_layer_set_text(hint_layer, "\nSetting\ntimeline\npin...");
  }
}
void main_window_set_status( bool connected )
{
  
  if ( LOCAL_last_status == connected )
    return;
  
  if ( LOCAL_last_status >= 0 )
    vibes_short_pulse();
  
  LOCAL_last_status = connected;
  
  GColor front = GColorWhite;
  GColor back  = GColorBlack;
  
  if ( connected == true )
  {
     back  = GColorWhite;
     front = GColorBlack;
  }
  
  for ( int loop = 0; loop < 4; loop ++ )
  {
    text_layer_set_background_color( LOCAL_layers[loop], back );
    text_layer_set_text_color( LOCAL_layers[loop] , front );
  }  
}
static void select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Got a click for row %d", cell_index->row);
  if (hint_layer) {
    text_layer_destroy(hint_layer);
    hint_layer = NULL;
  }
  if (cell_index->row > 0) {
    app_timer_reschedule(locationtimer, 1000 * (nextcall + 10));
    if (cell_index->row == 1) {
      strcpy(command, "set");
    text_layer_set_text(distance_layer, "0");
    } else
      snprintf(command, sizeof(command), "set%d", (cell_index->row)-2);
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    if (iter == NULL) {
      vibes_short_pulse();
      APP_LOG(APP_LOG_LEVEL_WARNING, "Can not send command %s to phone!", command);
      return;
    }
    dict_write_cstring(iter, CMD_KEY, command);
    const uint32_t final_size = dict_write_end(iter);
    app_message_outbox_send();
    APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent command '%s' to phone! (%d bytes)", command, (int) final_size);
  }
  window_stack_pop(animated);
}
Beispiel #23
0
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  
  Tuple *show_seconds_hand_t = dict_find(iter, KEY_SHOW_SECONDS_HAND);
  Tuple *connection_lost_vibe_t = dict_find(iter, KEY_CONNECTION_LOST_VIBE);
  Tuple *color_reverse_t = dict_find(iter, KEY_COLOR_REVERSE);

  
  if (show_seconds_hand_t) {
    s_show_seconds_hand = show_seconds_hand_t->value->int8;

    persist_write_bool(KEY_SHOW_SECONDS_HAND, s_show_seconds_hand);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "s_show_seconds_hand %d", s_show_seconds_hand);
    //vibes_short_pulse();
  } 
  
  if (connection_lost_vibe_t) {
    s_connection_lost_vibe = connection_lost_vibe_t->value->int8;

    persist_write_bool(KEY_CONNECTION_LOST_VIBE, s_connection_lost_vibe);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "s_connection_lost_vibe %d", s_connection_lost_vibe);
    vibes_short_pulse();
  } 

  if (color_reverse_t) {
    s_color_reverse = color_reverse_t->value->int8;

    persist_write_bool(KEY_COLOR_REVERSE, s_color_reverse);
    APP_LOG(APP_LOG_LEVEL_DEBUG, "s_color_reverse %d", s_color_reverse);
    set_color_data();
    set_layer_color();
  } 
}
Beispiel #24
0
static void counter_timeout(void)
{
    //Create variable to store count, down from 3
    static int8_t count = 3;
    static char count_str[] = " ";
    count--;
    if (0 == count)
    {
        //reset the counter for next time,
        app_timer_cancel(s_counter_timer);
        count = 3;
        //Alert chugger with short vibration
        vibes_short_pulse();
        //Start Accelerometer service
        uint32_t num_samples = 5;
        accel_data_service_subscribe(num_samples, data_handler);
        accel_service_set_sampling_rate(ACCEL_SAMPLING_100HZ);
    }
    else
    {
        SINGLE_DIGIT_TO_ASCII(count, count_str);
        text_layer_set_text(s_count_layer, count_str);
        app_timer_register(1000, (AppTimerCallback) counter_timeout, NULL);
    }
}
Beispiel #25
0
/*
static void send(int key, int msg) 
{
  DictionaryIterator *iter;
  app_message_outbox_begin(&iter);
  dict_write_int(iter, key, &msg, sizeof(int), true);
  app_message_outbox_send();
}
*/
static void inbox_received_handler(DictionaryIterator *iterator, void *context) {
  // Get the first pair
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch(t->key) {
      case KEY_VIBRATE:
        // Trigger vibration
        text_layer_set_text(s_text_layer, "Vibrate!");
        vibes_short_pulse();
        break;
       case KEY_DISTANCE:
        // When distance recieved set text to distance
        text_layer_set_text(s_text_layer,"Distance: ");
        break;
       case KEY_ETA:
        text_layer_set_text(s_text_layer,"ETA:");
        break;
      default:
        APP_LOG(APP_LOG_LEVEL_INFO, "Unknown key: %d", (int)t->key);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
Beispiel #26
0
static void handle_bluetooth(bool connected)
{
	if(!connected)
	{
		if(vibrate) vibes_short_pulse();
	}
}
Beispiel #27
0
// App message callbacks
void out_sent_handler(DictionaryIterator *sent, void *context)
{
	//APP_LOG(APP_LOG_LEVEL_INFO, "command sent");
	
	vibes_short_pulse();
	start_reset_timer();
}
Beispiel #28
0
static void update_time() {
  time_t temp = time(NULL); 
  struct tm *tick_time = localtime(&temp);
 
  min = tick_time->tm_min;

  if(min == 59 && hour_vibrate == 1){
    vibes_short_pulse();
  }
  
  if (clock_is_24h_style() == twenty_four_hour_format){
    strftime(buffer, sizeof(buffer), "%H:%M", tick_time);
  }else {
    strftime(buffer, sizeof(buffer), "%I:%M", tick_time);
  }
  
  
  if(change_date_format == 1){
    strftime(date, sizeof(date),"%d/%m/%y", tick_time);
  } else{
    strftime(date, sizeof(date),"%D", tick_time);
  }
  strftime(weekday, sizeof(weekday),"%A", tick_time);
  
for(char* pc=weekday;*pc!=0;++pc) *pc = lower_to_upper(*pc);
  
  text_layer_set_text(lower_text_layer, date);
  text_layer_set_text(upper_text_layer, buffer);
  battery_handler(battery_state_service_peek());

}
Beispiel #29
0
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  static char s_uptime_buffer[32];
  vibes_short_pulse();
  alert_time--;
  if(alert_time <= 0 ){
    //TODO: write notification code
    tick_timer_service_unsubscribe();
    vibes_cancel();
    text_layer_set_text(s_alert_text_layer, "Timout Reached\n:(");
    
    // Prepare dictionary
    DictionaryIterator *iterator;
    app_message_outbox_begin(&iterator);
    
    // Write data
    char buff[100];
    if(persist_exists(PERSIST_KEY_PHONE_NUMBER)){
      persist_read_string(PERSIST_KEY_PHONE_NUMBER, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_PHONE_NUMBER, buff);
    }
    if(persist_exists(PERSIST_KEY_NAME)){
      persist_read_string(PERSIST_KEY_NAME, buff, 100);
      dict_write_cstring(iterator, PERSIST_KEY_NAME, buff);
    }
    // Send the data!
    app_message_outbox_send();
    
  } else {
    snprintf(s_uptime_buffer, sizeof(s_uptime_buffer), BANNER_TEXT "\n" CLOCK_FORMAT_STRING, 
             alert_time/60, alert_time%60);
    text_layer_set_text(s_alert_text_layer, s_uptime_buffer);
  }
}
void calibrate_handle_final(Measurement m) {
	// store the measurement
	// check if same weight already exists and average both if it does
	Measurement *mf = NULL;
	for (int i = 0; i < calibrations_count; i++) {
		if (calibrations[i].weight != weight)
			continue;
		mf = &calibrations[i];
		mf->amp = (mf->amp + m.amp) / 2;
		mf->freq = (mf->freq + m.freq) / 2;
		mf->confidence = (mf->confidence + m.confidence) / 2;
		break;
	}
	if (mf == NULL) {
		m.weight = weight;
		calibrations[calibrations_count++] = m;
	}
	// store
	calibrations_save();
	
	// stop measuring and update layers
	stop_measure();
	layer_mark_dirty(text_layer);
	layer_mark_dirty(graph_layer);

	// vibrate to let the user know
	vibes_short_pulse();
}