Browse code

font and text layer tuning

louis.jonget authored on13/10/2022 15:01:07
Showing3 changed files
1 1
Binary files a/build/bike_companion.pbw and b/build/bike_companion.pbw differ
... ...
@@ -65,7 +65,7 @@ static void send_message(char * msg){
65 65
 
66 66
 
67 67
 static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
68
-  text_layer_set_text(s_speed_text_layer, "");
68
+  text_layer_set_text(s_speed_text_layer, "0.0");
69 69
   text_layer_set_text(s_other_text_layer, "sending get geoloc");
70 70
   send_message("get");
71 71
 }
... ...
@@ -88,16 +88,16 @@ static void prv_window_load(Window *window) {
88 88
   Layer *window_layer = window_get_root_layer(window);
89 89
   GRect bounds = layer_get_bounds(window_layer);
90 90
 
91
-  s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h/2));
91
+  s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, 54));
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_ROBOTO_BOLD_SUBSET_49));
95
+  text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
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
 
99 99
 
100
-  s_other_text_layer = text_layer_create(GRect(0, bounds.size.h/2,bounds.size.w, bounds.size.h/2));
100
+  s_other_text_layer = text_layer_create(GRect(0, 55 ,bounds.size.w, bounds.size.h/2));
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);
... ...
@@ -113,8 +113,7 @@ static void prv_window_unload(Window *window) {
113 113
 void comm_is_ready() {
114 114
 
115 115
   // set the text
116
-  text_layer_set_text(s_speed_text_layer, "Press a button to start");
117
-  text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JSready");
116
+  text_layer_set_text(s_other_text_layer, "Press a button to start");
118 117
 
119 118
 }
120 119
 
... ...
@@ -260,9 +259,9 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
260 259
     memset(s_msg,'\0',sizeof(s_msg));
261 260
     strncpy(s_msg, "Acc. ",5);
262 261
     strcat(s_msg, s_accuracy);
263
-    strcat(s_msg, "    Alt. ");
262
+    strcat(s_msg, "\nAlt. ");
264 263
     strcat(s_msg, s_altitude);
265
-    strcat(s_msg, "\n Max. ");
264
+    strcat(s_msg, "\nMax. ");
266 265
     strcat(s_msg, s_max_speed);
267 266
     //strcat(s_msg, "\n Lat. ");
268 267
     //strcat(s_msg, s_latitude);
... ...
@@ -327,15 +327,17 @@ function locationSuccess(new_pos) {
327 327
       altitudeString = splitFloatNumber(new_pos.coords.altitude)[0].toString().substring(0, 5);
328 328
       timestampISO = new Date(new_pos.timestamp).toISOString();
329 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") {
330
+      if (isNaN(speed)) {
336 331
         speedString = "---";
337
-      }
332
+      } else {
333
+        speedString = splitFloatNumber(speed)[0].toString().substring(0, 3) + "." + splitFloatNumber(speed)[1].toString().substring(0, 1);
334
+        if (speedString == "0.N") {
335
+          speedString = "0.0";
336
+        }
338 337
 
338
+        //console.log("split num : " + getMaxSpeed(speed));
339
+        maxSpeedString = splitFloatNumber(getMaxSpeed(speed))[0].toString().substring(0, 3);
340
+      }
339 341
       if (gpx_to_strava || gpx_to_web) {
340 342
         //add a new datapoint to GPX file
341 343
         GPXtrkptBuilder(latitudeString, longitudeString, altitudeString, timestampISO);