Advertisement
Guest User

Pebble Hello World

a guest
Oct 13th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.09 KB | None | 0 0
  1. #include <pebble.h>
  2. #include "hello.h"
  3.  
  4. // BEGIN AUTO-GENERATED UI CODE; DO NOT MODIFY
  5. static Window *s_window;
  6. static TextLayer *s_textlayer_1;
  7.  
  8. static void initialise_ui(void) {
  9.   s_window = window_create();
  10.   #ifndef PBL_SDK_3
  11.     window_set_fullscreen(s_window, true);
  12.   #endif
  13.  
  14.   // s_textlayer_1
  15.   s_textlayer_1 = text_layer_create(GRect(20, 74, 100, 17));
  16.   text_layer_set_text(s_textlayer_1, "Hello World");
  17.   text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
  18.   layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1);
  19. }
  20.  
  21. static void destroy_ui(void) {
  22.   window_destroy(s_window);
  23.   text_layer_destroy(s_textlayer_1);
  24. }
  25. // END AUTO-GENERATED UI CODE
  26.  
  27. static void handle_window_unload(Window* window) {
  28.   destroy_ui();
  29. }
  30.  
  31. void show_hello(void) {
  32.   initialise_ui();
  33.   window_set_window_handlers(s_window, (WindowHandlers) {
  34.     .unload = handle_window_unload,
  35.   });
  36.   window_stack_push(s_window, true);
  37. }
  38.  
  39. void hide_hello(void) {
  40.   window_stack_remove(s_window, true);
  41. }
  42.  
  43. int main(void) {
  44.     show_hello();
  45.  
  46.     app_event_loop();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement