| ... | ... |
@@ -21,8 +21,8 @@ static char s_accuracy[5]; |
| 21 | 21 |
static char s_altitude[6]; |
| 22 | 22 |
static char s_altitude_accuracy[4]; |
| 23 | 23 |
static char s_timestamp[14]; |
| 24 |
-static char s_speed[6]; |
|
| 25 |
-static char s_max_speed[5]; |
|
| 24 |
+static char s_speed[5]; |
|
| 25 |
+static char s_max_speed[3]; |
|
| 26 | 26 |
|
| 27 | 27 |
static char s_msg[50]; |
| 28 | 28 |
|
| ... | ... |
@@ -92,7 +92,7 @@ static void prv_window_load(Window *window) {
|
| 92 | 92 |
|
| 93 | 93 |
text_layer_set_background_color(s_speed_text_layer, GColorBlack); |
| 94 | 94 |
text_layer_set_text_color(s_speed_text_layer, GColorWhite); |
| 95 |
- text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
|
| 95 |
+ text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49)); |
|
| 96 | 96 |
text_layer_set_text_alignment(s_speed_text_layer, GTextAlignmentCenter); |
| 97 | 97 |
layer_add_child(window_layer, text_layer_get_layer(s_speed_text_layer)); |
| 98 | 98 |
|
| ... | ... |
@@ -101,7 +101,7 @@ static void prv_window_load(Window *window) {
|
| 101 | 101 |
|
| 102 | 102 |
text_layer_set_background_color(s_other_text_layer, GColorClear); |
| 103 | 103 |
text_layer_set_text_color(s_other_text_layer, GColorBlack); |
| 104 |
- text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 104 |
+ text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); |
|
| 105 | 105 |
text_layer_set_text_alignment(s_other_text_layer, GTextAlignmentCenter); |
| 106 | 106 |
layer_add_child(window_layer, text_layer_get_layer(s_other_text_layer)); |
| 107 | 107 |
} |
| ... | ... |
@@ -238,7 +238,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 238 | 238 |
|
| 239 | 239 |
if(max_speed_tuple) {
|
| 240 | 240 |
memset(s_max_speed,'\0',sizeof(s_max_speed)); |
| 241 |
- strncpy(s_max_speed, max_speed_tuple->value->cstring, 5); |
|
| 241 |
+ strncpy(s_max_speed, max_speed_tuple->value->cstring, 3); |
|
| 242 | 242 |
//uint i_max_speed=atoi(s_max_speed); |
| 243 | 243 |
// Display in the TextLayer |
| 244 | 244 |
//text_layer_set_text(s_max_speed_text_layer, lf_max_speed); |
| ... | ... |
@@ -290,74 +290,74 @@ function locationSuccess(new_pos) {
|
| 290 | 290 |
var prev_pos = getLocation(); |
| 291 | 291 |
storeLocation(new_pos); |
| 292 | 292 |
if (prev_pos === null) {
|
| 293 |
- console.log('--- start building gpx');
|
|
| 293 |
+ console.log('--- start building gpx');
|
|
| 294 | 294 |
|
| 295 |
- if (gpx_to_strava || gpx_to_web) {
|
|
| 296 |
- // Start the GPX file |
|
| 297 |
- GPXHeadersBuilder(new Date(new_pos.timestamp).toISOString(), "test", "18"); |
|
| 298 |
- } |
|
| 295 |
+ if (gpx_to_strava || gpx_to_web) {
|
|
| 296 |
+ // Start the GPX file |
|
| 297 |
+ GPXHeadersBuilder(new Date(new_pos.timestamp).toISOString(), "test", "18"); |
|
| 298 |
+ } |
|
| 299 | 299 |
} else {
|
| 300 |
- //clear watch of new position to avoid overlap |
|
| 301 |
- //navigator.geolocation.clearWatch(geoloc_id); |
|
| 302 |
- //console.log('--- watch geoloc cleared');
|
|
| 303 |
- //var speed = speed_from_distance_and_time(prev_pos, new_pos); |
|
| 304 |
- |
|
| 305 |
- //get speed from geoloc API isntead of calculate it |
|
| 306 |
- // speed is initially in m/s, get it at km/h |
|
| 307 |
- if (new_pos.coords.speed === null) {
|
|
| 308 |
- var speed = 0; |
|
| 309 |
- } else {
|
|
| 310 |
- var speed = new_pos.coords.speed * 3.6; |
|
| 311 |
- } |
|
| 312 |
- |
|
| 313 |
- // Prepare display on watch |
|
| 314 |
- // now it's only raw data |
|
| 315 |
- // init strings |
|
| 316 |
- var latitudeString = ""; |
|
| 317 |
- var longitudeString = ""; |
|
| 318 |
- var accuracyString = ""; |
|
| 319 |
- var altitudeString = ""; |
|
| 320 |
- var speedString = ""; |
|
| 321 |
- |
|
| 322 |
- //formating for precision and max size |
|
| 323 |
- latitudeString = new_pos.coords.latitude.toString().substring(0, 12); |
|
| 324 |
- longitudeString = new_pos.coords.longitude.toString().substring(0, 12); |
|
| 325 |
- accuracyString = new_pos.coords.accuracy.toString().substring(0, 4); |
|
| 326 |
- //console.log("split num : " + new_pos.coords.altitude);
|
|
| 327 |
- altitudeString = splitFloatNumber(new_pos.coords.altitude)[0].toString().substring(0, 5); |
|
| 328 |
- timestampISO = new Date(new_pos.timestamp).toISOString(); |
|
| 329 |
- //console.log("split num : " + speed);
|
|
| 330 |
- speedString = splitFloatNumber(speed)[0].toString().substring(0, 3); //+ "." + splitFloatNumber(speed)[1].toString().substring(0, 1); |
|
| 331 |
- |
|
| 332 |
- //console.log("split num : " + getMaxSpeed(speed));
|
|
| 333 |
- maxSpeedString = splitFloatNumber(getMaxSpeed(speed))[0].toString().substring(0, 4); |
|
| 334 |
- |
|
| 335 |
- if (speedString == "NaN") {
|
|
| 336 |
- speedString = "---"; |
|
| 337 |
- } |
|
| 338 |
- |
|
| 339 |
- if (gpx_to_strava || gpx_to_web) {
|
|
| 340 |
- //add a new datapoint to GPX file |
|
| 341 |
- GPXtrkptBuilder(latitudeString, longitudeString, altitudeString, timestampISO); |
|
| 342 |
- |
|
| 343 |
- } |
|
| 344 |
- |
|
| 345 |
- // Build message |
|
| 346 |
- message = "OK"; |
|
| 347 |
- var dict = {
|
|
| 348 |
- 'accuracy': accuracyString, |
|
| 349 |
- 'altitude': altitudeString, |
|
| 350 |
- 'speed': speedString, |
|
| 351 |
- 'max_speed': maxSpeedString, |
|
| 352 |
- 'status': message |
|
| 353 |
- }; |
|
| 354 |
- |
|
| 355 |
- // Send the message |
|
| 356 |
- Pebble.sendAppMessage(dict, function() {
|
|
| 357 |
- console.log('Message sent successfully: ' + JSON.stringify(dict));
|
|
| 358 |
- }, function(e) {
|
|
| 359 |
- console.log('Message (' + JSON.stringify(dict) + ') failed: ' + JSON.stringify(e));
|
|
| 360 |
- }); |
|
| 300 |
+ //clear watch of new position to avoid overlap |
|
| 301 |
+ //navigator.geolocation.clearWatch(geoloc_id); |
|
| 302 |
+ //console.log('--- watch geoloc cleared');
|
|
| 303 |
+ //var speed = speed_from_distance_and_time(prev_pos, new_pos); |
|
| 304 |
+ |
|
| 305 |
+ //get speed from geoloc API isntead of calculate it |
|
| 306 |
+ // speed is initially in m/s, get it at km/h |
|
| 307 |
+ if (new_pos.coords.speed === null) {
|
|
| 308 |
+ var speed = 0; |
|
| 309 |
+ } else {
|
|
| 310 |
+ var speed = new_pos.coords.speed * 3.6; |
|
| 311 |
+ } |
|
| 312 |
+ |
|
| 313 |
+ // Prepare display on watch |
|
| 314 |
+ // now it's only raw data |
|
| 315 |
+ // init strings |
|
| 316 |
+ var latitudeString = ""; |
|
| 317 |
+ var longitudeString = ""; |
|
| 318 |
+ var accuracyString = ""; |
|
| 319 |
+ var altitudeString = ""; |
|
| 320 |
+ var speedString = ""; |
|
| 321 |
+ |
|
| 322 |
+ //formating for precision and max size |
|
| 323 |
+ latitudeString = new_pos.coords.latitude.toString().substring(0, 12); |
|
| 324 |
+ longitudeString = new_pos.coords.longitude.toString().substring(0, 12); |
|
| 325 |
+ accuracyString = new_pos.coords.accuracy.toString().substring(0, 4); |
|
| 326 |
+ //console.log("split num : " + new_pos.coords.altitude);
|
|
| 327 |
+ altitudeString = splitFloatNumber(new_pos.coords.altitude)[0].toString().substring(0, 5); |
|
| 328 |
+ timestampISO = new Date(new_pos.timestamp).toISOString(); |
|
| 329 |
+ //console.log("split num : " + speed);
|
|
| 330 |
+ speedString = splitFloatNumber(speed)[0].toString().substring(0, 3) + "." + splitFloatNumber(speed)[1].toString().substring(0, 1); |
|
| 331 |
+ |
|
| 332 |
+ //console.log("split num : " + getMaxSpeed(speed));
|
|
| 333 |
+ maxSpeedString = splitFloatNumber(getMaxSpeed(speed))[0].toString().substring(0, 3); |
|
| 334 |
+ |
|
| 335 |
+ if (speedString == "NaN") {
|
|
| 336 |
+ speedString = "---"; |
|
| 337 |
+ } |
|
| 338 |
+ |
|
| 339 |
+ if (gpx_to_strava || gpx_to_web) {
|
|
| 340 |
+ //add a new datapoint to GPX file |
|
| 341 |
+ GPXtrkptBuilder(latitudeString, longitudeString, altitudeString, timestampISO); |
|
| 342 |
+ |
|
| 343 |
+ } |
|
| 344 |
+ |
|
| 345 |
+ // Build message |
|
| 346 |
+ message = "OK"; |
|
| 347 |
+ var dict = {
|
|
| 348 |
+ 'accuracy': accuracyString, |
|
| 349 |
+ 'altitude': altitudeString, |
|
| 350 |
+ 'speed': speedString, |
|
| 351 |
+ 'max_speed': maxSpeedString, |
|
| 352 |
+ 'status': message |
|
| 353 |
+ }; |
|
| 354 |
+ |
|
| 355 |
+ // Send the message |
|
| 356 |
+ Pebble.sendAppMessage(dict, function () {
|
|
| 357 |
+ console.log('Message sent successfully: ' + JSON.stringify(dict));
|
|
| 358 |
+ }, function (e) {
|
|
| 359 |
+ console.log('Message (' + JSON.stringify(dict) + ') failed: ' + JSON.stringify(e));
|
|
| 360 |
+ }); |
|
| 361 | 361 |
} |
| 362 | 362 |
|
| 363 | 363 |
} |