Webpage IR codes using Actions
|Top Previous Next|
Note that with a little bit of creativity you can see that this tutorial can also be used to learn how to place events on a web page, which is really all this is.
The web page
Let's say we created a file called "irbuttons.html" inside this we'll add the following bits and pieces to create a barebones HTML file with Girder integration.
There are two lines that are of interest here. First the line:
•eventString, as the name implies is a string, a piece of text that we can randomly select. Pick something memorable link "IR Button 1".
•eventDevice is a number Girder uses to determine who is responsible for this event. In this case we'll use 18, which is the magic number for Girder's own events (or external events like this).
•keyModifier is the number that determines if this is a "NONE" (=0), "ON" (=1), "REPEAT" (=4) or "OFF" (=2).
•payloads is an array of strings that should be passed to Girder as a payload.
•cb is a callback parameters. Pass a function to this if you'd like to be notified of success or failure.
This function we use on the second line of interest in the HTML file:
This tells HTML to create a button element and when it is clicked it calls our gir.triggerEvent function!
Hooking it all together
Now that we have a very basic we page we'd like pressing that button to do something. You might have noticed that pressing the button on that page will trigger an event in Girder, specifically the "IR Button 1" event. All we need to do now is tell Girder to trigger the Send IR action when this event comes in. This of course is discussed in the "Hook Events to Actions" tutorial. Press the button on the web page after you hooked the event to the IR action and you should magically now be sending IR codes out of your PIR-1! Congratulations.
You can find this also as an example in triggerEvent.html in the httpd directory