Skip to content

Commit d559791

Browse files
committed
Seconds display on tap and README update
1 parent c67e853 commit d559791

File tree

4 files changed

+76
-33
lines changed

4 files changed

+76
-33
lines changed

README.MD

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
This watchface is an adaptation of Simple Weather for Pebble by Evandro Muller.
1+
This clockface is an adaptation of Simple Weather for Pebble by Evandro Muller.
22
It uses OpenWeather as weather service and the icon are from the Oxygen project (https://techbase.kde.org/Projects/Oxygen) under LGPLv3 licence.
3+
34
Weather is updated every half hour.
4-
Tap to switch form steps to heart rate, calories and floors.
55

6-
No configuration. It uses your system settings.
6+
Tap on time to display it in minutes:seconds until another tap or the screen goes off.
7+
Tap somewhere else to switch form steps to heart rate, calories and floors.
8+
9+
It uses your system settings for date, time and temperature format.
10+
Text color can be configured.
11+
712

813
Feel free to contribute or open an issue on github : https://github.com/lemnet/SimpleWeather/

README_FR.MD

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
Cette watchface est une adaptation de Simple Weather pour Pebble par Evandro Muller.
1+
Cette clockface est une adaptation de Simple Weather pour Pebble par Evandro Muller.
22
Elle utilise OpenWeather pour la météo and les icônes viennent du projet Oxygen (https://techbase.kde.org/Projects/Oxygen) sous licence LGPLv3.
3+
34
La météo est mise à jour toutes les demies heures.
4-
Taper to passer des pas au rythme cardiaque, aux calories, et aux étages.
55

6-
Pas de configuration. Elle utilise vos paramètres systèmes.
6+
Tapez sur l'heure pour l'afficher en minutes:secondes jusqu'a ce que vous tapiez encore ou que l'écran s'éteigne.
7+
Tapez ailleurs pour passer des pas au rythme cardiaque, aux calories, et aux étages.
8+
9+
Elle utilise vos paramètres systèmes pour le format de la date, de l'heure et de la température.
10+
La couleur est paramétrable.
11+
712

813
N'hésitez pas à contribuer ou ouvrir un ticket sur github : https://github.com/lemnet/SimpleWeather/

app/index.js

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { units } from "user-settings";
44
import * as util from "../common/utils";
55
import { gettext } from "i18n";
66
import { getDate } from "./date";
7-
import { getTime } from './time';
7+
import { getTimeHM } from './time';
8+
import { getTimeMS } from './time';
89
import { today } from 'user-activity'
910
import { HeartRateSensor } from 'heart-rate';
1011
import { display } from "display";
@@ -15,7 +16,6 @@ import { me as device } from "device";
1516
import * as messaging from "messaging";
1617
import * as fs from "fs";
1718

18-
1919
// Update the clock every minute
2020
clock.granularity = "minutes";
2121

@@ -40,6 +40,7 @@ let currentAct = 0;
4040
let latitude = 0;
4141
let longitude = 0;
4242
let lastfetch = 0;
43+
let secDisplay = 0;
4344

4445

4546
// load weather
@@ -72,7 +73,7 @@ hrm.addEventListener("reading", () => {
7273
if (currentAct == 1)
7374
display.on ? hrm.start() : hrm.stop();
7475
});
75-
actText.text = hrm.heartRate;
76+
actText.text = hrm.heartRate;
7677
});
7778

7879

@@ -168,7 +169,10 @@ clock.ontick = (evt) => {
168169
actText.text = today.adjusted.calories || 0;
169170
else if (currentAct == 3) //elevation
170171
actText.text = today.adjusted.elevationGain || 0;
171-
timeText.text = getTime(currentDate);
172+
if (secDisplay == 0)
173+
timeText.text = getTimeHM(currentDate);
174+
else
175+
timeText.text = getTimeMS(currentDate);
172176
//try to get location and weather
173177
setTimeout(function(){
174178
if ((currentDate.getTime() - lastfetch) > 1800000) { //every 30 min
@@ -191,28 +195,49 @@ clock.ontick = (evt) => {
191195

192196

193197
//onclick
194-
main.onclick = () => {
198+
main.onclick = (evt) => {
195199
vibration.start('bump');
196-
if (currentAct == 0) { //steps
197-
hrm.start();
198-
actIcon.href="icons/heart.png"
199-
actText.text = hrm.heartRate;
200-
currentAct = 1;
201-
}
202-
else if (currentAct == 1) { //HR
203-
hrm.stop();
204-
actIcon.href="icons/flame.png"
205-
actText.text = today.adjusted.calories || 0;
206-
currentAct = 2;
207-
}
208-
else if (currentAct == 2) { // calo
209-
actIcon.href="icons/stairs.png"
210-
actText.text = today.adjusted.elevationGain || 0;
211-
currentAct = 3;
200+
if ((evt.screenX) > 150 && (evt.screenY) < 150) {
201+
if (secDisplay == 0) {
202+
clock.granularity = "seconds";
203+
secDisplay = 1;
204+
}
205+
else {
206+
secDisplay = 0;
207+
setTimeout(function(){
208+
clock.granularity = "minutes";
209+
}, 1500);
210+
}
212211
}
213-
else if (currentAct == 3) { // elevation
214-
actIcon.href="icons/step.png"
215-
actText.text = today.adjusted.steps || 0;
216-
currentAct = 0;
212+
else {
213+
if (currentAct == 0) { //steps
214+
hrm.start();
215+
actIcon.href="icons/heart.png"
216+
actText.text = hrm.heartRate;
217+
currentAct = 1;
218+
}
219+
else if (currentAct == 1) { //HR
220+
hrm.stop();
221+
actIcon.href="icons/flame.png"
222+
actText.text = today.adjusted.calories || 0;
223+
currentAct = 2;
224+
}
225+
else if (currentAct == 2) { // calo
226+
actIcon.href="icons/stairs.png"
227+
actText.text = today.adjusted.elevationGain || 0;
228+
currentAct = 3;
229+
}
230+
else if (currentAct == 3) { // elevation
231+
actIcon.href="icons/step.png"
232+
actText.text = today.adjusted.steps || 0;
233+
currentAct = 0;
234+
}
217235
}
218-
}
236+
}
237+
238+
display.addEventListener("change", () => {
239+
if (!display.on) {
240+
secDisplay = 0;
241+
clock.granularity = "minutes";
242+
}
243+
});

app/time.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const zeroPad = number => {
1010
return padded;
1111
};
1212

13-
export function getTime(date) {
13+
export function getTimeHM(date) {
1414
const hours = date.getHours();
1515
const ret;
1616
if (preferences.clockDisplay === '12h') {
@@ -23,4 +23,12 @@ export function getTime(date) {
2323
ret += ":"
2424
ret += zeroPad(date.getMinutes());
2525
return ret;
26+
};
27+
28+
export function getTimeMS(date) {
29+
const ret;
30+
ret = zeroPad(date.getMinutes());
31+
ret += ":"
32+
ret += zeroPad(date.getSeconds());
33+
return ret;
2634
};

0 commit comments

Comments
 (0)