mirror of
https://github.com/alinanorakari/Pebble-Time-Watchface-Super-Simple.git
synced 2025-12-14 07:35:21 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6d3c9c3f5 | |||
| e7c01919d4 | |||
| e3216b3352 | |||
| 2604a8d3ae | |||
| d0fa7bc990 | |||
| f032dc6488 | |||
| a27ed69547 | |||
| ff15d72028 | |||
| 5296df4453 | |||
| e1511925f8 | |||
| d93e38187a | |||
| 55d64b8f9c |
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
assets
|
||||
config
|
||||
bin
|
||||
|
||||
# Created by https://www.gitignore.io/api/osx
|
||||
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
@@ -3,7 +3,8 @@
|
||||
"colorbg": 0,
|
||||
"colorh": 2,
|
||||
"colorm": 1,
|
||||
"colorp": 3
|
||||
"colorp": 3,
|
||||
"shadows": 4
|
||||
},
|
||||
"capabilities": [
|
||||
"configurable"
|
||||
@@ -21,7 +22,7 @@
|
||||
"chalk"
|
||||
],
|
||||
"uuid": "ceeae81b-6b50-43b6-8bbb-6d6f6eb62b69",
|
||||
"versionLabel": "0.9",
|
||||
"versionLabel": "1.2",
|
||||
"watchapp": {
|
||||
"watchface": true
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 4.6 KiB |
1
config/css/slate.min.css
vendored
1
config/css/slate.min.css
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -1,40 +0,0 @@
|
||||
<!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>
|
||||
@@ -1,63 +0,0 @@
|
||||
(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
2
config/js/slate.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@ Pebble.addEventListener('ready', function() {
|
||||
});
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function() {
|
||||
var url='http://pebble.lastfuture.de/config/supersimple/';
|
||||
var url='http://pebble.lastfuture.de/config/supersimple12/';
|
||||
console.log('Showing configuration page: '+url);
|
||||
Pebble.openURL(url);
|
||||
});
|
||||
@@ -16,7 +16,8 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||
colorbg: parseInt(configData.colorbg, 16),
|
||||
colorm: parseInt(configData.colorm, 16),
|
||||
colorh: parseInt(configData.colorh, 16),
|
||||
colorp: parseInt(configData.colorp, 16)
|
||||
colorp: parseInt(configData.colorp, 16),
|
||||
shadows: configData.shadows === true
|
||||
}, function() {
|
||||
console.log('Send successful!');
|
||||
}, function() {
|
||||
|
||||
79
src/main.c
79
src/main.c
@@ -4,6 +4,7 @@
|
||||
#define KEY_MINUTE_COLOR 1
|
||||
#define KEY_HOUR_COLOR 2
|
||||
#define KEY_PEG_COLOR 3
|
||||
#define KEY_SHADOWS 4
|
||||
|
||||
|
||||
#define ANTIALIASING true
|
||||
@@ -13,10 +14,31 @@
|
||||
#define DOT_RADIUS HAND_WIDTH/4
|
||||
#define HAND_MARGIN_OUTER 10-(HAND_WIDTH/2)
|
||||
#define HAND_MARGIN_INNER 0
|
||||
#define SHADOW_OFFSET 2
|
||||
|
||||
#define ANIMATION_DURATION 600
|
||||
#define ANIMATION_DELAY 150
|
||||
|
||||
static uint8_t shadowtable[] = {192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
||||
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
||||
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
||||
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
||||
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
||||
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
||||
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
||||
208,208,208,209,208,208,208,209,208,208,208,209,212,212,212,213, \
|
||||
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
|
||||
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
|
||||
208,208,209,210,208,208,209,210,212,212,213,214,216,216,217,218, \
|
||||
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234, \
|
||||
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, \
|
||||
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, \
|
||||
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, \
|
||||
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};
|
||||
|
||||
// alpha should only be 0b??111111 where ?? = 00 (full shade), 01 (much shade), 10 (some shade), 11 (none shade)
|
||||
static uint8_t alpha = 0b10111111;
|
||||
|
||||
typedef struct {
|
||||
int hours;
|
||||
int minutes;
|
||||
@@ -28,21 +50,23 @@ static Layer *s_canvas_layer;
|
||||
static GPoint s_center;
|
||||
static Time s_last_time;
|
||||
static int s_radius = 0;
|
||||
static bool s_animating = false;
|
||||
static bool s_animating = false, shadows = false;
|
||||
static float anim_offset;
|
||||
|
||||
static GColor gcolorbg, gcolorm, gcolorh, gcolorp;
|
||||
static GColor gcolorbg, gcolorm, gcolorh, gcolorp, gcolorshadow;
|
||||
|
||||
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);
|
||||
Tuple *shadows_t = dict_find(iter, KEY_SHADOWS);
|
||||
|
||||
if(colorbg_t) {
|
||||
int colorbg = colorbg_t->value->int32;
|
||||
persist_write_int(KEY_BG_COLOR, colorbg);
|
||||
gcolorbg = GColorFromHEX(colorbg);
|
||||
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
|
||||
}
|
||||
if(colorm_t) {
|
||||
int colorm = colorm_t->value->int32;
|
||||
@@ -59,6 +83,13 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
persist_write_int(KEY_PEG_COLOR, colorp);
|
||||
gcolorp = GColorFromHEX(colorp);
|
||||
}
|
||||
if(shadows_t && shadows_t->value->int32 > 0) {
|
||||
persist_write_bool(KEY_SHADOWS, true);
|
||||
shadows = true;
|
||||
} else {
|
||||
persist_write_bool(KEY_SHADOWS, false);
|
||||
shadows = false;
|
||||
}
|
||||
if(s_canvas_layer) {
|
||||
layer_mark_dirty(s_canvas_layer);
|
||||
}
|
||||
@@ -140,12 +171,29 @@ static void update_proc(Layer *layer, GContext *ctx) {
|
||||
.y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)HAND_MARGIN_INNER / TRIG_MAX_RATIO) + s_center.y,
|
||||
};
|
||||
// Draw hands with positive length only
|
||||
//gcolorshadow gcolorh gcolorm
|
||||
if((s_radius - HAND_MARGIN_OUTER) > HAND_MARGIN_INNER) {
|
||||
if(shadows) {
|
||||
if(s_radius > 2 * HAND_MARGIN_OUTER) {
|
||||
graphics_context_set_stroke_color(ctx, gcolorshadow);
|
||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||
hour_hand_inner.y += SHADOW_OFFSET; hour_hand_outer.y += SHADOW_OFFSET;
|
||||
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
||||
hour_hand_inner.y -= SHADOW_OFFSET; hour_hand_outer.y -= SHADOW_OFFSET;
|
||||
}
|
||||
if(s_radius > HAND_MARGIN_OUTER) {
|
||||
graphics_context_set_stroke_color(ctx, gcolorshadow);
|
||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||
minute_hand_inner.y += SHADOW_OFFSET+1; minute_hand_outer.y += SHADOW_OFFSET+1;
|
||||
graphics_draw_line(ctx, minute_hand_inner, minute_hand_outer);
|
||||
minute_hand_inner.y -= SHADOW_OFFSET+1; minute_hand_outer.y -= SHADOW_OFFSET+1;
|
||||
}
|
||||
}
|
||||
if(s_radius > 2 * HAND_MARGIN_OUTER) {
|
||||
graphics_context_set_stroke_color(ctx, gcolorh);
|
||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||
graphics_draw_line(ctx, hour_hand_inner, hour_hand_outer);
|
||||
}
|
||||
}
|
||||
if(s_radius > HAND_MARGIN_OUTER) {
|
||||
graphics_context_set_stroke_color(ctx, gcolorm);
|
||||
graphics_context_set_stroke_width(ctx, HAND_WIDTH);
|
||||
@@ -163,29 +211,35 @@ static void window_load(Window *window) {
|
||||
|
||||
s_center = grect_center_point(&window_bounds);
|
||||
|
||||
if (persist_read_int(KEY_BG_COLOR)) {
|
||||
if (persist_exists(KEY_BG_COLOR)) {
|
||||
int colorbg = persist_read_int(KEY_BG_COLOR);
|
||||
gcolorbg = GColorFromHEX(colorbg);
|
||||
} else {
|
||||
gcolorbg=GColorBlack;
|
||||
gcolorbg = GColorBlack;
|
||||
}
|
||||
if (persist_read_int(KEY_MINUTE_COLOR)) {
|
||||
gcolorshadow = (GColor8) shadowtable[alpha & gcolorbg.argb];
|
||||
if (persist_exists(KEY_MINUTE_COLOR)) {
|
||||
int colorm = persist_read_int(KEY_MINUTE_COLOR);
|
||||
gcolorm = GColorFromHEX(colorm);
|
||||
} else {
|
||||
gcolorm=GColorWhite;
|
||||
gcolorm = GColorWhite;
|
||||
}
|
||||
if (persist_read_int(KEY_HOUR_COLOR)) {
|
||||
if (persist_exists(KEY_HOUR_COLOR)) {
|
||||
int colorh = persist_read_int(KEY_HOUR_COLOR);
|
||||
gcolorh = GColorFromHEX(colorh);
|
||||
} else {
|
||||
gcolorh=GColorRed;
|
||||
gcolorh = GColorRed;
|
||||
}
|
||||
if (persist_read_int(KEY_PEG_COLOR)) {
|
||||
if (persist_exists(KEY_PEG_COLOR)) {
|
||||
int colorp = persist_read_int(KEY_PEG_COLOR);
|
||||
gcolorp = GColorFromHEX(colorp);
|
||||
} else {
|
||||
gcolorp=GColorDarkGray;
|
||||
gcolorp = GColorDarkGray;
|
||||
}
|
||||
if (persist_exists(KEY_SHADOWS)) {
|
||||
shadows = persist_read_bool(KEY_SHADOWS);
|
||||
} else {
|
||||
shadows = false;
|
||||
}
|
||||
|
||||
s_canvas_layer = layer_create(window_bounds);
|
||||
@@ -210,6 +264,8 @@ static void radius_update(Animation *anim, AnimationProgress dist_normalized) {
|
||||
|
||||
static void init() {
|
||||
srand(time(NULL));
|
||||
|
||||
//light_enable(true);
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm *time_now = localtime(&t);
|
||||
@@ -244,4 +300,3 @@ int main() {
|
||||
deinit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user