static void http_capture_send_buffer() { int len = 64; if (http_capture_sentLen+len > 18*168) len = 18*168 - http_capture_sentLen; if (len <= 0) return; Tuplet start = TupletInteger(0xFFF9, http_capture_sentLen); Tuplet buf = TupletBytes(1000, &http_capture_frameBuffer[http_capture_sentLen], len); DictionaryIterator *iter; app_message_out_get(&iter); if (iter == NULL) return; dict_write_tuplet(iter, &start); dict_write_tuplet(iter, &buf); dict_write_end(iter); http_capture_sentLen += len; app_message_out_send(); app_message_out_release(); }
void send_ip(unsigned char ip[]) { Tuplet value = TupletBytes(IP_KEY, ip, 4); DictionaryIterator *iter; app_message_outbox_begin(&iter); if (iter == NULL) { return; } dict_write_tuplet(iter, &value); dict_write_end(iter); AppMessageResult res = app_message_outbox_send(); APP_LOG(APP_LOG_LEVEL_DEBUG, translate_error(res)); }
void init() { big_bold_font = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK); med_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); small_bold_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); conditions[WEATHER_UNKNOWN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_UNKNOWN); conditions[WEATHER_CLEAR_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_DAY); conditions[WEATHER_CLEAR_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLEAR_NIGHT); conditions[WEATHER_RAIN] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_RAIN); conditions[WEATHER_SNOW] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SNOW); // conditions[WEATHER_SLEET] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_SLEET); conditions[WEATHER_WIND] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_WIND); conditions[WEATHER_FOG] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_FOG); conditions[WEATHER_CLOUDY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_CLOUDY); conditions[WEATHER_PARTLY_CLOUDY_DAY] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_DAY); conditions[WEATHER_PARTLY_CLOUDY_NIGHT] = gbitmap_create_with_resource(RESOURCE_ID_WEATHER_PARTLY_CLOUDY_NIGHT); // Set up main window mainwindow = window_create(); window_set_background_color(mainwindow, GColorBlack); window_set_fullscreen(mainwindow, true); for ( int i = 0; i < MAX_WATCH_FACES; i++) { // This layer displays the time. 12-hour, 24-hour or how the watch is configured watchfaces[i].main_time_layer = text_layer_create(GRect(0, i*56, 144, 32)); text_layer_set_text(watchfaces[i].main_time_layer, watchfaces[i].time_text); text_layer_set_text_color(watchfaces[i].main_time_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].main_time_layer, GColorClear); text_layer_set_font(watchfaces[i].main_time_layer, big_bold_font); text_layer_set_text_alignment(watchfaces[i].main_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_time_layer); // This layer displays the selected time zone city, including GMT offset watchfaces[i].main_city_layer = text_layer_create(GRect(0, (i*56)+32, 144, 24)); text_layer_set_text_color(watchfaces[i].main_city_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].main_city_layer, GColorClear); text_layer_set_font(watchfaces[i].main_city_layer, small_bold_font); text_layer_set_text_alignment(watchfaces[i].main_city_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(mainwindow), (Layer *)watchfaces[i].main_city_layer); watchfaces[i].window = window_create(); window_set_background_color(watchfaces[i].window, GColorBlack); window_set_fullscreen(watchfaces[i].window, true); window_set_click_config_provider(watchfaces[i].window, (ClickConfigProvider) watchface_click_config_provider); // This layer displays the time. 12-hour, 24-hour or how the watch is configured watchfaces[i].text_time_layer = text_layer_create(GRect(0, 6, 144, 44)); text_layer_set_text(watchfaces[i].text_time_layer, watchfaces[i].time_text); text_layer_set_text_color(watchfaces[i].text_time_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_time_layer, GColorClear); text_layer_set_font(watchfaces[i].text_time_layer, big_bold_font); text_layer_set_text_alignment(watchfaces[i].text_time_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_time_layer); // This layer displays the date watchfaces[i].text_date_layer = text_layer_create(GRect(0, 44, 144, 28)); text_layer_set_text(watchfaces[i].text_date_layer, watchfaces[i].date_text); text_layer_set_text_color(watchfaces[i].text_date_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_date_layer, GColorClear); text_layer_set_font(watchfaces[i].text_date_layer, med_bold_font); text_layer_set_text_alignment(watchfaces[i].text_date_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_date_layer); // This layer displays the selected time zone city, including GMT offset watchfaces[i].text_city_layer = text_layer_create(GRect(0, 72, 146, 22)); text_layer_set_text_color(watchfaces[i].text_city_layer, GColorWhite); text_layer_set_background_color(watchfaces[i].text_city_layer, GColorClear); text_layer_set_font(watchfaces[i].text_city_layer, small_bold_font); text_layer_set_text_alignment(watchfaces[i].text_city_layer, GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_city_layer); for ( int j = 0; j < MAX_WEATHER_DAYS; j++ ) { // This layer displays a weather image, if available. watchfaces[i].bitmap_weather_layer[j] = bitmap_layer_create(GRect(9+(j*(36+9)), 94, 36, 36)); bitmap_layer_set_background_color(watchfaces[i].bitmap_weather_layer[j], GColorClear); bitmap_layer_set_alignment(watchfaces[i].bitmap_weather_layer[j], GAlignCenter); bitmap_layer_set_compositing_mode(watchfaces[i].bitmap_weather_layer[j], GCompOpAssignInverted); bitmap_layer_set_bitmap(watchfaces[i].bitmap_weather_layer[j], conditions[WEATHER_UNKNOWN]); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].bitmap_weather_layer[j]); // This layer displays the time zone temperature, high and low, below the weather icon watchfaces[i].text_temp_layer[j] = text_layer_create(GRect(9+(j*(36+9)), 130, 36, 38)); text_layer_set_text(watchfaces[i].text_temp_layer[j], watchfaces[i].temps[j]); text_layer_set_text_color(watchfaces[i].text_temp_layer[j], GColorWhite); text_layer_set_background_color(watchfaces[i].text_temp_layer[j], GColorClear); text_layer_set_font(watchfaces[i].text_temp_layer[j], small_bold_font); text_layer_set_text_alignment(watchfaces[i].text_temp_layer[j], GTextAlignmentCenter); layer_add_child(window_get_root_layer(watchfaces[i].window), (Layer *)watchfaces[i].text_temp_layer[j]); } } Tuplet initial_values[] = { TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) -28800), TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(LOCAL_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_WATCH_CONFIG_TIME), TupletCString(LOCAL_WATCH_OFFSET+PBCOMM_CITY_KEY, "Watch Time"), TupletBytes( LOCAL_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) 0), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(TZ1_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_24_HOUR_TIME), TupletCString(TZ1_WATCH_OFFSET+PBCOMM_CITY_KEY, "London, England"), TupletBytes( TZ1_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_GMT_SEC_OFFSET_KEY, (int32_t) 32400), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_BACKGROUND_KEY, (uint8_t) BACKGROUND_SUNS), TupletInteger(TZ2_WATCH_OFFSET+PBCOMM_12_24_DISPLAY_KEY, (uint8_t) DISPLAY_24_HOUR_TIME), TupletCString(TZ2_WATCH_OFFSET+PBCOMM_CITY_KEY, "Tokyo, Japan"), TupletBytes( TZ2_WATCH_OFFSET+PBCOMM_WEATHER_KEY, weather, WEATHER_KEY_LEN) }; // Initialize watchfaces[].time_format as it may be used before sync_tuple_changed_callback // is executed to set up the proper value. for (int i = 0; i < MAX_WATCH_FACES; i++) { strncpy (watchfaces[i].time_format, time_12h_format, sizeof(time_12h_format)); } // Initialize status window, but don't populate unless it's requested via tap statuswindow = window_create(); window_set_background_color(statuswindow, GColorBlack); window_set_window_handlers(statuswindow, (WindowHandlers) { .load = statuswindow_load, .unload = statuswindow_unload });