Пример #1
0
void updateDisplay() {
  int elapsed = 0;
  int countdown = 0;
  elapsed = s_currentTimer/2;
  countdown = s_selectedDuration - elapsed;
  
  if(s_currentTimer%2 == 0) {
    static char bUp[10];
    static char bDown[4];
    //static char bDuration[10];
    //static char bDuration[5];
    //static int elapsed = 0;
    //static int countdown = 0;
    
    //elapsed = s_currentTimer/2;
    //countdown = s_selectedDuration - elapsed;
    if(countdown > 0) {
      //printInt(s_countup, elapsed, bUp);
      printInt(s_countdown, countdown, bDown);
      //printInt(s_duration, s_selectedDuration, bDuration);
      
      snprintf(bUp, 10, "%d / %d", elapsed, s_selectedDuration);
      text_layer_set_text(s_countup, bUp);
    } else {
      printInt(s_countup, elapsed - s_selectedDuration, bUp);
      //text_layer_set_text(s_duration, "");
    }
    
     if(countdown == 10) {
      vibes_double_pulse();
    } else if(countdown == 3) {
      vibes_long_pulse();
    } else if(countdown == 2 || countdown == 1) {
      vibes_short_pulse();
    } else if(countdown == 0) {
      window_set_background_color(s_window, GColorWhite);
      vibes_long_pulse();
      s_timerActive = false;
      updateMenu(s_selectedDuration);
      text_layer_set_text(s_countdown, "");
      text_layer_set_text(s_countup, "");
      updateSets();
    }
  }
  
  if(s_timerActive) {
    if(countdown <= 10) {
       window_set_background_color(s_window, GColorRed);
    } else if (s_currentTimer < s_selectedDuration) {
      window_set_background_color(s_window, GColorGreen);
    } else {
      window_set_background_color(s_window, GColorOrange);
      if(s_currentTimer == s_selectedDuration) { // halfway point
        vibes_double_pulse();
      } 
    }
  }
}
Пример #2
0
static void menu_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
	switch (cell_index->row) {
    	case 0:
			vibes_double_pulse();
	  		checkin_send_request(venueid, venuename, 0, 0, 0, true);
      		break;
		case 1:
			share_menu_show(!split_bar, venueid, venuename);
			break;
		case 2:
			vibes_double_pulse();
			checkin_send_request(venueid, venuename, 1, 0, 0, true);
			break;
	}
}
Пример #3
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();
    }
  }

}
Пример #4
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();
    }
}
Пример #5
0
void cdt_update(SWTime sw_elapsed) {
  // Preclude if disabled
  if (cdt.enable == false) { return; }
  
  // Invoke vibration alert
  if (SWTime_compare(cdt.next_split, sw_elapsed) == -1 && cdt.overflow == false) {
    // Call buzzer
    vibes_double_pulse();
  }

  // Increment cdt_index until overflow condition detected (only in single mode)
  // or cdt.next_split is greater than sw_elapsed
  while (!cdt.overflow && (SWTime_compare(cdt.next_split, sw_elapsed)==-1)) {
    cdt.index++;
    
    // Exit condition for single mode
    if (!cdt.repeat && (cdt.index >= cdt.length)) {
      cdt.overflow = true;
      break;
    }
    
    cdt.next_split = SWTime_add(cdt.next_split, cdt.lap[cdt.index%cdt.length]);
  }
  
  // Calculate displayed timer
  cdt.display = cdt.overflow ?
                SWTime_subtract(sw_elapsed, cdt.next_split) :
                SWTime_subtract(cdt.next_split, sw_elapsed);
  
  // Prevent displaying over 9:59:59.99
  if (cdt.display.hour >= 10) {
    cdt.display = (SWTime){.hour=9, .minute=59, .second=59, .centisecond=99};
  }
}
Пример #6
0
static void bt_handler(bool connected) {
  layer_set_hidden(s_bt_layer, connected);

  if(!connected) {
    vibes_double_pulse();
  }
}
Пример #7
0
void end_round() {
    round_started = false;
    club_menu_index = 0;
	text_layer_set_text(&club, club_menu[club_menu_index]);
	window_init(&finalscore, "Final Score");
	window_stack_push(&finalscore, true /* Animated */);
	text_layer_init(&finalscore_score, GRect(0, 0, 144, 168-16));
	text_layer_set_background_color(&finalscore_score, GColorWhite);
	text_layer_set_text_color(&finalscore_score, GColorBlack);
	text_layer_set_font(&finalscore_score,fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD));
	mini_snprintf(s_final_score, 25, "Final Score %d", totalshots);
	text_layer_set_text(&finalscore_score, s_final_score);
	text_layer_set_text_alignment(&finalscore_score, GTextAlignmentCenter);
	layer_add_child(&finalscore.layer, &finalscore_score.layer);
	
	text_layer_init(&finalscore_putts, GRect(0, 126, 144, 168-16-126));
	text_layer_set_background_color(&finalscore_putts, GColorWhite);
	text_layer_set_text_color(&finalscore_putts, GColorBlack);
	text_layer_set_font(&finalscore_putts,fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	mini_snprintf(s_final_putts, 25, "Total Putts: %d", totalputts);
	text_layer_set_text(&finalscore_putts, s_final_putts);
	text_layer_set_text_alignment(&finalscore_putts, GTextAlignmentCenter);
	layer_add_child(&finalscore.layer, &finalscore_putts.layer);
	
	vibes_double_pulse();
	// Need to destroy list_of_shots array.
	
}
Пример #8
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);
  }
}
Пример #9
0
static void bluetooth_handler (bool connected){

  
    if(connected) {
    #ifdef PBL_COLOR
    text_layer_set_text_color(s_minute_layer , GColorSpringBud);
    text_layer_set_text_color(s_hour_layer , GColorGreen);
    #endif
    }
    else{
    
    #ifdef PBL_COLOR
    text_layer_set_text_color(s_hour_layer, GColorVividCerulean);
    text_layer_set_text_color(s_minute_layer, GColorPictonBlue);
    
    #endif
  }
      
    if (!connected && bluetooth_vibration == 1){
      vibes_double_pulse();
    }
    else {
        return;
    }
  persist_write_int(KEY_BLUETOOTH_VIBRATION, bluetooth_vibration);
  

}
Пример #10
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "Demo");
  window_stack_push(&window, false /* Not animated */);

  vibes_double_pulse();
}
Пример #11
0
// Record Bluetooth connection state
static void bluetooth_callback(bool connected) {
	
  if (bt_toggle == 1) {   
      APP_LOG(APP_LOG_LEVEL_INFO, "Hide Bluetooth connection symbol"); 
      if		(!connected) {bitmap_layer_set_bitmap(s_bt_icon_layer, gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_0));}
      else	{bitmap_layer_set_bitmap(s_bt_icon_layer,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLANK));}			    			
  } else {
      APP_LOG(APP_LOG_LEVEL_INFO, "Show Bluetooth connection symbol"); 
      if		(!connected) {bitmap_layer_set_bitmap(s_bt_icon_layer, gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_0));}
	    else	{bitmap_layer_set_bitmap(s_bt_icon_layer,gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BT_1));}			    
  }

  // set vibrations
  if (!connected) {		
		if (vibe_on_disconnect == 1) {
      APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate on Bluetooth disconnect"); 
			vibes_long_pulse();
		}
	} else {
		if (vibe_on_connect == 1) {
      APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate on Bluetooth reconnection"); 
			vibes_double_pulse();
		}
	}
  
}
Пример #12
0
/*
 * Tick-Handler - executes once every second using watch's internal clock.
 * Switched every other second between getting most recent temp (if desired) and checking for tripped alarm.
 */
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
  if (tickTimerMod % 2 == 0){
      if (wantAverage && !standbyEngaged && !tripped){
        DictionaryIterator *iter;
        app_message_outbox_begin(&iter);
        int key = 0;
        // send the message "b" to the phone, using key #0
        Tuplet value = TupletCString(key, "b");
        dict_write_tuplet(iter, &value);
        app_message_outbox_send();
      }
  }
  else{
      //checks if alarm has been tripped, checks to see every 10 seconds if not
      if (tripped){
          text_layer_set_text(hello_layer, "INTRUDER ALERT!!!");
          vibes_double_pulse();
      }
      else { 
          DictionaryIterator *iter;
          app_message_outbox_begin(&iter);
          int key = 0;
          // send the message "t" to the phone, using key #0
          Tuplet value = TupletCString(key, "t");
          dict_write_tuplet(iter, &value);
          app_message_outbox_send();
      }
  }
  tickTimerMod += 1;
}
Пример #13
0
void display_time(struct tm* tick_time) {
    int h = tick_time->tm_hour;
    int m = tick_time->tm_min;
#ifdef DEBUG_MODE
    h = m;
    m = tick_time->tm_sec;
    if ((m%5) != 0) return; //update every 5secs to allow time for animation
#endif

    if ((m_nVibes & MASKV_HOURLY) //option enabled to vibrate hourly
        && (m == 0)) //hourly mark reached
    {
        int from = (m_nVibes & MASKV_FROM) >> 8,
            to = m_nVibes & MASKV_TO;
        bool bShake = false;
        if (from <= to)
        {
            bShake = (h >= from) && (h <= to);
        }
        else
        {
            bShake = (h >= from) || (h <= to);
        }
        if (bShake)
        {
            vibes_double_pulse();
        }
    }
Пример #14
0
// Handles tick of the system clock.
static void handle_tick(struct tm *tick_time, TimeUnits units_changed) {
    if(units_changed & SECOND_UNIT) {

      // Update control block.
      control_block_tick();
    
      // Redraw the timer.
      draw_timer();
    
      // Update UI.
      if (control_block_is_program_over()){
          // Vibrate with different pattern at the end of the program.
          vibes_double_pulse();
    
          // And update the screen with a final message.
          layer_set_hidden((Layer *)tw_tl_time, true);
          layer_set_hidden((Layer *)tw_tl_interval, true);
    
          text_layer_set_text(tw_tl_type, "Done!");
          layer_mark_dirty((Layer *)tw_tl_type);
    
          return;
      } else if (control_block_is_interval_over()){
        vibes_long_pulse();
      }
    }  
}
Пример #15
0
void handle_tick(AppContextRef ctx, PebbleTickEvent *t){
  (void)t;
  (void)ctx;

  if(t->tick_time->tm_sec%10==0)
  {
     layer_mark_dirty(&minute_display_layer);
     
     if(t->tick_time->tm_sec==0)
     {
        if(t->tick_time->tm_min%2==0)
        {
           layer_mark_dirty(&hour_display_layer);
#if DISPLAY_DATE
           if(t->tick_time->tm_min==0&&t->tick_time->tm_hour==0)
           {
              draw_date();
           }
#endif
#if HOUR_VIBRATION
           if(t->tick_time->tm_min==0
                 &&t->tick_time->tm_hour>=HOUR_VIBRATION_START
                    &&t->tick_time->tm_hour<=HOUR_VIBRATION_END)
           {
              vibes_double_pulse();
           }
#endif
        }
     }
  }

#if DISPLAY_SECONDS
  layer_mark_dirty(&second_display_layer);
#endif
}
Пример #16
0
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);
      }
    }
  }
}
Пример #17
0
static void tick_handler(struct tm *tick_time, TimeUnits units_changed){
	set_time();
	
	if(mins != 0 && (tick_time->tm_min +(tick_time->tm_hour*60))%mins == 0){
		vibes_double_pulse();
		APP_LOG(APP_LOG_LEVEL_DEBUG, "fmt");
	}
}
Пример #18
0
static void game_end(unsigned finished)
{
    if (finished) {
        vibes_double_pulse();
        debrief_user_with_score(game->score);
        game->is_resetting = 1;
    }
}
Пример #19
0
static void bt_handler(bool connected) {
	if (connected) {
		vibes_short_pulse();
	}
	else {
		vibes_double_pulse();
	}
}
Пример #20
0
static void handle_bt(bool bt_state)
{
	if (last_bt_state && !bt_state)
		vibes_double_pulse();

	last_bt_state = bt_state;
	layer_set_hidden(bitmap_layer_get_layer(bt_layer), bt_state);
}
Пример #21
0
static void handle_bluetooth_event(bool connected) {
  if(BT_VIBE){
  if (connected)
    vibes_double_pulse();
  else
    vibes_short_pulse();
  }
}
Пример #22
0
static void bt_handler(bool connected) {
  // Show current connection state
  if (connected) {
    vibes_long_pulse(); // vibrate long pulse when connection is back
  } else {
    vibes_double_pulse(); // vibrate two short pulses when connection is lost
  }
}
Пример #23
0
static void bt_handler(bool connected) {
  if(connected) {
    layer_set_hidden(s_bt_layer, true);
  } else {
    vibes_double_pulse();
    layer_set_hidden(s_bt_layer, false);
  }
}
Пример #24
0
static void handle_vibe_packet(Simply *simply, Packet *data) {
  VibePacket *packet = (VibePacket*) data;
  switch (packet->type) {
    case VibeShort: vibes_short_pulse(); break;
    case VibeLong: vibes_long_pulse(); break;
    case VibeDouble: vibes_double_pulse(); break;
  }
}
Пример #25
0
static void bt_handler(bool connected) {
#if defined(PBL_COLOR)
  pge_set_background_color(connected ? data_get_color(ColorBackground) : GColorDarkGray);
#endif

  if(!connected) {
    vibes_double_pulse();
  }
}
void handle_bluetooth(bool connected) {
	int i;
	
	if (lastBluetoothStatus == connected) {
		return;
	} else {
		lastBluetoothStatus = connected;
	
		if (splashEnded && !animRunning) {
			if (animation_is_scheduled(anim)) {
				animation_unschedule(anim);
			}
			
			animRunning = true;
			
			for (i=0; i<NUMSLOTS; i++) {
				slot[i].prevDigit = slot[i].curDigit;
			}
			
			slot[0].curDigit = 'B' - '0';
			slot[1].curDigit = 'T' - '0';
			
			if (connected) {
				slot[2].curDigit = 'O' - '0';
				slot[3].curDigit = 'K' - '0';

				slot[4].curDigit  = SPACE_D;
				slot[5].curDigit  = SPACE_D;
				slot[6].curDigit  = SPACE_D;
				slot[7].curDigit  = SPACE_D;
				slot[8].curDigit  = SPACE_D;
				slot[9].curDigit  = SPACE_D;
				slot[10].curDigit = SPACE_D;
				slot[11].curDigit = SPACE_D;

				vibes_double_pulse();
			} else {
				slot[2].curDigit = SPACE_L;
				slot[3].curDigit = SPACE_R;

				slot[4].curDigit  = SPACE_D;
				slot[5].curDigit  = 'F' - '0';
				slot[6].curDigit  = 'A' - '0';
				slot[7].curDigit  = 'I' - '0';
				slot[8].curDigit  = 'L' - '0';
				slot[9].curDigit  = 'E' - '0';
				slot[10].curDigit = 'D' - '0';
				slot[11].curDigit = SPACE_D;

				vibes_long_pulse();
			}
			
			animation_schedule(anim);
			app_timer_register(BATTERYDELAY, handle_timer, NULL);
		}
	}
}
Пример #27
0
// displays error message and re-prompts for password
static void s_display_error_msg(void *data) {  
  int i;
  vibes_double_pulse();
  s_curr_state = 4;
  passcode_counter = 0;
  for (i = 0; i < PASSCODE_LEN; i++) {
    s_entry[i] = ' ';
  }
}
Пример #28
0
static void in_received_handler(DictionaryIterator *iter, void *context) {
  //Recieve data from phone
  Tuple *buses_tuple = dict_find(iter, BUSES_KEY);
  if (buses_tuple) {
    vibes_double_pulse();
    strncpy(buses,buses_tuple->value->cstring, 512);
    text_layer_set_text(list_layer, buses);
  }
}
static void bluetooth_callback(bool connected) {
	// Show icon if disconnected
  layer_set_hidden(bitmap_layer_get_layer(s_bitmap_layer_bluetooth), !connected);

  if(!connected) {
    // Issue a vibrating alert
    vibes_double_pulse();
  }
}
Пример #30
0
static void bluetooth_callback(bool connected){
  // show icon if disconnected
  layer_set_hidden(bitmap_layer_get_layer(s_bt_icon_layer), !connected);

  if(!connected){
    // issue a vribrate alert
    vibes_double_pulse();
  }
}