2022-02-25 16:55:47 +00:00
|
|
|
# Timer Widget
|
2022-02-25 16:14:19 +00:00
|
|
|
|
|
|
|
This is a fork of the Chrono Widget, but implements a
|
|
|
|
simpler UI which to be able to set a timer faster with
|
|
|
|
less interaction. Additionally, it exposes some functions
|
|
|
|
that can be used by other apps or clocks to easily
|
|
|
|
implement a timer. It is used e.g. by lcars or notanalog.
|
|
|
|
|
2022-02-25 17:07:09 +00:00
|
|
|
# Overview
|
|
|
|
If you open the app, you can simply control the timer
|
|
|
|
by clicking on top, bottom, left or right of the screen.
|
|
|
|
If you tab at the middle of the screen, the timer is
|
|
|
|
started / stopped.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
2022-02-25 17:58:35 +00:00
|
|
|
# Library for other Apps
|
2022-02-25 16:55:47 +00:00
|
|
|
Different functions are exposed to integrate a timer
|
|
|
|
into your own app.
|
2022-02-25 16:14:19 +00:00
|
|
|
|
2022-02-25 17:07:09 +00:00
|
|
|
The following functions are available:
|
|
|
|
- isStarted() -> boolean
|
|
|
|
- setStarted(boolean) -> void
|
2022-02-26 08:53:38 +00:00
|
|
|
- setTime(t) -> void
|
2022-02-25 17:07:09 +00:00
|
|
|
- increaseTimer(int) -> void
|
|
|
|
- decreaseTimer(int) -> void
|
|
|
|
- getRemainingMinutes() -> int
|
2022-02-26 08:17:46 +00:00
|
|
|
- getRemainingTime() -> DateTime
|
2022-02-26 08:24:42 +00:00
|
|
|
- getRemainingTimeStr() -> str
|
2022-02-25 17:07:09 +00:00
|
|
|
|
2022-02-26 08:36:29 +00:00
|
|
|
For example if we want to increase the timer by +5 minutes each time
|
|
|
|
the touch event is fired:
|
2022-02-25 16:55:47 +00:00
|
|
|
```Javascript
|
2022-02-25 17:58:35 +00:00
|
|
|
Bangle.loadWidgets();
|
|
|
|
...
|
2022-02-26 08:36:29 +00:00
|
|
|
Bangle.on('touch', function(btn, e){
|
|
|
|
// Set to zero if alarm was disabled before
|
|
|
|
if(!isAlarmEnabled()){
|
2022-02-26 08:53:38 +00:00
|
|
|
WIDGETS["widtmr"].setTime(0);
|
2022-02-26 08:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WIDGETS["widtmr"].increaseTimer(5);
|
|
|
|
WIDGETS["widtmr"].setStarted(true);
|
|
|
|
});
|
2022-02-25 16:55:47 +00:00
|
|
|
```
|
2022-02-25 17:07:09 +00:00
|
|
|
|
2022-02-26 08:36:29 +00:00
|
|
|
Example to decrease the timer by 5 and stop if 0 is reached:
|
2022-02-25 17:07:09 +00:00
|
|
|
```Javascript
|
2022-02-25 17:58:35 +00:00
|
|
|
Bangle.loadWidgets();
|
|
|
|
...
|
2022-02-26 08:36:29 +00:00
|
|
|
Bangle.on('touch', function(btn, e){
|
|
|
|
WIDGETS["widtmr"].decreaseTimer(5);
|
|
|
|
}
|
2022-02-25 17:07:09 +00:00
|
|
|
```
|
|
|
|
|
2022-02-26 08:53:38 +00:00
|
|
|
You can find even more examples in the lcars or notanalog app ...
|
|
|
|
|
2022-02-25 16:55:47 +00:00
|
|
|
# Creator
|
|
|
|
|
|
|
|
[David Peer](https://github.com/peerdavid)
|
2022-02-25 17:13:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Thanks to...
|
2022-02-25 17:58:35 +00:00
|
|
|
Forked from Chrono Widget of [Purple-Tentacle](https://github.com/Purple-Tentacle)
|
|
|
|
|
|
|
|
Time icon created by <a href="https://www.flaticon.com/free-icons/time" title="time icons">CreativeCons - Flaticon</a>
|