aboutsummaryrefslogtreecommitdiffstats
path: root/demos/modules/gadc
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-12-22 21:37:41 +1000
committerinmarket <andrewh@inmarket.com.au>2013-12-22 21:37:41 +1000
commit301f871ee796a3cb84688648b92dfb71d6ca1103 (patch)
treeba6190de8fc660973ca1a86c7bde6c6165030dde /demos/modules/gadc
parent53aa406668762b6b849807852b26d425be46166d (diff)
downloaduGFX-301f871ee796a3cb84688648b92dfb71d6ca1103.tar.gz
uGFX-301f871ee796a3cb84688648b92dfb71d6ca1103.tar.bz2
uGFX-301f871ee796a3cb84688648b92dfb71d6ca1103.zip
Update GAUDIN and GADC demos to new internal GWIN structures.
Also add support for signed sample formats.
Diffstat (limited to 'demos/modules/gadc')
-rw-r--r--demos/modules/gadc/gwinosc.c14
-rw-r--r--demos/modules/gadc/gwinosc.h8
2 files changed, 15 insertions, 7 deletions
diff --git a/demos/modules/gadc/gwinosc.c b/demos/modules/gadc/gwinosc.c
index 60dc1798..b7201088 100644
--- a/demos/modules/gadc/gwinosc.c
+++ b/demos/modules/gadc/gwinosc.c
@@ -64,9 +64,9 @@ static const gwinVMT scopeVMT = {
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 */
- if (!(gs = (GScopeObject *)_gwindowCreate(&gs->g, pInit, &scopeVMT, 0)))
+ if (!(gs = (GScopeObject *)_gwindowCreate(g, &gs->g, pInit, &scopeVMT, 0)))
return 0;
gfxSemInit(&gs->bsem, 0, 1);
gs->nextx = 0;
@@ -114,10 +114,12 @@ void gwinScopeWaitForTrace(GHandle gh) {
/* Ensure we are drawing in the right area */
#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
- 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;
pc = gs->lastscopetrace+x;
pa = gs->myEvent.buffer;
@@ -188,8 +190,8 @@ void gwinScopeWaitForTrace(GHandle gh) {
}
/* Clear the old scope pixel and then draw the new scope value */
- gdispDrawPixel(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+pc[0], gh->bgcolor);
+ gdispGDrawPixel(gh->display, gh->x+x, gh->y+y, gh->color);
/* Save the value */
*pc++ = y;
diff --git a/demos/modules/gadc/gwinosc.h b/demos/modules/gadc/gwinosc.h
index ecf5108c..56de0f11 100644
--- a/demos/modules/gadc/gwinosc.h
+++ b/demos/modules/gadc/gwinosc.h
@@ -34,6 +34,11 @@
* --------------------------- Our Custom GWIN Oscilloscope ---------------
*
* 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 */
@@ -78,7 +83,8 @@ extern "C" {
/**
* 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.