Pulse does not work...

33 views
Skip to first unread message

Russell Selkirk

unread,
Feb 25, 2019, 5:58:39 PM2/25/19
to WebIOPi
I need to code a single button for a one-shot pulse. I've got the "Tutorial : Framework basis" light to work fine, but cannot seem to adapt it to pulse...

TIA!

Russ

jose correia

unread,
Feb 26, 2019, 9:02:17 AM2/26/19
to web...@googlegroups.com

I already did what u want to do. As i'm not working with, i need to find the script. I'll send to you.

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Russell Selkirk

unread,
Feb 26, 2019, 11:05:11 AM2/26/19
to WebIOPi
I think some of the problem is the original "pulse" code was written in 2012 and the syntax and/or library has since changed. I've tried pasting the pulse code into the "framework" tutorial and it does nothing. I can tweak it so it shows the pulse button, but then it acts as a simple on-off toggle. Maybe I'll soon learn enough java to better understand the flow...


Russ

Russell Selkirk

unread,
Feb 26, 2019, 12:13:04 PM2/26/19
to WebIOPi
OK, finally got my relay to pulse, but it only works with the "hold" code. Now I need to fins a way to make the button "release" after, say. 300 ms. 

This the index file, no script.py needed:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>WebIOPi : Hold</title>
    <script type="text/javascript" src="/webiopi.js"></script>
    <script type="text/javascript">
    webiopi().ready(function() {
        // Create a "Pulse" labeled button for GPIO 21
            button = webiopi().createButton("hold", "Hold", mousedown, mouseup);
         // Append button to HTML element with ID="controls" using jQuery
            $("#controls").append(button);

        // Refresh GPIO buttons
        // pass true to refresh repeatedly or false to refresh once
            webiopi().refreshGPIO(true);
    });

     function mousedown() {
        webiopi().digitalWrite(21, 0); // trigger relay
    }

    function mouseup() {
        webiopi().digitalWrite(21, 1); // release relay
    }
       
    </script>
    <style type="text/css">
        button {
            display: block;
            margin: 5px 5px 5px 5px;
            width: 160px;
            height: 45px;
            font-size: 24pt;
            font-weight: bold;
            color: white;
    </style>
</head>
<body>
    <div id="controls" align="center"></div>
</body>
</html>

Any ideas on the 300 ms timeout (or better yet, the proper pulse code) would be appreciated!

Russ

jose correia

unread,
Feb 27, 2019, 5:08:40 AM2/27/19
to web...@googlegroups.com
I got pulse Button working like that

Js file

Webiopi().ready(function(){
                                            webiopi().setFunction(22,"out");

var content, button;
content=$("#content");

webiopi().refreshGPIO(true);

//create a button which output a bit sequence on GPIO 22 with a 1sec period
button = webiopi().createSequenceButton("sos", "NameButton", 22, 1000, "10");
content.append(button);

});

Note: time is in miliseconds. If u want to Change the button time on, u should Change the 1000 value. If u want the button 2s on, the value should be 2000.

I hope this info help u. I also spent a huge amount of time digging around.    



--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.

Russell Selkirk

unread,
Feb 27, 2019, 12:36:47 PM2/27/19
to WebIOPi
On Wednesday, February 27, 2019 at 4:08:40 AM UTC-6, jose correia wrote:
I got pulse Button working like that

Js file

Webiopi().ready(function(){
                                            webiopi().setFunction(22,"out");

var content, button;
content=$("#content");

webiopi().refreshGPIO(true);

//create a button which output a bit sequence on GPIO 22 with a 1sec period
button = webiopi().createSequenceButton("sos", "NameButton", 22, 1000, "10");
content.append(button);

});

Note: time is in miliseconds. If u want to Change the button time on, u should Change the 1000 value. If u want the button 2s on, the value should be 2000.

I hope this info help u. I also spent a huge amount of time digging around.    

Jose, that works! Not knowing any of the syntax, I stumbled around and got the action reversed (to suit my app) by changing the "10" to "01". Have you ever run across any reference resources explaining all the parameters? There has to be an explanation for.the WebioPI functions, parameters, syntax, etc somewhere out there!

Thanks bud!

Russ
Reply all
Reply to author
Forward
0 new messages