 |
|
 |
| Author |
Message |
|
|
Post subject: PtTrend help
Posted: Jan 28, 2008 - 04:21 PM
|
|
Active Member
Joined: Jun 14, 2007
Posts: 14
|
|
Hello, I'm starting to learn how to do an application with PhAB. I want to learn how to use PtTrend widget. I'd tried to do a window with a button which sets a function in a trend when it is pressed.
The function is:
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
#define SAMPLES 1000
int dibujar( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo){
int j;
short trendData[SAMPLES];
PtArg_t args[3];
/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;
for (j = 0; j< SAMPLES; j++){
trendData[j] = j;
}
PtSetArg(&args[0], Pt_ARG_TREND_MIN, 0, 0);
PtSetArg(&args[1], Pt_ARG_TREND_MAX, 1005, 0);
PtSetArg(&args[2], Pt_ARG_TREND_INC, 1, 0);
PtSetResources(ABW_pantalla, 3, args);
PtTrendChangeData(ABW_pantalla, (short const*)trendData, 0, 1000)
return (Pt_CONTINUE);
}
when I press the button (widget in this function) it supposed that a line from left bottom to right top could be drawn in trend widget but instead of this a reverse triangle is drawn.
I don't know what I'm doing wrong.
Moreover, i want refresh the function in the trend when i push the button. I read something about PtFlush() but I don't understand how it works.
Thanks.
P.D. Sorry for my poor English. If someone needs any explanation ask me for it. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: PtTrend help
Posted: Apr 04, 2008 - 07:35 PM
|
|
Active Member
Joined: Dec 14, 2005
Posts: 85
|
|
|
Quote:
it supposed that a line from left bottom to right top could be drawn in trend widget but instead of this a reverse triangle is drawn
Hello Gareth_00,
Actually there is no reason to expect that the line in this case will go from left bottom to right top corner. Please consider the following fragment from PtTrendChangeData description:
“If last_sample + nsamples - 1 is outside the range of samples for the widget, some initial portion of the new data is discarded”.
That is what happens here.
#define SAMPLES 500 will change the display.
I am not sure I properly understood your requirement to “refresh the function”. I have slightly modified your function to demonstrate how the trend may be updated.
Thanks,
Yuriy
----------
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"
#define SAMPLES 500
int dibujar( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo)
{
static int i = 0;
int j;
short trendData[SAMPLES];
PtArg_t args[13];
i++;
for (j = 0; j< SAMPLES; j++)
{
if ( (i%2) == 0 )
{
trendData[j] = j;
}
else
{
trendData[j] = SAMPLES - j;
}
}
PtSetArg(&args[0], Pt_ARG_TREND_MIN, 0, 0);
PtSetArg(&args[1], Pt_ARG_TREND_MAX, SAMPLES+10, 0);
PtSetArg(&args[2], Pt_ARG_TREND_INC, 1, 0);
PtSetResources(ABW_pantalla, 3, args);
PtTrendChangeData(ABW_pantalla, (short const*)trendData, 0, SAMPLES);
return (Pt_CONTINUE);
} |
|
|
| |
|
|
|
 |
|
|
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group Credits |
|
|
|
 |