mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Added clock notifications for elapsed time.
Added notifications to default `clock` module to broadcast: - `CLOCK_SECOND` for a clock second, and - `CLOCK_MINUTE` for a clock minute having elapsed. Each notification is broadcasted with the corresponding value i.e. `CLOCK_SECOND` -> `30` and `CLOCK_MINUTE` -> `5` .
This commit is contained in:
parent
c7d79bb893
commit
b2f59d6813
@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Calendar module: added `nextDaysRelative` config option
|
- Calendar module: added `nextDaysRelative` config option
|
||||||
- Add `broadcastPastEvents` config option for calendars to include events from the past `maximumNumberOfDays` in event broadcasts
|
- Add `broadcastPastEvents` config option for calendars to include events from the past `maximumNumberOfDays` in event broadcasts
|
||||||
- Added feature to broadcast news feed items `NEWS_FEED` and updated news items `NEWS_FEED_UPDATED` in default [newsfeed](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/newsfeed) module (when news is updated) with documented default and `config.js` options in [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md)
|
- Added feature to broadcast news feed items `NEWS_FEED` and updated news items `NEWS_FEED_UPDATED` in default [newsfeed](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/newsfeed) module (when news is updated) with documented default and `config.js` options in [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md)
|
||||||
|
- Added notifications to default `clock` module broadcasting `CLOCK_SECOND` and `CLOCK_MINUTE` for the respective time elapsed.
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- English translation for "Feels" to "Feels like"
|
- English translation for "Feels" to "Feels like"
|
||||||
|
@ -44,3 +44,14 @@ The following properties can be configured:
|
|||||||
| `analogPlacement` | **Specific to the analog clock. _(requires displayType set to `'both'`)_** Specifies where the analog clock is in relation to the digital clock <br><br> **Possible values:** `top`, `right`, `bottom`, or `left` <br> **Default value:** `bottom`
|
| `analogPlacement` | **Specific to the analog clock. _(requires displayType set to `'both'`)_** Specifies where the analog clock is in relation to the digital clock <br><br> **Possible values:** `top`, `right`, `bottom`, or `left` <br> **Default value:** `bottom`
|
||||||
| `analogShowDate` | **Specific to the analog clock.** If the clock is used as a separate module and set to analog only, this configures whether a date is also displayed with the clock. <br><br> **Possible values:** `false`, `top`, or `bottom` <br> **Default value:** `top`
|
| `analogShowDate` | **Specific to the analog clock.** If the clock is used as a separate module and set to analog only, this configures whether a date is also displayed with the clock. <br><br> **Possible values:** `false`, `top`, or `bottom` <br> **Default value:** `top`
|
||||||
| `timezone` | Specific a timezone to show clock. <br><br> **Possible examples values:** `America/New_York`, `America/Santiago`, `Etc/GMT+10` <br> **Default value:** `none`. See more informations about configuration value [here](https://momentjs.com/timezone/docs/#/data-formats/packed-format/)
|
| `timezone` | Specific a timezone to show clock. <br><br> **Possible examples values:** `America/New_York`, `America/Santiago`, `Etc/GMT+10` <br> **Default value:** `none`. See more informations about configuration value [here](https://momentjs.com/timezone/docs/#/data-formats/packed-format/)
|
||||||
|
|
||||||
|
## Notifications
|
||||||
|
|
||||||
|
The clock makes use of the built-in [Notification Mechanism](https://github.com/michMich/MagicMirror/wiki/notifications) to relay notifications to all modules.
|
||||||
|
|
||||||
|
Current notifications are:
|
||||||
|
|
||||||
|
| Notification | Description
|
||||||
|
| ----------------- | -----------
|
||||||
|
| `CLOCK_SECOND` | A second has elapsed. <br> *Parameter*: second value
|
||||||
|
| `CLOCK_MINUTE` | A minute has elapsed <br> *Parameter*: minute value
|
@ -41,11 +41,25 @@ Module.register("clock",{
|
|||||||
|
|
||||||
// Schedule update interval.
|
// Schedule update interval.
|
||||||
var self = this;
|
var self = this;
|
||||||
|
self.second = 0;
|
||||||
|
self.minute = 0;
|
||||||
self.lastDisplayedMinute = null;
|
self.lastDisplayedMinute = null;
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) {
|
if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) {
|
||||||
self.updateDom();
|
self.updateDom();
|
||||||
}
|
}
|
||||||
|
if (self.second === 59) {
|
||||||
|
self.second = 0;
|
||||||
|
if (self.minute === 59){
|
||||||
|
self.minute = 0;
|
||||||
|
} else {
|
||||||
|
self.minute++;
|
||||||
|
}
|
||||||
|
self.sendNotification("CLOCK_MINUTE", self.minute);
|
||||||
|
} else {
|
||||||
|
self.second++;
|
||||||
|
self.sendNotification("CLOCK_SECOND", self.second);
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// Set locale.
|
// Set locale.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user