Étape 3: Programmation du temps de galets
Configurer un compte de galets sur cloudpebble
Assurez-vous que le PC et Smartphone sont sur le même réseau local, puis allument le développeur connexion sur votre smartphone Pebble temps app Paramètres--> Developer ConnectionCréez un nouveau projet vide, ajoutez un nouveau fichier source nommé « main.c » puis mettre le code suivant à!= SmartstrapResultOk) {APP_LOG (APP_LOG_LEVEL_ERROR, « attribut de lecture d’erreur (< %p >, %d) ", attr, résultat);}} else {APP_LOG (APP_LOG_LEVEL_ERROR, "notifiée (%p < >)", attr);}} public static void up_click_handler (module de reconnaissance ClickRecognizerRef, Sub * contexte) {prv_write_button_action(0x02, 0x01);} public static void select_click_handler (module de reconnaissance ClickRecognizerRef, Sub * contexte) {prv_write_button_action(0x03, 0x01);} public static void down_click_handler (module de reconnaissance ClickRecognizerRef, Sub * contexte) {prv_write_button_action(0x04, 0x01);} public static void click_config_provider(void *context) {window_single_click_subscribe (BUTTON_ID_UP, up_click_handler); window_single_click_subscribe (BUTTON_ID_SELECT select_click_handler) ; window_single_click_subscribe (BUTTON_ID_DOWN, down_click_handler) ; } public static void prv_main_window_load(Window *window) {s_status_layer = text_layer_create (GRect (0, 15, 144, 40)); text_layer_set_font (s_status_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)) ; prv_update_text() ; text_layer_set_text_color (s_status_layer, GColorBlack); text_layer_set_background_color (s_status_layer, GColorClear); text_layer_set_text_alignment (s_status_layer GTextAlignmentCenter) ; text_layer_set_overflow_mode (s_status_layer, GTextOverflowModeWordWrap) ; layer_add_child(window_get_root_layer(Window), text_layer_get_layer(s_status_layer)) ; s_attr_text_layer = text_layer_create (GRect (0, 40, 60, 144)) ; text_layer_set_font (s_attr_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)) ; text_layer_set_text (s_attr_text_layer, "-") ; text_layer_set_text_color (s_attr_text_layer, GColorBlack) ; text_layer_set_background_color (s_attr_text_layer, GColorClear) ; text_layer_set_text_alignment (s_attr_text_layer, GTextAlignmentCenter) ; text_layer_set_overflow_mode (s_attr_text_layer, GTextOverflowModeWordWrap) ; layer_add_child(window_get_root_layer(Window), text_layer_get_layer(s_attr_text_layer)) ; } public static void prv_main_window_unload(Window *window) {text_layer_destroy(s_status_layer);} public static void prv_init(void) {s_main_window = window_create() ; window_set_click_config_provider (s_main_window, click_config_provider); window_set_window_handlers (s_main_window, (WindowHandlers) {.load = prv_main_window_load, .unload = prv_main_window_unload}); window_stack_push (s_main_window, true) ; Gestionnaires de SmartstrapHandlers = (SmartstrapHandlers) {.availability_did_change = prv_availablility_status_changed, .did_write = prv_did_write, .did_read = prv_did_read, .notified = prv_notified} ; smartstrap_subscribe(Handlers) ; smartstrap_set_timeout(50) ; s_raw_attribute = smartstrap_attribute_create (0, 0, 2000) ; s_attr_attribute = smartstrap_attribute_create (0x1001, 0x1001, 20) ; } public static prv_deinit(void) Sub {window_destroy(s_main_window) ; smartstrap_unsubscribe() ; smartstrap_attribute_destroy(s_raw_attribute) ; smartstrap_attribute_destroy(s_attr_attribute);} int main (void) {prv_init() ; APP_LOG (APP_LOG_LEVEL_DEBUG, « À PARTIR DE APP ») ; Si (s_attr_attribute & & s_raw_attribute) {app_event_loop();} APP_LOG (APP_LOG_LEVEL_DEBUG, « FIN APP ») ; prv_deinit() ; }
4. dans l' onglet Paramètres , désélectionnez Build Aplite puisque nous construisons pour exécuter sur les montres de temps Pebble
5. dansl ' onglet Compilation sélectionnez téléphone au lieu de l’émulateur pour programmer notre vraie montre
6. exécuter le code en cliquant sur le bouton play