gfischershaw / MMM-Touch

MagicMirror module for universal touch gesture commander using touchscreen
MIT License
12 stars 5 forks source link

Problems with "onNotification" #5

Open McNose opened 3 years ago

McNose commented 3 years ago

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

McNose commented 3 years ago

Ah..sorry. maybe it is getting late already. If I am right, the module recognizes which other module is touched by me and changes the mode? That would be awesome. And no more buttons would be necessary.

So guess i will have a sleep now and another deeper look tomorrow.

Regards

McNose commented 3 years ago

Ok. Seems like now I got it how the module works. Great stuff. Thanks for sharing. But I still got two questions.

  1. If I enter some code in the section "onNotification" and restart the mirror, nothing happens. The monitor stays black. Not even an error in the config is mentioned. I tried your example code and even code on my own. Both the same. Do you have any idea what the reason might be? is it a bug or my fault?
  2. I unterstood that I just define the mode and it is not important where to touch on the display as long it is my defined gesture. What I would love to do, is have a floorplan on my mirror with my smart home connected. For example I would have 5 icons of bulbs, which should be turned on by pressing the icon. Is it possible to modify the module in such a way? If I am right, it is not possible right now, because a gesture like pressing can only be used once.

Thanks a lot.

gfischershaw commented 3 years ago

Been on other projects for some time now and did not see this issue. I will get back to you next week.

McNose commented 3 years ago

No problem. Take your time.

gfischershaw commented 3 years ago

Have you looked at the "notes" file in the project? What you might want to use is autoMode and use a value of "module" which will set the mode to whichever module owns the screen real estate that was touched.

I don't believe there is such a bug that you describe at this time. There was an issue that I just merged when modules were disabled (was not checking for validity of the array index). Could be that you hit that.

McNose commented 3 years ago

Could you please explain the auto mode a bit more. Especially the example:

autoMode: ["swipe_page_override","nytimes","module"]

I just wrote: autoMode: "module" , which seems to work fine with my newsfeed-modules. But what is the rest of your example code?

Besides this: Is there a way to change the gestureCommand for particular icons, buttons or areas of a module? I am thinking of a floorplan with some bulbs on it, to control my smart home.

Thx for helping Great work!

gfischershaw commented 3 years ago

I only used MM briefly, and some time ago now. Moved on to another platform.

autoMode: “module” checks over which module a touch event is actually happening and sets the current mode to that module. If the touch does not occur over any module at all, then the current mode is retained. This allows the NYT to pop up full screen, and then use a gesture to leave full screen.

autoMode: “instanceId” instead uses the module's optional instanceId as the current mode.

If you are going to modify code, you might as well add instanceId to newsfeed in notificationReceived() so that if an instanceId is passed, it will only pay attention to notifications meant for its own instance:

if(payload && payload.hasOwnProperty('instanceId') && (!this.config.instanceId.length || (this.config.instanceId != payload.instanceId))){ return false }

Then in your config add an instanceId entry to each of the newsfeed config entries. You can then name your gesture sections as the instanceId, such as “nytimes” rather than “newsfeed”.

As you are using newsfeed you may notice a bug, in that the headline timer does not reset itself when you move prev/next article manually. https://github.com/MichMich/MagicMirror/issues/2005