Exemple #1
0
void do_vibrate(void) {
  if(s_vibration_pattern)
  {
    s_pwmPat.durations[1] = (s_vibe_counter/s_vibration_pattern)+1;
    s_vibe_counter++;
    vibes_enqueue_custom_pwm_pattern(&s_pwmPat);
  }
  else
    vibes_long_pulse();
  vibe_timer = app_timer_register(1000,vibe_timer_callback,NULL);
}
Exemple #2
0
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
   text_layer_set_text(text_layer, "Ramp down");
	
   // demonstrate a straightforward vibration ramp
   static uint32_t segments[] = { 300, 10, 300, 9, 300, 8, 300, 7, 300, 6, 300, 5, 300, 4, 300, 3, 300, 2, 300*10, 1 }; //note very long final pulse
   VibePatternPWM pwmPat = {
      .durations = segments,
      .num_segments = ARRAY_LENGTH(segments),
   };
   
   bool isFull = vibes_enqueue_custom_pwm_pattern(&pwmPat);
   if(isFull) {
      APP_LOG(APP_LOG_LEVEL_DEBUG, "Note: Due to the very long final pulse, it will not render the full duration");
   }
}
Exemple #3
0
void do_vibrate(void) {
  if(s_vibration_pattern) {
    s_pwmPat.durations[1] = (s_vibe_counter/s_vibration_pattern)+1;
    s_vibe_counter++;
    vibes_enqueue_custom_pwm_pattern(&s_pwmPat);
  }
  else
    vibes_long_pulse();
  
  if(s_snoozes>=preferences_get()->flashingAfterXSnoozes) {
    if(get_lfx_state_power()) {
      send(DURATION_OFF_MS, 50);
    } else {
      send(DURATION_ON_MS, 50);
    }
  }

  vibe_timer = app_timer_register(1000,vibe_timer_callback,NULL);
}
void do_vibrate(void) {
#ifndef PBL_PLATFORM_APLITE
  if(s_vibration_pattern)
  {
    s_pwmPat.durations[1] = (s_vibe_counter/s_vibration_pattern)+1;
    s_vibe_counter++;
    vibes_enqueue_custom_pwm_pattern(&s_pwmPat);
  }
#else
  if(s_vibration_pattern)
  {
    s_segments[0] = min((s_vibe_counter/s_vibration_pattern)*50,500);
    s_vibe_counter++;
    vibes_enqueue_custom_pattern(s_pat);
  }
#endif
  else
    vibes_long_pulse();

  vibe_timer = app_timer_register(1000,vibe_timer_callback,NULL);
}
Exemple #5
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
   text_layer_set_text(text_layer, "Wobble up");
  
   uint32_t segments[40];
   VibePatternPWM pwmPat = {
      .durations = segments,
      .num_segments = 0, //pulseCount*2,
   };
	
   // demonstrate use of vibesPatternPWM_addpulse
   vibesPatternPWM_addpulse(&pwmPat, 300, 1);
   vibesPatternPWM_addpulse(&pwmPat, 300, 6);
   vibesPatternPWM_addpulse(&pwmPat, 300, 2);
   vibesPatternPWM_addpulse(&pwmPat, 300, 7);
   vibesPatternPWM_addpulse(&pwmPat, 300, 3);
   vibesPatternPWM_addpulse(&pwmPat, 300, 8);
   vibesPatternPWM_addpulse(&pwmPat, 300, 4);
   vibesPatternPWM_addpulse(&pwmPat, 300, 9);
   vibesPatternPWM_addpulse(&pwmPat, 300, 5);
   vibesPatternPWM_addpulse(&pwmPat, 300, 10);

   vibes_enqueue_custom_pwm_pattern(&pwmPat);
}

static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
  text_layer_set_text(text_layer, "Ramp up");

   // demonstrate a straightforward vibration ramp
   static uint32_t segments[] = { 300, 1, 300, 2, 300, 3, 300, 4, 300, 5, 300, 6, 300, 7, 300, 8, 300, 9, 300, 10 };
   //static uint32_t segments[] = { 100, 2, 1000, 0, 100, 10, 1000, 0, 100, 2, 1000, 0, 100, 10, 1000, 0, 100, 2 };
   VibePatternPWM pwmPat = {
      .durations = segments,
      .num_segments = ARRAY_LENGTH(segments),
   };
   
   //Could just call vibes_enqueue_custom_pwm_pattern,
   //but will instead do it in two steps - prepare and play:
   vibes_prepare_custom_pwm_pattern(&pwmPat); //Note this will not cause it to actually vibrate!
   vibes_play_current_custom_pwm_pattern(); //Now it actually plays the pattern that was "prepared"
}