| ... | ... |
@@ -373,13 +373,22 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 373 | 373 |
*/ |
| 374 | 374 |
|
| 375 | 375 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
| 376 |
- |
|
| 377 |
- text_layer_set_text(s_upperleft_text_layer, s_altitude); |
|
| 378 |
- text_layer_set_text(s_upperright_text_layer, s_distance); |
|
| 379 |
- text_layer_set_text(s_main_text_layer, s_speed); |
|
| 380 |
- text_layer_set_text(s_lowerleft_text_layer, s_avg_speed); |
|
| 381 |
- text_layer_set_text(s_lowerright_text_layer, s_max_speed); |
|
| 382 |
- text_layer_set_text(s_lower_text_layer, s_duration); |
|
| 376 |
+ if(strcmp(s_status, "L200")==0){
|
|
| 377 |
+ text_layer_set_text(s_upperleft_text_layer, s_altitude); |
|
| 378 |
+ text_layer_set_text(s_upperright_text_layer, s_distance); |
|
| 379 |
+ text_layer_set_text(s_main_text_layer, s_speed); |
|
| 380 |
+ text_layer_set_text(s_lowerleft_text_layer, s_avg_speed); |
|
| 381 |
+ text_layer_set_text(s_lowerright_text_layer, s_max_speed); |
|
| 382 |
+ text_layer_set_text(s_lower_text_layer, s_duration); |
|
| 383 |
+ }else if(strcmp(s_status, "S200")==0){
|
|
| 384 |
+ text_layer_set_text(s_lower_text_layer, "upload OK"); |
|
| 385 |
+ vibes_short_pulse(); |
|
| 386 |
+ }else if(strcmp(s_status, "S401")==0){
|
|
| 387 |
+ text_layer_set_text(s_lower_text_layer, "auth err, retrying"); |
|
| 388 |
+ }else{
|
|
| 389 |
+ text_layer_set_text(s_lower_text_layer, s_status); |
|
| 390 |
+ vibes_double_pulse(); |
|
| 391 |
+ } |
|
| 383 | 392 |
}else{
|
| 384 | 393 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| 385 | 394 |
} |
| ... | ... |
@@ -21,7 +21,7 @@ static char s_status[4]; |
| 21 | 21 |
//restricting long and lat to 13 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal, 1 for \0 |
| 22 | 22 |
static char s_longitude[13]; |
| 23 | 23 |
static char s_latitude[13]; |
| 24 |
-static char s_distance[6]; |
|
| 24 |
+static char s_distance[7]; |
|
| 25 | 25 |
|
| 26 | 26 |
static char s_accuracy[5]; |
| 27 | 27 |
static char s_altitude[6]; |
| ... | ... |
@@ -237,7 +237,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 237 | 237 |
|
| 238 | 238 |
if(distance_tuple) {
|
| 239 | 239 |
memset(s_distance,'\0',sizeof(s_distance)); |
| 240 |
- strncpy(s_distance, distance_tuple->value->cstring, 6); |
|
| 240 |
+ strncpy(s_distance, distance_tuple->value->cstring, 7); |
|
| 241 | 241 |
}else{
|
| 242 | 242 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not distance message... "); |
| 243 | 243 |
} |
| ... | ... |
@@ -77,12 +77,12 @@ static void send_message(char * msg){
|
| 77 | 77 |
|
| 78 | 78 |
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 79 | 79 |
text_layer_set_text(s_main_text_layer, ""); |
| 80 |
- text_layer_set_text(s_lower_text_layer, "sending get geoloc"); |
|
| 80 |
+ text_layer_set_text(s_lower_text_layer, "started/stopped"); |
|
| 81 | 81 |
send_message("startstop");
|
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 85 |
- text_layer_set_text(s_lower_text_layer, "Tracking stopped, sending track..."); |
|
| 85 |
+ text_layer_set_text(s_lower_text_layer, "uploading..."); |
|
| 86 | 86 |
send_message("send");
|
| 87 | 87 |
} |
| 88 | 88 |
|
| ... | ... |
@@ -1,11 +1,16 @@ |
| 1 | 1 |
#include <pebble.h> |
| 2 | 2 |
|
| 3 | 3 |
static Window *s_window; |
| 4 |
-static TextLayer *s_speed_text_layer; |
|
| 5 |
-static TextLayer *s_other_text_layer; |
|
| 4 |
+static StatusBarLayer *s_status_text_layer; |
|
| 5 |
+static TextLayer *s_upperleft_text_layer; |
|
| 6 |
+static TextLayer *s_upperright_text_layer; |
|
| 7 |
+static TextLayer *s_main_text_layer; |
|
| 8 |
+static TextLayer *s_lowerleft_text_layer; |
|
| 9 |
+static TextLayer *s_lowerright_text_layer; |
|
| 10 |
+static TextLayer *s_lower_text_layer; |
|
| 6 | 11 |
|
| 7 | 12 |
// Largest expected inbox and outbox message sizes |
| 8 |
-const uint32_t inbox_size = 64; |
|
| 13 |
+const uint32_t inbox_size = 150; |
|
| 9 | 14 |
const uint32_t outbox_size = 64; |
| 10 | 15 |
|
| 11 | 16 |
static uint32_t size ; |
| ... | ... |
@@ -16,13 +21,16 @@ static char s_status[4]; |
| 16 | 21 |
//restricting long and lat to 13 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal, 1 for \0 |
| 17 | 22 |
static char s_longitude[13]; |
| 18 | 23 |
static char s_latitude[13]; |
| 24 |
+static char s_distance[6]; |
|
| 19 | 25 |
|
| 20 | 26 |
static char s_accuracy[5]; |
| 21 | 27 |
static char s_altitude[6]; |
| 22 | 28 |
static char s_altitude_accuracy[4]; |
| 23 | 29 |
static char s_timestamp[14]; |
| 30 |
+static char s_duration[9]; |
|
| 24 | 31 |
static char s_speed[6]; |
| 25 | 32 |
static char s_max_speed[5]; |
| 33 |
+static char s_avg_speed[4]; |
|
| 26 | 34 |
|
| 27 | 35 |
static char s_msg[50]; |
| 28 | 36 |
|
| ... | ... |
@@ -32,12 +40,15 @@ typedef enum {
|
| 32 | 40 |
status, |
| 33 | 41 |
latitude, |
| 34 | 42 |
longitude, |
| 43 |
+ distance, |
|
| 35 | 44 |
altitude, |
| 36 | 45 |
accuracy, |
| 37 | 46 |
altitude_accuracy, |
| 38 | 47 |
speed, |
| 39 | 48 |
max_speed, |
| 40 |
- timestamp |
|
| 49 |
+ avg_speed, |
|
| 50 |
+ timestamp, |
|
| 51 |
+ duration |
|
| 41 | 52 |
} AppKey; |
| 42 | 53 |
|
| 43 | 54 |
|
| ... | ... |
@@ -65,25 +76,27 @@ static void send_message(char * msg){
|
| 65 | 76 |
|
| 66 | 77 |
|
| 67 | 78 |
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 68 |
- text_layer_set_text(s_speed_text_layer, ""); |
|
| 69 |
- text_layer_set_text(s_other_text_layer, "sending get geoloc"); |
|
| 70 |
- send_message("get");
|
|
| 79 |
+ text_layer_set_text(s_main_text_layer, ""); |
|
| 80 |
+ text_layer_set_text(s_lower_text_layer, "sending get geoloc"); |
|
| 81 |
+ send_message("startstop");
|
|
| 71 | 82 |
} |
| 72 | 83 |
|
| 73 | 84 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 74 |
- text_layer_set_text(s_other_text_layer, "Tracking stopped, sending..."); |
|
| 75 |
- send_message("exit");
|
|
| 85 |
+ text_layer_set_text(s_lower_text_layer, "Tracking stopped, sending track..."); |
|
| 86 |
+ send_message("send");
|
|
| 76 | 87 |
} |
| 77 | 88 |
|
| 78 | 89 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 79 |
- text_layer_set_text(s_other_text_layer, "Tracking stopped, sending..."); |
|
| 80 |
- send_message("exit");
|
|
| 90 |
+ //text_layer_set_text(s_lower_text_layer, "Tracking stopped, sending track..."); |
|
| 91 |
+ //send_message("exit");
|
|
| 81 | 92 |
} |
| 82 | 93 |
|
| 94 |
+/* |
|
| 83 | 95 |
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 84 | 96 |
//text_layer_set_text(s_other_text_layer, "back"); |
| 85 | 97 |
//send_message("exit");
|
| 86 | 98 |
} |
| 99 |
+*/ |
|
| 87 | 100 |
|
| 88 | 101 |
static void prv_click_config_provider(void *context) {
|
| 89 | 102 |
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler); |
| ... | ... |
@@ -96,33 +109,82 @@ static void prv_window_load(Window *window) {
|
| 96 | 109 |
Layer *window_layer = window_get_root_layer(window); |
| 97 | 110 |
GRect bounds = layer_get_bounds(window_layer); |
| 98 | 111 |
|
| 99 |
- s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h/2)); |
|
| 100 |
- |
|
| 101 |
- text_layer_set_background_color(s_speed_text_layer, GColorBlack); |
|
| 102 |
- text_layer_set_text_color(s_speed_text_layer, GColorWhite); |
|
| 103 |
- text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
|
| 104 |
- text_layer_set_text_alignment(s_speed_text_layer, GTextAlignmentCenter); |
|
| 105 |
- layer_add_child(window_layer, text_layer_get_layer(s_speed_text_layer)); |
|
| 106 |
- |
|
| 107 |
- |
|
| 108 |
- s_other_text_layer = text_layer_create(GRect(0, bounds.size.h/2,bounds.size.w, bounds.size.h/2)); |
|
| 112 |
+ // creation of all text layers |
|
| 113 |
+ s_status_text_layer = status_bar_layer_create(); |
|
| 114 |
+ s_upperleft_text_layer = text_layer_create(GRect(0, 18, bounds.size.w/2, 34)); |
|
| 115 |
+ s_upperright_text_layer = text_layer_create(GRect(bounds.size.w/2, 18, bounds.size.w/2, 34)); |
|
| 116 |
+ s_main_text_layer = text_layer_create(GRect(0, 52, bounds.size.w, 52)); |
|
| 117 |
+ s_lowerleft_text_layer = text_layer_create(GRect(0, 104, bounds.size.w/2, 34)); |
|
| 118 |
+ s_lowerright_text_layer = text_layer_create(GRect(bounds.size.w/2, 104, bounds.size.w/2, 34)); |
|
| 119 |
+ s_lower_text_layer = text_layer_create(GRect(0, 138, bounds.size.w, 30)); |
|
| 120 |
+ |
|
| 121 |
+ // settings of status layer |
|
| 122 |
+ status_bar_layer_set_colors(s_status_text_layer, GColorBlack, GColorWhite); |
|
| 123 |
+ status_bar_layer_set_separator_mode(s_status_text_layer, StatusBarLayerSeparatorModeDotted); |
|
| 124 |
+ layer_set_frame(status_bar_layer_get_layer(s_status_text_layer), GRect(0, 0, bounds.size.w, 18)); |
|
| 125 |
+ layer_add_child(window_layer, status_bar_layer_get_layer(s_status_text_layer)); |
|
| 126 |
+ /* |
|
| 127 |
+ may need to add other layers to disply BT and GPS in status bar ? |
|
| 128 |
+ */ |
|
| 129 |
+ |
|
| 130 |
+ // settings of upperleft layer |
|
| 131 |
+ text_layer_set_background_color(s_upperleft_text_layer, GColorWhite); |
|
| 132 |
+ text_layer_set_text_color(s_upperleft_text_layer, GColorBlack); |
|
| 133 |
+ text_layer_set_font(s_upperleft_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 134 |
+ text_layer_set_text_alignment(s_upperleft_text_layer, GTextAlignmentCenter); |
|
| 135 |
+ layer_add_child(window_layer, text_layer_get_layer(s_upperleft_text_layer)); |
|
| 136 |
+ |
|
| 137 |
+ // settings of upperright layer |
|
| 138 |
+ text_layer_set_background_color(s_upperright_text_layer, GColorWhite); |
|
| 139 |
+ text_layer_set_text_color(s_upperright_text_layer, GColorBlack); |
|
| 140 |
+ text_layer_set_font(s_upperright_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 141 |
+ text_layer_set_text_alignment(s_upperright_text_layer, GTextAlignmentCenter); |
|
| 142 |
+ layer_add_child(window_layer, text_layer_get_layer(s_upperright_text_layer)); |
|
| 143 |
+ |
|
| 144 |
+ // settings of main layer |
|
| 145 |
+ text_layer_set_background_color(s_main_text_layer, GColorBlack); |
|
| 146 |
+ text_layer_set_text_color(s_main_text_layer, GColorWhite); |
|
| 147 |
+ text_layer_set_font(s_main_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
|
| 148 |
+ text_layer_set_text_alignment(s_main_text_layer, GTextAlignmentCenter); |
|
| 149 |
+ layer_add_child(window_layer, text_layer_get_layer(s_main_text_layer)); |
|
| 150 |
+ |
|
| 151 |
+ // settings of lowerleft layer |
|
| 152 |
+ text_layer_set_background_color(s_lowerleft_text_layer, GColorWhite); |
|
| 153 |
+ text_layer_set_text_color(s_lowerleft_text_layer, GColorBlack); |
|
| 154 |
+ text_layer_set_font(s_lowerleft_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 155 |
+ text_layer_set_text_alignment(s_lowerleft_text_layer, GTextAlignmentCenter); |
|
| 156 |
+ layer_add_child(window_layer, text_layer_get_layer(s_lowerleft_text_layer)); |
|
| 157 |
+ |
|
| 158 |
+ // settings of lowerright layer |
|
| 159 |
+ text_layer_set_background_color(s_lowerright_text_layer, GColorWhite); |
|
| 160 |
+ text_layer_set_text_color(s_lowerright_text_layer, GColorBlack); |
|
| 161 |
+ text_layer_set_font(s_lowerright_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 162 |
+ text_layer_set_text_alignment(s_lowerright_text_layer, GTextAlignmentCenter); |
|
| 163 |
+ layer_add_child(window_layer, text_layer_get_layer(s_lowerright_text_layer)); |
|
| 164 |
+ |
|
| 165 |
+ // settings of lower layer |
|
| 166 |
+ text_layer_set_background_color(s_lower_text_layer, GColorBlack); |
|
| 167 |
+ text_layer_set_text_color(s_lower_text_layer, GColorWhite); |
|
| 168 |
+ text_layer_set_font(s_lower_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 169 |
+ text_layer_set_text_alignment(s_lower_text_layer, GTextAlignmentCenter); |
|
| 170 |
+ layer_add_child(window_layer, text_layer_get_layer(s_lower_text_layer)); |
|
| 109 | 171 |
|
| 110 |
- text_layer_set_background_color(s_other_text_layer, GColorClear); |
|
| 111 |
- text_layer_set_text_color(s_other_text_layer, GColorBlack); |
|
| 112 |
- text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 113 |
- text_layer_set_text_alignment(s_other_text_layer, GTextAlignmentCenter); |
|
| 114 |
- layer_add_child(window_layer, text_layer_get_layer(s_other_text_layer)); |
|
| 115 | 172 |
} |
| 116 | 173 |
|
| 117 | 174 |
static void prv_window_unload(Window *window) {
|
| 118 |
- text_layer_destroy(s_speed_text_layer); |
|
| 175 |
+ text_layer_destroy(s_main_text_layer); |
|
| 119 | 176 |
} |
| 120 | 177 |
|
| 121 | 178 |
void comm_is_ready() {
|
| 122 | 179 |
|
| 123 | 180 |
// set the text |
| 124 |
- text_layer_set_text(s_speed_text_layer, "Press Select"); |
|
| 125 |
- text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JS is ready"); |
|
| 181 |
+ //text_layer_set_text(s_status_text_layer, "0......................................"); |
|
| 182 |
+ text_layer_set_text(s_upperleft_text_layer, "-"); |
|
| 183 |
+ text_layer_set_text(s_upperleft_text_layer, "-"); |
|
| 184 |
+ text_layer_set_text(s_main_text_layer, "Ready"); |
|
| 185 |
+ text_layer_set_text(s_lowerleft_text_layer, "-"); |
|
| 186 |
+ text_layer_set_text(s_lowerright_text_layer, "-"); |
|
| 187 |
+ text_layer_set_text(s_lower_text_layer, "--:--:--"); |
|
| 126 | 188 |
|
| 127 | 189 |
} |
| 128 | 190 |
|
| ... | ... |
@@ -170,6 +232,16 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 170 | 232 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not longitude message... "); |
| 171 | 233 |
} |
| 172 | 234 |
|
| 235 |
+ // Read distance returns |
|
| 236 |
+ Tuple *distance_tuple = dict_find(iter, MESSAGE_KEY_distance); |
|
| 237 |
+ |
|
| 238 |
+ if(distance_tuple) {
|
|
| 239 |
+ memset(s_distance,'\0',sizeof(s_distance)); |
|
| 240 |
+ strncpy(s_distance, distance_tuple->value->cstring, 6); |
|
| 241 |
+ }else{
|
|
| 242 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not distance message... "); |
|
| 243 |
+ } |
|
| 244 |
+ |
|
| 173 | 245 |
// Read accuracy returns |
| 174 | 246 |
Tuple *accuracy_tuple = dict_find(iter, MESSAGE_KEY_accuracy); |
| 175 | 247 |
|
| ... | ... |
@@ -226,6 +298,16 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 226 | 298 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not timestamp message... "); |
| 227 | 299 |
} |
| 228 | 300 |
|
| 301 |
+ // Read duration returns |
|
| 302 |
+ Tuple *duration_tuple = dict_find(iter, MESSAGE_KEY_duration); |
|
| 303 |
+ |
|
| 304 |
+ if(duration_tuple) {
|
|
| 305 |
+ memset(s_duration,'\0',sizeof(s_duration)); |
|
| 306 |
+ strncpy(s_duration, duration_tuple->value->cstring, 9); |
|
| 307 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "duration message received : %s",s_duration); |
|
| 308 |
+ }else{
|
|
| 309 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not duration message... "); |
|
| 310 |
+ } |
|
| 229 | 311 |
|
| 230 | 312 |
// Read speed returns |
| 231 | 313 |
Tuple *speed_tuple = dict_find(iter, MESSAGE_KEY_speed); |
| ... | ... |
@@ -255,6 +337,15 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 255 | 337 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not max_speed message... "); |
| 256 | 338 |
} |
| 257 | 339 |
|
| 340 |
+ // Read avg_speed returns |
|
| 341 |
+ Tuple *avg_speed_tuple = dict_find(iter, MESSAGE_KEY_avg_speed); |
|
| 342 |
+ |
|
| 343 |
+ if(avg_speed_tuple) {
|
|
| 344 |
+ memset(s_avg_speed,'\0',sizeof(s_avg_speed)); |
|
| 345 |
+ strncpy(s_avg_speed, avg_speed_tuple->value->cstring, 4); |
|
| 346 |
+ }else{
|
|
| 347 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not avg_speed message... "); |
|
| 348 |
+ } |
|
| 258 | 349 |
|
| 259 | 350 |
// Read status returns |
| 260 | 351 |
Tuple *status_tuple = dict_find(iter, MESSAGE_KEY_status); |
| ... | ... |
@@ -266,25 +357,29 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 266 | 357 |
|
| 267 | 358 |
// DEBUG concatenate all data received |
| 268 | 359 |
/* |
| 269 |
- memset(s_msg,'\0',sizeof(s_msg)); |
|
| 270 |
- strncpy(s_msg, "Acc. ",5); |
|
| 271 |
- strcat(s_msg, s_accuracy); |
|
| 272 |
- strcat(s_msg, " Alt. "); |
|
| 273 |
- strcat(s_msg, s_altitude); |
|
| 274 |
- strcat(s_msg, "\n Max. "); |
|
| 275 |
- strcat(s_msg, s_max_speed); |
|
| 276 |
- strcat(s_msg, "\n Lat. "); |
|
| 277 |
- strcat(s_msg, s_latitude); |
|
| 278 |
- strcat(s_msg, "\n Long. "); |
|
| 279 |
- strcat(s_msg, s_longitude); |
|
| 280 |
- strcat(s_msg, "\n Time. "); |
|
| 281 |
- strcat(s_msg, s_timestamp); |
|
| 360 |
+ memset(s_msg,'\0',sizeof(s_msg)); |
|
| 361 |
+ strncpy(s_msg, "Acc. ",5); |
|
| 362 |
+ strcat(s_msg, s_accuracy); |
|
| 363 |
+ strcat(s_msg, " Alt. "); |
|
| 364 |
+ strcat(s_msg, s_altitude); |
|
| 365 |
+ strcat(s_msg, "\n Max. "); |
|
| 366 |
+ strcat(s_msg, s_max_speed); |
|
| 367 |
+ strcat(s_msg, "\n Lat. "); |
|
| 368 |
+ strcat(s_msg, s_latitude); |
|
| 369 |
+ strcat(s_msg, "\n Long. "); |
|
| 370 |
+ strcat(s_msg, s_longitude); |
|
| 371 |
+ strcat(s_msg, "\n Time. "); |
|
| 372 |
+ strcat(s_msg, s_timestamp); |
|
| 282 | 373 |
*/ |
| 283 | 374 |
|
| 284 | 375 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
| 285 | 376 |
|
| 286 |
- text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 287 |
- text_layer_set_text(s_other_text_layer, s_msg); |
|
| 377 |
+ text_layer_set_text(s_upperleft_text_layer, s_altitude); |
|
| 378 |
+ text_layer_set_text(s_upperright_text_layer, s_distance); |
|
| 379 |
+ text_layer_set_text(s_main_text_layer, s_speed); |
|
| 380 |
+ text_layer_set_text(s_lowerleft_text_layer, s_avg_speed); |
|
| 381 |
+ text_layer_set_text(s_lowerright_text_layer, s_max_speed); |
|
| 382 |
+ text_layer_set_text(s_lower_text_layer, s_duration); |
|
| 288 | 383 |
}else{
|
| 289 | 384 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| 290 | 385 |
} |
| ... | ... |
@@ -71,16 +71,17 @@ static void prv_select_click_handler(ClickRecognizerRef recognizer, void *contex |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 | 73 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 74 |
- //text_layer_set_text(s_other_text_layer, "Up"); |
|
| 74 |
+ text_layer_set_text(s_other_text_layer, "Tracking stopped, sending..."); |
|
| 75 |
+ send_message("exit");
|
|
| 75 | 76 |
} |
| 76 | 77 |
|
| 77 | 78 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 78 |
- //text_layer_set_text(s_other_text_layer, "Down"); |
|
| 79 |
+ text_layer_set_text(s_other_text_layer, "Tracking stopped, sending..."); |
|
| 79 | 80 |
send_message("exit");
|
| 80 | 81 |
} |
| 81 | 82 |
|
| 82 | 83 |
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 83 |
- //text_layer_set_text(s_other_text_layer, "Down"); |
|
| 84 |
+ //text_layer_set_text(s_other_text_layer, "back"); |
|
| 84 | 85 |
//send_message("exit");
|
| 85 | 86 |
} |
| 86 | 87 |
|
| ... | ... |
@@ -120,14 +121,14 @@ static void prv_window_unload(Window *window) {
|
| 120 | 121 |
void comm_is_ready() {
|
| 121 | 122 |
|
| 122 | 123 |
// set the text |
| 123 |
- text_layer_set_text(s_speed_text_layer, "Press a button to start"); |
|
| 124 |
- text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JSready"); |
|
| 124 |
+ text_layer_set_text(s_speed_text_layer, "Press Select"); |
|
| 125 |
+ text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JS is ready"); |
|
| 125 | 126 |
|
| 126 | 127 |
} |
| 127 | 128 |
|
| 128 | 129 |
static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 129 | 130 |
// A new message has been successfully received |
| 130 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "New message! "); |
|
| 131 |
+ APP_LOG(APP_LOG_LEVEL_INFO, "New message! "); |
|
| 131 | 132 |
|
| 132 | 133 |
size = dict_size(iter); |
| 133 | 134 |
|
| ... | ... |
@@ -138,7 +139,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 138 | 139 |
//Pebblekit JS is ready ! Safe to send messages |
| 139 | 140 |
s_js_ready = true; |
| 140 | 141 |
comm_is_ready(); |
| 141 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "received jsready message on watch... "); |
|
| 142 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "received jsready message on watch... "); |
|
| 142 | 143 |
} |
| 143 | 144 |
|
| 144 | 145 |
// Read latitude returns |
| ... | ... |
@@ -150,7 +151,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 150 | 151 |
|
| 151 | 152 |
// Display in the TextLayer |
| 152 | 153 |
//text_layer_set_text(s_speed_text_layer, lf_latitude); |
| 153 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "latitude message received : %s",s_latitude); |
|
| 154 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "latitude message received : %s",s_latitude); |
|
| 154 | 155 |
}else{
|
| 155 | 156 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not latitude message... "); |
| 156 | 157 |
} |
| ... | ... |
@@ -164,7 +165,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 164 | 165 |
|
| 165 | 166 |
// Display in the TextLayer |
| 166 | 167 |
//text_layer_set_text(s_speed_text_layer, lf_longitude); |
| 167 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "longitude message received : %s",s_longitude); |
|
| 168 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "longitude message received : %s",s_longitude); |
|
| 168 | 169 |
}else{
|
| 169 | 170 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not longitude message... "); |
| 170 | 171 |
} |
| ... | ... |
@@ -178,7 +179,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 178 | 179 |
|
| 179 | 180 |
// Display in the TextLayer |
| 180 | 181 |
//text_layer_set_text(s_speed_text_layer, lf_accuracy); |
| 181 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "accuracy message received : %s",s_accuracy); |
|
| 182 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "accuracy message received : %s",s_accuracy); |
|
| 182 | 183 |
}else{
|
| 183 | 184 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not accuracy message... "); |
| 184 | 185 |
} |
| ... | ... |
@@ -192,7 +193,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 192 | 193 |
|
| 193 | 194 |
// Display in the TextLayer |
| 194 | 195 |
//text_layer_set_text(s_speed_text_layer, lf_altitude); |
| 195 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",altitude_tuple->value->cstring); |
|
| 196 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",altitude_tuple->value->cstring); |
|
| 196 | 197 |
}else{
|
| 197 | 198 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude message... "); |
| 198 | 199 |
} |
| ... | ... |
@@ -206,7 +207,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 206 | 207 |
|
| 207 | 208 |
// Display in the TextLayer |
| 208 | 209 |
//text_layer_set_text(s_speed_text_layer, lf_altitude_accuracy); |
| 209 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude_accuracy message received : %s",s_altitude_accuracy); |
|
| 210 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude_accuracy message received : %s",s_altitude_accuracy); |
|
| 210 | 211 |
}else{
|
| 211 | 212 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude_accuracy message... "); |
| 212 | 213 |
} |
| ... | ... |
@@ -220,7 +221,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 220 | 221 |
|
| 221 | 222 |
// Display in the TextLayer |
| 222 | 223 |
//text_layer_set_text(s_speed_text_layer, lf_timestamp); |
| 223 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "timestamp message received : %s",s_timestamp); |
|
| 224 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "timestamp message received : %s",s_timestamp); |
|
| 224 | 225 |
}else{
|
| 225 | 226 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not timestamp message... "); |
| 226 | 227 |
} |
| ... | ... |
@@ -235,7 +236,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 235 | 236 |
//uint i_speed=atoi(s_speed); |
| 236 | 237 |
// Display in the TextLayer |
| 237 | 238 |
//text_layer_set_text(s_speed_text_layer, lf_speed); |
| 238 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s ",s_speed); |
|
| 239 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s ",s_speed); |
|
| 239 | 240 |
}else{
|
| 240 | 241 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not speed message... "); |
| 241 | 242 |
} |
| ... | ... |
@@ -249,7 +250,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 249 | 250 |
//uint i_max_speed=atoi(s_max_speed); |
| 250 | 251 |
// Display in the TextLayer |
| 251 | 252 |
//text_layer_set_text(s_max_speed_text_layer, lf_max_speed); |
| 252 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "max_speed message received : %s ",s_max_speed); |
|
| 253 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "max_speed message received : %s ",s_max_speed); |
|
| 253 | 254 |
}else{
|
| 254 | 255 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not max_speed message... "); |
| 255 | 256 |
} |
| ... | ... |
@@ -261,31 +262,29 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 261 | 262 |
if(status_tuple) {
|
| 262 | 263 |
memset(s_status,'\0',sizeof(s_status)); |
| 263 | 264 |
strncpy(s_status, status_tuple->value->cstring, 4); |
| 264 |
- /*if (strcmp(s_status,"KO")== 0){
|
|
| 265 |
- //find a way to exit |
|
| 266 |
- }else{*/
|
|
| 267 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
|
| 268 |
- |
|
| 269 |
- // DEBUG concatenate all data received |
|
| 270 |
- memset(s_msg,'\0',sizeof(s_msg)); |
|
| 271 |
- strncpy(s_msg, "Acc. ",5); |
|
| 272 |
- strcat(s_msg, s_accuracy); |
|
| 273 |
- strcat(s_msg, " Alt. "); |
|
| 274 |
- strcat(s_msg, s_altitude); |
|
| 275 |
- strcat(s_msg, "\n Max. "); |
|
| 276 |
- strcat(s_msg, s_max_speed); |
|
| 277 |
- //strcat(s_msg, "\n Lat. "); |
|
| 278 |
- //strcat(s_msg, s_latitude); |
|
| 279 |
- //strcat(s_msg, "\n Long. "); |
|
| 280 |
- //strcat(s_msg, s_longitude); |
|
| 281 |
- //strcat(s_msg, "\n Time. "); |
|
| 282 |
- //strcat(s_msg, s_timestamp); |
|
| 283 |
- |
|
| 284 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
|
| 285 |
- |
|
| 286 |
- text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 287 |
- text_layer_set_text(s_other_text_layer, s_msg); |
|
| 288 |
- // } |
|
| 265 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
|
| 266 |
+ |
|
| 267 |
+ // DEBUG concatenate all data received |
|
| 268 |
+ /* |
|
| 269 |
+ memset(s_msg,'\0',sizeof(s_msg)); |
|
| 270 |
+ strncpy(s_msg, "Acc. ",5); |
|
| 271 |
+ strcat(s_msg, s_accuracy); |
|
| 272 |
+ strcat(s_msg, " Alt. "); |
|
| 273 |
+ strcat(s_msg, s_altitude); |
|
| 274 |
+ strcat(s_msg, "\n Max. "); |
|
| 275 |
+ strcat(s_msg, s_max_speed); |
|
| 276 |
+ strcat(s_msg, "\n Lat. "); |
|
| 277 |
+ strcat(s_msg, s_latitude); |
|
| 278 |
+ strcat(s_msg, "\n Long. "); |
|
| 279 |
+ strcat(s_msg, s_longitude); |
|
| 280 |
+ strcat(s_msg, "\n Time. "); |
|
| 281 |
+ strcat(s_msg, s_timestamp); |
|
| 282 |
+ */ |
|
| 283 |
+ |
|
| 284 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
|
| 285 |
+ |
|
| 286 |
+ text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 287 |
+ text_layer_set_text(s_other_text_layer, s_msg); |
|
| 289 | 288 |
}else{
|
| 290 | 289 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| 291 | 290 |
} |
| ... | ... |
@@ -340,7 +339,7 @@ static void prv_deinit(void) {
|
| 340 | 339 |
int main(void) {
|
| 341 | 340 |
prv_init(); |
| 342 | 341 |
|
| 343 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", s_window); |
|
| 342 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", s_window); |
|
| 344 | 343 |
|
| 345 | 344 |
app_event_loop(); |
| 346 | 345 |
prv_deinit(); |
| ... | ... |
@@ -11,7 +11,7 @@ const uint32_t outbox_size = 64; |
| 11 | 11 |
static uint32_t size ; |
| 12 | 12 |
//static char * msg; |
| 13 | 13 |
|
| 14 |
-static char s_status[3]; |
|
| 14 |
+static char s_status[4]; |
|
| 15 | 15 |
|
| 16 | 16 |
//restricting long and lat to 13 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal, 1 for \0 |
| 17 | 17 |
static char s_longitude[13]; |
| ... | ... |
@@ -76,7 +76,7 @@ static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 76 | 76 |
|
| 77 | 77 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 78 | 78 |
//text_layer_set_text(s_other_text_layer, "Down"); |
| 79 |
- //send_message("exit");
|
|
| 79 |
+ send_message("exit");
|
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 | 82 |
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| ... | ... |
@@ -260,7 +260,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 260 | 260 |
|
| 261 | 261 |
if(status_tuple) {
|
| 262 | 262 |
memset(s_status,'\0',sizeof(s_status)); |
| 263 |
- strncpy(s_status, status_tuple->value->cstring, 2); |
|
| 263 |
+ strncpy(s_status, status_tuple->value->cstring, 4); |
|
| 264 | 264 |
/*if (strcmp(s_status,"KO")== 0){
|
| 265 | 265 |
//find a way to exit |
| 266 | 266 |
}else{*/
|
| ... | ... |
@@ -333,7 +333,7 @@ static void prv_init(void) {
|
| 333 | 333 |
} |
| 334 | 334 |
|
| 335 | 335 |
static void prv_deinit(void) {
|
| 336 |
- send_message("exit");
|
|
| 336 |
+ //send_message("exit");
|
|
| 337 | 337 |
window_destroy(s_window); |
| 338 | 338 |
} |
| 339 | 339 |
|
| ... | ... |
@@ -76,7 +76,7 @@ static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 76 | 76 |
|
| 77 | 77 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 78 | 78 |
//text_layer_set_text(s_other_text_layer, "Down"); |
| 79 |
- send_message("exit");
|
|
| 79 |
+ //send_message("exit");
|
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 | 82 |
static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| ... | ... |
@@ -88,7 +88,7 @@ static void prv_click_config_provider(void *context) {
|
| 88 | 88 |
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler); |
| 89 | 89 |
window_single_click_subscribe(BUTTON_ID_UP, prv_up_click_handler); |
| 90 | 90 |
window_single_click_subscribe(BUTTON_ID_DOWN, prv_down_click_handler); |
| 91 |
- window_single_click_subscribe(BUTTON_ID_BACK, prv_back_click_handler); |
|
| 91 |
+ //window_single_click_subscribe(BUTTON_ID_BACK, prv_back_click_handler); |
|
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 | 94 |
static void prv_window_load(Window *window) {
|
| ... | ... |
@@ -333,6 +333,7 @@ static void prv_init(void) {
|
| 333 | 333 |
} |
| 334 | 334 |
|
| 335 | 335 |
static void prv_deinit(void) {
|
| 336 |
+ send_message("exit");
|
|
| 336 | 337 |
window_destroy(s_window); |
| 337 | 338 |
} |
| 338 | 339 |
|
| ... | ... |
@@ -76,12 +76,19 @@ static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 76 | 76 |
|
| 77 | 77 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 78 | 78 |
//text_layer_set_text(s_other_text_layer, "Down"); |
| 79 |
+ send_message("exit");
|
|
| 80 |
+} |
|
| 81 |
+ |
|
| 82 |
+static void prv_back_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 83 |
+ //text_layer_set_text(s_other_text_layer, "Down"); |
|
| 84 |
+ //send_message("exit");
|
|
| 79 | 85 |
} |
| 80 | 86 |
|
| 81 | 87 |
static void prv_click_config_provider(void *context) {
|
| 82 | 88 |
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler); |
| 83 | 89 |
window_single_click_subscribe(BUTTON_ID_UP, prv_up_click_handler); |
| 84 | 90 |
window_single_click_subscribe(BUTTON_ID_DOWN, prv_down_click_handler); |
| 91 |
+ window_single_click_subscribe(BUTTON_ID_BACK, prv_back_click_handler); |
|
| 85 | 92 |
} |
| 86 | 93 |
|
| 87 | 94 |
static void prv_window_load(Window *window) {
|
| ... | ... |
@@ -254,27 +261,31 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 254 | 261 |
if(status_tuple) {
|
| 255 | 262 |
memset(s_status,'\0',sizeof(s_status)); |
| 256 | 263 |
strncpy(s_status, status_tuple->value->cstring, 2); |
| 257 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
|
| 258 |
- |
|
| 259 |
- // DEBUG concatenate all data received |
|
| 260 |
- memset(s_msg,'\0',sizeof(s_msg)); |
|
| 261 |
- strncpy(s_msg, "Acc. ",5); |
|
| 262 |
- strcat(s_msg, s_accuracy); |
|
| 263 |
- strcat(s_msg, " Alt. "); |
|
| 264 |
- strcat(s_msg, s_altitude); |
|
| 265 |
- strcat(s_msg, "\n Max. "); |
|
| 266 |
- strcat(s_msg, s_max_speed); |
|
| 267 |
- //strcat(s_msg, "\n Lat. "); |
|
| 268 |
- //strcat(s_msg, s_latitude); |
|
| 269 |
- //strcat(s_msg, "\n Long. "); |
|
| 270 |
- //strcat(s_msg, s_longitude); |
|
| 271 |
- //strcat(s_msg, "\n Time. "); |
|
| 272 |
- //strcat(s_msg, s_timestamp); |
|
| 273 |
- |
|
| 274 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
|
| 275 |
- |
|
| 276 |
- text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 277 |
- text_layer_set_text(s_other_text_layer, s_msg); |
|
| 264 |
+ /*if (strcmp(s_status,"KO")== 0){
|
|
| 265 |
+ //find a way to exit |
|
| 266 |
+ }else{*/
|
|
| 267 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
|
| 268 |
+ |
|
| 269 |
+ // DEBUG concatenate all data received |
|
| 270 |
+ memset(s_msg,'\0',sizeof(s_msg)); |
|
| 271 |
+ strncpy(s_msg, "Acc. ",5); |
|
| 272 |
+ strcat(s_msg, s_accuracy); |
|
| 273 |
+ strcat(s_msg, " Alt. "); |
|
| 274 |
+ strcat(s_msg, s_altitude); |
|
| 275 |
+ strcat(s_msg, "\n Max. "); |
|
| 276 |
+ strcat(s_msg, s_max_speed); |
|
| 277 |
+ //strcat(s_msg, "\n Lat. "); |
|
| 278 |
+ //strcat(s_msg, s_latitude); |
|
| 279 |
+ //strcat(s_msg, "\n Long. "); |
|
| 280 |
+ //strcat(s_msg, s_longitude); |
|
| 281 |
+ //strcat(s_msg, "\n Time. "); |
|
| 282 |
+ //strcat(s_msg, s_timestamp); |
|
| 283 |
+ |
|
| 284 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
|
| 285 |
+ |
|
| 286 |
+ text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 287 |
+ text_layer_set_text(s_other_text_layer, s_msg); |
|
| 288 |
+ // } |
|
| 278 | 289 |
}else{
|
| 279 | 290 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| 280 | 291 |
} |
| ... | ... |
@@ -322,7 +333,6 @@ static void prv_init(void) {
|
| 322 | 333 |
} |
| 323 | 334 |
|
| 324 | 335 |
static void prv_deinit(void) {
|
| 325 |
- send_message("exit");
|
|
| 326 | 336 |
window_destroy(s_window); |
| 327 | 337 |
} |
| 328 | 338 |
|
| ... | ... |
@@ -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); |
| ... | ... |
@@ -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); |
| ... | ... |
@@ -65,16 +65,17 @@ 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_other_text_layer, "Select - sending get geoloc"); |
|
| 68 |
+ text_layer_set_text(s_speed_text_layer, ""); |
|
| 69 |
+ text_layer_set_text(s_other_text_layer, "sending get geoloc"); |
|
| 69 | 70 |
send_message("get");
|
| 70 | 71 |
} |
| 71 | 72 |
|
| 72 | 73 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 73 |
- text_layer_set_text(s_other_text_layer, "Up"); |
|
| 74 |
+ //text_layer_set_text(s_other_text_layer, "Up"); |
|
| 74 | 75 |
} |
| 75 | 76 |
|
| 76 | 77 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 77 |
- text_layer_set_text(s_other_text_layer, "Down"); |
|
| 78 |
+ //text_layer_set_text(s_other_text_layer, "Down"); |
|
| 78 | 79 |
} |
| 79 | 80 |
|
| 80 | 81 |
static void prv_click_config_provider(void *context) {
|
| ... | ... |
@@ -93,7 +94,6 @@ static void prv_window_load(Window *window) {
|
| 93 | 94 |
text_layer_set_text_color(s_speed_text_layer, GColorWhite); |
| 94 | 95 |
text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
| 95 | 96 |
text_layer_set_text_alignment(s_speed_text_layer, GTextAlignmentCenter); |
| 96 |
- text_layer_set_text(s_speed_text_layer, "Press a button"); |
|
| 97 | 97 |
layer_add_child(window_layer, text_layer_get_layer(s_speed_text_layer)); |
| 98 | 98 |
|
| 99 | 99 |
|
| ... | ... |
@@ -101,9 +101,8 @@ 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_14)); |
|
| 104 |
+ text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); |
|
| 105 | 105 |
text_layer_set_text_alignment(s_other_text_layer, GTextAlignmentCenter); |
| 106 |
- text_layer_set_text(s_other_text_layer, "Press a button"); |
|
| 107 | 106 |
layer_add_child(window_layer, text_layer_get_layer(s_other_text_layer)); |
| 108 | 107 |
} |
| 109 | 108 |
|
| ... | ... |
@@ -114,6 +113,7 @@ static void prv_window_unload(Window *window) {
|
| 114 | 113 |
void comm_is_ready() {
|
| 115 | 114 |
|
| 116 | 115 |
// set the text |
| 116 |
+ text_layer_set_text(s_speed_text_layer, "Press a button to start"); |
|
| 117 | 117 |
text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JSready"); |
| 118 | 118 |
|
| 119 | 119 |
} |
| ... | ... |
@@ -273,7 +273,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 273 | 273 |
|
| 274 | 274 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
| 275 | 275 |
|
| 276 |
- text_layer_set_text(s_speed_text_layer, strcat(s_speed," km/h")); |
|
| 276 |
+ text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 277 | 277 |
text_layer_set_text(s_other_text_layer, s_msg); |
| 278 | 278 |
}else{
|
| 279 | 279 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| ... | ... |
@@ -9,7 +9,7 @@ const uint32_t inbox_size = 64; |
| 9 | 9 |
const uint32_t outbox_size = 64; |
| 10 | 10 |
|
| 11 | 11 |
static uint32_t size ; |
| 12 |
-static char * msg; |
|
| 12 |
+//static char * msg; |
|
| 13 | 13 |
|
| 14 | 14 |
static char s_status[3]; |
| 15 | 15 |
|
| ... | ... |
@@ -22,6 +22,7 @@ static char s_altitude[6]; |
| 22 | 22 |
static char s_altitude_accuracy[4]; |
| 23 | 23 |
static char s_timestamp[14]; |
| 24 | 24 |
static char s_speed[6]; |
| 25 |
+static char s_max_speed[5]; |
|
| 25 | 26 |
|
| 26 | 27 |
static char s_msg[50]; |
| 27 | 28 |
|
| ... | ... |
@@ -35,13 +36,12 @@ typedef enum {
|
| 35 | 36 |
accuracy, |
| 36 | 37 |
altitude_accuracy, |
| 37 | 38 |
speed, |
| 39 |
+ max_speed, |
|
| 38 | 40 |
timestamp |
| 39 | 41 |
} AppKey; |
| 40 | 42 |
|
| 41 | 43 |
|
| 42 |
- |
|
| 43 |
-static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 44 |
- text_layer_set_text(s_other_text_layer, "Select - sending get geoloc"); |
|
| 44 |
+static void send_message(char * msg){
|
|
| 45 | 45 |
|
| 46 | 46 |
// Declare the dictionary's iterator |
| 47 | 47 |
DictionaryIterator *out_iter; |
| ... | ... |
@@ -50,8 +50,6 @@ static void prv_select_click_handler(ClickRecognizerRef recognizer, void *contex |
| 50 | 50 |
AppMessageResult result = app_message_outbox_begin(&out_iter); |
| 51 | 51 |
|
| 52 | 52 |
if(result == APP_MSG_OK) {
|
| 53 |
- // Add an item to ask for geoloc |
|
| 54 |
- msg = "get"; |
|
| 55 | 53 |
dict_write_cstring(out_iter, status, msg); |
| 56 | 54 |
|
| 57 | 55 |
// Send this message |
| ... | ... |
@@ -63,8 +61,12 @@ static void prv_select_click_handler(ClickRecognizerRef recognizer, void *contex |
| 63 | 61 |
// The outbox cannot be used right now |
| 64 | 62 |
APP_LOG(APP_LOG_LEVEL_ERROR, "Error preparing the outbox: %d", (int)result); |
| 65 | 63 |
} |
| 66 |
- // Button click provider |
|
| 67 |
- // window_set_click_config_provider(s_window, click_config_provider); |
|
| 64 |
+} |
|
| 65 |
+ |
|
| 66 |
+ |
|
| 67 |
+static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 68 |
+ text_layer_set_text(s_other_text_layer, "Select - sending get geoloc"); |
|
| 69 |
+ send_message("get");
|
|
| 68 | 70 |
} |
| 69 | 71 |
|
| 70 | 72 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| ... | ... |
@@ -223,14 +225,28 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 223 | 225 |
if(speed_tuple) {
|
| 224 | 226 |
memset(s_speed,'\0',sizeof(s_speed)); |
| 225 | 227 |
strncpy(s_speed, speed_tuple->value->cstring, 5); |
| 226 |
- |
|
| 228 |
+ //uint i_speed=atoi(s_speed); |
|
| 227 | 229 |
// Display in the TextLayer |
| 228 | 230 |
//text_layer_set_text(s_speed_text_layer, lf_speed); |
| 229 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s",s_speed); |
|
| 231 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s ",s_speed); |
|
| 230 | 232 |
}else{
|
| 231 | 233 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not speed message... "); |
| 232 | 234 |
} |
| 233 | 235 |
|
| 236 |
+ // Read max_speed returns |
|
| 237 |
+ Tuple *max_speed_tuple = dict_find(iter, MESSAGE_KEY_max_speed); |
|
| 238 |
+ |
|
| 239 |
+ if(max_speed_tuple) {
|
|
| 240 |
+ memset(s_max_speed,'\0',sizeof(s_max_speed)); |
|
| 241 |
+ strncpy(s_max_speed, max_speed_tuple->value->cstring, 5); |
|
| 242 |
+ //uint i_max_speed=atoi(s_max_speed); |
|
| 243 |
+ // Display in the TextLayer |
|
| 244 |
+ //text_layer_set_text(s_max_speed_text_layer, lf_max_speed); |
|
| 245 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "max_speed message received : %s ",s_max_speed); |
|
| 246 |
+ }else{
|
|
| 247 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not max_speed message... "); |
|
| 248 |
+ } |
|
| 249 |
+ |
|
| 234 | 250 |
|
| 235 | 251 |
// Read status returns |
| 236 | 252 |
Tuple *status_tuple = dict_find(iter, MESSAGE_KEY_status); |
| ... | ... |
@@ -242,23 +258,22 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 242 | 258 |
|
| 243 | 259 |
// DEBUG concatenate all data received |
| 244 | 260 |
memset(s_msg,'\0',sizeof(s_msg)); |
| 245 |
- strncpy(s_msg, s_status, 2); |
|
| 246 |
- //strcat(s_msg, "Lat. "); |
|
| 261 |
+ strncpy(s_msg, "Acc. ",5); |
|
| 262 |
+ strcat(s_msg, s_accuracy); |
|
| 263 |
+ strcat(s_msg, " Alt. "); |
|
| 264 |
+ strcat(s_msg, s_altitude); |
|
| 265 |
+ strcat(s_msg, "\n Max. "); |
|
| 266 |
+ strcat(s_msg, s_max_speed); |
|
| 267 |
+ //strcat(s_msg, "\n Lat. "); |
|
| 247 | 268 |
//strcat(s_msg, s_latitude); |
| 248 | 269 |
//strcat(s_msg, "\n Long. "); |
| 249 | 270 |
//strcat(s_msg, s_longitude); |
| 250 |
- strcat(s_msg, "\n Acc. "); |
|
| 251 |
- strcat(s_msg, s_accuracy); |
|
| 252 |
- strcat(s_msg, "\n Alt. "); |
|
| 253 |
- strcat(s_msg, s_altitude); |
|
| 254 |
- //strcat(s_msg, "\n Speed. "); |
|
| 255 |
- //strcat(s_msg, s_speed); |
|
| 256 | 271 |
//strcat(s_msg, "\n Time. "); |
| 257 | 272 |
//strcat(s_msg, s_timestamp); |
| 258 | 273 |
|
| 259 | 274 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
| 260 |
- // DEBUG Display in the TextLayer |
|
| 261 |
- text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 275 |
+ |
|
| 276 |
+ text_layer_set_text(s_speed_text_layer, strcat(s_speed," km/h")); |
|
| 262 | 277 |
text_layer_set_text(s_other_text_layer, s_msg); |
| 263 | 278 |
}else{
|
| 264 | 279 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| ... | ... |
@@ -307,6 +322,7 @@ static void prv_init(void) {
|
| 307 | 322 |
} |
| 308 | 323 |
|
| 309 | 324 |
static void prv_deinit(void) {
|
| 325 |
+ send_message("exit");
|
|
| 310 | 326 |
window_destroy(s_window); |
| 311 | 327 |
} |
| 312 | 328 |
|
| ... | ... |
@@ -41,7 +41,30 @@ typedef enum {
|
| 41 | 41 |
|
| 42 | 42 |
|
| 43 | 43 |
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 44 |
- text_layer_set_text(s_other_text_layer, "Select"); |
|
| 44 |
+ text_layer_set_text(s_other_text_layer, "Select - sending get geoloc"); |
|
| 45 |
+ |
|
| 46 |
+ // Declare the dictionary's iterator |
|
| 47 |
+ DictionaryIterator *out_iter; |
|
| 48 |
+ |
|
| 49 |
+ // Prepare the outbox buffer for this message |
|
| 50 |
+ AppMessageResult result = app_message_outbox_begin(&out_iter); |
|
| 51 |
+ |
|
| 52 |
+ if(result == APP_MSG_OK) {
|
|
| 53 |
+ // Add an item to ask for geoloc |
|
| 54 |
+ msg = "get"; |
|
| 55 |
+ dict_write_cstring(out_iter, status, msg); |
|
| 56 |
+ |
|
| 57 |
+ // Send this message |
|
| 58 |
+ result = app_message_outbox_send(); |
|
| 59 |
+ if(result != APP_MSG_OK) {
|
|
| 60 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Error sending the outbox: %d", (int)result); |
|
| 61 |
+ } |
|
| 62 |
+ } else {
|
|
| 63 |
+ // The outbox cannot be used right now |
|
| 64 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Error preparing the outbox: %d", (int)result); |
|
| 65 |
+ } |
|
| 66 |
+ // Button click provider |
|
| 67 |
+ // window_set_click_config_provider(s_window, click_config_provider); |
|
| 45 | 68 |
} |
| 46 | 69 |
|
| 47 | 70 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| ... | ... |
@@ -63,7 +86,7 @@ static void prv_window_load(Window *window) {
|
| 63 | 86 |
GRect bounds = layer_get_bounds(window_layer); |
| 64 | 87 |
|
| 65 | 88 |
s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h/2)); |
| 66 |
- |
|
| 89 |
+ |
|
| 67 | 90 |
text_layer_set_background_color(s_speed_text_layer, GColorBlack); |
| 68 | 91 |
text_layer_set_text_color(s_speed_text_layer, GColorWhite); |
| 69 | 92 |
text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
| ... | ... |
@@ -71,9 +94,9 @@ static void prv_window_load(Window *window) {
|
| 71 | 94 |
text_layer_set_text(s_speed_text_layer, "Press a button"); |
| 72 | 95 |
layer_add_child(window_layer, text_layer_get_layer(s_speed_text_layer)); |
| 73 | 96 |
|
| 74 |
- |
|
| 97 |
+ |
|
| 75 | 98 |
s_other_text_layer = text_layer_create(GRect(0, bounds.size.h/2,bounds.size.w, bounds.size.h/2)); |
| 76 |
- |
|
| 99 |
+ |
|
| 77 | 100 |
text_layer_set_background_color(s_other_text_layer, GColorClear); |
| 78 | 101 |
text_layer_set_text_color(s_other_text_layer, GColorBlack); |
| 79 | 102 |
text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); |
| ... | ... |
@@ -91,29 +114,6 @@ void comm_is_ready() {
|
| 91 | 114 |
// set the text |
| 92 | 115 |
text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JSready"); |
| 93 | 116 |
|
| 94 |
- // Declare the dictionary's iterator |
|
| 95 |
- DictionaryIterator *out_iter; |
|
| 96 |
- |
|
| 97 |
- // Prepare the outbox buffer for this message |
|
| 98 |
- AppMessageResult result = app_message_outbox_begin(&out_iter); |
|
| 99 |
- |
|
| 100 |
- if(result == APP_MSG_OK) {
|
|
| 101 |
- // Add an item to ask for weather data |
|
| 102 |
- msg = "get"; |
|
| 103 |
- dict_write_cstring(out_iter, status, msg); |
|
| 104 |
- |
|
| 105 |
- // Send this message |
|
| 106 |
- result = app_message_outbox_send(); |
|
| 107 |
- if(result != APP_MSG_OK) {
|
|
| 108 |
- APP_LOG(APP_LOG_LEVEL_ERROR, "Error sending the outbox: %d", (int)result); |
|
| 109 |
- } |
|
| 110 |
- } else {
|
|
| 111 |
- // The outbox cannot be used right now |
|
| 112 |
- APP_LOG(APP_LOG_LEVEL_ERROR, "Error preparing the outbox: %d", (int)result); |
|
| 113 |
- } |
|
| 114 |
- // Button click provider |
|
| 115 |
- // window_set_click_config_provider(s_window, click_config_provider); |
|
| 116 |
- |
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 | 119 |
static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| ... | ... |
@@ -64,8 +64,8 @@ static void prv_window_load(Window *window) {
|
| 64 | 64 |
|
| 65 | 65 |
s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h/2)); |
| 66 | 66 |
|
| 67 |
- text_layer_set_background_color(s_speed_text_layer, GColorClear); |
|
| 68 |
- text_layer_set_text_color(s_speed_text_layer, PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack)); |
|
| 67 |
+ text_layer_set_background_color(s_speed_text_layer, GColorBlack); |
|
| 68 |
+ text_layer_set_text_color(s_speed_text_layer, GColorWhite); |
|
| 69 | 69 |
text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
| 70 | 70 |
text_layer_set_text_alignment(s_speed_text_layer, GTextAlignmentCenter); |
| 71 | 71 |
text_layer_set_text(s_speed_text_layer, "Press a button"); |
| ... | ... |
@@ -75,7 +75,7 @@ static void prv_window_load(Window *window) {
|
| 75 | 75 |
s_other_text_layer = text_layer_create(GRect(0, bounds.size.h/2,bounds.size.w, bounds.size.h/2)); |
| 76 | 76 |
|
| 77 | 77 |
text_layer_set_background_color(s_other_text_layer, GColorClear); |
| 78 |
- text_layer_set_text_color(s_other_text_layer, PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack)); |
|
| 78 |
+ text_layer_set_text_color(s_other_text_layer, GColorBlack); |
|
| 79 | 79 |
text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); |
| 80 | 80 |
text_layer_set_text_alignment(s_other_text_layer, GTextAlignmentCenter); |
| 81 | 81 |
text_layer_set_text(s_other_text_layer, "Press a button"); |
| ... | ... |
@@ -1,7 +1,8 @@ |
| 1 | 1 |
#include <pebble.h> |
| 2 | 2 |
|
| 3 | 3 |
static Window *s_window; |
| 4 |
-static TextLayer *s_text_layer; |
|
| 4 |
+static TextLayer *s_speed_text_layer; |
|
| 5 |
+static TextLayer *s_other_text_layer; |
|
| 5 | 6 |
|
| 6 | 7 |
// Largest expected inbox and outbox message sizes |
| 7 | 8 |
const uint32_t inbox_size = 64; |
| ... | ... |
@@ -40,15 +41,15 @@ typedef enum {
|
| 40 | 41 |
|
| 41 | 42 |
|
| 42 | 43 |
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 43 |
- text_layer_set_text(s_text_layer, "Select"); |
|
| 44 |
+ text_layer_set_text(s_other_text_layer, "Select"); |
|
| 44 | 45 |
} |
| 45 | 46 |
|
| 46 | 47 |
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 47 |
- text_layer_set_text(s_text_layer, "Up"); |
|
| 48 |
+ text_layer_set_text(s_other_text_layer, "Up"); |
|
| 48 | 49 |
} |
| 49 | 50 |
|
| 50 | 51 |
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
| 51 |
- text_layer_set_text(s_text_layer, "Down"); |
|
| 52 |
+ text_layer_set_text(s_other_text_layer, "Down"); |
|
| 52 | 53 |
} |
| 53 | 54 |
|
| 54 | 55 |
static void prv_click_config_provider(void *context) {
|
| ... | ... |
@@ -61,20 +62,34 @@ static void prv_window_load(Window *window) {
|
| 61 | 62 |
Layer *window_layer = window_get_root_layer(window); |
| 62 | 63 |
GRect bounds = layer_get_bounds(window_layer); |
| 63 | 64 |
|
| 64 |
- s_text_layer = text_layer_create(GRect(0, 72, bounds.size.w, bounds.size.h)); |
|
| 65 |
- text_layer_set_text(s_text_layer, "Press a button"); |
|
| 66 |
- text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter); |
|
| 67 |
- layer_add_child(window_layer, text_layer_get_layer(s_text_layer)); |
|
| 65 |
+ s_speed_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h/2)); |
|
| 66 |
+ |
|
| 67 |
+ text_layer_set_background_color(s_speed_text_layer, GColorClear); |
|
| 68 |
+ text_layer_set_text_color(s_speed_text_layer, PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack)); |
|
| 69 |
+ text_layer_set_font(s_speed_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); |
|
| 70 |
+ text_layer_set_text_alignment(s_speed_text_layer, GTextAlignmentCenter); |
|
| 71 |
+ text_layer_set_text(s_speed_text_layer, "Press a button"); |
|
| 72 |
+ layer_add_child(window_layer, text_layer_get_layer(s_speed_text_layer)); |
|
| 73 |
+ |
|
| 74 |
+ |
|
| 75 |
+ s_other_text_layer = text_layer_create(GRect(0, bounds.size.h/2,bounds.size.w, bounds.size.h/2)); |
|
| 76 |
+ |
|
| 77 |
+ text_layer_set_background_color(s_other_text_layer, GColorClear); |
|
| 78 |
+ text_layer_set_text_color(s_other_text_layer, PBL_IF_COLOR_ELSE(GColorWhite, GColorBlack)); |
|
| 79 |
+ text_layer_set_font(s_other_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); |
|
| 80 |
+ text_layer_set_text_alignment(s_other_text_layer, GTextAlignmentCenter); |
|
| 81 |
+ text_layer_set_text(s_other_text_layer, "Press a button"); |
|
| 82 |
+ layer_add_child(window_layer, text_layer_get_layer(s_other_text_layer)); |
|
| 68 | 83 |
} |
| 69 | 84 |
|
| 70 | 85 |
static void prv_window_unload(Window *window) {
|
| 71 |
- text_layer_destroy(s_text_layer); |
|
| 86 |
+ text_layer_destroy(s_speed_text_layer); |
|
| 72 | 87 |
} |
| 73 | 88 |
|
| 74 | 89 |
void comm_is_ready() {
|
| 75 | 90 |
|
| 76 | 91 |
// set the text |
| 77 |
- text_layer_set_text(s_text_layer, "Welcome to Bike Companion ! JSready"); |
|
| 92 |
+ text_layer_set_text(s_other_text_layer, "Welcome to Bike Companion ! JSready"); |
|
| 78 | 93 |
|
| 79 | 94 |
// Declare the dictionary's iterator |
| 80 | 95 |
DictionaryIterator *out_iter; |
| ... | ... |
@@ -125,7 +140,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 125 | 140 |
strncpy(s_latitude, latitude_tuple->value->cstring, 12); |
| 126 | 141 |
|
| 127 | 142 |
// Display in the TextLayer |
| 128 |
- //text_layer_set_text(s_text_layer, lf_latitude); |
|
| 143 |
+ //text_layer_set_text(s_speed_text_layer, lf_latitude); |
|
| 129 | 144 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "latitude message received : %s",s_latitude); |
| 130 | 145 |
}else{
|
| 131 | 146 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not latitude message... "); |
| ... | ... |
@@ -139,7 +154,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 139 | 154 |
strncpy(s_longitude, longitude_tuple->value->cstring, 12); |
| 140 | 155 |
|
| 141 | 156 |
// Display in the TextLayer |
| 142 |
- //text_layer_set_text(s_text_layer, lf_longitude); |
|
| 157 |
+ //text_layer_set_text(s_speed_text_layer, lf_longitude); |
|
| 143 | 158 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "longitude message received : %s",s_longitude); |
| 144 | 159 |
}else{
|
| 145 | 160 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not longitude message... "); |
| ... | ... |
@@ -153,7 +168,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 153 | 168 |
strncpy(s_accuracy, accuracy_tuple->value->cstring, 4); |
| 154 | 169 |
|
| 155 | 170 |
// Display in the TextLayer |
| 156 |
- //text_layer_set_text(s_text_layer, lf_accuracy); |
|
| 171 |
+ //text_layer_set_text(s_speed_text_layer, lf_accuracy); |
|
| 157 | 172 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "accuracy message received : %s",s_accuracy); |
| 158 | 173 |
}else{
|
| 159 | 174 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not accuracy message... "); |
| ... | ... |
@@ -167,7 +182,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 167 | 182 |
strncpy(s_altitude, altitude_tuple->value->cstring, 5); |
| 168 | 183 |
|
| 169 | 184 |
// Display in the TextLayer |
| 170 |
- //text_layer_set_text(s_text_layer, lf_altitude); |
|
| 185 |
+ //text_layer_set_text(s_speed_text_layer, lf_altitude); |
|
| 171 | 186 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",altitude_tuple->value->cstring); |
| 172 | 187 |
}else{
|
| 173 | 188 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude message... "); |
| ... | ... |
@@ -181,7 +196,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 181 | 196 |
strncpy(s_altitude_accuracy, altitude_accuracy_tuple->value->cstring, 3); |
| 182 | 197 |
|
| 183 | 198 |
// Display in the TextLayer |
| 184 |
- //text_layer_set_text(s_text_layer, lf_altitude_accuracy); |
|
| 199 |
+ //text_layer_set_text(s_speed_text_layer, lf_altitude_accuracy); |
|
| 185 | 200 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude_accuracy message received : %s",s_altitude_accuracy); |
| 186 | 201 |
}else{
|
| 187 | 202 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude_accuracy message... "); |
| ... | ... |
@@ -195,7 +210,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 195 | 210 |
strncpy(s_timestamp, timestamp_tuple->value->cstring, 13); |
| 196 | 211 |
|
| 197 | 212 |
// Display in the TextLayer |
| 198 |
- //text_layer_set_text(s_text_layer, lf_timestamp); |
|
| 213 |
+ //text_layer_set_text(s_speed_text_layer, lf_timestamp); |
|
| 199 | 214 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "timestamp message received : %s",s_timestamp); |
| 200 | 215 |
}else{
|
| 201 | 216 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not timestamp message... "); |
| ... | ... |
@@ -210,7 +225,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 210 | 225 |
strncpy(s_speed, speed_tuple->value->cstring, 5); |
| 211 | 226 |
|
| 212 | 227 |
// Display in the TextLayer |
| 213 |
- //text_layer_set_text(s_text_layer, lf_speed); |
|
| 228 |
+ //text_layer_set_text(s_speed_text_layer, lf_speed); |
|
| 214 | 229 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s",s_speed); |
| 215 | 230 |
}else{
|
| 216 | 231 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not speed message... "); |
| ... | ... |
@@ -227,23 +242,24 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 227 | 242 |
|
| 228 | 243 |
// DEBUG concatenate all data received |
| 229 | 244 |
memset(s_msg,'\0',sizeof(s_msg)); |
| 230 |
- strncpy(s_msg, s_status, 2);/* |
|
| 231 |
- strcat(s_msg, "Lat. "); |
|
| 232 |
- strcat(s_msg, s_latitude); |
|
| 233 |
- strcat(s_msg, "\n Long. "); |
|
| 234 |
- strcat(s_msg, s_longitude); |
|
| 245 |
+ strncpy(s_msg, s_status, 2); |
|
| 246 |
+ //strcat(s_msg, "Lat. "); |
|
| 247 |
+ //strcat(s_msg, s_latitude); |
|
| 248 |
+ //strcat(s_msg, "\n Long. "); |
|
| 249 |
+ //strcat(s_msg, s_longitude); |
|
| 235 | 250 |
strcat(s_msg, "\n Acc. "); |
| 236 |
- strcat(s_msg, s_accuracy);*/ |
|
| 251 |
+ strcat(s_msg, s_accuracy); |
|
| 237 | 252 |
strcat(s_msg, "\n Alt. "); |
| 238 | 253 |
strcat(s_msg, s_altitude); |
| 239 |
- strcat(s_msg, "\n Speed. "); |
|
| 240 |
- strcat(s_msg, s_speed); |
|
| 241 |
- /*strcat(s_msg, "\n Time. "); |
|
| 242 |
- strcat(s_msg, s_timestamp);*/ |
|
| 254 |
+ //strcat(s_msg, "\n Speed. "); |
|
| 255 |
+ //strcat(s_msg, s_speed); |
|
| 256 |
+ //strcat(s_msg, "\n Time. "); |
|
| 257 |
+ //strcat(s_msg, s_timestamp); |
|
| 243 | 258 |
|
| 244 | 259 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
| 245 | 260 |
// DEBUG Display in the TextLayer |
| 246 |
- text_layer_set_text(s_text_layer, s_msg); |
|
| 261 |
+ text_layer_set_text(s_speed_text_layer, s_speed); |
|
| 262 |
+ text_layer_set_text(s_other_text_layer, s_msg); |
|
| 247 | 263 |
}else{
|
| 248 | 264 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
| 249 | 265 |
} |
| ... | ... |
@@ -10,17 +10,17 @@ const uint32_t outbox_size = 64; |
| 10 | 10 |
static uint32_t size ; |
| 11 | 11 |
static char * msg; |
| 12 | 12 |
|
| 13 |
-static char s_status[2]; |
|
| 13 |
+static char s_status[3]; |
|
| 14 | 14 |
|
| 15 |
-//restricting long and lat to 12 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal |
|
| 16 |
-static char s_longitude[12]; |
|
| 17 |
-static char s_latitude[12]; |
|
| 15 |
+//restricting long and lat to 13 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal, 1 for \0 |
|
| 16 |
+static char s_longitude[13]; |
|
| 17 |
+static char s_latitude[13]; |
|
| 18 | 18 |
|
| 19 |
-static char s_accuracy[4]; |
|
| 20 |
-static char s_altitude[5]; |
|
| 21 |
-static char s_altitude_accuracy[3]; |
|
| 22 |
-static char s_timestamp[13]; |
|
| 23 |
-static char s_speed[5]; |
|
| 19 |
+static char s_accuracy[5]; |
|
| 20 |
+static char s_altitude[6]; |
|
| 21 |
+static char s_altitude_accuracy[4]; |
|
| 22 |
+static char s_timestamp[14]; |
|
| 23 |
+static char s_speed[6]; |
|
| 24 | 24 |
|
| 25 | 25 |
static char s_msg[50]; |
| 26 | 26 |
|
| ... | ... |
@@ -121,6 +121,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 121 | 121 |
Tuple *latitude_tuple = dict_find(iter, MESSAGE_KEY_latitude); |
| 122 | 122 |
|
| 123 | 123 |
if(latitude_tuple) {
|
| 124 |
+ memset(s_latitude,'\0',sizeof(s_latitude)); |
|
| 124 | 125 |
strncpy(s_latitude, latitude_tuple->value->cstring, 12); |
| 125 | 126 |
|
| 126 | 127 |
// Display in the TextLayer |
| ... | ... |
@@ -134,6 +135,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 134 | 135 |
Tuple *longitude_tuple = dict_find(iter, MESSAGE_KEY_longitude); |
| 135 | 136 |
|
| 136 | 137 |
if(longitude_tuple) {
|
| 138 |
+ memset(s_longitude,'\0',sizeof(s_longitude)); |
|
| 137 | 139 |
strncpy(s_longitude, longitude_tuple->value->cstring, 12); |
| 138 | 140 |
|
| 139 | 141 |
// Display in the TextLayer |
| ... | ... |
@@ -147,6 +149,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 147 | 149 |
Tuple *accuracy_tuple = dict_find(iter, MESSAGE_KEY_accuracy); |
| 148 | 150 |
|
| 149 | 151 |
if(accuracy_tuple) {
|
| 152 |
+ memset(s_accuracy,'\0',sizeof(s_accuracy)); |
|
| 150 | 153 |
strncpy(s_accuracy, accuracy_tuple->value->cstring, 4); |
| 151 | 154 |
|
| 152 | 155 |
// Display in the TextLayer |
| ... | ... |
@@ -160,11 +163,12 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 160 | 163 |
Tuple *altitude_tuple = dict_find(iter, MESSAGE_KEY_altitude); |
| 161 | 164 |
|
| 162 | 165 |
if(altitude_tuple) {
|
| 166 |
+ memset(s_altitude,'\0',sizeof(s_altitude)); |
|
| 163 | 167 |
strncpy(s_altitude, altitude_tuple->value->cstring, 5); |
| 164 | 168 |
|
| 165 | 169 |
// Display in the TextLayer |
| 166 | 170 |
//text_layer_set_text(s_text_layer, lf_altitude); |
| 167 |
- APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",s_altitude); |
|
| 171 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",altitude_tuple->value->cstring); |
|
| 168 | 172 |
}else{
|
| 169 | 173 |
//APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude message... "); |
| 170 | 174 |
} |
| ... | ... |
@@ -173,6 +177,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 173 | 177 |
Tuple *altitude_accuracy_tuple = dict_find(iter, MESSAGE_KEY_altitude_accuracy); |
| 174 | 178 |
|
| 175 | 179 |
if(altitude_accuracy_tuple) {
|
| 180 |
+ memset(s_altitude_accuracy,'\0',sizeof(s_altitude_accuracy)); |
|
| 176 | 181 |
strncpy(s_altitude_accuracy, altitude_accuracy_tuple->value->cstring, 3); |
| 177 | 182 |
|
| 178 | 183 |
// Display in the TextLayer |
| ... | ... |
@@ -186,6 +191,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 186 | 191 |
Tuple *timestamp_tuple = dict_find(iter, MESSAGE_KEY_timestamp); |
| 187 | 192 |
|
| 188 | 193 |
if(timestamp_tuple) {
|
| 194 |
+ memset(s_timestamp,'\0',sizeof(s_timestamp)); |
|
| 189 | 195 |
strncpy(s_timestamp, timestamp_tuple->value->cstring, 13); |
| 190 | 196 |
|
| 191 | 197 |
// Display in the TextLayer |
| ... | ... |
@@ -200,6 +206,7 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 200 | 206 |
Tuple *speed_tuple = dict_find(iter, MESSAGE_KEY_speed); |
| 201 | 207 |
|
| 202 | 208 |
if(speed_tuple) {
|
| 209 |
+ memset(s_speed,'\0',sizeof(s_speed)); |
|
| 203 | 210 |
strncpy(s_speed, speed_tuple->value->cstring, 5); |
| 204 | 211 |
|
| 205 | 212 |
// Display in the TextLayer |
| ... | ... |
@@ -214,20 +221,21 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
| 214 | 221 |
Tuple *status_tuple = dict_find(iter, MESSAGE_KEY_status); |
| 215 | 222 |
|
| 216 | 223 |
if(status_tuple) {
|
| 224 |
+ memset(s_status,'\0',sizeof(s_status)); |
|
| 217 | 225 |
strncpy(s_status, status_tuple->value->cstring, 2); |
| 218 | 226 |
APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
| 219 | 227 |
|
| 220 | 228 |
// DEBUG concatenate all data received |
| 221 |
- memset(s_msg,0,sizeof(s_msg)); |
|
| 229 |
+ memset(s_msg,'\0',sizeof(s_msg)); |
|
| 222 | 230 |
strncpy(s_msg, s_status, 2);/* |
| 223 | 231 |
strcat(s_msg, "Lat. "); |
| 224 | 232 |
strcat(s_msg, s_latitude); |
| 225 | 233 |
strcat(s_msg, "\n Long. "); |
| 226 | 234 |
strcat(s_msg, s_longitude); |
| 227 | 235 |
strcat(s_msg, "\n Acc. "); |
| 228 |
- strcat(s_msg, s_accuracy); |
|
| 236 |
+ strcat(s_msg, s_accuracy);*/ |
|
| 229 | 237 |
strcat(s_msg, "\n Alt. "); |
| 230 |
- strcat(s_msg, s_altitude);*/ |
|
| 238 |
+ strcat(s_msg, s_altitude); |
|
| 231 | 239 |
strcat(s_msg, "\n Speed. "); |
| 232 | 240 |
strcat(s_msg, s_speed); |
| 233 | 241 |
/*strcat(s_msg, "\n Time. "); |
| ... | ... |
@@ -260,7 +268,7 @@ static void outbox_failed_callback(DictionaryIterator *iter, AppMessageResult re |
| 260 | 268 |
static void prv_init(void) {
|
| 261 | 269 |
|
| 262 | 270 |
// Open AppMessage |
| 263 |
- app_message_open(app_message_inbox_size_maximum(), outbox_size); |
|
| 271 |
+ app_message_open(inbox_size, outbox_size); |
|
| 264 | 272 |
|
| 265 | 273 |
// Register to be notified about inbox received events |
| 266 | 274 |
app_message_register_inbox_received(inbox_received_callback); |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,296 @@ |
| 1 |
+#include <pebble.h> |
|
| 2 |
+ |
|
| 3 |
+static Window *s_window; |
|
| 4 |
+static TextLayer *s_text_layer; |
|
| 5 |
+ |
|
| 6 |
+// Largest expected inbox and outbox message sizes |
|
| 7 |
+const uint32_t inbox_size = 64; |
|
| 8 |
+const uint32_t outbox_size = 64; |
|
| 9 |
+ |
|
| 10 |
+static uint32_t size ; |
|
| 11 |
+static char * msg; |
|
| 12 |
+ |
|
| 13 |
+static char s_status[2]; |
|
| 14 |
+ |
|
| 15 |
+//restricting long and lat to 12 char : 0-1 for the sign, 1-3 for integer, 1 for the point, 7-10 for decimal |
|
| 16 |
+static char s_longitude[12]; |
|
| 17 |
+static char s_latitude[12]; |
|
| 18 |
+ |
|
| 19 |
+static char s_accuracy[4]; |
|
| 20 |
+static char s_altitude[5]; |
|
| 21 |
+static char s_altitude_accuracy[3]; |
|
| 22 |
+static char s_timestamp[13]; |
|
| 23 |
+static char s_speed[5]; |
|
| 24 |
+ |
|
| 25 |
+static char s_msg[50]; |
|
| 26 |
+ |
|
| 27 |
+static bool s_js_ready; |
|
| 28 |
+ |
|
| 29 |
+typedef enum {
|
|
| 30 |
+ status, |
|
| 31 |
+ latitude, |
|
| 32 |
+ longitude, |
|
| 33 |
+ altitude, |
|
| 34 |
+ accuracy, |
|
| 35 |
+ altitude_accuracy, |
|
| 36 |
+ speed, |
|
| 37 |
+ timestamp |
|
| 38 |
+} AppKey; |
|
| 39 |
+ |
|
| 40 |
+ |
|
| 41 |
+ |
|
| 42 |
+static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 43 |
+ text_layer_set_text(s_text_layer, "Select"); |
|
| 44 |
+} |
|
| 45 |
+ |
|
| 46 |
+static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 47 |
+ text_layer_set_text(s_text_layer, "Up"); |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 50 |
+static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
|
| 51 |
+ text_layer_set_text(s_text_layer, "Down"); |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+static void prv_click_config_provider(void *context) {
|
|
| 55 |
+ window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler); |
|
| 56 |
+ window_single_click_subscribe(BUTTON_ID_UP, prv_up_click_handler); |
|
| 57 |
+ window_single_click_subscribe(BUTTON_ID_DOWN, prv_down_click_handler); |
|
| 58 |
+} |
|
| 59 |
+ |
|
| 60 |
+static void prv_window_load(Window *window) {
|
|
| 61 |
+ Layer *window_layer = window_get_root_layer(window); |
|
| 62 |
+ GRect bounds = layer_get_bounds(window_layer); |
|
| 63 |
+ |
|
| 64 |
+ s_text_layer = text_layer_create(GRect(0, 72, bounds.size.w, bounds.size.h)); |
|
| 65 |
+ text_layer_set_text(s_text_layer, "Press a button"); |
|
| 66 |
+ text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter); |
|
| 67 |
+ layer_add_child(window_layer, text_layer_get_layer(s_text_layer)); |
|
| 68 |
+} |
|
| 69 |
+ |
|
| 70 |
+static void prv_window_unload(Window *window) {
|
|
| 71 |
+ text_layer_destroy(s_text_layer); |
|
| 72 |
+} |
|
| 73 |
+ |
|
| 74 |
+void comm_is_ready() {
|
|
| 75 |
+ |
|
| 76 |
+ // set the text |
|
| 77 |
+ text_layer_set_text(s_text_layer, "Welcome to Bike Companion ! JSready"); |
|
| 78 |
+ |
|
| 79 |
+ // Declare the dictionary's iterator |
|
| 80 |
+ DictionaryIterator *out_iter; |
|
| 81 |
+ |
|
| 82 |
+ // Prepare the outbox buffer for this message |
|
| 83 |
+ AppMessageResult result = app_message_outbox_begin(&out_iter); |
|
| 84 |
+ |
|
| 85 |
+ if(result == APP_MSG_OK) {
|
|
| 86 |
+ // Add an item to ask for weather data |
|
| 87 |
+ msg = "get"; |
|
| 88 |
+ dict_write_cstring(out_iter, status, msg); |
|
| 89 |
+ |
|
| 90 |
+ // Send this message |
|
| 91 |
+ result = app_message_outbox_send(); |
|
| 92 |
+ if(result != APP_MSG_OK) {
|
|
| 93 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Error sending the outbox: %d", (int)result); |
|
| 94 |
+ } |
|
| 95 |
+ } else {
|
|
| 96 |
+ // The outbox cannot be used right now |
|
| 97 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Error preparing the outbox: %d", (int)result); |
|
| 98 |
+ } |
|
| 99 |
+ // Button click provider |
|
| 100 |
+ // window_set_click_config_provider(s_window, click_config_provider); |
|
| 101 |
+ |
|
| 102 |
+} |
|
| 103 |
+ |
|
| 104 |
+static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
|
| 105 |
+ // A new message has been successfully received |
|
| 106 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "New message! "); |
|
| 107 |
+ |
|
| 108 |
+ size = dict_size(iter); |
|
| 109 |
+ |
|
| 110 |
+ // JS readiness |
|
| 111 |
+ Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_JSReady); |
|
| 112 |
+ |
|
| 113 |
+ if(ready_tuple){
|
|
| 114 |
+ //Pebblekit JS is ready ! Safe to send messages |
|
| 115 |
+ s_js_ready = true; |
|
| 116 |
+ comm_is_ready(); |
|
| 117 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "received jsready message on watch... "); |
|
| 118 |
+ } |
|
| 119 |
+ |
|
| 120 |
+ // Read latitude returns |
|
| 121 |
+ Tuple *latitude_tuple = dict_find(iter, MESSAGE_KEY_latitude); |
|
| 122 |
+ |
|
| 123 |
+ if(latitude_tuple) {
|
|
| 124 |
+ strncpy(s_latitude, latitude_tuple->value->cstring, 12); |
|
| 125 |
+ |
|
| 126 |
+ // Display in the TextLayer |
|
| 127 |
+ //text_layer_set_text(s_text_layer, lf_latitude); |
|
| 128 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "latitude message received : %s",s_latitude); |
|
| 129 |
+ }else{
|
|
| 130 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not latitude message... "); |
|
| 131 |
+ } |
|
| 132 |
+ |
|
| 133 |
+ // Read longitude returns |
|
| 134 |
+ Tuple *longitude_tuple = dict_find(iter, MESSAGE_KEY_longitude); |
|
| 135 |
+ |
|
| 136 |
+ if(longitude_tuple) {
|
|
| 137 |
+ strncpy(s_longitude, longitude_tuple->value->cstring, 12); |
|
| 138 |
+ |
|
| 139 |
+ // Display in the TextLayer |
|
| 140 |
+ //text_layer_set_text(s_text_layer, lf_longitude); |
|
| 141 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "longitude message received : %s",s_longitude); |
|
| 142 |
+ }else{
|
|
| 143 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not longitude message... "); |
|
| 144 |
+ } |
|
| 145 |
+ |
|
| 146 |
+ // Read accuracy returns |
|
| 147 |
+ Tuple *accuracy_tuple = dict_find(iter, MESSAGE_KEY_accuracy); |
|
| 148 |
+ |
|
| 149 |
+ if(accuracy_tuple) {
|
|
| 150 |
+ strncpy(s_accuracy, accuracy_tuple->value->cstring, 4); |
|
| 151 |
+ |
|
| 152 |
+ // Display in the TextLayer |
|
| 153 |
+ //text_layer_set_text(s_text_layer, lf_accuracy); |
|
| 154 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "accuracy message received : %s",s_accuracy); |
|
| 155 |
+ }else{
|
|
| 156 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not accuracy message... "); |
|
| 157 |
+ } |
|
| 158 |
+ |
|
| 159 |
+ // Read altitude returns |
|
| 160 |
+ Tuple *altitude_tuple = dict_find(iter, MESSAGE_KEY_altitude); |
|
| 161 |
+ |
|
| 162 |
+ if(altitude_tuple) {
|
|
| 163 |
+ strncpy(s_altitude, altitude_tuple->value->cstring, 5); |
|
| 164 |
+ |
|
| 165 |
+ // Display in the TextLayer |
|
| 166 |
+ //text_layer_set_text(s_text_layer, lf_altitude); |
|
| 167 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude message received : %s",s_altitude); |
|
| 168 |
+ }else{
|
|
| 169 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude message... "); |
|
| 170 |
+ } |
|
| 171 |
+ |
|
| 172 |
+ // Read altitude accuracy returns |
|
| 173 |
+ Tuple *altitude_accuracy_tuple = dict_find(iter, MESSAGE_KEY_altitude_accuracy); |
|
| 174 |
+ |
|
| 175 |
+ if(altitude_accuracy_tuple) {
|
|
| 176 |
+ strncpy(s_altitude_accuracy, altitude_accuracy_tuple->value->cstring, 3); |
|
| 177 |
+ |
|
| 178 |
+ // Display in the TextLayer |
|
| 179 |
+ //text_layer_set_text(s_text_layer, lf_altitude_accuracy); |
|
| 180 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "altitude_accuracy message received : %s",s_altitude_accuracy); |
|
| 181 |
+ }else{
|
|
| 182 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not altitude_accuracy message... "); |
|
| 183 |
+ } |
|
| 184 |
+ |
|
| 185 |
+ // Read timestamp returns |
|
| 186 |
+ Tuple *timestamp_tuple = dict_find(iter, MESSAGE_KEY_timestamp); |
|
| 187 |
+ |
|
| 188 |
+ if(timestamp_tuple) {
|
|
| 189 |
+ strncpy(s_timestamp, timestamp_tuple->value->cstring, 13); |
|
| 190 |
+ |
|
| 191 |
+ // Display in the TextLayer |
|
| 192 |
+ //text_layer_set_text(s_text_layer, lf_timestamp); |
|
| 193 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "timestamp message received : %s",s_timestamp); |
|
| 194 |
+ }else{
|
|
| 195 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not timestamp message... "); |
|
| 196 |
+ } |
|
| 197 |
+ |
|
| 198 |
+ |
|
| 199 |
+ // Read speed returns |
|
| 200 |
+ Tuple *speed_tuple = dict_find(iter, MESSAGE_KEY_speed); |
|
| 201 |
+ |
|
| 202 |
+ if(speed_tuple) {
|
|
| 203 |
+ strncpy(s_speed, speed_tuple->value->cstring, 5); |
|
| 204 |
+ |
|
| 205 |
+ // Display in the TextLayer |
|
| 206 |
+ //text_layer_set_text(s_text_layer, lf_speed); |
|
| 207 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "speed message received : %s",s_speed); |
|
| 208 |
+ }else{
|
|
| 209 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not speed message... "); |
|
| 210 |
+ } |
|
| 211 |
+ |
|
| 212 |
+ |
|
| 213 |
+ // Read status returns |
|
| 214 |
+ Tuple *status_tuple = dict_find(iter, MESSAGE_KEY_status); |
|
| 215 |
+ |
|
| 216 |
+ if(status_tuple) {
|
|
| 217 |
+ strncpy(s_status, status_tuple->value->cstring, 2); |
|
| 218 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "status message received : %s",s_status); |
|
| 219 |
+ |
|
| 220 |
+ // DEBUG concatenate all data received |
|
| 221 |
+ memset(s_msg,0,sizeof(s_msg)); |
|
| 222 |
+ strncpy(s_msg, s_status, 2);/* |
|
| 223 |
+ strcat(s_msg, "Lat. "); |
|
| 224 |
+ strcat(s_msg, s_latitude); |
|
| 225 |
+ strcat(s_msg, "\n Long. "); |
|
| 226 |
+ strcat(s_msg, s_longitude); |
|
| 227 |
+ strcat(s_msg, "\n Acc. "); |
|
| 228 |
+ strcat(s_msg, s_accuracy); |
|
| 229 |
+ strcat(s_msg, "\n Alt. "); |
|
| 230 |
+ strcat(s_msg, s_altitude);*/ |
|
| 231 |
+ strcat(s_msg, "\n Speed. "); |
|
| 232 |
+ strcat(s_msg, s_speed); |
|
| 233 |
+ /*strcat(s_msg, "\n Time. "); |
|
| 234 |
+ strcat(s_msg, s_timestamp);*/ |
|
| 235 |
+ |
|
| 236 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "to display : %s ",s_msg); |
|
| 237 |
+ // DEBUG Display in the TextLayer |
|
| 238 |
+ text_layer_set_text(s_text_layer, s_msg); |
|
| 239 |
+ }else{
|
|
| 240 |
+ //APP_LOG(APP_LOG_LEVEL_DEBUG, "not status message... "); |
|
| 241 |
+ } |
|
| 242 |
+ |
|
| 243 |
+} |
|
| 244 |
+ |
|
| 245 |
+static void inbox_dropped_callback(AppMessageResult reason, void *context) {
|
|
| 246 |
+ // A message was received, but had to be dropped |
|
| 247 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Message dropped. Reason: %d", (int)reason); |
|
| 248 |
+} |
|
| 249 |
+ |
|
| 250 |
+static void outbox_sent_callback(DictionaryIterator *iter, void *context) {
|
|
| 251 |
+ // The message just sent has been successfully delivered |
|
| 252 |
+ APP_LOG(APP_LOG_LEVEL_INFO, "Message sent. "); |
|
| 253 |
+} |
|
| 254 |
+ |
|
| 255 |
+static void outbox_failed_callback(DictionaryIterator *iter, AppMessageResult reason, void *context) {
|
|
| 256 |
+ // The message just sent failed to be delivered |
|
| 257 |
+ APP_LOG(APP_LOG_LEVEL_ERROR, "Message send failed. Reason: %d", (int)reason); |
|
| 258 |
+} |
|
| 259 |
+ |
|
| 260 |
+static void prv_init(void) {
|
|
| 261 |
+ |
|
| 262 |
+ // Open AppMessage |
|
| 263 |
+ app_message_open(app_message_inbox_size_maximum(), outbox_size); |
|
| 264 |
+ |
|
| 265 |
+ // Register to be notified about inbox received events |
|
| 266 |
+ app_message_register_inbox_received(inbox_received_callback); |
|
| 267 |
+ // Register to be notified about inbox dropped events |
|
| 268 |
+ app_message_register_inbox_dropped(inbox_dropped_callback); |
|
| 269 |
+ // Register to be notified about outbox sent events |
|
| 270 |
+ app_message_register_outbox_sent(outbox_sent_callback); |
|
| 271 |
+ // Register to be notified about outbox failed events |
|
| 272 |
+ app_message_register_outbox_failed(outbox_failed_callback); |
|
| 273 |
+ |
|
| 274 |
+ |
|
| 275 |
+ s_window = window_create(); |
|
| 276 |
+ window_set_click_config_provider(s_window, prv_click_config_provider); |
|
| 277 |
+ window_set_window_handlers(s_window, (WindowHandlers) {
|
|
| 278 |
+ .load = prv_window_load, |
|
| 279 |
+ .unload = prv_window_unload, |
|
| 280 |
+ }); |
|
| 281 |
+ const bool animated = true; |
|
| 282 |
+ window_stack_push(s_window, animated); |
|
| 283 |
+} |
|
| 284 |
+ |
|
| 285 |
+static void prv_deinit(void) {
|
|
| 286 |
+ window_destroy(s_window); |
|
| 287 |
+} |
|
| 288 |
+ |
|
| 289 |
+int main(void) {
|
|
| 290 |
+ prv_init(); |
|
| 291 |
+ |
|
| 292 |
+ APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", s_window); |
|
| 293 |
+ |
|
| 294 |
+ app_event_loop(); |
|
| 295 |
+ prv_deinit(); |
|
| 296 |
+} |