Add date
This commit is contained in:
@@ -5,7 +5,7 @@ Since the original watchface is **NOT** open source, this port could be more acc
|
|||||||
|
|
||||||
# Differences From The Original
|
# Differences From The Original
|
||||||
- Re-scaled to look better on the larger displays of the Pebble Time/Round 2
|
- Re-scaled to look better on the larger displays of the Pebble Time/Round 2
|
||||||
- Some of the extra screen space is used to display the date, the battery level, and bluetooth status
|
- Some of the extra screen space is used to display the date and bluetooth status
|
||||||
- Original creature part modifications (for the pre-compiled version available on the Rebble app store)
|
- Original creature part modifications (for the pre-compiled version available on the Rebble app store)
|
||||||
- Some creature parts that resulted in broken-looking creatures were overhauled
|
- Some creature parts that resulted in broken-looking creatures were overhauled
|
||||||
- Any creature parts that previously had cut-off details to fit on the smaller display have been extended
|
- Any creature parts that previously had cut-off details to fit on the smaller display have been extended
|
||||||
|
|||||||
19
src/c/main.c
19
src/c/main.c
@@ -5,6 +5,7 @@
|
|||||||
static Window *s_main_window;
|
static Window *s_main_window;
|
||||||
static GFont s_custom_font;
|
static GFont s_custom_font;
|
||||||
static TextLayer *s_time_layer;
|
static TextLayer *s_time_layer;
|
||||||
|
static TextLayer *s_date_layer;
|
||||||
static BitmapLayer *s_guy_head_layer;
|
static BitmapLayer *s_guy_head_layer;
|
||||||
static BitmapLayer *s_guy_butt_layer;
|
static BitmapLayer *s_guy_butt_layer;
|
||||||
|
|
||||||
@@ -58,12 +59,16 @@ static void update_minute_1() {
|
|||||||
time_t temp = time(NULL);
|
time_t temp = time(NULL);
|
||||||
struct tm *tick_time = localtime(&temp);
|
struct tm *tick_time = localtime(&temp);
|
||||||
|
|
||||||
// write the current hours and minutes into a buffer
|
// write the current hours and minutes into a buffer & format
|
||||||
static char s_time_buffer[8];
|
static char s_time_buffer[8];
|
||||||
strftime(s_time_buffer, sizeof(s_time_buffer), clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
|
strftime(s_time_buffer, sizeof(s_time_buffer), clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
|
||||||
|
|
||||||
// display this time on the TextLayer
|
// write the current date into a buffer & format
|
||||||
|
static char s_date_buffer[16];
|
||||||
|
strftime(s_date_buffer, sizeof(s_date_buffer), "%m/%d", tick_time);
|
||||||
|
|
||||||
text_layer_set_text(s_time_layer, s_time_buffer);
|
text_layer_set_text(s_time_layer, s_time_buffer);
|
||||||
|
text_layer_set_text(s_date_layer, s_date_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_minute_30() {
|
static void update_minute_30() {
|
||||||
@@ -120,16 +125,23 @@ static void main_window_load(Window *window) {
|
|||||||
bitmap_layer_set_background_color(s_guy_butt_layer, GColorBlack);
|
bitmap_layer_set_background_color(s_guy_butt_layer, GColorBlack);
|
||||||
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt_current);
|
bitmap_layer_set_bitmap(s_guy_butt_layer, s_butt_current);
|
||||||
|
|
||||||
// set up info layers
|
// format time layer
|
||||||
s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(110, 94), PBL_IF_ROUND_ELSE(260, 200), 32));
|
s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(110, 94), PBL_IF_ROUND_ELSE(260, 200), 32));
|
||||||
text_layer_set_background_color(s_time_layer, GColorClear);
|
text_layer_set_background_color(s_time_layer, GColorClear);
|
||||||
text_layer_set_font(s_time_layer, s_custom_font);
|
text_layer_set_font(s_time_layer, s_custom_font);
|
||||||
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
|
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
|
||||||
|
|
||||||
|
// format date layer
|
||||||
|
s_date_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(22, 8), PBL_IF_ROUND_ELSE(120, 104), PBL_IF_ROUND_ELSE(260, 200), 14));
|
||||||
|
text_layer_set_background_color(s_date_layer, GColorClear);
|
||||||
|
text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
|
||||||
|
text_layer_set_text_alignment(s_date_layer, GTextAlignmentLeft);
|
||||||
|
|
||||||
// add layers as children to window
|
// add layers as children to window
|
||||||
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_head_layer));
|
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_head_layer));
|
||||||
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_butt_layer));
|
layer_add_child(window_layer, bitmap_layer_get_layer(s_guy_butt_layer));
|
||||||
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
|
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
|
||||||
|
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// free memory on Window close;
|
// free memory on Window close;
|
||||||
@@ -138,6 +150,7 @@ static void main_window_unload(Window *window) {
|
|||||||
bitmap_layer_destroy(s_guy_head_layer);
|
bitmap_layer_destroy(s_guy_head_layer);
|
||||||
bitmap_layer_destroy(s_guy_butt_layer);
|
bitmap_layer_destroy(s_guy_butt_layer);
|
||||||
text_layer_destroy(s_time_layer);
|
text_layer_destroy(s_time_layer);
|
||||||
|
text_layer_destroy(s_date_layer);
|
||||||
fonts_unload_custom_font(s_custom_font);
|
fonts_unload_custom_font(s_custom_font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user