-->
Page 1 of 2

Pin status check with basic

PostPosted: Sat Nov 28, 2015 4:43 am
by forlotto
After trying a million ways from Sunday

I would like the ability to check pin status of an output much like the vars page now does in code.

I think it makes since to want to know if something is on or off and if you were to visit the page again
have it change with the static and not remain a static value.

Code: Select all
if io(pi,D1) = 1 then statusofpin = "<p>Pin high</p>" else statusofpin = "<p>pin low</p>"
print statusofpin

  Button "On" [on]
Button "Off" [off]
Wait

[on]
Po D1 1
Wait



I have tried with buttons and msg handler etc but for some odd reason the value always sits static even with buttons it just has got to be something that needs to be added somehow. I thought it may just be me for some time now but after following all examples to a T I have deduced that it simply appears to be impossible without modification to the code.

However there is hope it can be done with LUA and it is done on the var's page in basic so I feel it may be my incorrect ways of approaching the problem maybe I need to use:

onload xxxxx

Which I would like to see an example of.

Or possibly an html variable .

I've messed with both very little and don't know if I am doing things correctly and will mess with them some more as time provides but really this should be a fairly basic thing to do one would assume or implement at least. I appreciate the attempt at the vars page showing pin stats and such but for my project I would like to print out or display information relative to the status of the pin. For instance "Light 1 is On"

I apologize if there is some way of doing this that I was already told and it was overlooked or not working or if you already explained to me how to accomplish it but I have taken what was explained and ran with it for hours trying many different ways of storing values and different places of running the code different ways of terminating the values.

I have began to reduce the code to its simplest form as above to make the discovery how to do this an easier process rather than 50 lines of code I have cut it down in hopes to get status of one pin and have it update when the status changes.

Other things I could try are loading picture buttons if the status is currently On have on be lit up green etc... But really I would like to handle with MyMsgBranch if possible I don't want to have buttons hosted on the esp per say just the ability to see the status and send on/off commands to it.

Dynamic Values I believe would be the correct terminology. Maybe I could have just little pictures and text load to show the status I really don't know but if the text stays static chances are so will the pictures.


Anyhow just a suggestion in the suggestion box even if it somehow scrapes the values off of the vars page and allows me to put the values in plain english as such and such is off or on.

Re: Pin status check with basic

PostPosted: Sat Nov 28, 2015 8:41 am
by Mmiscool
In your example you are using PIN D1 as an input at the top and an output at the bottom. Is this intended?

Re: Pin status check with basic

PostPosted: Sat Nov 28, 2015 12:11 pm
by forlotto
Or better yet how do you show the pin status on the vars page what is the code for that?
If it is written in C how would I use the basic interpreter to do the same thing?

I really don't know how else to explain the trouble I am having so you understand just what it is I am requesting. The status is live on the vars page it is constantly changing etc.

I am curious how you do this as I need this similar ability ....

Re: Pin status check with basic

PostPosted: Sat Nov 28, 2015 1:55 pm
by Mmiscool
The code below will display the status of the pin D3 on the page. It will pull the status from the page each time the page is loaded. I used pin D3 because it hook to the flash button on the node mcu board.

Code: Select allONLOAD [testpins]
print htmlvar(statusofpin)
wait

[testpins]
if io(pi,D3) = 1 then statusofpin = "<p>Pin high</p>" else statusofpin = "<p>pin low</p>"
wait