Comments (13)
Didn't have time to test it, but this should work. Just send a request to /resettimer
.
from led-control.
Thanks for the quick answer and solution! I don't have access to the Pi's at the moment, but I'll let you know as soon as I'm able to test this.
from led-control.
Just tested the update with 3 devices and it works great! Thanks again.
I'll close this issue.
from led-control.
Thank you for this great tool. I've added a webpage to use as a simple controller, with buttons that use GET requests to so I can easily switch between specific settings. For example: Button A might set the brightness to 0.2, speed to 0.1 and select the 'fire' color palette, while button B will set the brightness to 1.0, speed to 1.0 and enable a custom movement pattern. This works great, and by sending the same GET request to multiple IP addresses I can control a couple of Raspberry Pi's at the same time.
The only problem I have is the cycle on the Pi's not being in sync. When I press button B to start a wiping movement on all Pi's they will switch to the pattern at (pretty much) the same time, but the position might be different as their current cycle positions are not the same.
I've been checking the code, but it doesn't seem to be an endpoint to reset the cycle, or am I missing something? If there isn't, do you have any suggestions on how to implement this?
(I hope my question is clear, feel free to let me know if it isn't).
Can you give me an example of this GET request on another pi ?
Tkanks a lot
from led-control.
hi @Fitipalek
This isn't the most sophisticated way to do things, but it worked for the quick fix I needed. In my case I have 5 devices I wanted to sync, so I added a button in HTML:
<button onclick="sync()">Sync</button>
Then in the javascript I defined a list of IP addresses for all my devices (I made them static in the router so they never change):
const endpoints = [
'http://192.168.1.201',
'http://192.168.1.202',
'http://192.168.1.203',
'http://192.168.1.204',
'http://192.168.1.205',
];
Lastly, the sync()
function simply iterates over this list and requests the resettimer endpoint from all of them. Technically there might be a small delay between the calls, but in practise this seems to work fine and you can always hit the sync button again.
function sync(){
for (let i=0; i<endpoints.length;i++) {
fetch(`${endpoints[i]}/resettimer`)
}
}
(Fetch is a command build into modern browsers, and we're ignoring whatever it might return)
from led-control.
@javl thanks a lot, it works, do you have also example of usage of /updatesettings parameter........ i tried but not succeeded
from led-control.
I don't, but you probably didn't mean me ;)
from led-control.
I don't, but you probably didn't mean me ;)
sorry :)
from led-control.
@Fitipalek I haven't used it but judging by the code here you need to send it a json object with the values you want to change, something like:
{
'setting1': 'value1',
'setting2': 'value2'
}
from led-control.
@javl I found in java this piece of code:
async set(path, value) {
_.set(this.settings, path, value);
console.log('Store set:', path, value);
const delta = {};
_.set(delta, path, value);
await axios.post('/updatesettings', delta);
}
when i run it like this :
async set(path, value) {
_.set(this.settings, path, value);
console.log('Store set:', path, value);
const delta = {};
_.set(delta, path, value);
//fetch('http://10.23.24.12:8001/updatesettings',delta);
axios.post('http://10.23.24.13:8001/updatesettings',delta);
axios.post('http://10.23.24.12:8001/updatesettings',delta);
}
it is working for local raspberry but not for the other
when i use postman tool from chrome and send post request, that way i can control both raspberries
Is there something what is blocking post requests but not get requests ?
Thanks :)
from led-control.
I edited this piece of code in Python on one of the rasperries and now it is working for me :)
@app.post('/updatesettings') def update_settings(): 'Update settings' new_settings = request.json x = requests.post('http://10.23.24.12:8001/updatesettings', json = new_settings ) controller.update_settings(new_settings) return jsonify(result='')
Thanks :)
from led-control.
@javl I found in java this piece of code:
async set(path, value) { _.set(this.settings, path, value); console.log('Store set:', path, value); const delta = {}; _.set(delta, path, value); await axios.post('/updatesettings', delta); }
when i run it like this :
async set(path, value) { _.set(this.settings, path, value); console.log('Store set:', path, value); const delta = {}; _.set(delta, path, value); //fetch('http://10.23.24.12:8001/updatesettings',delta); axios.post('http://10.23.24.13:8001/updatesettings',delta); axios.post('http://10.23.24.12:8001/updatesettings',delta); }
it is working for local raspberry but not for the other when i use postman tool from chrome and send post request, that way i can control both raspberries
Is there something what is blocking post requests but not get requests ?
Thanks :)
This doesn't work because you can't send cross-origin requests from Javascript code running inside of a website. This is a security feature. If you were to send these POST requests from Javascript code running in Node.js or from a program written in any other language, they would work.
from led-control.
@jackw01 Not necessarily. By default cross-origin requests are not allowed, but I've added flask-cors in my fork to allow these requests.
javl@489ec91
Note: opening up your server this way can be a very bad idea. Imagine someone turning on all of your LEDs to full brightness while your power supply is not rated for full power / long durations of such power delivery.
I needed this so I can control my setup from a phone, but the router I'm using is NOT connected to the internet, it's just for a local network.
from led-control.
Related Issues (20)
- ledcontrol service needs manual restart after klipper restarts
- can I include speed and scale in a custom pattern?
- How many LED's with 1 data pin HOT 2
- Fixed it with reinstall of raspbian
- Controlling multiple LED strips from a single frontend
- Support 6 LEDs-per-pixel (24v strips) HOT 1
- Alternative sigle board computers? HOT 2
- sacn enforced to off on startup
- Get an error if I try the --hap argument
- Failed building wheel for pyfastnoisesimd HOT 5
- pyOpenSSL dependency breaks install
- V.2.1.1 don't work with my raspberry version - setup.py don't work HOT 5
- issu sudo command not working HOT 6
- Issue starting up HOT 3
- Unable to start ledcontrol HOT 3
- No module named '_ledcontrol_rpi_ws281x_driver HOT 4
- Raspberry Pi 3A+ Revision 1.1 not yet supported by rpi_ws281x
- can't run setup , something to do with bjoern? HOT 5
- sACN input not processed unless an animated pattern is selected
- Error when running setup.py - deprecation warning, script not starting :( HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from led-control.