Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send PAUSE/RESUME notification ? #11

Open
maxencekyz opened this issue Mar 28, 2021 · 6 comments
Open

How to send PAUSE/RESUME notification ? #11

maxencekyz opened this issue Mar 28, 2021 · 6 comments

Comments

@maxencekyz
Copy link

Hello @edward-shen @Burnallover ,

Your module is just AWESOME ! You guys are so nice to develop it, thank you so much !
Everything works fine, i can increment/decrement pages. However, impossible to have a PAUSE / RESUME notifications.

Here is my module Remote-Control menu, when i click on your module "page-indicator" :

image

The menu is just showing what's inside the MMM-page-indicator.js
Which is:

image

So after this :

if (notification === 'PAGE_INCREMENT') {
Log.log(${this.name} recieved a notification to increment pages!);
this.curPage = mod(this.curPage + 1, this.config.pages);
this.updateDom();
} else if (notification === 'PAGE_DECREMENT') {
Log.log(${this.name} recieved a notification to decrement pages!);
this.curPage = mod(this.curPage - 1, this.config.pages);
this.updateDom();
}

What should I write ?

} else if (notification === 'PAUSE_ROTATION') {
????????????????????????????

} else if (notification === 'RESUME_ROTATION') {
????????????????????????????

Thanks per advance guys !
Have a wonderful day

@edward-shen
Copy link
Owner

If you're using MMM-pages, then that has the notification hooks you're looking for.

Please note that this is just a indicator module, and is not supposed to have any other functionality.

@maxencekyz
Copy link
Author

Hello @edward-shen,

Thanks for your reply. I agree with you, it's just an indicator module.
However, I don't find the notification hooks i'm looking for in MMM-pages.js

I only see this in MMM-pages.js :

case 'PAUSE_ROTATION':
this.setRotation(false);
break;
case 'RESUME_ROTATION':
this.setRotation(true);
break;

But it do not work. When i copy/paste it in MMM-page-indicator.js , it crash the magic mirror.

You made this module, do you have any idea of what should I write to send pause/resume notification?

Thanks ! :)))

@edward-shen
Copy link
Owner

You shouldn't need to copy or paste anything. Both already work together to pause rotation and show that rotation is paused, repsectively.

@maxencekyz
Copy link
Author

Why i don't see it in page indicator then ?

@edward-shen
Copy link
Owner

Because you should be sending paused and resume notifications to MMM-pages instead.

@maxencekyz
Copy link
Author

maxencekyz commented Apr 1, 2021

I found the solution you were 50% wrong. haha
Actually, yes i need to send pause/resume notifications to MMM-pages,
BUT you can just write the notifications in MMM-pages indicator directly.

So I wrote in MMM-page-indicator.js this code below and it shows perfectly everything in the Remote-control menu:

if (notification === 'RESUME_ROTATION') {
Log.log('${this.name} resuming rotation due to notification');
this.curPage = this.rotationPaused = false;
this.updateDom();
} else if (notification === 'PAUSE_ROTATION') {
Log.log('${this.name} pausing rotation due to notification');
this.curPage = clearInterval(this.timer);
this.curPage = clearInterval(this.delayTimer);
this.curPage = this.rotationPaused = true;
this.updateDom();
} else if (notification === 'PAGE_INCREMENT') {
Log.log(${this.name} recieved a notification to increment pages!);
this.curPage = mod(this.curPage + 1, this.config.pages);
this.updateDom();
} else if (notification === 'PAGE_DECREMENT') {
Log.log(${this.name} recieved a notification to decrement pages!);
this.curPage = mod(this.curPage - 1, this.config.pages);
this.updateDom();
}
},
});

The only problem now is that :
I currently have a timer changing from page 1 to page 2 every 10 seconds.
If I click on PAUSE ROTATION, it says "it's already on pause"
So everytime i wanna pause, i need to send "RESUME_ROTATION" first and then click on "PAUSE_ROTATION"
This is probably because when the time is on, PAUSE_ROTATION is on aswell in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants