コード例 #1
0
ファイル: am_i_normal.c プロジェクト: pebblespot/aminormal
static void window_unload(Window *window) {
  text_layer_destroy(s_output_layer);
  app_timer_cancel(timer);  //Cancel timer
}//window_unload()
コード例 #2
0
/* Handles the user pressing the back button (returns the user to the main menu) */
void back_handler(ClickRecognizerRef recognizer, void* context) {
  app_timer_cancel(timer); // Stop polling for the current temperature
  window_stack_pop(true);
  window = window_stack_get_top_window();
}
コード例 #3
0
void communication_deinit() {
  if (reset_data_timer) {
    app_timer_cancel(reset_data_timer);
  }
}
コード例 #4
0
// Update the bottom half of the screen: icon and temperature
void npr_layer_update(NprData *npr_data) 
{
  // We have no npr data yet... don't update until we do
  if (npr_data->updated == 0) {
    return;
  }

  NprLayerData *nld = layer_get_data(npr_layer);

  if (npr_animation_timer && animation_timer_enabled) {
    app_timer_cancel(npr_animation_timer);
    // this is only needed to stop the error message when cancelling an already cancelled timer... 
    animation_timer_enabled = false;
    layer_set_hidden(nld->loading_layer, true);
  }

  time_t current_time = time(NULL);
  bool stale = false;

  // APP_LOG(APP_LOG_LEVEL_DEBUG, "ct:%i wup:%i, stale:%i", 
  //   (int)current_time, (int)npr_data->updated, (int)NPR_STALE_TIMEOUT);

  // Update the npr icon and temperature
  if (npr_data->error) {
    // Only update the error icon if the npr data is stale
    if (stale) {
      switch (npr_data->error) {
        case ERROR_NETWORK:
          //npr_layer_set_icon(NPR_ICON_CLOUD_ERROR);
          debug_update_message("Network error");
          break;
        case ERROR_DISCONNECTED:
        case ERROR_PHONE:
        default:
          //npr_layer_set_icon(NPR_ICON_PHONE_ERROR);
          debug_update_message("Phone disco / error");
          break;
      }
    }
  } 
  else {

    layer_set_hidden(bitmap_layer_get_layer(nld->error_icon_layer), true);

    text_layer_set_text(nld->primary_frequency_layer, npr_data->primary_frequency);
    text_layer_set_text(nld->primary_call_layer, npr_data->primary_call);
    //text_layer_set_text(nld->primary_band_layer, npr_data->primary_band);

    nld->primary_strength = npr_data->primary_strength;
    layer_mark_dirty(nld->primary_strength_layer);

    if (npr_data->secondary_available) {

      text_layer_set_text(nld->secondary_frequency_layer, npr_data->secondary_frequency);
      text_layer_set_text(nld->secondary_call_layer, npr_data->secondary_call);
      //text_layer_set_text(nld->secondary_band_layer, npr_data->secondary_band);

      nld->secondary_strength = npr_data->secondary_strength;
      layer_mark_dirty(nld->secondary_strength_layer);
    }

    text_layer_set_text(nld->primary_program_layer, npr_data->primary_program);
    text_layer_set_text(nld->secondary_program_layer, npr_data->secondary_program);
  }
}
コード例 #5
0
ファイル: pedometer.c プロジェクト: sidslog/SleepTracker
void stopTrack() {
    app_timer_cancel(timer);
    accel_data_service_unsubscribe();
}
コード例 #6
0
void communication_in_received_callback(DictionaryIterator *iter, void *context) {
    Tuple *tuple = dict_read_first(iter);
#define SIZE_OF_A_FRIEND 9
    //char friend[100];
    //int8_t live_max_name = -1;
    uint16_t time0;
    int16_t xpos = 0, ypos = 0;

    while (tuple) {
        switch (tuple->key) {
        case MSG_LIVE_NAME0:
            //vibes_short_pulse();
            strncpy(s_live.friends[0].name, tuple->value->cstring, 10);
            break;
        case MSG_LIVE_NAME1:
            strncpy(s_live.friends[1].name, tuple->value->cstring, 10);
            break;
        case MSG_LIVE_NAME2:
            strncpy(s_live.friends[2].name, tuple->value->cstring, 10);
            break;
        case MSG_LIVE_NAME3:
            strncpy(s_live.friends[3].name, tuple->value->cstring, 10);
            break;
        case MSG_LIVE_NAME4:
            strncpy(s_live.friends[4].name, tuple->value->cstring, 10);
            break;

        case MSG_LIVE_SHORT:
            nb_tuple_live++;
            //strcpy(s_data.friends, "");

            s_live.nb = tuple->value->data[0];
            if (s_live.nb > NUM_LIVE_FRIENDS) {
                s_live.nb = NUM_LIVE_FRIENDS;
            }

            for (int i = 0; i < s_live.nb; i++) {
                /*if (strcmp(s_live.friends[i].name, "") != 0) {
                  // we already know the name
                  live_max_name = i;
                }*/


                if (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 1] >= 128) {
                    s_live.friends[i].xpos = -1 * (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 0] + 256 * (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 1] - 128));
                } else {
                    s_live.friends[i].xpos = tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 0] + 256 * tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 1];
                }
                if (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 3] >= 128) {
                    s_live.friends[i].ypos = -1 * (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 2] + 256 * (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 3] - 128));
                } else {
                    s_live.friends[i].ypos = tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 2] + 256 * tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 3];
                }
                s_live.friends[i].distance = (tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 4] + 256 * tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 5]) * 10; // in m
                s_live.friends[i].bearing = 360 * tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 6] / 256;
                s_live.friends[i].lastviewed = tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 7] + 256 * tuple->value->data[1 + i * SIZE_OF_A_FRIEND + 8]; // in seconds

                /*
                if (i < 3) {
                  snprintf(friend, sizeof(friend),
                    "%d/%d %s %.0f(m)\n"
                    //"%d|%d\n"
                    "b:%u lv:%d(s)\n",
                    i, s_live.nb, s_live.friends[i].name, s_live.friends[i].distance,
                    //s_live.friends[i].xpos, s_live.friends[i].ypos,
                    s_live.friends[i].bearing, s_live.friends[i].lastviewed
                  );

                  strcat(s_data.friends, friend);
                }
                */

            }
            screen_live_menu_update();
            if (s_data.page_number == PAGE_MAP) {
                layer_mark_dirty(s_data.page_map);
            }

            //if (live_max_name != s_live.nb) {
            //    send_ask_name(live_max_name);
            //}

            break;

        case MSG_LOCATION_DATA:
        case MSG_LOCATION_DATA_V2:
        case MSG_LOCATION_DATA_V3:
            nb_tuple_altitude++;
            if (tuple->key == MSG_LOCATION_DATA) {
                //APP_LOG(APP_LOG_LEVEL_DEBUG, "MSG_LOCATION_DATA");
                change_units((tuple->value->data[0] & 0b00000001) >> 0, false);
                change_state((tuple->value->data[0] & 0b00000010) >> 1);
                s_data.debug = (tuple->value->data[0] & 0b00000100) >> 2;
                s_data.live = (tuple->value->data[0] & 0b00001000) >> 3;
                s_data.refresh_code = (tuple->value->data[0] & 0b00110000) >> 4;
            }
            if (tuple->key >= MSG_LOCATION_DATA_V2) {
                //APP_LOG(APP_LOG_LEVEL_DEBUG, "MSG_LOCATION_DATA_v2");
                change_units((tuple->value->data[0] & 0b00000111) >> 0, false);
                change_state((tuple->value->data[0] & 0b00001000) >> 3);
                s_data.debug = (tuple->value->data[0] & 0b00010000) >> 4;
                s_data.live = (tuple->value->data[0] & 0b00100000) >> 5;
                s_data.refresh_code = (tuple->value->data[0] & 0b11000000) >> 6;
            }
            // if (tuple->key == MSG_LOCATION_DATA_V2) {
            //   APP_LOG(APP_LOG_LEVEL_DEBUG, "MSG_LOCATION_DATA_v2");
            // }
            // if (tuple->key == MSG_LOCATION_DATA_V3) {
            //   APP_LOG(APP_LOG_LEVEL_DEBUG, "MSG_LOCATION_DATA_v3");
            // }

            s_gpsdata.accuracy = tuple->value->data[1];
            s_gpsdata.distance100 = (tuple->value->data[2] + 256 * tuple->value->data[3]); // in 0.01km or 0.01miles
            time0 = s_gpsdata.time;
            s_gpsdata.time = tuple->value->data[BYTE_TIME1] + 256 * tuple->value->data[BYTE_TIME2];
            if (s_gpsdata.time != 0) {
              if (s_gpsdata.units == UNITS_RUNNING_IMPERIAL || s_gpsdata.units == UNITS_RUNNING_METRIC) {
                // pace: min per mile_or_km
                if (s_gpsdata.distance100 > 0) {
                    s_gpsdata.avgspeed100 = 100 * 100 / 60 * s_gpsdata.time / s_gpsdata.distance100; // min per mile_or_km
                  } else {
                    s_gpsdata.avgspeed100 = 0;
                  }
                } else {
                  s_gpsdata.avgspeed100 = 3600 * s_gpsdata.distance100 / s_gpsdata.time; // 0.01km/h or 0.01mph
                }
            } else {
                s_gpsdata.avgspeed100 = 0;
            }
            //APP_LOG(APP_LOG_LEVEL_DEBUG, "dist=%ld, time=%d, avg=%ld", s_gpsdata.distance100, s_gpsdata.time, s_gpsdata.avgspeed100);
            s_gpsdata.speed100 = ((tuple->value->data[BYTE_SPEED1] + 256 * tuple->value->data[BYTE_SPEED2])) * 10;
            s_gpsdata.maxspeed100 = ((tuple->value->data[BYTE_MAXSPEED1] + 256 * tuple->value->data[BYTE_MAXSPEED2])) * 10;
            s_gpsdata.altitude = tuple->value->data[6] + 256 * tuple->value->data[7];
            if (tuple->value->data[9] >= 128) {
                s_gpsdata.ascent = -1 * (tuple->value->data[8] + 256 * (tuple->value->data[9] - 128));
            } else {
                s_gpsdata.ascent = tuple->value->data[8] + 256 * tuple->value->data[9];
            }

            if (tuple->value->data[11] >= 128) {
                s_gpsdata.ascentrate = -1 * (tuple->value->data[10] + 256 * (tuple->value->data[11] - 128));
            } else {
                s_gpsdata.ascentrate = tuple->value->data[10] + 256 * tuple->value->data[11];
            }
            if (tuple->value->data[BYTE_SLOPE] >= 128) {
                s_gpsdata.slope = -1 * (tuple->value->data[BYTE_SLOPE] - 128);
            } else {
                s_gpsdata.slope = tuple->value->data[BYTE_SLOPE];
            }



            if (tuple->value->data[14] >= 128) {
                xpos = -1 * (tuple->value->data[13] + 256 * (tuple->value->data[14] - 128));
            } else {
                xpos = tuple->value->data[13] + 256 * tuple->value->data[14];
            }
            if (tuple->value->data[16] >= 128) {
                ypos = -1 * (tuple->value->data[15] + 256 * (tuple->value->data[16] - 128));
            } else {
                ypos = tuple->value->data[15] + 256 * tuple->value->data[16];
            }

            if ((xpos == 0 && ypos == 0) || (time0 > s_gpsdata.time)) {
                // ignore old values (can happen if gps is stopped/restarted)
                #if DEBUG
                  if (s_data.debug) {
                    
                        APP_LOG(APP_LOG_LEVEL_DEBUG, "==> time0=%d t=%d xpos=%d ypos=%d", time0, s_gpsdata.time, xpos, ypos);      
                        //vibes_short_pulse();
                  }
                #endif
                xpos = s_gpsdata.xpos;
                ypos = s_gpsdata.ypos;
            }
            s_gpsdata.xpos = xpos;
            s_gpsdata.ypos = ypos;

            s_gpsdata.bearing = 360 * tuple->value->data[BYTE_BEARING] / 256;
            s_gpsdata.heartrate = tuple->value->data[BYTE_HEARTRATE];
            if (tuple->key >= MSG_LOCATION_DATA_V3) {
              s_gpsdata.cadence = tuple->value->data[BYTE_CADENCE];
            } else {
              s_gpsdata.cadence = tuple->value->data[BYTE_HEARTRATE]; // no specific field until MSG_LOCATION_DATA_V3
            }


            snprintf(s_data.accuracy,   sizeof(s_data.accuracy),   "%d",   s_gpsdata.accuracy);
            snprintf(s_data.distance,   sizeof(s_data.distance),   "%ld.%ld", s_gpsdata.distance100 / 100, s_gpsdata.distance100 % 100 / 10);
            copy_speed(s_data.avgspeed, sizeof(s_data.avgspeed), s_gpsdata.avgspeed100);
            snprintf(s_data.altitude,   sizeof(s_data.altitude),   "%u",   s_gpsdata.altitude);
            snprintf(s_data.ascent,     sizeof(s_data.ascent),     "%d",   s_gpsdata.ascent);
            snprintf(s_data.ascentrate, sizeof(s_data.ascentrate), "%d",   s_gpsdata.ascentrate);
            snprintf(s_data.slope,      sizeof(s_data.slope),      "%d",   s_gpsdata.slope);
            snprintf(s_data.bearing,    sizeof(s_data.bearing),    "%d",   s_gpsdata.bearing);
            if (s_gpsdata.heartrate != 255) {
              snprintf(s_data.heartrate,  sizeof(s_data.heartrate),  "%d",   s_gpsdata.heartrate);
            } else {
              strcpy(s_data.heartrate, "-");
            }
            if (s_gpsdata.cadence != 255) {
              snprintf(s_data.cadence,  sizeof(s_data.cadence),  "%d",   s_gpsdata.cadence);
            } else {
              strcpy(s_data.cadence, "-");
            }            
            if (s_gpsdata.time / 3600 > 0) {
              snprintf(s_data.elapsedtime,sizeof(s_data.elapsedtime),"%d:%.2d:%.2d", s_gpsdata.time / 3600, (s_gpsdata.time / 60) % 60, s_gpsdata.time % 60);
            } else {
              snprintf(s_data.elapsedtime,sizeof(s_data.elapsedtime),"%d:%.2d", (s_gpsdata.time / 60) % 60, s_gpsdata.time % 60);
            }
            //APP_LOG(APP_LOG_LEVEL_DEBUG, "t:%d => %s", s_gpsdata.time, s_data.elapsedtime);

            screen_speed_show_speed(false);

            // reset data (instant speed...) after X if no data is received
            if (reset_data_timer) {
              //APP_LOG(APP_LOG_LEVEL_DEBUG, "app_timer_cancel()");
              app_timer_cancel(reset_data_timer);
            }
            // s_data.refresh_code == 3 => _refresh_interval [5;+inf
            reset_data_timer = app_timer_register(s_data.refresh_code == 3 ? 60000 : 20000, reset_data_timer_callback, NULL);

#if DEBUG
            ftoa(s_gpsdata.distance, tmp, 10, 1);
            snprintf(s_data.debug1, sizeof(s_data.debug1),
                     "#%d us:%d|%d A:%u\n"
                     "alt:%u asc:%d\n"
                     "pos:%d|%d #%u\n"
                     //"%d|%d|%d\n"
                     "s:%d b:%u\n"
                     "D:%s km T:%u\n"
                     "%d avg:%d\n",
                     s_gpsdata.nb_received++, s_gpsdata.units, s_data.state, s_gpsdata.accuracy,
                     s_gpsdata.altitude, s_gpsdata.ascent,
                     //s_gpsdata.ascentrate, s_gpsdata.slope,
                     s_gpsdata.xpos, s_gpsdata.ypos, nb_points,
                     //s_data.debug, s_data.live, s_data.refresh_code,
                     map_scale,s_gpsdata.bearing,
                     tmp, s_gpsdata.time,
                     (int) s_gpsdata.speed, (int) s_gpsdata.avgspeed
                    );
#endif

            screen_map_update_location();

            if (s_data.page_number == PAGE_SPEED || s_data.page_number == PAGE_HEARTRATE) {
                layer_mark_dirty(s_data.page_speed);
            }
            if (s_data.page_number == PAGE_ALTITUDE) {
                layer_mark_dirty(s_data.page_altitude);
            }
            if (s_data.page_number == PAGE_LIVE_TRACKING) {
                layer_mark_dirty((Layer *) s_data.page_live_tracking);
            }
#if DEBUG
            if (s_data.page_number == PAGE_DEBUG1) {
                layer_mark_dirty(s_data.page_debug1);
            }
            if (s_data.page_number == PAGE_DEBUG2) {
                layer_mark_dirty(s_data.page_debug2);
            }
#endif
            break;
        case MSG_SENSOR_TEMPERATURE:
            s_gpsdata.temperature10 = tuple->value->int16;
            snprintf(s_data.temperature,   sizeof(s_data.temperature),   "%d.%d", s_gpsdata.temperature10 / 10, s_gpsdata.temperature10 % 10);
            break;

        case STATE_CHANGED:
            nb_tuple_state++;
            //vibes_short_pulse();
            change_state(tuple->value->uint8);
            break;

        case MSG_VERSION_ANDROID:
            //vibes_short_pulse();
            s_data.android_version = tuple->value->int32;
            break;

        case MSG_BATTERY_LEVEL:
          //APP_LOG(APP_LOG_LEVEL_DEBUG, "MSG_BATTERY_LEVEL:%ld", tuple->value->int32);
          s_data.phone_battery_level = tuple->value->int32;
          break;
        }
コード例 #7
0
void process_tuple(Tuple *t){
	int key = t->key;
	int value = t->value->int32;
  switch (key) {
	  case 0:
		settings.invert = value;
	  	break;
	  case 1:
	  	settings.wordPack = value;
	  	break;
	  case 2:
	  	settings.progressiveDrunk = value;
	  	break;
	  case 3:
	  	settings.animation = value;
	  	break;
	  case 4:
	  	settings.dateFormat = value;
	  	break;
	  case 5:
	  	settings.seconds = value;
	  	break;
	  case 6:
	  	settings.shakeAction = value;
	  	break;
	  case 7:
	  	settings.batteryBar = value;
	  	break;
	  case 8:
	  	settings.btReAlert = value;
	  	break;
	  case 9:
	  	settings.btDisAlert = value;
	  	break;
	  case 10:
	  	settings.slotUse = value;
	  	break;
	  case 11:
	  	strcpy(settings.customslottext[0], t->value->cstring);
	  	break;
	  case 12:
	  	settings.fahrenheit = value;
	  	if(settings.fahrenheit){
	  		settings.previousTemp = (1.8*(settings.previousTempRaw-273)+32);
	  	}
	  	else{
	  		settings.previousTemp = settings.previousTempRaw-273;
	  	}
	  	break;
	  case 32:
	  	settings.updateFreq = value;
	  	break;
	  case 33:
	  	app_timer_cancel(refresh_timer);
	  	if(settings.fahrenheit){
	  		settings.previousTemp = (1.8*(value-273)+32);
	  	}
	  	else{
	  		settings.previousTemp = value-273;
	  	}
	  	settings.previousTempRaw = value;
	  	weather_refresh_timer = app_timer_register(500, weather_refresh_callback, NULL);
	  	break;
	  case 34:
	  	settings.previousCondition = value;
	  	break;
	  case 35:
	  	settings.alerts = value;
	  	break;
	  default:
	  	//APP_LOG(APP_LOG_LEVEL_ERROR, "Got key %d with string %s", key, t->value->cstring);
	  	phrases_strcpy(key, t->value->cstring);
	  	break;
  }
}
コード例 #8
0
// Update the bottom half of the screen: icon and temperature
void weather_layer_update(WeatherData *weather_data) 
{
  // We have no weather data yet... don't update until we do
  if (weather_data->updated == 0) {
    return;
  }

  WeatherLayerData *wld = layer_get_data(weather_layer);

  if (weather_animation_timer && animation_timer_enabled) {
    app_timer_cancel(weather_animation_timer);
    // this is only needed to stop the error message when cancelling an already cancelled timer... 
    animation_timer_enabled = false;
    layer_set_hidden(wld->loading_layer, true);
  }

  time_t current_time = time(NULL);

  bool stale = false;
  if (current_time - weather_data->updated > WEATHER_STALE_TIMEOUT) {
    stale = true;
  }

  //APP_LOG(APP_LOG_LEVEL_DEBUG, "ct:%i wup:%i, stale:%i", 
  //  (int)current_time, (int)weather_data->updated, (int)WEATHER_STALE_TIMEOUT);

  // Update the weather icon and temperature
  if (weather_data->error) {
    // Only update the error icon if the weather data is stale
    if (stale) {
      weather_layer_clear_temperature();
      switch (weather_data->error) {
        case WEATHER_E_NETWORK:
          weather_layer_set_error();
          debug_update_message("Network error");
          break;
        case WEATHER_E_DISCONNECTED:
        case WEATHER_E_PHONE:
        default:
          weather_layer_set_error();
          debug_update_message("Phone disco / error");
          break;
      }
    }
  } else {

    layer_set_frame(bitmap_layer_get_layer(wld->primary_icon_layer), PRIMARY_ICON_NORMAL_FRAME);

    // Show the temperature as 'stale' if it has not been updated in WEATHER_STALE_TIMEOUT
    weather_layer_set_temperature(weather_data->temperature, stale);

    // Day/night check
    time_t utc = current_time;
//    time_t utc = current_time + weather_data->tzoffset;                                ///////// Change utc value to current_time for SDK3 by ktagjp
    bool night_time = is_night_time(weather_data->sunrise, weather_data->sunset, utc);

    /*
    APP_LOG(APP_LOG_LEVEL_DEBUG, 
       "ct:%i, utc:%i sr:%i, ss:%i, nt:%i", 
       (int)current_time, (int)utc, weather_data->sunrise, weather_data->sunset, night_time);
    */

	if (strcmp(weather_data->service, SERVICE_OPEN_WEATHER) == 0) {
		weather_layer_set_icon(open_weather_icon_for_condition(weather_data->condition, night_time), AREA_PRIMARY);
	} else if (strcmp(weather_data->service, SERVICE_YAHOO_WEATHER) == 0) {
		weather_layer_set_icon(yahoo_weather_icon_for_condition(weather_data->condition, night_time), AREA_PRIMARY);
	} else {
		weather_layer_set_icon(wunder_weather_icon_for_condition(weather_data->condition, night_time), AREA_PRIMARY);
	}

	if (weather_data->hourly_updated != 0 && weather_data->hourly_enabled) {
		time_t h1t = weather_data->h1_time;
		time_t h2t = weather_data->h2_time;
//      time_t h1t = weather_data->h1_time - weather_data->tzoffset;      ///////// Change time value for SDK3 by ktagjp
//      time_t h2t = weather_data->h2_time - weather_data->tzoffset;      ///////// Change time value for SDK3 by ktagjp
      strftime(time_h1, sizeof(time_h1), "%I%p", localtime(&h1t));
      strftime(time_h2, sizeof(time_h2), "%I%p", localtime(&h2t));

      if (time_h1[0] == '0') {
        memmove(time_h1, &time_h1[1], sizeof(time_h1) - 1);
      }
      if (time_h2[0] == '0') {
        memmove(time_h2, &time_h2[1], sizeof(time_h2) - 1);
      }

      text_layer_set_text(wld->h1_time_layer, time_h1);
      text_layer_set_text(wld->h2_time_layer, time_h2);

      localtime(&current_time);

      night_time = is_night_time(weather_data->sunrise, weather_data->sunset, weather_data->h1_time);
      weather_layer_set_icon(wunder_weather_icon_for_condition(weather_data->h1_cond, night_time), AREA_HOURLY1);
      
      night_time = is_night_time(weather_data->sunrise, weather_data->sunset, weather_data->h2_time);
      weather_layer_set_icon(wunder_weather_icon_for_condition(weather_data->h2_cond, night_time), AREA_HOURLY2);
      
      snprintf(wld->h1_temp_str, sizeof(wld->h1_temp_str), 
        "%i%s", weather_data->h1_temp, "°");
      snprintf(wld->h2_temp_str, sizeof(wld->h2_temp_str), 
        "%i%s", weather_data->h2_temp, "°");

      text_layer_set_text(wld->h1_temp_layer, wld->h1_temp_str);
      text_layer_set_text(wld->h2_temp_layer, wld->h2_temp_str);
    }
  }
}
コード例 #9
0
void virtual_screen_deinit() {
  app_timer_cancel(s_timer);
  layer_destroy(s_layer);
}
コード例 #10
0
ファイル: comm.c プロジェクト: oschumac/urchin-cgm
static void clear_timer(AppTimer **timer) {
  if (*timer != NULL) {
    app_timer_cancel(*timer);
    *timer = NULL;
  }
}
コード例 #11
0
ファイル: mainwin.c プロジェクト: SeaPea/GentleWake
// Stops any active auto-close timer
static void stop_autoclose_timer() {
  if (s_autoclose_timer != NULL) {
    app_timer_cancel(s_autoclose_timer);
    s_autoclose_timer = NULL;
  }
}
コード例 #12
0
ファイル: kelkoSports.c プロジェクト: kelko/kelkoSport
void stopCurrentTimer() {
    app_timer_cancel(timerHandle);
}
コード例 #13
0
static void main_window_unload(Window *window) {
  app_timer_cancel(vibe_timer);
  //if(s_flip_to_snooze)
  //  accel_tap_service_unsubscribe();
}
コード例 #14
0
ファイル: graphics_round.c プロジェクト: ardaozkal/QuickAuth
void stop_managing_countdown_layer() {
  running = false;
  app_timer_cancel(timer);
  timer = NULL;
}
コード例 #15
0
void buzzer2() 
{
  app_timer_cancel( btBuzzerTimer);
  vibes_short_pulse();
} // buzzer2 
コード例 #16
0
ファイル: main.c プロジェクト: jsternfield/alienradar
static void window_unload(Window *window) 
{
    app_timer_cancel(timer);
    //layer_destroy(timeLayer);
}
コード例 #17
0
ファイル: Dashboard.c プロジェクト: rognvald/MrGibbs
void dashboard_init(void) {
	dashboard_window = window_create();
  #ifdef PBL_SDK_2
  window_set_fullscreen(dashboard_window,true);
  #endif
  window_set_background_color(dashboard_window,GColorBlack);
  window_set_click_config_provider(dashboard_window, dashboard_click_config_provider);
	window_stack_push(dashboard_window, true);
  dashboard_window_layer = window_get_root_layer(dashboard_window);
  
  GRect c1_bounds = layer_get_bounds(dashboard_window_layer);
  c1_text_layer = text_layer_create(c1_bounds);
  text_layer_set_background_color(c1_text_layer,GColorBlack);
  text_layer_set_text_color(c1_text_layer,GColorWhite);
  text_layer_set_font(c1_text_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text(c1_text_layer, "Starting up...");
  text_layer_set_text_alignment(c1_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(c1_text_layer));
  
  GSize v1_size = {.w=c1_bounds.size.w,.h=c1_bounds.size.h-42};
  GPoint v1_point = {.x=0,.y=8};
  GRect v1_bounds = {.size=v1_size,.origin=v1_point};
  v1_text_layer = text_layer_create(v1_bounds);
  text_layer_set_background_color(v1_text_layer,GColorClear);
  text_layer_set_text_color(v1_text_layer,GColorWhite);
  text_layer_set_font(v1_text_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_text(v1_text_layer, "");
  text_layer_set_text_alignment(v1_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(v1_text_layer));
  
  GSize c2_size = {.w=v1_bounds.size.w,.h=v1_bounds.size.h-8};
  GPoint c2_point = {.x=0,.y=50};
  GRect c2_bounds = {.size=c2_size,.origin=c2_point};
  c2_text_layer = text_layer_create(c2_bounds);
  text_layer_set_background_color(c2_text_layer,GColorClear);
  text_layer_set_text_color(c2_text_layer,GColorWhite);
  text_layer_set_font(c2_text_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text(c2_text_layer, "");
  text_layer_set_text_alignment(c2_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(c2_text_layer));
  
  GSize v2_size = {.w=c2_bounds.size.w,.h=c2_bounds.size.h-42};
  GPoint v2_point = {.x=0,.y=58};
  GRect v2_bounds = {.size=v2_size,.origin=v2_point};
  v2_text_layer = text_layer_create(v2_bounds);
  text_layer_set_background_color(v2_text_layer,GColorClear);
  text_layer_set_text_color(v2_text_layer,GColorWhite);
  text_layer_set_font(v2_text_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_text(v2_text_layer, "");
  text_layer_set_text_alignment(v2_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(v2_text_layer));
  
  GSize c3_size = {.w=v2_bounds.size.w,.h=v2_bounds.size.h-8};
  GPoint c3_point = {.x=0,.y=100};
  GRect c3_bounds = {.size=c3_size,.origin=c3_point};
  c3_text_layer = text_layer_create(c3_bounds);
  text_layer_set_background_color(c3_text_layer,GColorClear);
  text_layer_set_text_color(c3_text_layer,GColorWhite);
  text_layer_set_font(c3_text_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text(c3_text_layer, "");
  text_layer_set_text_alignment(c3_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(c3_text_layer));
  
  GSize v3_size = {.w=c3_bounds.size.w,.h=c3_bounds.size.h};
  GPoint v3_point = {.x=0,.y=108};
  GRect v3_bounds = {.size=v3_size,.origin=v3_point};
  v3_text_layer = text_layer_create(v3_bounds);
  text_layer_set_background_color(v3_text_layer,GColorClear);
  text_layer_set_text_color(v3_text_layer,GColorWhite);
  text_layer_set_font(v3_text_layer,fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
  text_layer_set_text(v3_text_layer, "");
  text_layer_set_text_alignment(v3_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(v3_text_layer));
  
  GSize m_size = {.w=v3_bounds.size.w,.h=v3_bounds.size.h-8};
  GPoint m_point = {.x=0,.y=152};
  GRect m_bounds = {.size=m_size,.origin=m_point};
  m_text_layer = text_layer_create(m_bounds);
  text_layer_set_font(m_text_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  text_layer_set_text(m_text_layer, "");
  text_layer_set_text_alignment(m_text_layer,GTextAlignmentCenter);
  layer_add_child(dashboard_window_layer, text_layer_get_layer(m_text_layer));
  
  clear_timer = app_timer_register(5000,dashboard_clear,dashboard_window);
}

void dashboard_deinit(void) {
  app_timer_cancel(clear_timer);
  window_destroy(dashboard_window);
}

void return_to_dashboard(bool animated){
  while(window_stack_get_top_window()!=dashboard_window){
    window_stack_pop(animated);
  }
}