Simplifying gdisp/arcsectors demo to only use the GDISP module
This commit is contained in:
parent
d4c68c5afe
commit
08292eb7d0
2 changed files with 6 additions and 24 deletions
|
@ -38,15 +38,11 @@
|
||||||
|
|
||||||
/* GFX sub-systems to turn on */
|
/* GFX sub-systems to turn on */
|
||||||
#define GFX_USE_GDISP TRUE
|
#define GFX_USE_GDISP TRUE
|
||||||
#define GFX_USE_GINPUT TRUE
|
|
||||||
#define GFX_USE_GEVENT TRUE
|
|
||||||
#define GFX_USE_GTIMER TRUE
|
|
||||||
|
|
||||||
/* Features for the GDISP subsystem. */
|
/* Features for the GDISP subsystem. */
|
||||||
#define GDISP_NEED_VALIDATION TRUE
|
#define GDISP_NEED_VALIDATION TRUE
|
||||||
#define GDISP_NEED_ARCSECTORS TRUE
|
#define GDISP_NEED_ARCSECTORS TRUE
|
||||||
|
|
||||||
#define GINPUT_NEED_MOUSE TRUE
|
|
||||||
|
|
||||||
#endif /* _GFXCONF_H */
|
#endif /* _GFXCONF_H */
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,9 @@
|
||||||
|
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
GListener gl;
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
coord_t width, height, r1, r2, cx, cy;
|
coord_t width, height, r1, r2, cx, cy;
|
||||||
uint8_t sectors;
|
uint8_t sectors;
|
||||||
GEventMouse *pme;
|
|
||||||
|
|
||||||
// Initialize and clear the display
|
// Initialize and clear the display
|
||||||
gfxInit();
|
gfxInit();
|
||||||
|
@ -42,35 +39,24 @@ int main(void) {
|
||||||
// Get the screen size
|
// Get the screen size
|
||||||
width = gdispGetWidth();
|
width = gdispGetWidth();
|
||||||
height = gdispGetHeight();
|
height = gdispGetHeight();
|
||||||
|
|
||||||
|
// Initialize some variables
|
||||||
r1 = width > height ? height/3 : width/3;
|
r1 = width > height ? height/3 : width/3;
|
||||||
r2 = r1*3/4;
|
r2 = r1*3/4;
|
||||||
cx = width/2;
|
cx = width/2;
|
||||||
cy = height/2;
|
cy = height/2;
|
||||||
sectors = 1;
|
sectors = 1;
|
||||||
|
|
||||||
// We want to listen for mouse button events
|
|
||||||
geventListenerInit(&gl);
|
|
||||||
geventAttachSource(&gl, ginputGetMouse(0), GLISTEN_MOUSEMETA);
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
// Draw the arc sectors
|
// Draw the arc sectors
|
||||||
gdispClear(White);
|
gdispClear(White);
|
||||||
gdispDrawArcSectors(cx, cy, r1, sectors, Blue);
|
gdispDrawArcSectors(cx, cy, r1, sectors, Blue);
|
||||||
gdispFillArcSectors(cx, cy, r2, sectors, Red);
|
gdispFillArcSectors(cx, cy, r2, sectors, Red);
|
||||||
|
|
||||||
// Get an Event
|
// Increase the sectors counter
|
||||||
pme = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
|
|
||||||
|
|
||||||
// Change our sectors based on the event.
|
|
||||||
switch(pme->type) {
|
|
||||||
case GEVENT_MOUSE:
|
|
||||||
case GEVENT_TOUCH:
|
|
||||||
if (pme->buttons & GMETA_MOUSE_CLICK)
|
|
||||||
sectors++;
|
sectors++;
|
||||||
else if (pme->buttons & GMETA_MOUSE_CXTCLICK)
|
|
||||||
sectors--;
|
// Waste some time
|
||||||
break;
|
gfxSleepMilliseconds(250);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue