Update GAUDIN and GADC demos to new internal GWIN structures.
Also add support for signed sample formats.
This commit is contained in:
parent
53aa406668
commit
301f871ee7
5 changed files with 29 additions and 19 deletions
|
@ -64,9 +64,9 @@ static const gwinVMT scopeVMT = {
|
||||||
0, // The after-clear routine
|
0, // The after-clear routine
|
||||||
};
|
};
|
||||||
|
|
||||||
GHandle gwinScopeCreate(GScopeObject *gs, GWindowInit *pInit, uint32_t physdev, uint32_t frequency) {
|
GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint32_t physdev, uint32_t frequency) {
|
||||||
/* Initialise the base class GWIN */
|
/* Initialise the base class GWIN */
|
||||||
if (!(gs = (GScopeObject *)_gwindowCreate(&gs->g, pInit, &scopeVMT, 0)))
|
if (!(gs = (GScopeObject *)_gwindowCreate(g, &gs->g, pInit, &scopeVMT, 0)))
|
||||||
return 0;
|
return 0;
|
||||||
gfxSemInit(&gs->bsem, 0, 1);
|
gfxSemInit(&gs->bsem, 0, 1);
|
||||||
gs->nextx = 0;
|
gs->nextx = 0;
|
||||||
|
@ -114,10 +114,12 @@ void gwinScopeWaitForTrace(GHandle gh) {
|
||||||
|
|
||||||
/* Ensure we are drawing in the right area */
|
/* Ensure we are drawing in the right area */
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
yoffset = gh->height/2 + (1<<SCOPE_Y_BITS)/2;
|
yoffset = gh->height/2;
|
||||||
|
if (!(GADC_SAMPLE_FORMAT & 1))
|
||||||
|
yoffset += (1<<SCOPE_Y_BITS)/2;
|
||||||
x = gs->nextx;
|
x = gs->nextx;
|
||||||
pc = gs->lastscopetrace+x;
|
pc = gs->lastscopetrace+x;
|
||||||
pa = gs->myEvent.buffer;
|
pa = gs->myEvent.buffer;
|
||||||
|
@ -188,8 +190,8 @@ void gwinScopeWaitForTrace(GHandle gh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the old scope pixel and then draw the new scope value */
|
/* Clear the old scope pixel and then draw the new scope value */
|
||||||
gdispDrawPixel(gh->x+x, gh->y+pc[0], gh->bgcolor);
|
gdispGDrawPixel(gh->display, gh->x+x, gh->y+pc[0], gh->bgcolor);
|
||||||
gdispDrawPixel(gh->x+x, gh->y+y, gh->color);
|
gdispGDrawPixel(gh->display, gh->x+x, gh->y+y, gh->color);
|
||||||
|
|
||||||
/* Save the value */
|
/* Save the value */
|
||||||
*pc++ = y;
|
*pc++ = y;
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
* --------------------------- Our Custom GWIN Oscilloscope ---------------
|
* --------------------------- Our Custom GWIN Oscilloscope ---------------
|
||||||
*
|
*
|
||||||
* This GWIN superset implements a simple audio oscilloscope using the GADC high speed device.
|
* This GWIN superset implements a simple audio oscilloscope using the GADC high speed device.
|
||||||
|
*
|
||||||
|
* It makes many assumptions.
|
||||||
|
*
|
||||||
|
* The GMISC module with GMISC_NEED_ARRAYOPS could be used to process the samples more
|
||||||
|
* correctly if we were really building something generic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The extent of scaling for our audio data - fixed scale at the moment */
|
/* The extent of scaling for our audio data - fixed scale at the moment */
|
||||||
|
@ -78,7 +83,8 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* Create a scope window.
|
* Create a scope window.
|
||||||
*/
|
*/
|
||||||
GHandle gwinScopeCreate(GScopeObject *gs, GWindowInit *pInit, uint32_t physdev, uint32_t frequency);
|
GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint32_t physdev, uint32_t frequency);
|
||||||
|
#define gwinScopeCreate(gs,pI,pd,f) gwinGScopeCreate(GDISP,gs,pI,pd,f)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for a scope trace to be ready and then draw it.
|
* Wait for a scope trace to be ready and then draw it.
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#define GFX_USE_GDISP TRUE
|
#define GFX_USE_GDISP TRUE
|
||||||
#define GFX_USE_GWIN TRUE
|
#define GFX_USE_GWIN TRUE
|
||||||
#define GFX_USE_GTIMER TRUE
|
#define GFX_USE_GTIMER TRUE
|
||||||
#define GFX_USE_GADC TRUE
|
//#define GFX_USE_GADC TRUE
|
||||||
#define GFX_USE_GAUDIN TRUE
|
#define GFX_USE_GAUDIN TRUE
|
||||||
|
|
||||||
/* Features for the GDISP sub-system. */
|
/* Features for the GDISP sub-system. */
|
||||||
|
|
|
@ -71,9 +71,9 @@ static const gwinVMT scopeVMT = {
|
||||||
0, // The after-clear routine
|
0, // The after-clear routine
|
||||||
};
|
};
|
||||||
|
|
||||||
GHandle gwinScopeCreate(GScopeObject *gs, GWindowInit *pInit, uint16_t channel, uint32_t frequency) {
|
GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint16_t channel, uint32_t frequency) {
|
||||||
/* Initialise the base class GWIN */
|
/* Initialise the base class GWIN */
|
||||||
if (!(gs = (GScopeObject *)_gwindowCreate(&gs->g, pInit, &scopeVMT, 0)))
|
if (!(gs = (GScopeObject *)_gwindowCreate(g, &gs->g, pInit, &scopeVMT, 0)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Initialise the scope object members and allocate memory for buffers */
|
/* Initialise the scope object members and allocate memory for buffers */
|
||||||
|
@ -81,7 +81,7 @@ GHandle gwinScopeCreate(GScopeObject *gs, GWindowInit *pInit, uint16_t channel,
|
||||||
gs->nextx = 0;
|
gs->nextx = 0;
|
||||||
if (!(gs->lastscopetrace = (coord_t *)gfxAlloc(gs->g.width * sizeof(coord_t))))
|
if (!(gs->lastscopetrace = (coord_t *)gfxAlloc(gs->g.width * sizeof(coord_t))))
|
||||||
return 0;
|
return 0;
|
||||||
if (!(gs->audiobuf = (adcsample_t *)gfxAlloc(AUDIOBUFSZ * sizeof(adcsample_t))))
|
if (!(gs->audiobuf = (audin_sample_t *)gfxAlloc(AUDIOBUFSZ * sizeof(audin_sample_t))))
|
||||||
return 0;
|
return 0;
|
||||||
#if TRIGGER_METHOD == TRIGGER_POSITIVERAMP
|
#if TRIGGER_METHOD == TRIGGER_POSITIVERAMP
|
||||||
gs->lasty = gs->g.height/2;
|
gs->lasty = gs->g.height/2;
|
||||||
|
@ -123,10 +123,12 @@ void gwinScopeWaitForTrace(GHandle gh) {
|
||||||
|
|
||||||
/* Ensure we are drawing in the right area */
|
/* Ensure we are drawing in the right area */
|
||||||
#if GDISP_NEED_CLIP
|
#if GDISP_NEED_CLIP
|
||||||
gdispSetClip(gh->x, gh->y, gh->width, gh->height);
|
gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
yoffset = gh->height/2 + (1<<SCOPE_Y_BITS)/2;
|
yoffset = gh->height/2;
|
||||||
|
if (!(GAUDIN_SAMPLE_FORMAT & 1))
|
||||||
|
yoffset += (1<<SCOPE_Y_BITS)/2;
|
||||||
x = gs->nextx;
|
x = gs->nextx;
|
||||||
pc = gs->lastscopetrace+x;
|
pc = gs->lastscopetrace+x;
|
||||||
pa = gs->myEvent.buffer;
|
pa = gs->myEvent.buffer;
|
||||||
|
@ -197,8 +199,8 @@ void gwinScopeWaitForTrace(GHandle gh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the old scope pixel and then draw the new scope value */
|
/* Clear the old scope pixel and then draw the new scope value */
|
||||||
gdispDrawPixel(gh->x+x, gh->y+pc[0], gh->bgcolor);
|
gdispGDrawPixel(gh->display, gh->x+x, gh->y+pc[0], gh->bgcolor);
|
||||||
gdispDrawPixel(gh->x+x, gh->y+y, gh->color);
|
gdispGDrawPixel(gh->display, gh->x+x, gh->y+y, gh->color);
|
||||||
|
|
||||||
/* Save the value */
|
/* Save the value */
|
||||||
*pc++ = y;
|
*pc++ = y;
|
||||||
|
|
|
@ -33,10 +33,9 @@
|
||||||
/**
|
/**
|
||||||
* --------------------------- Our Custom GWIN Oscilloscope ---------------
|
* --------------------------- Our Custom GWIN Oscilloscope ---------------
|
||||||
*
|
*
|
||||||
* This GWIN superset implements a simple audio oscilloscope using the GADC high speed device.
|
* This GWIN superset implements a simple audio oscilloscope using the GAUDIN device.
|
||||||
*
|
*
|
||||||
* It makes many assumptions, the most fundamental of which is that the audio device
|
* It makes many assumptions.
|
||||||
* produces unsigned integer samples.
|
|
||||||
*
|
*
|
||||||
* The GMISC module with GMISC_NEED_ARRAYOPS could be used to process the samples more
|
* The GMISC module with GMISC_NEED_ARRAYOPS could be used to process the samples more
|
||||||
* correctly if we were really building something generic.
|
* correctly if we were really building something generic.
|
||||||
|
@ -84,7 +83,8 @@ extern "C" {
|
||||||
/**
|
/**
|
||||||
* Create a scope window.
|
* Create a scope window.
|
||||||
*/
|
*/
|
||||||
GHandle gwinScopeCreate(GScopeObject *gs, GWindowInit *pInit, uint16_t channel, uint32_t frequency);
|
GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint16_t channel, uint32_t frequency);
|
||||||
|
#define gwinScopeCreate(gs,pI,ch,f) gwinGScopeCreate(GDISP,gs,pI,ch,f)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for a scope trace to be ready and then draw it.
|
* Wait for a scope trace to be ready and then draw it.
|
||||||
|
|
Loading…
Add table
Reference in a new issue