Skip to content

Commit

Permalink
- Updated to version 1.7
Browse files Browse the repository at this point in the history
- Added options for inverting and larger font
- Switched persistent data to ints (1 or 0)
- Removed animations completely
- Saved changes reflected immediately
  • Loading branch information
leovander committed Jun 3, 2015
1 parent d0539a7 commit 5054a6d
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 158 deletions.
3 changes: 2 additions & 1 deletion appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"watchface": true
},
"appKeys": {
"inverted": 0
"inverted": 0,
"fontsize": 1
},
"resources": {
"media": []
Expand Down
Binary file added resources/dani.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/layout.png
Binary file not shown.
Binary file removed resources/pebble-screenshot.png
Binary file not shown.
Binary file added resources/pebble-screenshot_2015-06-02_21-30-33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pebble-screenshot_2015-06-02_21-30-57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pebble-screenshot_2015-06-02_21-31-38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pebble-screenshot_2015-06-02_21-32-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/pebbs.gif
Binary file not shown.
289 changes: 146 additions & 143 deletions src/Dani.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,43 @@
void in_received_handler(DictionaryIterator *received, void *context) {
// incoming message received
Tuple *inverted_tuple = dict_find(received, CONFIG_INVERTED);
//Tuple *innerhours_tuple = dict_find(received, CONFIG_INNERHOURS);
Tuple *fontsize_tuple = dict_find(received, CONFIG_FONTSIZE);

if(inverted_tuple) {
strcpy(inverted_value, inverted_tuple->value->cstring);
if(inverted_tuple && fontsize_tuple) {
inverted_value = inverted_tuple->value->int8;
font_size_value = fontsize_tuple->value->int8;

if(strcmp(inverted_value, "invf") == 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Black");
if(inverted_value == 0) {
window_set_background_color(s_main_window, GColorBlack);
text_layer_set_text_color(text_layers[0], GColorWhite);
text_layer_set_text_color(text_layers[1], GColorWhite);
} else {
APP_LOG(APP_LOG_LEVEL_DEBUG, "White");
window_set_background_color(s_main_window, GColorWhite);
text_layer_set_text_color(text_layers[0], GColorBlack);
text_layer_set_text_color(text_layers[1], GColorBlack);
}

if(font_size_value == 0) {
text_layer_set_font(text_layers[0], fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
text_layer_set_font(text_layers[1], fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
} else {
text_layer_set_font(text_layers[0], fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_font(text_layers[1], fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));
}

fill_hour_frames();
update_time();

persist_write_int(CONFIG_INVERTED, inverted_value);
persist_write_int(CONFIG_FONTSIZE, font_size_value);
} else {
APP_LOG(APP_LOG_LEVEL_DEBUG, "No Background Option Set");
APP_LOG(APP_LOG_LEVEL_DEBUG, "No Options Set");
}

persist_write_string(CONFIG_INVERTED, inverted_value);
APP_LOG(APP_LOG_LEVEL_INFO, "%s", inverted_value);

vibes_short_pulse();

// if(innerhours_tuple) {
// strcpy(innerhours_value, innerhours_tuple->value->cstring);
//
// if(strcmp(innerhours_value, "0") == 0) {
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Normal");
// } else {
// APP_LOG(APP_LOG_LEVEL_DEBUG, "Inside");
// }
// } else {
// APP_LOG(APP_LOG_LEVEL_DEBUG, "No Hours Option Set");
// }
}

int main(void) {
init();

//register for messages
app_message_register_inbox_received(in_received_handler);
const uint32_t inbound_size = 64;
const uint32_t outbound_size = 64;
Expand All @@ -59,14 +54,15 @@ static void init() {
s_main_window = window_create();

if(persist_exists(CONFIG_INVERTED)) {
persist_read_string(CONFIG_INVERTED, inverted_value, sizeof(inverted_value));
APP_LOG(APP_LOG_LEVEL_INFO, "Stored Value: %s", inverted_value);
inverted_value = persist_read_int(CONFIG_INVERTED);
} else {
inverted_value = 0;
}

if(strcmp(inverted_value, "inv") == 0) {
APP_LOG(APP_LOG_LEVEL_INFO, "poop");
}
if(persist_exists(CONFIG_FONTSIZE)) {
font_size_value = persist_read_int(CONFIG_FONTSIZE);
} else {
strcpy(inverted_value, "invf");
font_size_value = 0;
}

window_set_window_handlers(s_main_window, (WindowHandlers) {
Expand All @@ -79,32 +75,23 @@ static void init() {
}

static void deinit() {
// persist_write_string(CONFIG_INVERTED, inverted_value);
//persist_write_string(CONFIG_INNERHOURS, innerhours_value);
window_destroy(s_main_window);
}

static void main_window_load(Window *window) {
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);

current_hour = tick_time->tm_hour;
startup = true;

if(strcmp(inverted_value, "invt") == 0) {
window_set_background_color(s_main_window, GColorWhite);
} else {
if(inverted_value == 0) {
window_set_background_color(s_main_window, GColorBlack);
} else {
window_set_background_color(s_main_window, GColorWhite);
}

fill_hour_frames();
update_time(tick_time);
updateTimeLayers();

free(tick_time);
fill_hour_frames();

layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layers[0]));
layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layers[1]));

update_time();
}

static void main_window_unload() {
Expand All @@ -116,7 +103,9 @@ static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
update_time(tick_time);
}

static void update_time(struct tm *tick_time) {
static void update_time() {
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
//APP_LOG(APP_LOG_LEVEL_DEBUG, "Heap Used: %d", heap_bytes_used());
//APP_LOG(APP_LOG_LEVEL_DEBUG, "Heap Free: %d", heap_bytes_free());
static char hours[] = "00";
Expand All @@ -125,7 +114,7 @@ static void update_time(struct tm *tick_time) {
strftime(hours, sizeof(hours), "%I", tick_time);
strftime(mins, sizeof(mins), "%M", tick_time);

trigger_custom_animation(tick_time);
update_positions(tick_time);
text_layer_set_text(text_layers[0], mins);

static char single_hour[] = "";
Expand All @@ -142,18 +131,13 @@ static void update_time(struct tm *tick_time) {
} else {
text_layer_set_text(text_layers[1], hours);
}

current_hour = tick_time->tm_hour;
}

static void anim_stopped_handler_1(Animation *animation, bool finished, void *context) {
#ifdef PBL_PLATFORM_APLITE
property_animation_destroy(s_property_animation_1);
#endif
}

static void trigger_custom_animation(struct tm *tick_time) {
static void update_positions(struct tm *tick_time) {
GRect to_frame_mins;
GRect to_frame_hours;
int x_pos, y_pos, mins, hours;

hours = tick_time->tm_hour;
mins = tick_time->tm_min;

Expand All @@ -165,111 +149,130 @@ static void trigger_custom_animation(struct tm *tick_time) {
mins += 60;
}

if(startup) {
//RIGHT
if((mins >= 6) && (mins <= 24)) {
y_pos = ((mins - 6) * 7) + 13;
text_layers[0] = text_layer_create(GRect(MIN_LEFT, y_pos, TM_SIZE, TM_SIZE));
}
if(font_size_value == 0) {
nextFrameNormal(x_pos, y_pos, mins, hours, to_frame_mins, to_frame_hours);
} else {
nextFrameLarge(x_pos, y_pos, mins, hours, to_frame_mins, to_frame_hours);
}
}

//LEFT
if((mins >= 36) && (mins <= 54)) {
y_pos = ((54 - mins) * 9) + 13;
text_layers[0] = text_layer_create(GRect(50, y_pos, TM_SIZE, TM_SIZE));
}
static void updateTimeLayers() {
text_layers[0] = text_layer_create(GRect(0, 0, TM_SIZE, TM_SIZE));
text_layers[1] = text_layer_create(GRect(0, 0, TM_SIZE, TM_SIZE));

//BOTTOM
if((mins >= 25) && (mins <= 35)) {
x_pos = ((35 - mins) * 8) + 50;
text_layers[0] = text_layer_create(GRect(x_pos, MIN_BOTTOM, TM_SIZE, TM_SIZE));
}
if(font_size_value == 0) {
text_layer_set_font(text_layers[0], fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
text_layer_set_font(text_layers[1], fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
} else {
text_layer_set_font(text_layers[0], fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_font(text_layers[1], fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT));
}

//TOP
if((mins >= 55) && (mins <= 65)) {
x_pos = ((mins - 55) * 8) + 50;
text_layers[0] = text_layer_create(GRect(x_pos, 0, TM_SIZE, TM_SIZE));
}
if(inverted_value == 0) {
text_layer_set_text_color(text_layers[0], GColorWhite);
text_layer_set_text_color(text_layers[1], GColorWhite);
} else {
text_layer_set_text_color(text_layers[0], GColorBlack);
text_layer_set_text_color(text_layers[1], GColorBlack);
}

text_layers[1] = text_layer_create(hour_pos[hours]);
text_layer_set_text(text_layers[0], "00");
text_layer_set_background_color(text_layers[0], GColorClear);

startup = false;
} else {
GRect from_frame_mins = layer_get_frame((Layer *)text_layers[0]);
GRect to_frame_mins;
text_layer_set_text(text_layers[1], "12");
text_layer_set_background_color(text_layers[1], GColorClear);
}

GRect from_frame_hours = layer_get_frame((Layer *)text_layers[1]);
GRect to_frame_hours;
static void nextFrameNormal(int x_pos, int y_pos, int mins, int hours, GRect to_frame_mins, GRect to_frame_hours) {
//RIGHT
if((mins >= 6) && (mins <= 24)) {
y_pos = ((mins - 6) * 7) + 13;
to_frame_mins = GRect(MIN_LEFT, y_pos, TM_SIZE, TM_SIZE);
}

//RIGHT
if((mins >= 6) && (mins <= 24)) {
y_pos = ((mins - 6) * 7) + 13;
to_frame_mins = GRect(MIN_LEFT, y_pos, TM_SIZE, TM_SIZE);
}
//LEFT
if((mins >= 36) && (mins <= 54)) {
y_pos = ((54 - mins) * 7) + 13;
to_frame_mins = GRect(50, y_pos, TM_SIZE, TM_SIZE);
}

//LEFT
if((mins >= 36) && (mins <= 54)) {
y_pos = ((54 - mins) * 7) + 13;
to_frame_mins = GRect(50, y_pos, TM_SIZE, TM_SIZE);
}
//BOTTOM
if((mins >= 25) && (mins <= 35)) {
x_pos = ((35 - mins) * 8) + 50;
to_frame_mins = GRect(x_pos, MIN_BOTTOM, TM_SIZE, TM_SIZE);
}

//BOTTOM
if((mins >= 25) && (mins <= 35)) {
x_pos = ((35 - mins) * 8) + 50;
to_frame_mins = GRect(x_pos, MIN_BOTTOM, TM_SIZE, TM_SIZE);
}
//TOP
if((mins >= 55) && (mins <= 65)) {
x_pos = ((mins - 55) * 8) + 50;
to_frame_mins = GRect(x_pos, 0, TM_SIZE, TM_SIZE);
}

//TOP
if((mins >= 55) && (mins <= 65)) {
x_pos = ((mins - 55) * 8) + 50;
to_frame_mins = GRect(x_pos, 0, TM_SIZE, TM_SIZE);
}
to_frame_hours = hour_pos[hours];

to_frame_hours = hour_pos[hours];
layer_set_frame((Layer *)text_layers[0], to_frame_mins);
layer_set_frame((Layer *)text_layers[1], to_frame_hours);
}

static void nextFrameLarge(int x_pos, int y_pos, int mins, int hours, GRect to_frame_mins, GRect to_frame_hours) {
//RIGHT
if((mins >= 6) && (mins <= 24)) {
y_pos = ((mins - 6) * 7) + 4;
to_frame_mins = GRect(MIN_LEFT-5, y_pos, TM_SIZE, TM_SIZE);
}

layer_set_frame((Layer *)text_layers[0], to_frame_mins);
//LEFT
if((mins >= 36) && (mins <= 54)) {
y_pos = ((54 - mins) * 7) + 4;
to_frame_mins = GRect(45, y_pos, TM_SIZE, TM_SIZE);
}

if(tick_time->tm_hour != current_hour) {
s_property_animation_1 = property_animation_create_layer_frame((Layer *)text_layers[1],
&from_frame_hours, &to_frame_hours);
animation_set_handlers((Animation*)s_property_animation_1, (AnimationHandlers) {
.stopped = anim_stopped_handler_1
}, NULL);
animation_schedule((Animation*) s_property_animation_1);
}
//BOTTOM
if((mins >= 25) && (mins <= 35)) {
x_pos = ((35 - mins) * 8) + 45;
to_frame_mins = GRect(x_pos, MIN_BOTTOM-10, TM_SIZE, TM_SIZE);
}
}

static void fill_hour_frames() {
hour_pos[0] = GRect(INNER_LEFT + 53, INNER_TOP, TH_SIZE_X, TH_SIZE_Y);
hour_pos[1] = GRect(INNER_RIGHT + 4, INNER_TOP, TH_SIZE_X, TH_SIZE_Y);
hour_pos[2] = GRect(INNER_RIGHT - 4, (INNER_BOTTOM / 4) + 8, TH_SIZE_X, TH_SIZE_Y);
hour_pos[3] = GRect(INNER_RIGHT - 5, (INNER_BOTTOM / 2) + 5, TH_SIZE_X, TH_SIZE_Y);
hour_pos[4] = GRect(INNER_RIGHT - 7, INNER_BOTTOM - 27, TH_SIZE_X, TH_SIZE_Y);
hour_pos[5] = GRect(INNER_RIGHT - 5, INNER_BOTTOM, TH_SIZE_X, TH_SIZE_Y);
hour_pos[6] = GRect(INNER_LEFT + 58, INNER_BOTTOM, TH_SIZE_X, TH_SIZE_Y);
hour_pos[7] = GRect(INNER_LEFT, INNER_BOTTOM, TH_SIZE_X, TH_SIZE_Y);
hour_pos[8] = GRect(INNER_LEFT - 1, INNER_BOTTOM - 27, TH_SIZE_X, TH_SIZE_Y);
hour_pos[9] = GRect(INNER_LEFT - 1, (INNER_BOTTOM / 2) + 5, TH_SIZE_X, TH_SIZE_Y);
hour_pos[10] = GRect(INNER_LEFT - 14, (INNER_BOTTOM / 4) + 8, TH_SIZE_X, TH_SIZE_Y);
hour_pos[11] = GRect(INNER_LEFT - 2, INNER_TOP, TH_SIZE_X, TH_SIZE_Y);
hour_pos[12] = GRect(INNER_LEFT + 53, INNER_TOP, TH_SIZE_X, TH_SIZE_Y);
}
//TOP
if((mins >= 55) && (mins <= 65)) {
x_pos = ((mins - 55) * 8) + 45;
to_frame_mins = GRect(x_pos, -8, TM_SIZE, TM_SIZE);
}

static void updateTimeLayers() {
text_layer_set_font(text_layers[0], fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
text_layer_set_text(text_layers[0], "");
text_layer_set_background_color(text_layers[0], GColorClear);
to_frame_hours = hour_pos[hours];

text_layer_set_font(text_layers[1], fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
text_layer_set_text(text_layers[1], "");
text_layer_set_background_color(text_layers[1], GColorClear);
layer_set_frame((Layer *)text_layers[0], to_frame_mins);
layer_set_frame((Layer *)text_layers[1], to_frame_hours);
}

if(strcmp(inverted_value, "invt") == 0) {
text_layer_set_text_color(text_layers[0], GColorBlack);
text_layer_set_text_color(text_layers[1], GColorBlack);
static void fill_hour_frames() {
if(font_size_value == 0) {
hour_pos[0] = GRect(INNER_LEFT + 53, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[1] = GRect(INNER_RIGHT + 4, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[2] = GRect(INNER_RIGHT - 4, (INNER_BOTTOM / 4) + 8, TM_SIZE, TM_SIZE);
hour_pos[3] = GRect(INNER_RIGHT - 5, (INNER_BOTTOM / 2) + 5, TM_SIZE, TM_SIZE);
hour_pos[4] = GRect(INNER_RIGHT - 7, INNER_BOTTOM - 27, TM_SIZE, TM_SIZE);
hour_pos[5] = GRect(INNER_RIGHT - 5, INNER_BOTTOM, TM_SIZE, TM_SIZE);
hour_pos[6] = GRect(INNER_LEFT + 58, INNER_BOTTOM, TM_SIZE, TM_SIZE);
hour_pos[7] = GRect(INNER_LEFT, INNER_BOTTOM, TM_SIZE, TM_SIZE);
hour_pos[8] = GRect(INNER_LEFT - 1, INNER_BOTTOM - 27, TM_SIZE, TM_SIZE);
hour_pos[9] = GRect(INNER_LEFT - 1, (INNER_BOTTOM / 2) + 5, TM_SIZE, TM_SIZE);
hour_pos[10] = GRect(INNER_LEFT - 14, (INNER_BOTTOM / 4) + 8, TM_SIZE, TM_SIZE);
hour_pos[11] = GRect(INNER_LEFT - 2, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[12] = GRect(INNER_LEFT + 53, INNER_TOP, TM_SIZE, TM_SIZE);
} else {
text_layer_set_text_color(text_layers[0], GColorWhite);
text_layer_set_text_color(text_layers[1], GColorWhite);
hour_pos[0] = GRect(INNER_LEFT + 53, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[1] = GRect(INNER_RIGHT - 1, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[2] = GRect(INNER_RIGHT - 9, (INNER_BOTTOM / 4) - 6, TM_SIZE, TM_SIZE);
hour_pos[3] = GRect(INNER_RIGHT - 10, (INNER_BOTTOM / 2) - 3, TM_SIZE, TM_SIZE);
hour_pos[4] = GRect(INNER_RIGHT - 12, INNER_BOTTOM - 41, TM_SIZE, TM_SIZE);
hour_pos[5] = GRect(INNER_RIGHT - 10, INNER_BOTTOM - 14, TM_SIZE, TM_SIZE);
hour_pos[6] = GRect(INNER_LEFT + 52, INNER_BOTTOM - 14, TM_SIZE, TM_SIZE);
hour_pos[7] = GRect(INNER_LEFT - 6, INNER_BOTTOM - 14, TM_SIZE, TM_SIZE);
hour_pos[8] = GRect(INNER_LEFT - 7, INNER_BOTTOM - 41, TM_SIZE, TM_SIZE);
hour_pos[9] = GRect(INNER_LEFT - 7, (INNER_BOTTOM / 2) - 3, TM_SIZE, TM_SIZE);
hour_pos[10] = GRect(INNER_LEFT - 20, (INNER_BOTTOM / 4) - 6, TM_SIZE, TM_SIZE);
hour_pos[11] = GRect(INNER_LEFT - 8, INNER_TOP, TM_SIZE, TM_SIZE);
hour_pos[12] = GRect(INNER_LEFT + 47, INNER_TOP, TM_SIZE, TM_SIZE);
}
}
Loading

0 comments on commit 5054a6d

Please sign in to comment.