estherjk / LediMote

Remote-controlled LEDs using Intel Edison and Node.js (iOS and Android apps also available)
MIT License
4 stars 3 forks source link

Feature Request; Sync Button Status #1

Open neileum opened 8 years ago

neileum commented 8 years ago

First off thank you for sharing this code its what i have been looking for. as i am still very new to coding i was wondering if it would be possible to save the state of a button. for example lets say i trigger led1 on from computer a when i pull up the web page on computer b i would like to to show the current state ie on. or if i close out of the browser when i go back in to it to show the current state of the buttons. iv tired tons of searches and playing around with the code a bit but haven't been able to figure it out. Also i would like to display input variables from the arduino breakout board on the web page such as temperature from pin 11 for example.

estherjk commented 8 years ago

I did think about a sync feature when I first created the project. But, it's been a matter of bandwidth, as I've had other things on my plate. I certainly hope to get to this sooner than later!

neileum commented 8 years ago

Hi i actually got the web pages to sync up rather easy using socket io the next issue i ran into was reading the initial state of the LED let say its already on when you load the web page the switch doesn't reflect that. i was looking in to passing it through to the client using the on.connection in socket io but had issues as the client doesn't load up that script on connection rather when you start the server it does so the on.connection wasn't working. i have not had time to look at it sense then and im learning how to code all at the same time.

Thanks, Neil Mueller

On Mon, Oct 12, 2015 at 5:42 PM, Esther Jun Kim notifications@github.com wrote:

I did think about a sync feature when I first created the project. But, it's been a matter of bandwidth, as I've had other things on my plate. I certainly hope to get to this sooner than later!

— Reply to this email directly or view it on GitHub https://github.com/drejkim/LediMote/issues/1#issuecomment-147559008.

estherjk commented 8 years ago

Glad you were able to make progress on this. I also hope to look at this before the end of the year. I should have some time during the holidays.

estherjk commented 8 years ago

@neileum I finally got around to looking at this. Take a look at the the branch, sync-states. It mostly works. There seems to be an issue when reading an LED pin's state with the MRAA library. On occasion, it outputs an off value for an LED, even though it's on. Not sure why this is. Take a look at the code though, and see if it helps you.

neileum commented 8 years ago

Thanks so much, I'm going to check it out this week. Yes iv noticed some issues with the mraa library and some of the newer version of the Intel software. It seems that using different pins seems to clear it up for me at least. I'll let you know how it works for me as soon as I can. Thanks again

On Dec 13, 2015, at 2:55 PM, Esther Jun Kim notifications@github.com wrote:

@neileum I finally got around to looking at this. Take a look at the the branch, sync-states. It mostly works. There seems to be an issue when reading an LED pin's state with the MRAA library. On occasion, it outputs an off value for an LED, even though it's on. Not sure why this is. Take a look at the code though, and see if it helps you.

— Reply to this email directly or view it on GitHub.

neileum commented 8 years ago

@drejkim im back at it again and i want to control a relay board rather then using the GPIO library i have a relay board and a USB controller for it. i have been able to get the relay board to work using this code here https://github.com/mvines/relay and can run the test pattern or turn a relay on or off but i would like to use the relays rather then the GPIO in your code, im hoping you can help point me in the right direction of what i would change to make this work. one thing i notice is that it seems i cant define a bunch of variables on the relay16.js lib as it holds open the communication which is why im assuming he used let in his scripts rather then var \

new relay16().set(id , state)

estherjk commented 8 years ago

You'll need to update socket.js to use the relay library instead of mraa. But unfortunately, I can't give much more guidance than that since I don't have experience with relays or the particular library you're using. :/

neileum commented 8 years ago

@drejkim Yes so what i have found is i can control the relays as such

`'use strict'; let relay16 = require('./relay16.js')

socket.on('red', function(data) { toggleLed(leds['red'], data.state); printLedState('red', data.state); new relay16().set(1, data.state); //this should toggle relay 1 ` so what i need to do now is remove the mraa stuff but i still need a var to hold the states unless it can be read from the relay directly which looks like it might be possible

tony-long commented 6 years ago

Thanks for sharing all of this - I came across this project while searching for an solution to an idea. I want to use Edison to turn on/off features on a model railroad display that guests can do use on their phone. The idea is they come to visit the model railroad display, connect to local wifi, get a default page of feature on/off buttons. Some features many be lights or motors controlling animations. However, in the testing of this if you rapid click on a button the LED goes into blink (spastic) mode and the buttons are not sure what position to be in. I'm wondering how best control this and maybe this is related to the questions about button state. If you have any suggestions on how to better secure and control the socket IO state to prevent this please let me know. Cheers!