Skip to content

A module to connect a rotary encoder to MagicMirror and use it for Navigation inside of MagicMirror

License

Notifications You must be signed in to change notification settings

jaffons/MMM-Navigate

 
 

Repository files navigation

MMM-Navigate

A module to connect a rotary encoder to MagicMirror and use it for Navigation inside of MagicMirror I wanted to use interaction to the MagicMirror and decided to use a rotary encoder, which has 3 functions: Clockwise, Counterclockwise and Press. These functions where combined to a navigation, so you have some possibilities, f.e.: Page increment/decrement, Newsfeed Article more/less details and actions for notification system. The navigation fades out, if not used.

Magic-Mirror Module MMM-Navigate screenshot1

Magic-Mirror Module MMM-Navigate screenshot2

Connect rotary encoder to raspberry pi

Using capacitors for CLK, DT and SW Pin can be usefull for debouncing. Magic-Mirror Module MMM-Navigate rotary encoder

Installing the module

Clone this repository in your ~/MagicMirror/modules/ folder ( $ cd ~MagicMirror/modules/ ):

git clone https://github.com/Ax-LED/MMM-Navigate
cd MMM-Navigate
npm install # this can take a while

Using the module

To use this module, add it to the modules array in the config/config.js file:

{
	module: "MMM-Navigate",
	header: "Navigation",
	position: "top_left",
	config: {
			Alias: [
				'Seiten blättern',
				'News (mehr/weniger Details)',
				'Test notification',
				'News - mehr Details',
				'News - weniger Details',
				'Neustart MagicMirror (PM2)',
				'Neustart',
				'Herunterfahren'
			],
			Action: [
				[{notification:'PAGE_INCREMENT',payload:''},{notification:'PAGE_DECREMENT',payload:''}],//action array, first press locks menu, after this rotation CW/CCW executes, second press release lock mode
				[{notification:'ARTICLE_MORE_DETAILS',payload:''},{notification:'ARTICLE_LESS_DETAILS',payload:''}],
				{notification: "SHOW_ALERT", payload: {type:"notification",message:"Dies ist eine Testnachricht"}},//single action, execute on press
				{notification:'ARTICLE_MORE_DETAILS',payload:''},
				{notification:'ARTICLE_LESS_DETAILS',payload:''},
				{notification: "REMOTE_ACTION", payload: {action: "RESTART"}},
				{notification: "REMOTE_ACTION", payload: {action: "REBOOT"}},
				{notification: "REMOTE_ACTION", payload: {action: "SHUTDOWN"}}
			],
			GPIOPins: [26,20,19]//rotary cw, rotary ccw, rotary press (BCM Numbering)
			},
},

Configuration options

The following properties can be configured:

Option Description
Alias An Array of the Alias for the navigation entries.
Action An Array of Action of the Alias. There are two modes:
1. Execution of a single action, for Example {notification:'PAGE_INCREMENT',payload:''} to send page increment to MMM-Pages Module.
2. Execution of an array of action, as there are some actions, which belong together (like PAGE_INCREMENT and PAGE_DECREMENT), Example Config: [{notification:'PAGE_INCREMENT',payload:''},{notification:'PAGE_DECREMENT',payload:''}]
Behavior: First press locks menu (can be identified by the red css frame), after this rotation CW/CCW executes actions from config, second press release lock mode so you can select another navigation entry.
GPIOPins Array for Definition of GPIO-Pins (BMC) to connect the rotary encoder for the following actions: Clockwise, Counterclockwise and Press
Further information:
In version 1.1 of the module, i added a 'second click confirmation notification' for the following REMOTE_ACTIONs.
- SHUTDOWN
- RESTART
- REBOOT
This means, if you select one of these entries and press the rotary, you get a notification to do a second press to execute the selected entry.

Further options

You can communication with this module also by sending notifications. Examples: yourmmip:8080/remote?action=NOTIFICATION&notification=CCW emulates turning rotary counterclockwise yourmmip:8080/remote?action=NOTIFICATION&notification=CW emulates turning rotary clockwise yourmmip:8080/remote?action=NOTIFICATION&notification=PRESSED emulates pressing rotary encoder

Version

1.1 Changelog:

  • added ability to send notifications to MMM-Navigate by other modules
  • added locked mode, so you can put two(2) actions in one(1) navigation link which belong together (like PAGE_INCREMENT and PAGE_DECREMENT). More details see Configuration options (Action).
  • modified css, so locked mode is visual (red frame when locked) in MM
  • added second click confirmation notification' for the following REMOTE_ACTIONs (SHUTDOWN, RESTART, REBOOT)

1.0 initial release

About

A module to connect a rotary encoder to MagicMirror and use it for Navigation inside of MagicMirror

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 96.0%
  • CSS 4.0%