Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pebble.h>
- ...
- #define KEY_BACKGROUND_COLOUR 7
- #define KEY_FOREGROUND_COLOUR 8
- ...
- static GColor bgcolour;
- static GColor fgcolour;
- ...
- static void window_load(Window *window)
- {
- // Background colour
- background_layer = text_layer_create(GRect(0,0,144,168));
- #ifdef PBL_COLOR
- bgcolour = GColorBlack; //but I don't want it hardcoded here, but from the configuration
- #endif
- #ifdef PBL_COLOR
- text_layer_set_background_color(background_layer, bgcolour);
- #else
- text_layer_set_background_color(background_layer, GColorClear);
- #endif
- layer_add_child(window_get_root_layer(window),text_layer_get_layer(background_layer));
- ...
- // Foreground colour
- #ifdef PBL_COLOR
- fgcolour = GColorBrightGreen; //but I don't want it hardcoded here, but from the configuration
- #endif
- #ifdef PBL_COLOR
- text_layer_set_text_color(time_layer, fgcolour);
- text_layer_set_text_color(time_label_layer, fgcolour);
- ...
- #else
- text_layer_set_text_color(time_layer, GColorBlack);
- text_layer_set_text_color(time_label_layer, GColorBlack);
- ...
- #endif
- }
- static void window_unload(Window *window)
- {
- text_layer_destroy(background_layer);
- text_layer_destroy(time_layer);
- text_layer_destroy(time_label_layer);
- ...
- }
- static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
- Tuple *t = dict_read_first(iterator);
- while(t != NULL) {
- // Which key was received?
- switch(t->key) {
- APP_LOG(APP_LOG_LEVEL_DEBUG, "%i, %s", (int)t->key, t->value->cstring);
- case KEY_BACKGROUND_COLOUR:
- #ifdef PBL_COLOR
- if(strcmp(t->value->cstring, "101") == 0) {bgcolour = GColorBlack;}
- else if(strcmp(t->value->cstring, "102") == 0) {bgcolour = GColorDarkGrey;}
- else if(strcmp(t->value->cstring, "103") == 0) {bgcolour = GColorLightGrey;}
- else if(strcmp(t->value->cstring, "104") == 0) {bgcolour = GColorCadetBlue;}
- else if(strcmp(t->value->cstring, "105") == 0) {bgcolour = GColorTiffanyBlue;}
- ...
- #endif
- break;
- case KEY_FOREGROUND_COLOUR:
- #ifdef PBL_COLOR
- if(strcmp(t->value->cstring, "101") == 0) {fgcolour = GColorBlack;}
- else if(strcmp(t->value->cstring, "102") == 0) {fgcolour = GColorDarkGrey;}
- else if(strcmp(t->value->cstring, "103") == 0) {fgcolour = GColorLightGrey;}
- else if(strcmp(t->value->cstring, "104") == 0) {fgcolour = GColorCadetBlue;}
- else if(strcmp(t->value->cstring, "105") == 0) {fgcolour = GColorTiffanyBlue;}
- ...
- #endif
- break;
- default:
- APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized!", (int)t->key);
- break;
- }
- // Look for next item
- t = dict_read_next(iterator);
- }
- }
- ...
- void handle_init(void)
- {
- ...
- }
- static void init()
- {
- ...
- }
- void handle_deinit(void)
- {
- ...
- }
- int main(void)
- {
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement