Simple photon question

Hi all,

I am now trying my hand at writing a simple Photon UI to test the driver
I’m writing. The UI consists of a number of sliders which the user can
manipulate and a number of labels which the UI panel uses to give
feedback to the user. As the user moves a given slider, the program
should read that slider’s value and possibly the value of other sliders,
calculate some value which will be used to program the driver, program
the driver with that value, and set the corresponding label in the UI to
indicate that the driver has been so programmed.

I’ve got the UI pretty well sketched out in PhAB. Each slider and label
has its own unique name (presumably to be used to find the widget
instance at runtime). I have a callback on the sliders which is being
called when the slider moves.

I cannot figure out how to get a given widget from within another
slider’s callback. For example, I’m thinking that my slider callback
should look something like this:

int
slider1_move( PtWidget_t *widget, ApInfo_t apinfo,
PtCallbackInfo_t cbinfo)
{
long myValue;
long value2;
long combination;
char theString[32];
PtWidget_t
slider2;
PtWidget_t
label;

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

myValue = PtGaugeValue(widget);

slider2 = (…, “slider2”);
value2 = PtGaugeValue(slider2);

combination = MyCombineValueFunction(myValue, value2);

sprintf(theString, “%ld”, combination);

label = (…, “label1”);
(theString);

return( Pt_CONTINUE );
}

The problem is that I do not know how to fill in the blanks, namely the
two mythical functions:

Can someone suggest answers to these questions or pointers to where I
may find them? Scrounging in the Photon headers or the online docs at
qnx.com have been singularly unenlightening.

Thanks in advance,
Eric

Eric Berdahl <berdahl@intelligentparadigm.com> wrote:

Hi all,

int
slider1_move( PtWidget_t *widget, ApInfo_t apinfo,
PtCallbackInfo_t cbinfo)
{
long myValue;
long value2;
long combination;
char theString[32];
PtWidget_t
slider2;
PtWidget_t
label;

/* eliminate ‘unreferenced’ warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

myValue = PtGaugeValue(widget);

slider2 = (…, “slider2”);
value2 = PtGaugeValue(slider2);

The names you gave to widgets in appbuilder can be used to reference
that widget so you can do the following:

value2 = PtGuageValue(ABW_slider2_name);

combination = MyCombineValueFunction(myValue, value2);

sprintf(theString, “%ld”, combination);

label = (…, “label1”);
some-function-to-set-label-strings>(theString);

Similarly you can use the name for the above code:
PtSetResource(ABW_label_name, Pt_ARG_TEXT_STRING, “string”, 0);

return( Pt_CONTINUE );
}

The problem is that I do not know how to fill in the blanks, namely the
two mythical functions:

some-function-to-get-widgets
some-function-to-set-label-strings

Can someone suggest answers to these questions or pointers to where I
may find them? Scrounging in the Photon headers or the online docs at
qnx.com have been singularly unenlightening.

I would really recommend you look through the Photon programmers guide and do
the appbuilder tutorials in the docs.

Brian


Brian Edmond (briane@qnx.com)
QNX Software Systems Ltd.