1
0
Fork 0

Compare commits

...

5 Commits
v1.1 ... master

Author SHA1 Message Date
Tomek Wójcik 3d6ac239ac Fixes the version number.
I should go to bed...
2015-08-27 23:22:22 +01:00
Tomek Wójcik 37192882ab Fixes config URL. 2015-08-27 23:19:15 +01:00
Tomek Wójcik 5ce403f650 Closes #2 2015-08-27 22:52:47 +01:00
Tomek Wójcik 4f3362d765 Fixes AM/PM indicator. 2015-08-27 22:16:48 +01:00
Tomek Wójcik cd213650e1 Closes #1 - wide layout. 2015-08-27 20:28:16 +01:00
11 changed files with 143 additions and 22 deletions

BIN
GFX/IntuiClock.psd Normal file

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@
"shortName": null,
"longName": null,
"companyName": null,
"versionLabel": null,
"versionLabel": "1.2",
"sdkVersion": "3",
"targetPlatforms": ["basalt"],
"watchapp": {
@ -13,8 +13,28 @@
"media": [
{
"type": "png",
"name": "IMG_BACKGROUND",
"file": "background.png"
"name": "IMG_BKG_CLASSIC_NARROW",
"file": "bkg_classic_narrow.png"
},
{
"type": "png",
"name": "IMG_BKG_CLASSIC_WIDE",
"file": "bkg_classic_wide.png"
},
{
"type": "png",
"name": "IMG_BKG_XEN_NARROW",
"file": "bkg_xen_narrow.png"
},
{
"type": "png",
"name": "IMG_BKG_XEN_WIDE",
"file": "bkg_xen_wide.png"
},
{
"type": "png",
"name": "IMG_BACKGROUND_WIDE",
"file": "background_wide.png"
},
{
"type": "png",
@ -34,6 +54,8 @@
"appKeys": {
"KEY_SECONDS_HAND": 0,
"KEY_BATTERY_INDICATOR": 1,
"KEY_DATE_FORMAT": 2
"KEY_DATE_FORMAT": 2,
"KEY_WIDE_LAYOUT": 3,
"KEY_XEN_STYLE": 4
}
}

View File

@ -11,16 +11,12 @@
<body>
<form id="main-form">
<div class="item-container">
<div class="item-container-header">Features</div>
<div class="item-container-header">Time &amp; Date</div>
<div class="item-container-content">
<label class="item">
Seconds Hand
<input id="input-seconds-hand" type="checkbox" class="item-toggle" name="seconds-hand" checked>
</label>
<label class="item">
Battery Indicator
<input id="input-battery-indicator" type="checkbox" class="item-toggle" name="battery-indicator" checked>
</label>
<label class="item">
Date Format
<select id="input-date-format" name="date-format" class="item-select">
@ -33,6 +29,24 @@
<div class="item-container-footer">Disable the seconds hand to reduce battery use.</div>
</div>
<div class="item-container">
<div class="item-container-header">Appearance</div>
<div class="item-container-content">
<label class="item">
Battery Indicator
<input id="input-battery-indicator" type="checkbox" class="item-toggle" name="battery-indicator" checked>
</label>
<label class="item">
Wide Window
<input id="input-wide-layout" type="checkbox" class="item-toggle" name="wide-layout">
</label>
<label class="item">
XEN Style
<input id="input-xen-style" type="checkbox" class="item-toggle" name="xen-style">
</label>
</div>
</div>
<div class="item-container">
<div class="button-container">
<input id="button-submit" type="button" class="item-button" value="SAVE">
@ -45,20 +59,26 @@
function getConfigData() {
var input_seconds_hand = document.getElementById('input-seconds-hand'),
input_battery_indicator = document.getElementById('input-battery-indicator'),
input_date_format = document.getElementById('input-date-format');
input_date_format = document.getElementById('input-date-format'),
input_wide_layout = document.getElementById('input-wide-layout'),
input_xen_style = document.getElementById('input-xen-style');
var options = {
'seconds_hand': input_seconds_hand.checked,
'battery_indicator': input_battery_indicator.checked,
'date_format': input_date_format.value
'date_format': input_date_format.value,
'wide_layout': input_wide_layout.checked,
'xen_style': input_xen_style.checked
};
// Save for next launch
localStorage['seconds_hand'] = options['seconds_hand'];
localStorage['battery_indicator'] = options['battery_indicator'];
localStorage['date_format'] = options['date_format'];
localStorage['wide_layout'] = options['wide_layout'];
localStorage['xen_style'] = options['xen_style'];
console.log('Got options: ' + JSON.stringify(options));
// console.log('Got options: ' + JSON.stringify(options));
return options;
}
@ -78,7 +98,7 @@
var button_submit = document.getElementById('button-submit');
button_submit.addEventListener('click', function() {
console.log('Submit');
// console.log('Submit');
// Set the return URL depending on the runtime environment
var return_to = getQueryParam('return_to', 'pebblejs://close#');
@ -88,7 +108,9 @@
(function() {
var input_seconds_hand = document.getElementById('input-seconds-hand'),
input_battery_indicator = document.getElementById('input-battery-indicator'),
input_date_format = document.getElementById('input-date-format');
input_date_format = document.getElementById('input-date-format'),
input_wide_layout = document.getElementById('input-wide-layout'),
input_xen_style = document.getElementById('input-xen-style');
if (localStorage['seconds_hand']) {
input_seconds_hand.checked = JSON.parse(localStorage['seconds_hand']);
@ -101,6 +123,14 @@
if (localStorage['date_format']) {
input_date_format.value = localStorage['date_format'];
}
if (localStorage['wide_layout']) {
input_wide_layout.checked = JSON.parse(localStorage['wide_layout']);
}
if (localStorage['xen_style']) {
input_xen_style.checked = JSON.parse(localStorage['xen_style']);
}
})();
</script>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
resources/bkg_xen_wide.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -39,6 +39,8 @@ static uint8_t battery_charge = 0;
static bool hide_seconds_hand = false;
static bool hide_battery_indicator = false;
static char date_format[2];
static bool use_wide_layout = false;
static bool use_xen_style = false;
static const GPathInfo MINUTE_HAND_POINTS = {
4,
@ -69,6 +71,8 @@ static const GPathInfo HOUR_HAND_POINTS = {
#define KEY_SECONDS_HAND 0
#define KEY_BATTERY_INDICATOR 1
#define KEY_DATE_FORMAT 2
#define KEY_WIDE_LAYOUT 3
#define KEY_XEN_STYLE 4
static void update_date_text_layer() {
static char date_text[DATE_TEXT_SIZE];
@ -102,6 +106,8 @@ static void update_ampm_text_layer() {
text_layer_set_text(s_ampm_layer, DUMMY_AMPM_TEXT);
}
}
text_layer_set_text(s_ampm_layer, ampm_text);
}
static void tick_handler(struct tm *tick_time, TimeUnits changed_units) {
@ -195,6 +201,40 @@ static void start_battery_tracking() {
layer_set_hidden(s_battery_indicator_layer, hide_battery_indicator);
}
static void update_geometry() {
if (s_background_bitmap) {
gbitmap_destroy(s_background_bitmap);
}
if (use_wide_layout == false) {
if (use_xen_style == false) {
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_CLASSIC_NARROW);
} else {
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_XEN_NARROW);
}
layer_set_frame(text_layer_get_layer(s_title_layer), GRect(36, 2, 46, 18));
layer_set_frame(text_layer_get_layer(s_date_layer), GRect(17, 130, 109, 16));
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(108, 26, 16, 16));
layer_set_frame(bitmap_layer_get_layer(s_battery_icon_layer), GRect(20, 26, 16, 7));
layer_set_frame(s_battery_indicator_layer, GRect(21, 27, 13, 5));
} else {
if (use_xen_style == false) {
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_CLASSIC_WIDE);
} else {
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BKG_XEN_WIDE);
}
layer_set_frame(text_layer_get_layer(s_title_layer), GRect(24, 2, 71, 18));
layer_set_frame(text_layer_get_layer(s_date_layer), GRect(4, 130, 136, 16));
layer_set_frame(text_layer_get_layer(s_ampm_layer), GRect(123, 25, 16, 16));
layer_set_frame(bitmap_layer_get_layer(s_battery_icon_layer), GRect(7, 26, 16, 7));
layer_set_frame(s_battery_indicator_layer, GRect(8, 27, 13, 5));
}
bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
}
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
// Handling seconds_hand setting.
Tuple *seconds_hand_t = dict_find(iter, KEY_SECONDS_HAND);
@ -226,11 +266,33 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
persist_write_string(KEY_DATE_FORMAT, date_format);
update_date_text_layer();
// Handling wide_layout setting.
Tuple *wide_layout_t = dict_find(iter, KEY_WIDE_LAYOUT);
if (wide_layout_t && wide_layout_t->value->int32 > 0) {
use_wide_layout = true;
} else {
use_wide_layout = false;
}
persist_write_bool(KEY_WIDE_LAYOUT, use_wide_layout);
// Handling xen_style setting.
Tuple *xen_style_t = dict_find(iter, KEY_XEN_STYLE);
if (xen_style_t && xen_style_t->value->int32 > 0) {
use_xen_style = true;
} else {
use_xen_style = false;
}
persist_write_bool(KEY_XEN_STYLE, use_xen_style);
// Updating geometry according to settings.
update_geometry();
}
static void main_window_load(Window *window) {
// Loading resources.
s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BACKGROUND);
s_battery_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMG_BATTERY);
s_text_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TOPAZ_16));
@ -243,12 +305,11 @@ static void main_window_load(Window *window) {
// Creating background image layer.
s_background_layer = bitmap_layer_create(bounds);
bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
bitmap_layer_set_compositing_mode(s_background_layer, GCompOpSet);
layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer));
// Creating title text layer.
s_title_layer = text_layer_create(GRect(36, 2, 46, 18));
s_title_layer = text_layer_create(GRect(0, 0, 71, 18));
text_layer_set_background_color(s_title_layer, GColorClear);
text_layer_set_text(s_title_layer, "Clock");
text_layer_set_font(s_title_layer, s_text_font);
@ -260,14 +321,14 @@ static void main_window_load(Window *window) {
layer_add_child(window_layer, s_hands_layer);
// Creating date layer.
s_date_layer = text_layer_create(GRect(17, 130, 109, 16));
s_date_layer = text_layer_create(GRect(0, 0, 136, 16));
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
text_layer_set_background_color(s_date_layer, GColorClear);
text_layer_set_font(s_date_layer, s_text_font);
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
// Creating AM/PM layer.
s_ampm_layer = text_layer_create(GRect(107, 26, 16, 16));
s_ampm_layer = text_layer_create(GRect(0, 0, 16, 16));
text_layer_set_text_alignment(s_ampm_layer, GTextAlignmentCenter);
text_layer_set_background_color(s_ampm_layer, GColorClear);
text_layer_set_text_color(s_ampm_layer, GColorWhite);
@ -275,16 +336,21 @@ static void main_window_load(Window *window) {
layer_add_child(window_layer, text_layer_get_layer(s_ampm_layer));
// Creating battery icon layer.
s_battery_icon_layer = bitmap_layer_create(GRect(20, 26, 16, 7));
s_battery_icon_layer = bitmap_layer_create(GRect(0, 0, 16, 7));
bitmap_layer_set_bitmap(s_battery_icon_layer, s_battery_bitmap);
bitmap_layer_set_compositing_mode(s_battery_icon_layer, GCompOpSet);
layer_add_child(window_layer, bitmap_layer_get_layer(s_battery_icon_layer));
// Creating battery indicator layer.
s_battery_indicator_layer = layer_create(GRect(21, 27, 13, 5));
s_battery_indicator_layer = layer_create(GRect(0, 0, 13, 5));
layer_set_update_proc(s_battery_indicator_layer, s_battery_indicator_layer_update);
layer_add_child(window_layer, s_battery_indicator_layer);
// Update geometry according to wide_layout and xen_style settings.
use_wide_layout = persist_read_bool(KEY_WIDE_LAYOUT);
use_xen_style = persist_read_bool(KEY_XEN_STYLE);
update_geometry();
// Read date_format setting from persistent storage.
int result = persist_read_string(KEY_DATE_FORMAT, date_format, 2);
if (result == E_DOES_NOT_EXIST) {

View File

@ -24,17 +24,20 @@
// });
Pebble.addEventListener('showConfiguration', function(e) {
//Pebble.openURL('http://192.168.1.113/u/bilbo/pebble/iclock/index.html');
Pebble.openURL('https://pconf.bthlabs.pl/intuiclock/index.html');
});
Pebble.addEventListener('webviewclosed', function(e) {
var config_data = JSON.parse(decodeURIComponent(e.response));
// console.log('Configuration page returned: ' + JSON.stringify(config_data));
console.log('Configuration page returned: ' + JSON.stringify(config_data));
var dict = {};
dict['KEY_SECONDS_HAND'] = config_data['seconds_hand'];
dict['KEY_BATTERY_INDICATOR'] = config_data['battery_indicator'];
dict['KEY_DATE_FORMAT'] = config_data['date_format'];
dict['KEY_WIDE_LAYOUT'] = config_data['wide_layout'];
dict['KEY_XEN_STYLE'] = config_data['xen_style'];
Pebble.sendAppMessage(dict, function() {
// console.log('Send successful!');