Skip to content

MagicMirror module that allows displaying and hiding modules when a hardware button is pushed.

License

Notifications You must be signed in to change notification settings

alexbergsland/MMM-ModuleToggleButton

 
 

Repository files navigation

MMM-ModuleToggleButton

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.

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, 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.

Using the module

To use this module follow these steps:

  1. Clone this repository to the modules folder of your MagicMirror:
git clone https://github.com/balassy/MMM-ModuleToggleButton.git
  1. Run npm install in the modules/MMM-ModuleToggleButton folder to install its dependencies.

  2. 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'
        ]
      }
    }
  ]
}
  1. 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<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

How it works

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.

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:
npm install
  1. Install Grunt:
npm install -g grunt
  1. Use Grunt to run all linters:
grunt

Got feedback?

Your feedback is more than welcome, please send your suggestions, feature requests or bug reports as Github issues.

About the author

This project is created and maintaned by György Balássy.

About

MagicMirror module that allows displaying and hiding modules when a hardware button is pushed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%