Frank Applin
|
How to swap images using a label
|
Frank Applin
07/26/2012 11:50 AM
post94434
|
How to swap images using a label
Hi,
I'm new to QNX and PhAB, but have been programming for 20+ years. I guess I'm most familiar with the Visual Studio
paradigm.
I am using Neil Carter's example of showing an image using a label.
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
PhImage_t *myImg;
char myImgFlnm[20] = "PICTURE.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
return( Pt_CONTINUE );
}
How can I swap out the current image with another image after a short delay?
I tried the following, but it simple shows the 2nd image:
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
PhImage_t *myImg, *myImg2;
char myImgFlnm[20] = "PICTURE.BMP";
char myImgFlnm2[20] = "PICTURE2.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
delay(5000); /* delay 5 secs */
if ((myImg2 = PxLoadImage( myImgFlnm2, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm2);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg2, 0);
return( Pt_CONTINUE );
}
Thanks,
Frank
|
|
|
Derek Leach
|
RE: How to swap images using a label
|
Derek Leach
07/26/2012 11:57 AM
post94435
|
RE: How to swap images using a label
Setup a PtTimer that checks a "image index" ... after the callback for the PtTimer fires, check the "image index" for
what image to display, and set the Pt_ARG_LABEL_IMAGE with that image, then change the "image index". The next time the
PtTimer fires, your "image index" will be different, so you would set the other image to the label.
Preload the image (PxLoadImage) in an application startup callback, you do not want to keep reloading the images -> slow
, and if you do not release, leads to memory leak.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-26-12 11:51 AM
To: photon-graphics
Subject: How to swap images using a label
Hi,
I'm new to QNX and PhAB, but have been programming for 20+ years. I guess I'm most familiar with the Visual Studio
paradigm.
I am using Neil Carter's example of showing an image using a label.
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) {
PhImage_t *myImg;
char myImgFlnm[20] = "PICTURE.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
return( Pt_CONTINUE );
}
How can I swap out the current image with another image after a short delay?
I tried the following, but it simple shows the 2nd image:
int ShowImage( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo ) {
PhImage_t *myImg, *myImg2;
char myImgFlnm[20] = "PICTURE.BMP";
char myImgFlnm2[20] = "PICTURE2.BMP";
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
if ((myImg = PxLoadImage( myImgFlnm, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg, 0);
delay(5000); /* delay 5 secs */
if ((myImg2 = PxLoadImage( myImgFlnm2, NULL)) == NULL) {
fprintf( stderr, "Error loading image file %s\n", myImgFlnm2);
PtExit( EXIT_FAILURE );
}
PtSetResource(ABW_lblMyImg, Pt_ARG_LABEL_IMAGE, myImg2, 0);
return( Pt_CONTINUE );
}
Thanks,
Frank
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94434
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: How to swap images using a label
|
Frank Applin
07/26/2012 1:38 PM
post94436
|
Re: RE: How to swap images using a label
Would I be able to change the timer to something that is not a set time?
What I am after is to be able to read a simple text file that has bitmap names and timings (usually in ms). This kind of
stuff is done in psychology experiments with EEG. You show an image for a period of time and delay. Move to the next
picture with a new period of time (just slightly staggered) and delay. And it keeps doing this process all the way
through the file.
So, the text file might look like:
beagle.bmp, 2000
blank.bmp, 2000
canary.bmp, 2015
blank.bmp, 2000
beagle.bmp, 2045
blank.bmp, 2000
canary.bmp, 2065
blank.bmp, 2000
beagle.bmp, 2100
blank.bmp, 2000
:
:
|
|
|
Derek Leach
|
RE: RE: How to swap images using a label
|
Derek Leach
07/26/2012 1:58 PM
post94437
|
RE: RE: How to swap images using a label
Ok, the key is that the Photon processing is not immediate in the callback versus what you see on the display, so if you
set image1 then image2, you will only ever see image2.
You never want to stall out in the middle of a callback.
What you want to do is of a rather synchronous nature, with non-equal delay time.
With a Photon app the PtMainLoop() is already running.
There are more hacker ways of going about this, but could you try setting the PtTimer to a really fine repeat, then
check your delays in there?
If not, I will have to think about this for a bit.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-26-12 1:39 PM
To: photon-graphics
Subject: Re: RE: How to swap images using a label
Would I be able to change the timer to something that is not a set time?
What I am after is to be able to read a simple text file that has bitmap names and timings (usually in ms). This kind of
stuff is done in psychology experiments with EEG. You show an image for a period of time and delay. Move to the next
picture with a new period of time (just slightly staggered) and delay. And it keeps doing this process all the way
through the file.
So, the text file might look like:
beagle.bmp, 2000
blank.bmp, 2000
canary.bmp, 2015
blank.bmp, 2000
beagle.bmp, 2045
blank.bmp, 2000
canary.bmp, 2065
blank.bmp, 2000
beagle.bmp, 2100
blank.bmp, 2000
:
:
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94436
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Thomas Haupt
|
AW: RE: RE: How to swap images using a label
|
Thomas Haupt
07/26/2012 1:43 PM
post94438
|
AW: RE: RE: How to swap images using a label
I think Derek's suggestion is just right. Set the PtTimer interval to 1ms or so; checking a delay count doesn't generate
so much overhead.
Try to pre-load the images and delay counts when starting your application (or when opening the definition file).
- Thomas
----- Originalnachricht -----
Von: Derek Leach [mailto:community-noreply@qnx.com]
Gesendet: Thursday, July 26, 2012 01:30 PM
An: photon-graphics <photon-graphics@community.qnx.com>
Betreff: RE: RE: How to swap images using a label
Ok, the key is that the Photon processing is not immediate in the callback versus what you see on the display, so if you
set image1 then image2, you will only ever see image2.
You never want to stall out in the middle of a callback.
What you want to do is of a rather synchronous nature, with non-equal delay time.
With a Photon app the PtMainLoop() is already running.
There are more hacker ways of going about this, but could you try setting the PtTimer to a really fine repeat, then
check your delays in there?
If not, I will have to think about this for a bit.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-26-12 1:39 PM
To: photon-graphics
Subject: Re: RE: How to swap images using a label
Would I be able to change the timer to something that is not a set time?
What I am after is to be able to read a simple text file that has bitmap names and timings (usually in ms). This kind of
stuff is done in psychology experiments with EEG. You show an image for a period of time and delay. Move to the next
picture with a new period of time (just slightly staggered) and delay. And it keeps doing this process all the way
through the file.
So, the text file might look like:
beagle.bmp, 2000
blank.bmp, 2000
canary.bmp, 2015
blank.bmp, 2000
beagle.bmp, 2045
blank.bmp, 2000
canary.bmp, 2065
blank.bmp, 2000
beagle.bmp, 2100
blank.bmp, 2000
:
:
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94436
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94437
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/26/2012 2:00 PM
post94439
|
Re: AW: RE: RE: How to swap images using a label
Thanks, guys. I am really new to this (just installed Neutrino, yesterday) and this isn't your normal C/C++/C#/Java
event handling coding. So, let me look at the PtTimer and try to absorb what you are talking about.
Should I even be attempting this via PhAB?
Frank
|
|
|
Thomas Haupt
|
AW: Re: AW: RE: RE: How to swap images using a label
|
Thomas Haupt
07/26/2012 1:54 PM
post94440
|
AW: Re: AW: RE: RE: How to swap images using a label
I'd suggest PhAb. It sets up the code framework for you, lets you drag-and-drop the widgets you want, and also generates
code templates for the callbacks you specify. Much easier than doing everything in code yourself.
- Thomas
----- Originalnachricht -----
Von: Frank Applin [mailto:community-noreply@qnx.com]
Gesendet: Thursday, July 26, 2012 02:00 PM
An: photon-graphics <photon-graphics@community.qnx.com>
Betreff: Re: AW: RE: RE: How to swap images using a label
Thanks, guys. I am really new to this (just installed Neutrino, yesterday) and this isn't your normal C/C++/C#/Java
event handling coding. So, let me look at the PtTimer and try to absorb what you are talking about.
Should I even be attempting this via PhAB?
Frank
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94439
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/26/2012 2:24 PM
post94442
|
Re: AW: RE: RE: How to swap images using a label
I will say this for Microsoft, though. Their documentation is chalked full of examples, which make learning a new tool
set and APIs much, much easier.
|
|
|
Derek Leach
|
RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/26/2012 2:31 PM
post94443
|
RE: AW: RE: RE: How to swap images using a label
You have read the Photon Programmers Guide? Yes, there could be more docs.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-26-12 2:24 PM
To: photon-graphics
Subject: Re: AW: RE: RE: How to swap images using a label
I will say this for Microsoft, though. Their documentation is chalked full of examples, which make learning a new tool
set and APIs much, much easier.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94442
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Steve Reid
|
RE: AW: RE: RE: How to swap images using a label
|
Steve Reid
07/26/2012 2:56 PM
post94444
|
RE: AW: RE: RE: How to swap images using a label
There's an example of this in the Photon Programmer's Guide. See "Animation" in this file:
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.photon_prog_guide/draw.html
Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: Thursday, July 26, 2012 2:24 PM
To: photon-graphics
Subject: Re: AW: RE: RE: How to swap images using a label
I will say this for Microsoft, though. Their documentation is chalked full of examples, which make learning a new tool
set and APIs much, much easier.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94442
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/26/2012 2:50 PM
post94447
|
Re: RE: AW: RE: RE: How to swap images using a label
Thanks, Steve!! That is very useful!
Frank
|
|
|
Frank Applin
|
Re: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/26/2012 2:48 PM
post94448
|
Re: RE: AW: RE: RE: How to swap images using a label
Steve do you have a suggestion for the staggered delays I'll need for how long the image is displayed? A couple of the
guys on here have suggested PtTimer, but the documentation said it's not very accurate (use RtTimer instead). Why
couldn't i use uSleep() or delay() kind of function to hold the image on the screen for a specified period of time?
Thanks again for the help.
|
|
|
Steve Reid
|
RE: RE: AW: RE: RE: How to swap images using a label
|
Steve Reid
07/26/2012 3:43 PM
post94450
|
RE: RE: AW: RE: RE: How to swap images using a label
I'm a bit rusty on Photon, as it's been a while since I worked on those docs. If you call delay() or something like that
in a callback, you're delaying the processing of events by PtMainLoop(), which isn't a good idea, as your entire
program--including the processing of mouse buttons, the refreshing of windows, and so on--is delayed. PtTimer and the
RtTimer* functions work correctly with the event loop. As I recall, the inaccuracy can happen because the expiry of the
timer joins any other events that are already in the event queue.
If you're doing a simple animation where the delays are in seconds, PtTimer is probably good enough. If you need hard
realtime, especially with very short delays, you need to use a timer in a separate process that doesn't use the Photon
event loop.
You can change the delay by resetting Pt_ARG_TIMER_INITIAL to the next delay, in the timer's Pt_CB_TIMER_ACTIVATE
callback.
Some of the people who are monitoring this forum know this stuff a lot better than I do, so I hope they'll correct me if
I got something wrong.
Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: Thursday, July 26, 2012 2:49 PM
To: photon-graphics
Subject: Re: RE: AW: RE: RE: How to swap images using a label
Steve do you have a suggestion for the staggered delays I'll need for how long the image is displayed? A couple of the
guys on here have suggested PtTimer, but the documentation said it's not very accurate (use RtTimer instead). Why
couldn't i use uSleep() or delay() kind of function to hold the image on the screen for a specified period of time?
Thanks again for the help.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94448
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 10:02 PM
post94457
|
Re: RE: RE: AW: RE: RE: How to swap images using a label
I guess this comes down to a design question then.
Should I be displaying the images (I'm assuming using RtTimer because I need accuracy) in a separate thread, in
background process, in work procedure, or in some other method that I haven't read up on, yet?
A user will basically be clicking on a Start Button of a simple dialog to open this new dialog that displays the images
for the staggered amount of times (read in from the file and stored in some global structure at the start of the
application).
Thanks.
|
|
|
Derek Leach
|
RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/27/2012 10:19 PM
post94458
|
RE: RE: RE: AW: RE: RE: How to swap images using a label
How "accurate" do you need? I understand your requirement for the delays, but how close to these delay values is
necessary?
PtTimer in most cases is feasible.
I would get it all running with a PtTimer, with a fine repeat, then check in the callback against your delay values, and
decide whether to swap the image or not.
It will not be a waste of time, as you could reuse a lot of the code with the RtTimer, if it is really necessary.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-27-12 10:03 PM
To: photon-graphics
Subject: Re: RE: RE: AW: RE: RE: How to swap images using a label
I guess this comes down to a design question then.
Should I be displaying the images (I'm assuming using RtTimer because I need accuracy) in a separate thread, in
background process, in work procedure, or in some other method that I haven't read up on, yet?
A user will basically be clicking on a Start Button of a simple dialog to open this new dialog that displays the images
for the staggered amount of times (read in from the file and stored in some global structure at the start of the
application).
Thanks.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94457
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 10:49 PM
post94460
|
Re: RE: RE: RE: AW: RE: RE: How to swap images using a label
Hi Derek,
First, thank you for taking your time to be so helpful. These are going to need to be accurate to within a few
milliseconds. The caveat that I don't know if I mentioned in a previous post or not is that before and after the image
is displayed I will be sending a short pulse to a parallel port line connected to a PC running EEG software. So, if an
image is displayed for 2025 milliseconds - we want to be able to look at the EEG between the parallel port pulses
(called events in the EEG world) and hopefully it's damn close to 2025 milliseconds. Does that answer your question?
Frank
|
|
|
Derek Leach
|
RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/27/2012 10:51 PM
post94461
|
RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Yes it does. Are you using QNX650?
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-27-12 10:49 PM
To: photon-graphics
Subject: Re: RE: RE: RE: AW: RE: RE: How to swap images using a label
Hi Derek,
First, thank you for taking your time to be so helpful. These are going to need to be accurate to within a few
milliseconds. The caveat that I don't know if I mentioned in a previous post or not is that before and after the image
is displayed I will be sending a short pulse to a parallel port line connected to a PC running EEG software. So, if an
image is displayed for 2025 milliseconds - we want to be able to look at the EEG between the parallel port pulses
(called events in the EEG world) and hopefully it's damn close to 2025 milliseconds. Does that answer your question?
Frank
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94460
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 10:59 PM
post94463
|
Re: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
|
|
Derek Leach
|
RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/27/2012 11:04 PM
post94464
|
RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Since you are looking for 'synchronous' updates of the images, have you considered going straight to the metal and use
GF instead?
Or are you hoping to have all the buttons and such in the same application as the image display?
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-27-12 10:59 PM
To: photon-graphics
Subject: Re: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Yes I am.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94463
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 11:12 PM
post94465
|
Re: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Forgive my ignorance, but what is GF? I would like to keep it all in one application if I can.
|
|
|
Derek Leach
|
RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/27/2012 11:20 PM
post94466
|
RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
It is the Advance Graphics Framework APIs. It is low level draw API calls, and is more synchronous in nature (no main
loop).
OK, if you want it all in one app, then get it up and running with PtTimer, then recode to RtTimer.
The only reason I am suggesting to use the PtTimer first, is because it is easier, and you can work out all the logic
first.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-27-12 11:12 PM
To: photon-graphics
Subject: Re: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Forgive my ignorance, but what is GF? I would like to keep it all in one application if I can.
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94465
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 11:25 PM
post94467
|
Re: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
OK. I'll head down that path, first. Thanks again for your patience and help.
Frank
|
|
|
Frank Applin
|
Re: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 11:47 AM
post94473
|
Re: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Hi Derek,
I hate to ask such basic questions, but the documentation is seriously lacking in example code.
I created a base dialog with a PtTimer and a button on it.
PtTimerImage has an initial value of 0 and a repeat value of 1. The Activate callback is called DisplayImage (just using
printf(), now).
PtButtonStart has an Activate callback named StartTimer.
What I am trying to accomplish in this little test program is that when I click the Start button, the timer's initial
value is set to 5000 which should then call the DisplayImage callback (if I'm understanding this correctly). In the
DisplayImage callback - I want to display the time of day and re-set the initial value of the timer to 1000.
So, the code for the StartTimer callback looks like:
PtSetResource(ABW_PtTimerImage, Pt_CB_TIMER_ACTIVATE, Pt_TIMER_INITIAL, 5000);
The code for the DisplayImage callback looks like:
printf("here\n");
time_of_day = time(NULL);
printf("It is now: %s\n", ctime(&time_of_day));
PtSetResource(ABW_PtTimerImage, Pt_CB_TIMER_ACTIVATE, Pt_TIMER_INITIAL, 1000);
It builds fine and when I run it from a terminal console - the dialog appears, I click Start, and I get a memory fault.
Can you help starighten me out, please?
Frank
|
|
|
Derek Leach
|
RE: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Derek Leach
07/27/2012 12:32 PM
post94474
|
RE: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
You want:
PtSetResource(ABW_PtTimerImage, Pt_ARG_TIMER_INITIAL, 5000, 0);
And if you want a repeat:
PtSetResource(ABW_PtTimerImage, Pt_ARG_TIMER_REPEAT, 5000, 0);
In the lines below you are setting the callback resource to reference the PtCallback_t pointer (void *)Pt_TIMER_INITIAL,
which is just a number constant, which causes the crash.
-----Original Message-----
From: Frank Applin [mailto:community-noreply@qnx.com]
Sent: July-27-12 11:48 AM
To: photon-graphics
Subject: Re: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Hi Derek,
I hate to ask such basic questions, but the documentation is seriously lacking in example code.
I created a base dialog with a PtTimer and a button on it.
PtTimerImage has an initial value of 0 and a repeat value of 1. The Activate callback is called DisplayImage (just using
printf(), now).
PtButtonStart has an Activate callback named StartTimer.
What I am trying to accomplish in this little test program is that when I click the Start button, the timer's initial
value is set to 5000 which should then call the DisplayImage callback (if I'm understanding this correctly). In the
DisplayImage callback - I want to display the time of day and re-set the initial value of the timer to 1000.
So, the code for the StartTimer callback looks like:
PtSetResource(ABW_PtTimerImage, Pt_CB_TIMER_ACTIVATE, Pt_TIMER_INITIAL, 5000);
The code for the DisplayImage callback looks like:
printf("here\n");
time_of_day = time(NULL);
printf("It is now: %s\n", ctime(&time_of_day));
PtSetResource(ABW_PtTimerImage, Pt_CB_TIMER_ACTIVATE, Pt_TIMER_INITIAL, 1000);
It builds fine and when I run it from a terminal console - the dialog appears, I click Start, and I get a memory fault.
Can you help starighten me out, please?
Frank
_______________________________________________
Photon microGUI
http://community.qnx.com/sf/go/post94473
To cancel your subscription to this discussion, please e-mail photon-graphics-unsubscribe@community.qnx.com
|
|
|
Frank Applin
|
Re: RE: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
|
Frank Applin
07/27/2012 1:49 PM
post94480
|
Re: RE: RE: RE: RE: RE: RE: RE: AW: RE: RE: How to swap images using a label
Thanks, again, Derek. That works.
I'll work on the image part next.
Have a great weekend!
Frank
|
|
|
|