Git Product home page Git Product logo

mmm-touch's People

Contributors

eouia avatar fewieden avatar gfischershaw avatar skuethe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mmm-touch's Issues

Problems with "onNotification"

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

Added features: DOUBLE_TAP, multiple modes, automatic modes, multiple module instances

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 }

MMM-Touch.zip

Great module - Poor Documentation

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:

  • I got one button with the text "default" on it, and use two different touch modes to turn light on/off. Works. What I would prefer: One button "Light on" with simple touch/move/whatever, one button "Light off" with simple touch. Maybe a setting to set the background color of the buttons.
  • A simple example of the easiest touch/button would be a big plus, otherwise you just read the documentation
  • How to get rid of that white bar?
  • How to rename button?
  • Can you give option the set backgroundcolor of buttons?

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

[feature request]: send custom notifications on "touchStarted()"

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:

  1. Every time I am using some touch gesture, the "touchStarted()" function will trigger my custom notification (f.e. "TOUCH_GESTURE_TRIGGERED", maybe even including the gesture as a payload?)
  2. A third party module could pick up this notification and react on it - f.e. some "sleep" module, which is always resetting a timer when receiving the above triggered notification and, if no notification arrives for X time, will put your monitor to sleep

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!

MMM-Touch not working when position parameter is not set

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

Unable to change mode with TAP_1

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

What are the hardware requirements for this?

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, can I ask some help?

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,

Clicks with mouse not working

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.