1
0
Fork 0
BangleApps/apps/widtmr
David Peer 61c29c1c7a First alarm lib test 2022-03-04 17:35:34 +01:00
..
ChangeLog Renaming 2022-02-25 17:14:19 +01:00
README.md Minor changes 2022-02-26 12:02:18 +01:00
app-icon.js New icon 2022-02-25 18:23:22 +01:00
app.js First alarm lib test 2022-03-04 17:35:34 +01:00
app.png Updated icons. 2022-02-25 18:13:01 +01:00
description.png Improved documentation 2022-02-25 18:07:09 +01:00
metadata.json Improved documentation 2022-02-25 18:07:09 +01:00
screenshot.png Improved documentation 2022-02-25 18:07:09 +01:00
screenshot_2.png Improved documentation 2022-02-25 18:07:09 +01:00
widget.js Renaming of setTime to setTimer. 2022-02-26 11:55:35 +01:00

README.md

Timer Widget

This is a fork of the Chrono Widget, but implements a simpler UI. Additionally, it exposes functions for other apps or clocks such that they can easily implement a timer. Currently, it is used by lcars and notanalog.

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.

Lib

Different functions are exposed by widtmr which enables other apps to directly use and integrate this functionality:

The following functions are available:

  • isStarted() -> boolean
  • setStarted(boolean) -> void
  • setTimer(t) -> void
  • increaseTimer(int) -> void
  • decreaseTimer(int) -> void
  • getRemainingMinutes() -> int
  • getRemainingTime() -> DateTime
  • getRemainingTimeStr() -> str

For example if we want to increase the timer by +5 minutes each time the touch event is fired:

Bangle.loadWidgets();
...
Bangle.on('touch', function(btn, e){
  // Set to zero if alarm was disabled before. Otherwise
  // it starts from the last setting made by the user.
  if(!isAlarmEnabled()){
    WIDGETS["widtmr"].setTimer(0);
  }

  WIDGETS["widtmr"].increaseTimer(5);
  WIDGETS["widtmr"].setStarted(true);
});

Example to decrease the timer by 5 and stop if 0 is reached:

Bangle.loadWidgets();
...
Bangle.on('touch', function(btn, e){
    WIDGETS["widtmr"].decreaseTimer(5);
}

You can find implementations and usages in the lcars or notanalog app.

Creator

David Peer

Thanks to...

Forked from Chrono Widget of Purple-Tentacle

Time icon created by CreativeCons - Flaticon