mirror of
https://github.com/alinanorakari/Pebble-Time-Watchface-Super-Simple.git
synced 2025-12-14 15:45:22 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c34c5e9b4c | |||
| c9d52de376 | |||
| 6d69c296d9 | |||
| f616ae6dd2 | |||
| 99e43e6502 | |||
| 99b0cdeee6 | |||
| aff6eaa6c0 |
@@ -1 +1 @@
|
|||||||
# Pebble-Time-Watchface---Super-Simple
|
# “Super Simple” watchface for Pebble Time Round and Pebble Time
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"appKeys": {},
|
"appKeys": {
|
||||||
|
"colorbg": 0,
|
||||||
|
"colorh": 2,
|
||||||
|
"colorm": 1,
|
||||||
|
"colorp": 3
|
||||||
|
},
|
||||||
"capabilities": [
|
"capabilities": [
|
||||||
"configurable"
|
"configurable"
|
||||||
],
|
],
|
||||||
|
|||||||
BIN
assets/basalt/screenshot.afphoto
Normal file
BIN
assets/basalt/screenshot.afphoto
Normal file
Binary file not shown.
BIN
assets/basalt/screenshot.png
Normal file
BIN
assets/basalt/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/chalk/screenshot.afphoto
Normal file
BIN
assets/chalk/screenshot.afphoto
Normal file
Binary file not shown.
BIN
assets/chalk/screenshot.png
Normal file
BIN
assets/chalk/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
1
config/css/slate.min.css
vendored
Executable file
1
config/css/slate.min.css
vendored
Executable file
File diff suppressed because one or more lines are too long
BIN
config/fonts/PFDinDisplayPro-Light.woff
Executable file
BIN
config/fonts/PFDinDisplayPro-Light.woff
Executable file
Binary file not shown.
BIN
config/fonts/ptsans-regular.woff
Executable file
BIN
config/fonts/ptsans-regular.woff
Executable file
Binary file not shown.
40
config/index.html
Normal file
40
config/index.html
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Super Simple Settings</title>
|
||||||
|
<link rel="stylesheet" href="css/slate.min.css">
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="item-container">
|
||||||
|
<div class="item-container-header">Color settings</div>
|
||||||
|
<div class="item-container-content">
|
||||||
|
<label class="item">
|
||||||
|
Background
|
||||||
|
<input id="color-bg" type="text" class="item-color item-color-normal" value="#000000">
|
||||||
|
</label>
|
||||||
|
<label class="item">
|
||||||
|
Minute Hand
|
||||||
|
<input id="color-m" type="text" class="item-color item-color-normal" value="#ffffff">
|
||||||
|
</label>
|
||||||
|
<label class="item">
|
||||||
|
Hour Hand
|
||||||
|
<input id="color-h" type="text" class="item-color item-color-normal" value="#ff0000">
|
||||||
|
</label>
|
||||||
|
<label class="item">
|
||||||
|
Center Peg
|
||||||
|
<input id="color-p" type="text" class="item-color item-color-normal" value="#555555">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item-container">
|
||||||
|
<div class="button-container">
|
||||||
|
<input id="send" type="button" class="item-button" value="SEND">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="js/slate.min.js"></script>
|
||||||
|
<script src="js/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
63
config/js/main.js
Normal file
63
config/js/main.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
(function() {
|
||||||
|
loadOptions();
|
||||||
|
submitHandler();
|
||||||
|
})();
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
var $submitButton = $('#send');
|
||||||
|
|
||||||
|
$submitButton.on('click', function() {
|
||||||
|
console.log('Submit');
|
||||||
|
|
||||||
|
var return_to = getQueryParam('return_to', 'pebblejs://close#');
|
||||||
|
document.location = return_to + encodeURIComponent(JSON.stringify(getAndStoreConfigData()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadOptions() {
|
||||||
|
var $colorbg = $('#color-bg');
|
||||||
|
var $colorm = $('#color-m');
|
||||||
|
var $colorh = $('#color-h');
|
||||||
|
var $colorp = $('#color-p');
|
||||||
|
|
||||||
|
if (localStorage.colorbg) {
|
||||||
|
$colorbg[0].value = localStorage.colorbg;
|
||||||
|
$colorm[0].value = localStorage.colorm;
|
||||||
|
$colorh[0].value = localStorage.colorh;
|
||||||
|
$colorp[0].value = localStorage.colorp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAndStoreConfigData() {
|
||||||
|
var $colorbg = $('#color-bg');
|
||||||
|
var $colorm = $('#color-m');
|
||||||
|
var $colorh = $('#color-h');
|
||||||
|
var $colorp = $('#color-p');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
colorbg: $colorbg.val(),
|
||||||
|
colorm: $colorm.val(),
|
||||||
|
colorh: $colorh.val(),
|
||||||
|
colorp: $colorp.val(),
|
||||||
|
};
|
||||||
|
|
||||||
|
localStorage.colorbg = options.colorbg;
|
||||||
|
localStorage.colorm = options.colorm;
|
||||||
|
localStorage.colorh = options.colorh;
|
||||||
|
localStorage.colorp = options.colorp;
|
||||||
|
|
||||||
|
console.log('Got options: ' + JSON.stringify(options));
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getQueryParam(variable, defaultValue) {
|
||||||
|
var query = location.search.substring(1);
|
||||||
|
var vars = query.split('&');
|
||||||
|
for (var i = 0; i < vars.length; i++) {
|
||||||
|
var pair = vars[i].split('=');
|
||||||
|
if (pair[0] === variable) {
|
||||||
|
return decodeURIComponent(pair[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue || false;
|
||||||
|
}
|
||||||
2
config/js/slate.min.js
vendored
Executable file
2
config/js/slate.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
26
src/js/pebble-js-app.js
Normal file
26
src/js/pebble-js-app.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Pebble.addEventListener('ready', function() {
|
||||||
|
console.log('PebbleKit JS ready!');
|
||||||
|
});
|
||||||
|
|
||||||
|
Pebble.addEventListener('showConfiguration', function() {
|
||||||
|
var url='http://pebble.lastfuture.de/config/supersimple/';
|
||||||
|
console.log('Showing configuration page: '+url);
|
||||||
|
Pebble.openURL(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
Pebble.addEventListener('webviewclosed', function(e) {
|
||||||
|
var configData = JSON.parse(decodeURIComponent(e.response));
|
||||||
|
console.log('Configuration page returned: '+JSON.stringify(configData));
|
||||||
|
if (configData.colorbg) {
|
||||||
|
Pebble.sendAppMessage({
|
||||||
|
colorbg: parseInt(configData.colorbg, 16),
|
||||||
|
colorm: parseInt(configData.colorm, 16),
|
||||||
|
colorh: parseInt(configData.colorh, 16),
|
||||||
|
colorp: parseInt(configData.colorp, 16)
|
||||||
|
}, function() {
|
||||||
|
console.log('Send successful!');
|
||||||
|
}, function() {
|
||||||
|
console.log('Send failed!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
77
src/main.c
77
src/main.c
@@ -1,9 +1,9 @@
|
|||||||
#include <pebble.h>
|
#include <pebble.h>
|
||||||
|
|
||||||
#define MINUTE_COLOR GColorWhite
|
#define KEY_BG_COLOR 0
|
||||||
#define HOUR_COLOR GColorRed
|
#define KEY_MINUTE_COLOR 1
|
||||||
#define PEG_COLOR GColorDarkGray
|
#define KEY_HOUR_COLOR 2
|
||||||
#define BG_COLOR GColorBlack
|
#define KEY_PEG_COLOR 3
|
||||||
|
|
||||||
|
|
||||||
#define ANTIALIASING true
|
#define ANTIALIASING true
|
||||||
@@ -31,6 +31,39 @@ static int s_radius = 0;
|
|||||||
static bool s_animating = false;
|
static bool s_animating = false;
|
||||||
static float anim_offset;
|
static float anim_offset;
|
||||||
|
|
||||||
|
static GColor gcolorbg, gcolorm, gcolorh, gcolorp;
|
||||||
|
|
||||||
|
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
|
Tuple *colorbg_t = dict_find(iter, KEY_BG_COLOR);
|
||||||
|
Tuple *colorm_t = dict_find(iter, KEY_MINUTE_COLOR);
|
||||||
|
Tuple *colorh_t = dict_find(iter, KEY_HOUR_COLOR);
|
||||||
|
Tuple *colorp_t = dict_find(iter, KEY_PEG_COLOR);
|
||||||
|
|
||||||
|
if(colorbg_t) {
|
||||||
|
int colorbg = colorbg_t->value->int32;
|
||||||
|
persist_write_int(KEY_BG_COLOR, colorbg);
|
||||||
|
gcolorbg = GColorFromHEX(colorbg);
|
||||||
|
}
|
||||||
|
if(colorm_t) {
|
||||||
|
int colorm = colorm_t->value->int32;
|
||||||
|
persist_write_int(KEY_MINUTE_COLOR, colorm);
|
||||||
|
gcolorm = GColorFromHEX(colorm);
|
||||||
|
}
|
||||||
|
if(colorh_t) {
|
||||||
|
int colorh = colorh_t->value->int32;
|
||||||
|
persist_write_int(KEY_HOUR_COLOR, colorh);
|
||||||
|
gcolorh = GColorFromHEX(colorh);
|
||||||
|
}
|
||||||
|
if(colorp_t) {
|
||||||
|
int colorp = colorp_t->value->int32;
|
||||||
|
persist_write_int(KEY_PEG_COLOR, colorp);
|
||||||
|
gcolorp = GColorFromHEX(colorp);
|
||||||
|
}
|
||||||
|
if(s_canvas_layer) {
|
||||||
|
layer_mark_dirty(s_canvas_layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************** AnimationImplementation **************************/
|
/*************************** AnimationImplementation **************************/
|
||||||
|
|
||||||
static void animation_started(Animation *anim, void *context) {
|
static void animation_started(Animation *anim, void *context) {
|
||||||
@@ -73,7 +106,7 @@ static void tick_handler(struct tm *tick_time, TimeUnits changed) {
|
|||||||
static void update_proc(Layer *layer, GContext *ctx) {
|
static void update_proc(Layer *layer, GContext *ctx) {
|
||||||
// Color background?
|
// Color background?
|
||||||
GRect bounds = layer_get_bounds(layer);
|
GRect bounds = layer_get_bounds(layer);
|
||||||
graphics_context_set_fill_color(ctx, BG_COLOR);
|
graphics_context_set_fill_color(ctx, gcolorbg);
|
||||||
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
|
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
|
||||||
graphics_context_set_antialiased(ctx, ANTIALIASING);
|
graphics_context_set_antialiased(ctx, ANTIALIASING);
|
||||||
|
|
||||||
@@ -109,17 +142,17 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
|||||||
// Draw hands with positive length only
|
// Draw hands with positive length only
|
||||||
if((s_radius - HAND_MARGIN_OUTER) > HAND_MARGIN_INNER) {
|
if((s_radius - HAND_MARGIN_OUTER) > HAND_MARGIN_INNER) {
|
||||||
if(s_radius > 2 * HAND_MARGIN_OUTER) {
|
if(s_radius > 2 * HAND_MARGIN_OUTER) {
|
||||||
graphics_context_set_stroke_color(ctx, HOUR_COLOR);
|
graphics_context_set_stroke_color(ctx, gcolorh);
|
||||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||||
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
||||||
}
|
}
|
||||||
if(s_radius > HAND_MARGIN_OUTER) {
|
if(s_radius > HAND_MARGIN_OUTER) {
|
||||||
graphics_context_set_stroke_color(ctx, MINUTE_COLOR);
|
graphics_context_set_stroke_color(ctx, gcolorm);
|
||||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||||
graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer);
|
graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
graphics_context_set_fill_color(ctx, PEG_COLOR);
|
graphics_context_set_fill_color(ctx, gcolorp);
|
||||||
graphics_fill_circle(ctx, s_center, DOT_RADIUS);
|
graphics_fill_circle(ctx, s_center, DOT_RADIUS);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -129,6 +162,31 @@ static void window_load(Window *window) {
|
|||||||
GRect window_bounds = layer_get_bounds(window_layer);
|
GRect window_bounds = layer_get_bounds(window_layer);
|
||||||
|
|
||||||
s_center = grect_center_point(&window_bounds);
|
s_center = grect_center_point(&window_bounds);
|
||||||
|
|
||||||
|
if (persist_read_int(KEY_BG_COLOR)) {
|
||||||
|
int colorbg = persist_read_int(KEY_BG_COLOR);
|
||||||
|
gcolorbg = GColorFromHEX(colorbg);
|
||||||
|
} else {
|
||||||
|
gcolorbg=GColorBlack;
|
||||||
|
}
|
||||||
|
if (persist_read_int(KEY_MINUTE_COLOR)) {
|
||||||
|
int colorm = persist_read_int(KEY_MINUTE_COLOR);
|
||||||
|
gcolorm = GColorFromHEX(colorm);
|
||||||
|
} else {
|
||||||
|
gcolorm=GColorWhite;
|
||||||
|
}
|
||||||
|
if (persist_read_int(KEY_HOUR_COLOR)) {
|
||||||
|
int colorh = persist_read_int(KEY_HOUR_COLOR);
|
||||||
|
gcolorh = GColorFromHEX(colorh);
|
||||||
|
} else {
|
||||||
|
gcolorh=GColorRed;
|
||||||
|
}
|
||||||
|
if (persist_read_int(KEY_PEG_COLOR)) {
|
||||||
|
int colorp = persist_read_int(KEY_PEG_COLOR);
|
||||||
|
gcolorp = GColorFromHEX(colorp);
|
||||||
|
} else {
|
||||||
|
gcolorp=GColorDarkGray;
|
||||||
|
}
|
||||||
|
|
||||||
s_canvas_layer = layer_create(window_bounds);
|
s_canvas_layer = layer_create(window_bounds);
|
||||||
layer_set_update_proc(s_canvas_layer, update_proc);
|
layer_set_update_proc(s_canvas_layer, update_proc);
|
||||||
@@ -165,6 +223,9 @@ static void init() {
|
|||||||
window_stack_push(s_main_window, true);
|
window_stack_push(s_main_window, true);
|
||||||
|
|
||||||
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
|
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
|
||||||
|
|
||||||
|
app_message_register_inbox_received(inbox_received_handler);
|
||||||
|
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
|
||||||
|
|
||||||
// Prepare animations
|
// Prepare animations
|
||||||
AnimationImplementation radius_impl = {
|
AnimationImplementation radius_impl = {
|
||||||
|
|||||||
Reference in New Issue
Block a user