MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

how to start an image slide show with a press of a button?



  • Hello,

    I would like to start an image slide show with a short press of a button and then stop the image slide show with a long press of a button.
    I have a button connected to pin 15 and I’ve tested with a python code that it works.
    I think that I need to use the MMM-Imageslideshow and the MMM-Buttons modules but I don’t know how to configure them to work as described.

    Can someone please help?

    thank you!



  • @xela
    As i can see there is no image module which allows sending/receiving notifications.

    but how about just hide and how the module?

    U would need MMM-RemoteControl, too.

    MMM-Buttons:

    		{
    		    module: 'MMM-Buttons',
    		    config: {
    			maxShortPressTime: 1000,
    		        buttons: [
    		            {
    		                pin: 15,
    		                name: "MMM-ImageSlideshow",
    		                shortPress: {
    		                    notification: "REMOTE_ACTION",
    		                    payload: {
                                action: "SHOW",
                                module: "module_0_MMM-ImageSlideshow"
                            }
    		                },
                              longPress: {
                              notification: "REMOTE_ACTION",
                              payload: {
                              action: "HIDE",
                              module: "module_0_MMM-ImageSlideshow"
                                              }
                                     },
    		       },
    		     ]
    		   }
    		},
    

    edit:
    the module_0_MMM-ImageSlideshow means, that this module is on the first position in your config.js.
    So u need to count to this module beginning with 0.
    If the module is at third position in your config it would be module_2_MMM-ImageSlideshow



  • Thank very much, but it didn’t work.
    the button definitely working outside MM (tested it with Python code).
    Also, is it possible to start the MMM-imageslideshow as hidden?

    Here is my config:

    /* Magic Mirror Config Sample
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     *
     * For more information how you can configurate this file
     * See https://github.com/MichMich/MagicMirror#configuration
     *
     */
    
    var config = {
    	address: "0.0.0.0", // Address to listen on, can be:
    	                      // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
    	                      // - another specific IPv4/6 to listen on a specific interface
    	                      // - "", "0.0.0.0", "::" to listen on any interface
    	                      // Default, when address config is left out, is "localhost"
    	port: 8080,
    	ipWhitelist: [], // Set [] to allow all IP addresses
    	                                                       // or add a specific IPv4 of 192.168.1.5 :
    	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
    	                                                       // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
    	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
    
    	language: "en",
    	timeFormat: 12,
    	units: "metric",
    
    	modules: [
    		{
    			module: 'MMM-ImageSlideshow',
    			position: 'bottom_left',
    			config: {
    				imagePaths: ['modules/MMM-ImageSlideshow/Images']
    		}
    		},
    		{
    			module: "alert",
    		},
    		{
    			module: "updatenotification",
    			position: "top_bar"
    		},
    		{
    			module: 'helloworld',
    			position: 'top_bar',	// This can be any of the regions.
    			classes: 'small bright',
    			config: {
    			text: 'The Modelevich family Magic Mirror, built by a very talented person!'
    		}
    		},
    		{
    			module: "clock",
    			position: "top_bar"
    		},
    		{
    			module: 'calendar',
                position: 'top_left',
    			config: {
    			urgency: 0,
    			getRelative: 6,
    			fade: 'false',
                timeFormat: 'absolute',
    			cssStyle: 'block', // block, clean, custom, (slate is for no mirror),
    				calendars: [
    					{
    						symbol: 'calendar-check-o ',
    						url: 'http://www.vic.gov.au/themes/v6/images/VictoriaCalendar-PublicHolidays.ics'
    					},
    					{	// YOU GET THE FOLLOWING URL FROM YOUR GOOGLE CALENDAR PAGE
    						url: 'https://calendar.google.com/calendar/ical/public/basic.ics'
    					},
    				],
    			}
    		},
    		{
        		module: 'MMM-WunderGround', // Just for forecast w/css entry
        		position: 'top_right',
        		config: {
            	apikey: '', // private; don't share!
            	pws: 'pws:I', // Bentleigh East Weather Station - Very Cool
    			currentweather: 1,
            	coloricon: true,
            	hourly: '1',
            	fctext: '1',
            	fcdaycount: "7",
            	fcdaystart: "0",
            	hourlyinterval: "2",
            	hourlycount: "1",
    			animationSpeed: 5000,
            	alerttime: 10000,
            	alerttruncatestring: "english:",
        		roundTmpDecs: 0,
        		UseCardinals: 1,
    			fade: false,
        		layout: "vertical",
    			windunits: "mph",
        		sysstat: "0"
    		}
    		},
    		{
    	        module: 'MMM-Traffic',
                position: 'top_left',
                classes: 'dimmed medium', //optional, default is 'bright medium', only applies to commute info not route_name
                config: {
                    api_key: '',
                    mode: 'driving',
    				origin: '9 Tambet Street, Bentleigh east, Australia 3165',
    				destination: '96 Herbert Street, Northcote, Australia 3070',
    				arrival_time: '0900', //optional, but needs to be in 24 hour time if used.
    				route_name: 'Home to Work',
                    changeColor: true,
                    showGreen: false,
                    limitYellow: 5, //Greater than 5% of journey time due to traffic
                    limitRed: 20, //Greater than 20% of journey time due to traffic
                    traffic_model: 'best_guess',
                    interval: 60000, //2 minutes
                    showWeekend: true,
                    allTime: true,
                    width: '300px',
                    height: '300px'
                }
            },
    		{
                module: 'MMM-GoogleMapsTraffic',
                position: 'top_left',
                config: {
                    key: '',
                    lat: -37.7685637,
                    lng: 144.9943173,
                    height: '400px',
                    width: '550px',
    				zoom: 13,
    				disableDefaultUI: false
                }
            },
    		{
        		module: 'voicecontrol',
        		position: 'top_right',
        		config: {
            		models: [
                	{
                    	keyword: "Show Camera",
                    	description: "Say 'Show Camera' to display camera",
                    	file: "showCamera.pmdl",
                    	message: "SHOW_CAMERA"
                	},
                	{
                    	keyword: "Hide Camera",
                    	description: "Say 'Hide Camera' to hide camera",
                    	file: "hideCamera.pmdl",
                    	message: "HIDE_CAMERA"
                	},
                	{
                    	keyword: "Selfie",
                    	description: "Say 'Selfie' when camera is visible",
                    	file: "selfie.pmdl",
                    	message: "SELFIE"
                	},
            ],
    		}
    		},
    		{
    			module: 'camera',
        		position: 'fullscreen_above',
        		config: {
    			selfieInterval: 3,  // Time interval in seconds before the photo will be taken.
            	emailConfig: {
                service: 'gamil', // Email provider to use to send email with a photo.
                auth: {
    
            }
            }
    		}
    		},
    
    		{
    			module: "compliments",
    			position: "lower_third"
    		},
    		{
    			module: 'newsfeed',
    			position: 'bottom_bar',
    			config: {
    				feeds: [
    					{
    						title: "The Age",
                                                    url: "http://feeds.theage.com.au/rssheadlines/top.xml",
                                          },
                                            {
                                                    title: "Sport",
                                                    url:  "http://www.theage.com.au/rssheadlines/sport/article/rss.xml"
                                            }
                                    ],
    				showSourceTitle: true,
    				showPublishDate: true
    			}
    		},
    {
    		    module: 'MMM-Buttons',
    		    config: {
    			maxShortPressTime: 1000,
    		        buttons: [
    		            {
    		                pin: 18,
    		                name: "MMM-ImageSlideshow",
    		                shortPress: {
    		                    notification: "REMOTE_ACTION",
    		                    payload: {
                                action: "HIDE",
                                module: "module_0_MMM-ImageSlideshow"
                            }
    		                },
                              longPress: {
                              notification: "REMOTE_ACTION",
                              payload: {
                              action: "SHOW",
                              module: "module_0_MMM-ImageSlideshow"
                                              }
                                     },
    		       },
    		     ]
    		   }
    		},
    		{
    		module: 'MMM-Remote-Control', 
    		position: 'bottom_right'
    		},
    	]
    
    };
    
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    


  • hmm…

    To start it hidden just open your remoteControl with http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote.html
    Go to “Edit view” and hide the module. Then press "SAVE"
    Note: Every time you change your config u need to do this again 😉

    so now to your button problem…

    please try this:

    open a browser on your pc and type:

    http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote?action=HIDE&module=module_0_ImageSlideshow

    http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote?action=SHOW&module=module_0_ImageSlideshow

    This should hide and show the module as these are the comments which the remote control is using.

    If this works its probably a configuration problem with the PIN.

    note that:

    +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
     | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
     +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
     |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
     |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
     |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
     |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 0 | IN   | TxD     | 15  | 14  |
     |     |     |      0v |      |   |  9 || 10 | 1 | IN   | RxD     | 16  | 15  |
     |  17 |   0 | GPIO. 0 |  OUT | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
     |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
     |  22 |   3 | GPIO. 3 |  OUT | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
     |     |     |    3.3v |      |   | 17 || 18 | 0 | OUT  | GPIO. 5 | 5   | 24  |
     |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
     |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
     |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
     |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
     |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
     |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
     |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
     |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
     |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 1 | OUT  | GPIO.27 | 27  | 16  |
     |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
     |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
     +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
     | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
     +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
    

    Don’t know what type u are using (BCM, w-pi, physical ??)

    In your config you wrote Pin: 18, but in your first post u said 15…

    Maybe try another one. For example u could use GPIO 29, which is physically Pin 40, which is BCM Pin 21…

    So in your config u must write, that u are using Pin 21!



  • thank you so much for your help!

    so, by going to the http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote.html and hiding the module, it works fine. under “edit view” when i slide it to hide the slideshow goes off and when i’m sliding it to on the slideshow goes on.

    however, both
    http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote?action=HIDE&module=module_0_ImageSlideshow

    http://YOUR.RASPBERRY.IP.ADDRESS:8080/remote?action=SHOW&module=module_0_ImageSlideshow
    don’t work although I’m getting “success” message.



  • @xela

    Ah sorry… the MMM was missing. should be this:

    http://your.raspberry.ip.address:8080/remote?action=HIDE&module=module_0_MMM-ImageSlideshow

    And

    http://your.raspberry.ip.address:8080/remote?action=SHOW&module=module_0_MMM-ImageSlideshow



  • works perfectly, thank you so much for your help!

    and now to the ultimate question for me… Is it possible to start the camera on full screen by a press of a button?



  • surely, but i don’t know what camera u mean^^

    A security camera somewhere at your house or the RPi camera?

    For security u could check this: https://github.com/shbatm/MMM-RTSPStream

    for RPi cam u could check this: https://forum.magicmirror.builders/topic/603/camera-module



  • I use a Microsoft round web cam that I’ve embedded into the frame and I’m using the camera module however the voice recognition is not very good so I wanted to start it with a press of a button, but I don’t know how and how to display the video vertically on full screen.



  • So you use the camera module i posted?

    unfortunately i don’t use this module, so i am maybe the wrong person to ask…

    But i took a look at the webcam.js of the module and in line 46/47 the width and hight is defined.
    Maybe u should play around with that…
    https://github.com/alexyak/camera/blob/master/webcam.js

    nano MagicMirror/modules/camera/webcam.js

    also check the camera.js at line 62/63…

    nano MagicMirror/modules/camera/camera.js

    I don’t know if it would be necessary to set the resolution of the cam within raspbian… ?

    To start the cam with a button u can even use the MMM-Buttons module. This should work, if i understand the camera-module correct ^^

    {
    		    module: 'MMM-Buttons',
    		    config: {
    			maxShortPressTime: 1000,
    		        buttons: [
    		            {
    		                pin: 15,
    		                name: "camera",
    		                shortPress: {
    		                    notification: "SHOW_CAMERA",
                                             }
    		             },
                                    longPress: {
                                    notification: "HIDE_CAMERA",
                                             },
    		             },
    		         ]
    		     }
    		},