Jimmy,
The example I am posting below will work and I use something very similar in my own setup. The example in the Dev Guide section 8.3.1 is pretty much identical to this except that instead of setting a label on a widget, I am simply executing actions on one of two widgets based on true/false being reported by power sense input.
Assumption is that you are running latest firmware which supports scheduleActions() on a widget. If not search this forum for executeActions() and find an example I have posted about wrapping it with try/catch.
Set up most of it like you would do regularly (using delays and a set of progress bar pages).
Next
Create 2 buttons on a hidden page in Home activity 'PROJ_STARTUP' is assigned as the ProntoScript name.
Button #1 (assign ProntoScript name of 'PROJ_OFF') - add actions to Power on projector, Jump through your progress pages (includes 30 second delay), and then jump to final page.
Button #2 (assign ProntoScript name of 'PROJ_ON') - add action to Jump directly to your final page.
Then, in the button on your home page (ProntoScript must be invoked from starting button, assuming extender #0 and Power Sense Port #1 add the following script.
var ext = CF.extender[0]; // Extender 0
var input = ext.input[0]; // Power Sense #1
var wTag;
try
{
// input.get() can raise an error. I have not built retry logic in here.
// I leave this as an exercise for the user.
// I use short-hand if clauses frequently. If you prefer longer form, simply use:
// if (input.get())
// wTag = 'PROJ_ON';
// else
// wTag = 'PROJ_OFF';
wTag = input.get() ? 'PROJ_ON' : 'PROJ_OFF';
}
catch(e)
{
// assume projector is off if input state retrieval fails (extender is busy).
wTag = 'PROJ_OFF';
}
// if hidden page with buttons not in current activity, specify prontoscript name
// of the activity that contains the hidden page as 3rd parameter.
w = CF.widget(wTag, 'PROJ_STARTUP');
if (w)
w.scheduleActions();
Last edited by Lyndel McGee on July 1, 2010 17:04.