diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-03-20 23:41:27 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-03-20 23:41:27 +1000 |
commit | 271f0c743f31d3ae21ede35909e1f14845c6d338 (patch) | |
tree | 03541486e35fd48b3dd76db6c0470a8d860cd964 /demos/modules | |
parent | 712ff73f77763eeee798d6913f57e5577adcef3f (diff) | |
download | uGFX-271f0c743f31d3ae21ede35909e1f14845c6d338.tar.gz uGFX-271f0c743f31d3ae21ede35909e1f14845c6d338.tar.bz2 uGFX-271f0c743f31d3ae21ede35909e1f14845c6d338.zip |
Updates to GADC to use new simpler gfx queued bufferring.
NOTE: code is still buggy (or the one and only driver is buggy).
Diffstat (limited to 'demos/modules')
-rw-r--r-- | demos/modules/gadc/gfxconf.h | 1 | ||||
-rw-r--r-- | demos/modules/gadc/gwinosc.c | 34 | ||||
-rw-r--r-- | demos/modules/gadc/gwinosc.h | 3 | ||||
-rw-r--r-- | demos/modules/gadc/main.c | 5 |
4 files changed, 17 insertions, 26 deletions
diff --git a/demos/modules/gadc/gfxconf.h b/demos/modules/gadc/gfxconf.h index 297265b5..d0da3943 100644 --- a/demos/modules/gadc/gfxconf.h +++ b/demos/modules/gadc/gfxconf.h @@ -51,7 +51,6 @@ #define GDISP_NEED_VALIDATION TRUE #define GDISP_NEED_CLIP TRUE #define GDISP_NEED_TEXT TRUE -#define GDISP_NEED_CONTROL TRUE #define GDISP_NEED_MULTITHREAD TRUE /* GDISP - builtin fonts */ diff --git a/demos/modules/gadc/gwinosc.c b/demos/modules/gadc/gwinosc.c index afa12bfc..84e7d645 100644 --- a/demos/modules/gadc/gwinosc.c +++ b/demos/modules/gadc/gwinosc.c @@ -38,9 +38,6 @@ /* Include internal GWIN routines so we can build our own superset class */ #include "src/gwin/class_gwin.h" -/* The size of our dynamically allocated audio buffer */ -#define AUDIOBUFSZ 64*2 - /* How many flat-line sample before we trigger */ #define FLATLINE_SAMPLES 8 @@ -50,10 +47,6 @@ static void _destroy(GHandle gh) { gfxFree(((GScopeObject *)gh)->lastscopetrace); ((GScopeObject *)gh)->lastscopetrace = 0; } - if (((GScopeObject *)gh)->audiobuf) { - gfxFree(((GScopeObject *)gh)->audiobuf); - ((GScopeObject *)gh)->audiobuf = 0; - } } static const gwinVMT scopeVMT = { @@ -68,12 +61,9 @@ GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint /* Initialise the base class GWIN */ if (!(gs = (GScopeObject *)_gwindowCreate(g, &gs->g, pInit, &scopeVMT, 0))) return 0; - gfxSemInit(&gs->bsem, 0, 1); gs->nextx = 0; if (!(gs->lastscopetrace = gfxAlloc(gs->g.width * sizeof(coord_t)))) return 0; - if (!(gs->audiobuf = gfxAlloc(AUDIOBUFSZ * sizeof(adcsample_t)))) - return 0; #if TRIGGER_METHOD == TRIGGER_POSITIVERAMP gs->lasty = gs->g.height/2; #elif TRIGGER_METHOD == TRIGGER_MINVALUE @@ -82,8 +72,7 @@ GHandle gwinGScopeCreate(GDisplay *g, GScopeObject *gs, GWindowInit *pInit, uint #endif /* Start the GADC high speed converter */ - gadcHighSpeedInit(physdev, frequency, gs->audiobuf, AUDIOBUFSZ, AUDIOBUFSZ/2); - gadcHighSpeedSetBSem(&gs->bsem, &gs->myEvent); + gadcHighSpeedInit(physdev, frequency); gadcHighSpeedStart(); gwinSetVisible((GHandle)gs, pInit->show); @@ -97,6 +86,8 @@ void gwinScopeWaitForTrace(GHandle gh) { coord_t yoffset; adcsample_t *pa; coord_t *pc; + GDataBuffer *pd; + uint8_t shr; #if TRIGGER_METHOD == TRIGGER_POSITIVERAMP bool_t rdytrigger; int flsamples; @@ -109,20 +100,21 @@ void gwinScopeWaitForTrace(GHandle gh) { if (gh->vmt != &scopeVMT) return; - /* Wait for a set of audio conversions */ - gfxSemWait(&gs->bsem, TIME_INFINITE); + /* Wait for a set of conversions */ + pd = gadcHighSpeedGetData(TIME_INFINITE); /* Ensure we are drawing in the right area */ #if GDISP_NEED_CLIP gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height); #endif + shr = 16 - gfxSampleFormatBits(GADC_SAMPLE_FORMAT); yoffset = gh->height/2; - if (!(GADC_SAMPLE_FORMAT & 1)) + if (!gfxSampleFormatIsSigned(GADC_SAMPLE_FORMAT)) yoffset += (1<<SCOPE_Y_BITS)/2; x = gs->nextx; pc = gs->lastscopetrace+x; - pa = gs->myEvent.buffer; + pa = (adcsample_t *)(pd+1); #if TRIGGER_METHOD == TRIGGER_POSITIVERAMP rdytrigger = FALSE; flsamples = 0; @@ -132,14 +124,10 @@ void gwinScopeWaitForTrace(GHandle gh) { scopemin = 0; #endif - for(i = gs->myEvent.count; i; i--) { + for(i = pd->len/sizeof(adcsample_t); i; i--) { /* Calculate the new scope value - re-scale using simple shifts for efficiency, re-center and y-invert */ - #if GADC_BITS_PER_SAMPLE > SCOPE_Y_BITS - y = yoffset - (*pa++ >> (GADC_BITS_PER_SAMPLE - SCOPE_Y_BITS)); - #else - y = yoffset - (*pa++ << (SCOPE_Y_BITS - GADC_BITS_PER_SAMPLE)); - #endif + y = yoffset - (((coord_t)(*pa++) << shr) >> (16-SCOPE_Y_BITS)); #if TRIGGER_METHOD == TRIGGER_MINVALUE /* Calculate the scopemin ready for the next trace */ @@ -205,5 +193,7 @@ void gwinScopeWaitForTrace(GHandle gh) { gs->scopemin = scopemin; #endif + gfxBufferRelease(pd); + #undef gs } diff --git a/demos/modules/gadc/gwinosc.h b/demos/modules/gadc/gwinosc.h index 56de0f11..8f5c1be3 100644 --- a/demos/modules/gadc/gwinosc.h +++ b/demos/modules/gadc/gwinosc.h @@ -64,9 +64,6 @@ typedef struct GScopeObject_t { GWindowObject g; // Base Class coord_t *lastscopetrace; // To store last scope trace - gfxSem bsem; // We get signalled on this - adcsample_t *audiobuf; // To store audio samples - GEventADC myEvent; // Information on received samples coord_t nextx; // Where we are up to #if TRIGGER_METHOD == TRIGGER_POSITIVERAMP coord_t lasty; // The last y value - used for trigger slope detection diff --git a/demos/modules/gadc/main.c b/demos/modules/gadc/main.c index 928635fa..8e5ecaa4 100644 --- a/demos/modules/gadc/main.c +++ b/demos/modules/gadc/main.c @@ -167,6 +167,11 @@ int main(void) { gtimerStart(&lsTimer, LowSpeedTimer, ghText, TRUE, MY_LS_DELAY); #endif + // Allocate buffers for the high speed GADC device - 4 x 128 byte buffers. + // You may need to increase this for slower cpu's. + // You may be able to decrease this for low latency operating systems. + gfxBufferAlloc(4, 128); + /* Set up the scope window in the top right on the screen */ { GWindowInit wi; |