This is a module for the 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.
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, MMM-Remote-Control, MMM-NetworkConnection or MMM-ip).
This module does not render anything to the screen of the MagicMirror, just controls other modules.
For updates, please check the CHANGELOG.
To use this module follow these steps:
modules
folder of your MagicMirror:git clone https://github.com/balassy/MMM-ModuleToggleButton.git
Run npm install
in the modules/MMM-ModuleToggleButton
folder to install its dependencies.
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:
var config = {
modules: [
{
module: 'MMM-ModuleToggleButton',
config: {
buttonGpioPin: 6,
moduleNames: [
'clock',
'calendar'
]
}
}
]
}
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<string> 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 |
This module uses the onoff NPM package to monitor the GPIO input, and uses the MM.getModules().withClass(...)
API of the MagicMirror to find the target modules by their name.
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:
npm ci
npm run lint
Your feedback is more than welcome, please send your suggestions, feature requests or bug reports as GitHub issues.
This project is created and maintaned by György Balássy.