Advertisement
Guest User

watchfacecode

a guest
May 3rd, 2015
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. #include <pebble.h>
  2.  
  3. ...
  4.  
  5. #define KEY_BACKGROUND_COLOUR 7
  6. #define KEY_FOREGROUND_COLOUR 8
  7.  
  8. ...
  9.  
  10. static GColor bgcolour;
  11. static GColor fgcolour;
  12.  
  13.  
  14. ...
  15.  
  16. static void window_load(Window *window)
  17. {
  18. // Background colour
  19.  
  20. background_layer = text_layer_create(GRect(0,0,144,168));
  21.  
  22. #ifdef PBL_COLOR
  23. bgcolour = GColorBlack; //but I don't want it hardcoded here, but from the configuration
  24. #endif
  25.  
  26. #ifdef PBL_COLOR
  27. text_layer_set_background_color(background_layer, bgcolour);
  28. #else
  29. text_layer_set_background_color(background_layer, GColorClear);
  30. #endif
  31. layer_add_child(window_get_root_layer(window),text_layer_get_layer(background_layer));
  32.  
  33. ...
  34.  
  35. // Foreground colour
  36.  
  37. #ifdef PBL_COLOR
  38. fgcolour = GColorBrightGreen; //but I don't want it hardcoded here, but from the configuration
  39. #endif
  40.  
  41. #ifdef PBL_COLOR
  42. text_layer_set_text_color(time_layer, fgcolour);
  43. text_layer_set_text_color(time_label_layer, fgcolour);
  44. ...
  45. #else
  46. text_layer_set_text_color(time_layer, GColorBlack);
  47. text_layer_set_text_color(time_label_layer, GColorBlack);
  48. ...
  49. #endif
  50.  
  51. }
  52.  
  53.  
  54.  
  55. static void window_unload(Window *window)
  56. {
  57.  
  58. text_layer_destroy(background_layer);
  59. text_layer_destroy(time_layer);
  60. text_layer_destroy(time_label_layer);
  61. ...
  62. }
  63.  
  64. static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  65.  
  66. Tuple *t = dict_read_first(iterator);
  67. while(t != NULL) {
  68. // Which key was received?
  69. switch(t->key) {
  70. APP_LOG(APP_LOG_LEVEL_DEBUG, "%i, %s", (int)t->key, t->value->cstring);
  71. case KEY_BACKGROUND_COLOUR:
  72. #ifdef PBL_COLOR
  73. if(strcmp(t->value->cstring, "101") == 0) {bgcolour = GColorBlack;}
  74. else if(strcmp(t->value->cstring, "102") == 0) {bgcolour = GColorDarkGrey;}
  75. else if(strcmp(t->value->cstring, "103") == 0) {bgcolour = GColorLightGrey;}
  76. else if(strcmp(t->value->cstring, "104") == 0) {bgcolour = GColorCadetBlue;}
  77. else if(strcmp(t->value->cstring, "105") == 0) {bgcolour = GColorTiffanyBlue;}
  78. ...
  79. #endif
  80. break;
  81. case KEY_FOREGROUND_COLOUR:
  82. #ifdef PBL_COLOR
  83. if(strcmp(t->value->cstring, "101") == 0) {fgcolour = GColorBlack;}
  84. else if(strcmp(t->value->cstring, "102") == 0) {fgcolour = GColorDarkGrey;}
  85. else if(strcmp(t->value->cstring, "103") == 0) {fgcolour = GColorLightGrey;}
  86. else if(strcmp(t->value->cstring, "104") == 0) {fgcolour = GColorCadetBlue;}
  87. else if(strcmp(t->value->cstring, "105") == 0) {fgcolour = GColorTiffanyBlue;}
  88. ...
  89. #endif
  90. break;
  91. default:
  92. APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized!", (int)t->key);
  93. break;
  94. }
  95.  
  96. // Look for next item
  97. t = dict_read_next(iterator);
  98. }
  99.  
  100. }
  101.  
  102.  
  103. ...
  104.  
  105.  
  106.  
  107.  
  108. void handle_init(void)
  109. {
  110. ...
  111. }
  112.  
  113.  
  114.  
  115. static void init()
  116. {
  117. ...
  118. }
  119.  
  120. void handle_deinit(void)
  121. {
  122. ...
  123. }
  124.  
  125.  
  126. int main(void)
  127. {
  128. ...
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement