gfischershaw / mmm-touch Goto Github PK
View Code? Open in Web Editor NEWMagicMirror module for universal touch gesture commander using touchscreen
License: MIT License
MagicMirror module for universal touch gesture commander using touchscreen
License: MIT License
I have just seen that Sean is not on duty anymore.
So thanks for taking care of this great module now.
I am not very good at programming, but playing around a little helped me understand.
However I am wondering if it is possible to create more buttons?
Is there a way to modify the code (if necessary just quick and dirty) or do you think I can run multiple instances at the same time?
And one more question: is it possible to change the displayed name to an icon?
Thanks a lot.
Mr.Coffee
I tried out this module and was frustrated with a few things, so made a few additions. If interested code is attached.
DOUBLE_TAP
Tracks the delta-T between successive single-finger TAP events and transforms the second TAP to a DOUBLE_TAP if it is within the threshold. This implies that any double tap will always be a DOUBLE_TAP_1. This can be disabled by setting the threshold to zero.
Allow arrays of modes:
The module handles an ordered list (i.e., array) of gesture modes which are searched in order for the first containing a supported gesture. defaultMode
can optionally be set to an array, and setMode()
optionally takes an array. For backwards compatibility getMode()
returns a string when only a single mode has been set. That can be overridden to provide a consistent return type by setting defaultMode
to an array rather than the default of being a string.
Automatic mode setting:
The current array of modes can be automatically determined by the target of the touch event. This allows one to tap say, a newsfeed module instance, and have the current mode automatically change to an appropriate set of gestures for that module. autoMode
is disabled by default for compatibility, and to enable can be set to either a string for a single item, or an array of multiple items. Valid values:
"module" - This entry is translated into the module name. If the target of the touch event is a newsfeed, then the resultant mode will be "newsfeed".
"index" - This entry is translated into the index of the module in MM.getModules()
. I.e., "1", "2", "3", etc. Not a great feature, but it appears elsewhere in modules, so it is here as well.
"instanceId" - This entry is translated into an optional string in the target module's config section of the same name. This is one piece of the support for multiple instances of a module. So one could add say, instanceId: "nytimes"
to a newsfeed config that sources the NY Times.
mode name - Lastly, any mode name can also be used as part of the list.
autoMode Example:
autoMode: ["swipe_page_override","nytimes","module"]
Gesture Examples:
"SWIPE_LEFT_1": (commander, gesture) => { commander.sendNotification("ARTICLE_NEXT", {instanceId: gesture.instanceId}) }, "MOVE_LEFT_1": (commander, gesture) => { commander.forceCommand(commander.getMode(), {gesture:"SWIPE_LEFT", fingers:"1", instanceId:gesture.instanceId}) }, "DOUBLE_TAP_1": (commander, gesture) => { commander.sendNotification("ARTICLE_MORE_DETAILS", {instanceId: gesture.instanceId}) }, "TAP_1": (commander, gesture) => { commander.sendNotification("ARTICLE_LESS_DETAILS", {instanceId: gesture.instanceId}) },
Added "instanceId" to the Gesture object passed to gesture commands. If autoMode
is enabled and if the module instance that receives a touch event has defined an "instanceId" then it will be passed through. Otherwise undefined. This should be passed as part of the payload to sendNotification()
for modules that can support multiple instances. When calling forceCommand()
the instanceId can be passed in the payload.
Of course to make multiple module instances actually work, a module needs to pay attention to the optional instance information within a sendNotification()
. The following newsfeed example code in notificationReceived()
will only rejects calls when an instanceId
has actually been passed, but the module instance does not define an instanceId
or they do not match. So notifications without an instanceId
are accepted by all module instances:
if(payload && payload.hasOwnProperty('instanceId') && (!this.config.instanceId.length || (this.config.instanceId != payload.instanceId))){ return false }
Hey there,
it seems to me this is a great module!
However the documentation is a little bit poor.
For me, I just want to have buttons, touch them, then do some stuff on the shell (light on/light off).
And in the ends, it finally works (somehow).
Thing is:
Works:
63 {
64 module: "MMM-Touch",
65 position: "top_right",
66 config: {
67 gestureCommands: {
68 "default": {
69 "MOVE_UP_1": (commander) => {
70 commander.shellExec("~/yeelight-shell-scripts/yeelight-scene .sh 0 On")
71
72 },
73 "MOVE_DOWN_1": (commander) => {
74 commander.shellExec("~/yeelight-shell-scripts/yeelight-scene .sh 0 Off")
75 }
76
77 }
78
79 }
80 }
81 },
Hey there,
awesome module you guys have here. Thanks for all your work.
I have a specific request and wanted to share with you if we could implement it here:
I want to be able to send customizable notifications when ANY touch is used.
Use-case: I don't have a PIR connected to my Pi, and want to be able to send the monitor into "sleep" mode after nobody used it for some time. Some basics in this module would be usable in that matter, but we are lacking some "send a notification after X amount of time after you clicked something" function. Implementing all of this is in this module is maybe a bit over the top, so I was wondering if we could go a step "smaller" and just be able to send custom notifications when you are actually using the touch functionality.
So to be more clear:
The alternative would be to implement the touch process into the "sleep" module, but that seems waisted time and effort, as everything is here in place :)
Tell me what you think about that. Thanks!
Hi, I'm running into a strange issue. If I have all of my modules set up and add the "position: {whatever, doesn't matter}" parameter, I can see the debug/touch bar wherever I specify it, however if I remove the "position" parameter, the touch triggers/notifications no longer work at all. It's acting as if omitting the position parameter is equivalent to setting the module as disabled. I think it might be perhaps be a compatibility issue with another module, but I'm not entirely sure. I'll poke around with trying to disable some other modules one at a time and see if I can find the culprit, but I'm a bit perplexed by this strange behavior.
Using modules:
clock
alert
MMM-Touch
MMM-Carousel (slide mode, intending to use MMM-Touch to assist in changing slides)
MMM-OpenWeatherMapForecast
MMM-CalendarExt2
I have a very simple config.js in MagicMirror setup for testing purposes where the MMM-Touch module will not change modes correctly. The config.js contains:
{
module: "MMM-Touch",
position: "top_right",
config: {
debug: true,
useDisplay: true,
defaultMode: "main",
gestureCommands: {
"main": {
"TAP_1": (commander) => {
commander.setMode("currentweather")}
},
"currentweather": {
"TAP_1": (commander) => {
commander.setMode("main")}
}
}
}
},
Upon tapping the touchscreen (a HyperPixel4 from pimoroni.com) the following error is displayed in the console:
Uncaught TypeError: Cannot set property 'innerHTML' of null :8080/modules/.../MMM-Touch.js:213
I'm trying to test some module compatibility and I can't get the touch event to fire. Even a straight default configuration doesn't produce the expected alert.
I don't have a touch screen on my Pi, but viewing it though a web browser on two different computers. One of which has a touch screen. Clicking on the button doesn't fire the event (Chrome, Firefox). Touching on the button (Edge) doesn't fire the event. No messages in the console, no messages on the Pi.
Hello,
This module is a life saver for me.
Except that I cannot write the config that works with MMM-pages and MMM-page-indicator.
I have a 32inch IR frame, and the touch screen works fine outside the magic mirror screen.
MMM-pages worked fine and created multiple pages
MMM-page-indicator shows at the bottom as I want it to as well.
I just need the page-indicator to be clicked in when I touch on it.
{
module: "MMM-Touch",
position: "top_right",
config:{
gestureCommands: {
"MMM-pages": {
"SWIPE_RIGHT": (commander) => {
commander.sendNotification("PAGE_INCREMENT")
},
"SWIPE_LEFT": (commander) => {
commander.sendNotification("PAGE_DECREMENT")
}
}
}
}
},
The above is my attempt at writing the config, which does not make anything happen.
Please can anyone help me with this??
Thank you kindly,
Hello, I can get this to work with my ir-frame without any problems, but when I try to use a mouse to click nothing happens.
I have enabled mouse in the main/custom .css so I can see the mouse cursor.
I also read on a forum that the region.fullscreen z-index should be set to 0 but that did nothing.
Do you know any changes I could make to enable your module to recognisce mouse clicks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.