aboutsummaryrefslogtreecommitdiffstats
path: root/demos
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
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')
-rw-r--r--demos/modules/gadc/gwinosc.c14
-rw-r--r--demos/modules/gadc/gwinosc.h8
-rw-r--r--demos/modules/gaudin/gfxconf.h2
-rw-r--r--demos/modules/gaudin/gwinosc.c16
-rw-r--r--demos/modules/gaudin/gwinosc.h8
5 files changed, 29 insertions, 19 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.
diff --git a/demos/modules/gaudin/gfxconf.h b/demos/modules/gaudin/gfxconf.h
index 9525a020..8733268d 100644
--- a/demos/modules/gaudin/gfxconf.h
+++ b/demos/modules/gaudin/gfxconf.h
@@ -45,7 +45,7 @@
#define GFX_USE_GDISP TRUE
#define GFX_USE_GWIN TRUE
#define GFX_USE_GTIMER TRUE
-#define GFX_USE_GADC TRUE
+//#define GFX_USE_GADC TRUE
#define GFX_USE_GAUDIN TRUE
/* Features for the GDISP sub-system. */
diff --git a/demos/modules/gaudin/gwinosc.c b/demos/modules/gaudin/gwinosc.c
index 9882bcde..28a5cf69 100644
--- a/demos/modules/gaudin/gwinosc.c
+++ b/demos/modules/gaudin/gwinosc.c
@@ -71,9 +71,9 @@ static const gwinVMT scopeVMT = {
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 */
- if (!(gs = (GScopeObject *)_gwindowCreate(&gs->g, pInit, &scopeVMT, 0)))
+ if (!(gs = (GScopeObject *)_gwindowCreate(g, &gs->g, pInit, &scopeVMT, 0)))
return 0;
/* 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;
if (!(gs->lastscopetrace = (coord_t *)gfxAlloc(gs->g.width * sizeof(coord_t))))
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;
#if TRIGGER_METHOD == TRIGGER_POSITIVERAMP
gs->lasty = gs->g.height/2;
@@ -123,10 +123,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 (!(GAUDIN_SAMPLE_FORMAT & 1))
+ yoffset += (1<<SCOPE_Y_BITS)/2;
x = gs->nextx;
pc = gs->lastscopetrace+x;
pa = gs->myEvent.buffer;
@@ -197,8 +199,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/gaudin/gwinosc.h b/demos/modules/gaudin/gwinosc.h
index 6a559c34..0efb403c 100644
--- a/demos/modules/gaudin/gwinosc.h
+++ b/demos/modules/gaudin/gwinosc.h
@@ -33,10 +33,9 @@
/**
* --------------------------- 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
- * produces unsigned integer samples.
+ * 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.
@@ -84,7 +83,8 @@ extern "C" {
/**
* 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.