Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New clock - Fuzzy Text Clock #1659

Merged
merged 42 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1e91a20
Create fuzzyw.app.js
sir-indy Mar 31, 2022
18ac62c
Add files via upload
sir-indy Mar 31, 2022
949e746
Add files via upload
sir-indy Mar 31, 2022
b039301
Add files via upload
sir-indy Mar 31, 2022
0689cb6
Update metadata.json
sir-indy Mar 31, 2022
96ea439
Create fuzzyw.settings.js
sir-indy Mar 31, 2022
a23dd54
Delete fuzzy.png
sir-indy Mar 31, 2022
c474d0c
Delete fuzzyw.icon.js
sir-indy Mar 31, 2022
c536aee
Rename fuzzyw-icon.js to fuzzyw.img.js
sir-indy Mar 31, 2022
991fd87
Rename fuzzyw.img.js to fuzzyw.icon.js
sir-indy Mar 31, 2022
2fc67c4
Update fuzzyw.icon.js
sir-indy Mar 31, 2022
52a237f
Add files via upload
sir-indy Mar 31, 2022
2e099e4
Merge branch 'espruino:master' into master
sir-indy Mar 31, 2022
bb712dc
Update fuzzyw.settings.js
sir-indy Mar 31, 2022
c270f8d
Create fuzzy_strings.json
sir-indy Mar 31, 2022
924c685
Update fuzzyw.settings.js
sir-indy Mar 31, 2022
dce327b
Update metadata.json
sir-indy Mar 31, 2022
f76cb9a
Update fuzzyw.app.js
sir-indy Mar 31, 2022
cc0e5f1
Update fuzzyw.app.js
sir-indy Mar 31, 2022
61c5c04
Update fuzzyw.app.js
sir-indy Mar 31, 2022
2391638
Update metadata.json
sir-indy Mar 31, 2022
ea6b462
Update fuzzy_strings.json
sir-indy Mar 31, 2022
5242d86
Update fuzzyw.settings.js
sir-indy Mar 31, 2022
1bc47eb
Update fuzzyw.app.js
sir-indy Apr 4, 2022
4e3a3c3
Update fuzzyw.settings.js
sir-indy Apr 4, 2022
1ee8dfd
Update fuzzyw.settings.js
sir-indy Apr 4, 2022
417a575
Update metadata.json
sir-indy Apr 4, 2022
195d279
Update metadata.json
sir-indy Apr 4, 2022
aab8df3
Update metadata.json
sir-indy Apr 4, 2022
d9a3c0a
Update fuzzyw.app.js
sir-indy Apr 4, 2022
1d122ef
Update fuzzyw.settings.js
sir-indy Apr 4, 2022
a719435
Update fuzzyw.settings.js
sir-indy Apr 4, 2022
b27b6b0
Update fuzzyw.settings.js
sir-indy Apr 4, 2022
8455486
Update metadata.json
sir-indy Apr 4, 2022
b496307
Update README.md
sir-indy Apr 4, 2022
c704958
Update README.md
sir-indy Apr 4, 2022
aed0aa1
Update README.md
sir-indy Apr 4, 2022
eb0d809
Update fuzzyw.app.js
sir-indy Apr 6, 2022
f0fce41
Update fuzzyw.app.js
sir-indy Apr 6, 2022
575926b
Update fuzzyw.app.js
sir-indy Apr 6, 2022
aaaf0b5
Merge branch 'espruino:master' into master
sir-indy Apr 6, 2022
fb3dc7f
Update fuzzy_strings.json
sir-indy Apr 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/fuzzyw/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: First release
26 changes: 26 additions & 0 deletions apps/fuzzyw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Fuzzy Text Clock

An imprecise clock for when you're not in a rush.

This clock is a remake of one of my favourite Pebble watchfaces, Fuzzy Text International. I use this watch for weekends and holidays, when 'within 5 minutes of the actual time' is close enough!

By default it will use the language set on the watch, go to settings to pick:
* en_GB - English
* en_US - American
* es_ES - Spanish
* fr_FR - French
* no_NO - Norwegian
* sv_SE - Swedish
* de_DE - German

Most translations are taken from the original Fuzzy Text International code.

## TODO
* Bold hour word (as the pebble version has)
* Animation when changing time?

## References
Based on Pebble app Fuzzy Text International: https://github.com/hallettj/Fuzzy-Text-International

![](fuzzyw-light.png)
![](fuzzyw-dark.png)
163 changes: 163 additions & 0 deletions apps/fuzzyw/fuzzy_strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"en_GB":{
"hours":[
"midnight", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven",
"twelve", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven"
],
"minutes":[
"*$1 o'clock",
"five past *$1",
"ten past *$1",
"quarter past *$1",
"twenty past *$1",
"twenty five past *$1",
"half past *$1",
"twenty five to *$2",
"twenty to *$2",
"quarter to *$2",
"ten to *$2",
"five to *$2"
],
"text_scale":3.5
},
"en_US":{
"hours":[
"midnight", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven",
"twelve", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven"
],
"minutes":[
"*$1 o'clock",
"five after *$1",
"ten after *$1",
"quarter after *$1",
"twenty after *$1",
"twenty five after *$1",
"half past *$1",
"twenty five to *$2",
"twenty to *$2",
"quarter to *$2",
"ten to *$2",
"five to *$2"
],
"text_scale":3.5
},
"es_ES":{
"hours":[
"doce", "una", "dos", "tres", "cuatro", "cinco",
"seis", "siete", "ocho", "nueve", "diez", "once",
"doce", "una", "dos", "tres", "cuatro", "cinco",
"seis", "siete", "ocho", "nueve", "diez", "once"
],
"minutes":[
"*$1 en punto",
"*$1 y cinco",
"*$1 y diez",
"*$1 y cuarto",
"*$1 y veinte",
"*$1 y veinti- cinco",
"*$1 y media",
"*$2 menos veinti- cinco",
"*$2 menos veinte",
"*$2 menos cuarto",
"*$2 menos diez",
"*$2 menos cinco"
],
"text_scale":3.5
},
"fr_FR":{
"hours":[
"douze", "une", "deux", "trois", "quatre", "cinq",
"six", "sept", "huit", "neuf", "dix", "onze",
"douze", "une", "deux", "trois", "quatre", "cinq",
"six", "sept", "huit", "neuf", "dix", "onze"
],
"minutes":[
"*$1 heures",
"*$1 heures cinq",
"*$1 heures dix",
"*$1 heures et quart",
"*$1 heures vingt",
"*$1 heures vingt- cinq",
"*$1 heures et demie",
"*$2 moins vingt- cinq",
"*$2 heures moins vingt",
"*$2 moins le quart",
"*$2 heures moins dix",
"*$2 heures moins cinq"
],
"text_scale":3.5
},
"no_NB":{
"hours":[
"tolv", "ett", "to", "tre", "fire", "fem",
"seks", "sju", "åtte", "ni", "ti", "elleve",
"tolv", "ett", "to", "tre", "fire", "fem",
"seks", "sju", "åtte", "ni", "ti", "elleve"
],
"minutes":[
"klokka er *$1",
"fem over *$1",
"ti over *$1",
"kvart over *$1",
"ti på halv *$2",
"fem på halv *$2",
"halv *$2",
"fem over halv *$2",
"ti over halv *$2",
"kvart på *$2",
"ti på *$2",
"fem på *$2"
],
"text_scale":3.5
},
"sv_SE":{
"hours":[
"tolv", "ett", "två", "tre", "fyra", "fem",
"sex", "sju", "åtta", "nio", "tio", "elva",
"tolv", "ett", "två", "tre", "fyra", "fem",
"sex", "sju", "åtta", "nio", "tio", "elva"
],
"minutes":[
"*$1",
"fem över *$1",
"tio över *$1",
"kvart över *$1",
"tjugo över *$1",
"fem i halv *$2",
"halv *$2",
"fem över halv *$2",
"tjugo i *$2",
"kvart i *$2",
"tio i *$2",
"fem i *$2"
],
"text_scale":3.5
},
"de_DE":{
"hours":[
"zwölf", "eins", "zwei", "drei", "vier", "fünf",
"sechs", "sieben", "acht", "neun", "zehn", "elf",
"zwölf", "eins", "zwei", "drei", "vier", "fünf",
"sechs", "sieben", "acht", "neun", "zehn", "elf"
],
"minutes":[
"*$1 uhr",
"fünf nach *$1",
"zehn nach *$1",
"viertel nach *$1",
"zwanzig nach *$1",
"fünf for halb *$2",
"halb *$2",
"fünf nach halb *$2",
"zwanzig vor *$2",
"viertel vor *$2",
"zehn vor *$2",
"fünf vor *$2"
],
"text_scale":3.5
}
}
Binary file added apps/fuzzyw/fuzzyw-dark.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 apps/fuzzyw/fuzzyw-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions apps/fuzzyw/fuzzyw.app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// adapted from https://github.com/hallettj/Fuzzy-Text-International/
const fuzzy_strings = require("Storage").readJSON("fuzzy_strings.json");

const SETTINGS_FILE = "fuzzyw.settings.json";
let settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'language': 'System', 'alignment':'Centre'};

if (settings.language == 'System') {
settings.language = require('locale').name;
}

let fuzzy_string = fuzzy_strings[settings.language];

let timeout = 2.5*60;
let drawTimeout;

function queueDraw(seconds) {
let millisecs = seconds * 1000;
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, millisecs - (Date.now() % millisecs));
}

const h = g.getHeight();
const w = g.getWidth();
let align_mode = 0;
let align_pos = w/2;
if (settings.alignment =='Left') {
align_mode = -1;
align_pos = 0;
} else if (settings.alignment == 'Right') {
align_mode = 1;
align_pos = w;
}

function getTimeString(date) {
let segment = Math.round((date.getMinutes()*60 + date.getSeconds() + 1)/300);
let hour = date.getHours() + Math.floor(segment/12);
f_string = fuzzy_string.minutes[segment % 12];
if (f_string.includes('$1')) {
f_string = f_string.replace('$1', fuzzy_string.hours[(hour) % 24]);
} else {
f_string = f_string.replace('$2', fuzzy_string.hours[(hour + 1) % 24]);
}
return f_string;
}

function draw() {
let time_string = getTimeString(new Date()).replace('*', '');
// print(time_string);
g.setFont('Vector', (h-24*2)/fuzzy_string.text_scale);
g.setFontAlign(align_mode, 0);
g.clearRect(0, 24, w, h-24);
g.setColor(g.theme.fg);
g.drawString(g.wrapString(time_string, w).join("\n"), align_pos, h/2);
queueDraw(timeout);
}

g.clear();
draw();

// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
if (on) {
draw(); // draw immediately, queue redraw
} else { // stop draw timer
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
}
});

Bangle.setUI('clock');
Bangle.loadWidgets();
Bangle.drawWidgets();
1 change: 1 addition & 0 deletions apps/fuzzyw/fuzzyw.icon.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added apps/fuzzyw/fuzzyw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions apps/fuzzyw/fuzzyw.settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(function(back) {
const SETTINGS_FILE = "fuzzyw.settings.json";

var align_options = ['Left','Centre','Right'];
var language_options = ['System', 'en_GB', 'en_US', 'es_ES', 'fr_FR', 'no_NO', 'sv_SE', 'de_DE'];

// initialize with default settings...
let s = {'language': 'System', 'alignment': 'Centre'};

// ...and overwrite them with any saved values
// This way saved values are preserved if a new version adds more settings
const storage = require('Storage')
let settings = storage.readJSON(SETTINGS_FILE, 1) || s;
const saved = settings || {}
for (const key in saved) {
s[key] = saved[key]
}

function save() {
settings = s
storage.write(SETTINGS_FILE, settings)
}

E.showMenu({
'': { 'title': 'Fuzzy Text Clock' },
'< Back': back,
'Language': {
value: 0 | language_options.indexOf(s.language),
min: 0, max: language_options.length - 1,
format: v => language_options[v],
onchange: v => {
s.language = language_options[v];
save();
}
},
'Alignment': {
value: 0 | align_options.indexOf(s.alignment),
min: 0, max: align_options.length - 1,
format: v => align_options[v],
onchange: v => {
s.alignment = align_options[v];
save();
}
},
});
})
20 changes: 20 additions & 0 deletions apps/fuzzyw/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"id":"fuzzyw",
"name":"Fuzzy Text Clock",
"shortName": "Fuzzy Text",
"version": "0.01",
"description": "An imprecise clock for when you're not in a rush",
"readme": "README.md",
"icon":"fuzzyw.png",
"screenshots": [{"url":"fuzzyw-light.png"},{"url":"fuzzyw-dark.png"}],
"type": "clock",
"tags": "clock",
"supports": ["BANGLEJS", "BANGLEJS2"],
"allow_emulator": true,
"storage": [
{"name":"fuzzyw.app.js","url":"fuzzyw.app.js"},
{"name":"fuzzyw.settings.js","url":"fuzzyw.settings.js"},
{"name":"fuzzyw.img","url":"fuzzyw.icon.js","evaluate":true},
{"name":"fuzzy_strings.json","url":"fuzzy_strings.json"}
]
}