https://github.com/balassy/mmm-moduletogglebutton
MagicMirror module that allows displaying and hiding modules when a hardware button is pushed.
https://github.com/balassy/mmm-moduletogglebutton
button javascript magicmirror magicmirror2 module raspberry-pi raspberrypi
Last synced: 5 months ago
JSON representation
MagicMirror module that allows displaying and hiding modules when a hardware button is pushed.
- Host: GitHub
- URL: https://github.com/balassy/mmm-moduletogglebutton
- Owner: balassy
- License: mit
- Created: 2018-08-03T04:15:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-11T03:17:38.000Z (almost 2 years ago)
- Last Synced: 2024-03-11T04:27:01.946Z (almost 2 years ago)
- Topics: button, javascript, magicmirror, magicmirror2, module, raspberry-pi, raspberrypi
- Language: JavaScript
- Size: 46.9 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MMM-ModuleToggleButton
This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror/) to show and hide modules when a hardware button is pushed. This can be useful to temporarily display modules for debugging after the mirror is deployed.
## Features
With this module you can control the visibility of a set of modules by pressing a temporary push button connected to a GPIO port of your Raspberry Pi. This module will hide the target modules when the MagicMirror is started, and show them when you press and release the push button. To hide the target modules press and release the push button again.
This module can be useful to temporary display modules that you need only for maintenance (e.g. [MMM-SystemStats](https://github.com/BenRoe/MMM-SystemStats), [MMM-Remote-Control](https://github.com/Jopyth/MMM-Remote-Control), [MMM-NetworkConnection](https://github.com/slametps/MMM-NetworkConnection) or [MMM-ip](https://github.com/fewieden/MMM-ip)).
This module does not render anything to the screen of the MagicMirror, just controls other modules.
For updates, please check the [CHANGELOG](https://github.com/balassy/MMM-ModuleToggleButton/blob/master/CHANGELOG.md).
## Using the module
To use this module follow these steps:
1. Clone this repository to the `modules` folder of your MagicMirror:
```bash
git clone https://github.com/balassy/MMM-ModuleToggleButton.git
```
2. Run `npm install` in the `modules/MMM-ModuleToggleButton` folder to install its dependencies.
3. Add the following configuration block to the modules array in the `config/config.js` file to control the visibility of the built-in Clock and Calendar modules:
```js
var config = {
modules: [
{
module: 'MMM-ModuleToggleButton',
config: {
buttonGpioPin: 6,
moduleNames: [
'clock',
'calendar'
]
}
}
]
}
```
4. Connect a momentary push button between the GPIO 6 and GND (Ground) pins of the Raspberry Pi.
## Configuration options
| Option | Description
|------------------------|-----------
| `buttonGpioPin` | **REQUIRED** The number of the GPIO pin to what the button is connected.
**Type:** `number`
**Default value:** `6`
| `moduleNames` | **REQUIRED** The list of module names that are controlled by this module.
**Type:** `Array`
**Default value:** `[]` (empty string array - does nothing)
| `debounceTimeoutInMilliseconds`| *Optional* The delay in milliseconds before the button push is detected while the GPIO input is bouncing.
**Type:** `number`
**Default value:** `500`
## How it works
This module uses the [onoff NPM package](https://www.npmjs.com/package/onoff) to monitor the GPIO input, and uses the `MM.getModules().withClass(...)` API of the MagicMirror to find the target modules by their name.
## Contribution
If you would like to contribute to the codebase, please use the preconfigured linters to analyze the source code before sending a pull request. To run the linters follow these steps:
1. Install developer dependencies:
```bash
npm ci
```
2. Run all linters:
```bash
npm run lint
```
## Got feedback?
Your feedback is more than welcome, please send your suggestions, feature requests or bug reports as [GitHub issues](https://github.com/balassy/MMM-ModuleToggleButton/issues).
## About the author
This project is created and maintaned by [György Balássy](https://www.linkedin.com/in/balassy).