Author |
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 18 2005 at 22:44 | IP Logged
|
|
|
I'm working in flash to make an LCARS themed control interface. Unfortunately I am not a flash expert, nor am I an expert in making powerhome web interfaces yet. The thing I'm stuck on is how to set a button element in flash to send the proper codes to turn on/off lights etc.
I have to script it as an action and got stuck. I am more than willing to share the source flash files once I get some momentum so anyone that wants to play with it can.
Any help would be awesome!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 19 2005 at 22:15 | IP Logged
|
|
|
guerrand,
Welcome to PowerHome!
I would be more than happy to help, but Flash is one of those areas that I just havent found the time to explorer yet. However, if you have any questions on how to make something work within PowerHome using HTTP, then I can definately help you out. If Im not mistaken, a Flash action is nothing more than an HTTP request.
There are a number of internal CGI functions built into the PowerHome webserver for control. I'll hit some of the important ones below.
If you merly want to launch a macro, then you could use the HTTP request below:
http://yourpowerhomewebserverip/ph-cgi/playmacro?id=YOURMACR OID&nexturl=yournexturl
In the above example, this is typical of what you would type into a web browser. If your PowerHome machines IP is 192.168.0.10 and the webserver is on port 80 and the macro ID you wish to play is "CHANGE CHANNEL" and the URL you wish to load after playing the macro is "yourflashpage.htm" then you would structure this as:
http://192.168.0.10/ph-cgi/playmacro?id=CHANGE+CHANNEL&nextu rl=yourflashpage.htm
If you were going to embed this within a hyperlink in the HTML page called "yourflashpage.htm" and you wanted this page to automatically reload after playing your macro, you could use code like:
<a href="/ph-cgi/playmacro?id=CHANGE+CHANNEL&nexturl=yourflashp age.htm">Hyperlink Text</a>
Other CGI commands are:
/ph-cgi/devicebtn?type=BUTTONTYPE&id=BUTTONID&cmd=BUTTONCOMM AND&level=BUTTONLEVEL&nexturl=YOURNEXTURL
Another useful one for executing any valid PowerHome formula is:
/ph-cgi/evalformula?formula=AVALIDPOWERHOMEFORMULA&nexturl=Y OURNEXTURL
Hope this helps get you started and if you have any specific questions, don't hesitate to ask.
Dave.
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 20 2005 at 00:24 | IP Logged
|
|
|
Is there any way to have it just stay on the page it is on? I tried fiddleing with the http request but there doesn't seem to be a way to have it just stay put. (the lights are working btw :D) but it always resets to the inital flash page, the light controls are on a sub flash page.
Any thoughts?
Almost forgot to say thanks! You rock!
Edited by guerrand
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 20 2005 at 11:34 | IP Logged
|
|
|
guerrand,
Yep, you can make the current page stay. It has nothing to do with PowerHome, it's an HTML trick however. A good example of a couple of ways is the web based Control Center.
The trick here is that every HTTP request will result in HTML being returned and your browser loading that HTML. What you've got to do, is make the HTML go somewhere else. One way to do it is with frames. You can declare a frameset with two frames and have your main page displayed in the first frame that takes up the entire page. You then have a second frame that is basically 0 height (effective invisible). When you make a request from within your main page, just set the target to be the name of the invisible frame:
<a href="/ph-cgi/playmacro?id=TEST1&nexturl=blank.htm" target=YOURBLANKFRAMEID>Hyperlink</a>
You can also send the returned HTML to a completely different window and with Javascript have the window hidden behind your main browser (like all those pop-under windows we always get ).
I prefer the frames method, but either should work for you.
HTH,
Dave.
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 20 2005 at 12:13 | IP Logged
|
|
|
The frames trick is workig like a charm, I'll post screenies of it soon!
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 20 2005 at 12:26 | IP Logged
|
|
|
So, How's it look?
(only links since I don't want to distort the forum layout)
http://img.photobucket.com/albums/v102/ssguerrand/main.png
Main Screen
http://img.photobucket.com/albums/v102/ssguerrand/roomshot.p ng
Room Controls
Edited by guerrand
|
Back to Top |
|
|
krommetje Super User
Joined: December 29 2004 Location: Netherlands
Online Status: Offline Posts: 695
|
Posted: December 20 2005 at 12:47 | IP Logged
|
|
|
Hey that looks great...
Is it copyrighted? would love a copy!!!
Peter
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 20 2005 at 15:11 | IP Logged
|
|
|
nope, it's open to anyone, you can get the source files from http://www.lcarsdeveloper.com/ in the downloads area. That's where I got mine. You'll need to be able to edit flash files (ie. have flash developer) it's pretty easy to work with though. The tips dhoward gave are working great so far!
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 20 2005 at 22:39 | IP Logged
|
|
|
I'm getting along ok with macros so far but want to branch this out to use formulas. However I am finding myself somewhat frustrated getting a working formula together.
If it's not too much of a bother could you give me an example of a simple formula that would dim/bright a light.
For example say I want to bright m2 to 100% or simply turn on/off m1. I figure it would be easier to put the formula in the flash button rather than setting up the macro and referencing it in the flash button. (powerhome is running on a seperate server comp I have) It's a bit of a hassle to remote in to set up the macro and if I could just do it in a formula that would be so much easier. (sorry for what may be a ridiculously simple question)
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 21 2005 at 00:10 | IP Logged
|
|
|
This will brighten M1 to 100%...
Code:
ph_x10( 1, "M", 1, 0) + ph_x10( 1, "M", 105, 100) |
|
|
Dim to 100%...
Code:
ph_x10( 1, "M", 1, 0) + ph_x10( 1, "M", 104, 100) |
|
|
This is just an on...
Code:
ph_x10( 1, "M", 1, 0) + ph_x10( 1, "M", 102, 0) |
|
|
This is an off...
Code:
ph_x10( 1, "M", 1, 0) + ph_x10( 1, "M", 103, 0) |
|
|
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 21 2005 at 20:22 | IP Logged
|
|
|
Guys, I can't thank you enough for all the help!
dhoward, I'm having some trouble with the cgi function for executing a formula. I am testing various one by putting it in the address bar and when I try
http://5.12.96.187/ph-cgi/evalformula?formula=ph_x10(1,"M",2 ,0)+ph_x10(1,"M",104,100)
it just gives me the formula page from the generated interface and doesn't seem to have evaluated the formula, it's just the blank page like when you first go to it. I test the formula itself in the box and it executes the control as expected. There's gotta be something simple that I'm doing wrong, I'm just not sure what. Is there a full reference for all the cgi functions? I haven't been able to find anything in the pdf's.
Edited by guerrand
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 21 2005 at 21:42 | IP Logged
|
|
|
I just ran this...
Code:
/ph-cgi/evalformula?formula=ph_tts("Testing") |
|
|
and it excuted and went to the formula page.
Don't forget about the nexturl parameter...
Code:
/ph-cgi/evalformula?formula=AVALIDPOWERHOMEFORMULA&nexturl=Y OURNEXTURL |
|
|
This one speaks and then goes to the main PH page...
Code:
/ph-cgi/evalformula?formula=ph_tts("Testing")&nexturl=/ |
|
|
However, I did just find that the ?formula=ph_x10 seems to have a problem.
This does work...
Code:
ph-cgi/evalformula?formula=ph_x10btn("M",1,2,0) |
|
|
|
Back to Top |
|
|
guerrand Senior Member
Joined: December 18 2005 Location: United States
Online Status: Offline Posts: 106
|
Posted: December 21 2005 at 22:44 | IP Logged
|
|
|
Woooooo Hoooooo! I figured out why flash was freaking and giving errors! (after the inital prob) the quotes around the house code were throwing it off, so I switched it to single quotes -->' and it liked it. This will be sooo much easier to set up now!
I can't thank you guys enough, I haven't bought PowerHome yet but now that I have this licked it's definate!
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 22 2005 at 20:43 | IP Logged
|
|
|
Dave,
Any ideas why "?formula=ph_x10" won't work?
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 22 2005 at 20:47 | IP Logged
|
|
|
guerrand,
Glad to hear it's working for you. Yep, in PowerHome, you can delimit strings with either single or double quotes. My guess is that the double quotes were throwing the flash off since HTML commonly uses double quotes to delimit parameter values.
I havent got a completely documented list of all the ph-cgi functions. I will be working on them shortly. Most of the available functions can be seen by viewing the default pages served by the PowerHome webserver though.
BTW, the LCARS interface looks pretty cool. I know the static images don't even begin to do it justice however.
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 22 2005 at 20:52 | IP Logged
|
|
|
Tony,
Were posting at the same time .
It should work. The ph-cgi/formula just passes the formula back and evaluates it just like any other formula. So if it works in the formula builder, it should work passed in the ph-cgi function.
If you execute the ph_x10 from the ph-cgi/formula web page (the one with the multi-line edit box where you can enter a formula), does it still fail? If not, my guess is that some form of escape characters may be needed if it's just failing from the address bar.
Can you post for me the actual command line you're using and how you're doing it (for example in IE's address bar)?
Thanks,
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 22 2005 at 20:59 | IP Logged
|
|
|
Tony,
I got it!!! I bet you're doing the whole formula from the address of IE. In that case the '+' sign you're probably using from two consecutive ph_x10 functions (1 for the address, 1 for the command) is being interpreted by the webserver as a space character. The '+' sign is a common "quick" way of escaping the space character. So the webserver replaces the '+' with a space and evaluates the formula and it results in an error.
Try escaping the '+' symbol with a %2b and I'll bet that works.
Dave.
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 22 2005 at 21:01 | IP Logged
|
|
|
Or, replace the '+' with a '-'. Who says we always have to "add" our functions together
Dave.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 22 2005 at 21:10 | IP Logged
|
|
|
Formula page version works fine.
http://kids:8000/ph-cgi/evalformula?ph_x10(1,"A",7,0) + ph_x10(1,"A",103,0)
and
http://kids:8000/ph-cgi/evalformula?ph_x10(1,'A',7,0) + ph_x10(1,'A',103,0)
...in FF (and IE) address bar does nothing.
|
Back to Top |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: December 22 2005 at 21:12 | IP Logged
|
|
|
%2b and '-' didn't help...
|
Back to Top |
|
|