diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d9eea9..2dab4880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Calendar module: added `nextDaysRelative` config option - 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 notifications to default `clock` module broadcasting `CLOCK_SECOND` and `CLOCK_MINUTE` for the respective time elapsed. ### Updated - English translation for "Feels" to "Feels like" diff --git a/modules/default/clock/README.md b/modules/default/clock/README.md index 27e2ca5d..19e6a005 100644 --- a/modules/default/clock/README.md +++ b/modules/default/clock/README.md @@ -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

**Possible values:** `top`, `right`, `bottom`, or `left`
**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.

**Possible values:** `false`, `top`, or `bottom`
**Default value:** `top` | `timezone` | Specific a timezone to show clock.

**Possible examples values:** `America/New_York`, `America/Santiago`, `Etc/GMT+10`
**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.
*Parameter*: second value +| `CLOCK_MINUTE` | A minute has elapsed
*Parameter*: minute value \ No newline at end of file diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index e4942076..a6855aff 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -41,11 +41,25 @@ Module.register("clock",{ // Schedule update interval. var self = this; + self.second = 0; + self.minute = 0; self.lastDisplayedMinute = null; setInterval(function() { if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) { 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); // Set locale.