gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE

release/v2.9
inmarket 2018-07-08 15:15:15 +10:00
parent 215f31ee3d
commit 93da5a0578
65 changed files with 170 additions and 167 deletions

View File

@ -84,9 +84,9 @@
uint8_t data[2]; \
data[0] = 0; \
data[1] = cmd; \
i2cMasterTransmitTimeout (UEXT_I2C, I2C_ADDRESS, data, 2, 0, 0, TIME_INFINITE); \
i2cMasterTransmitTimeout (UEXT_I2C, I2C_ADDRESS, data, 2, 0, 0, gDelayForever); \
}
#define I2C_WRITEBYTES(pdata, len) i2cMasterTransmitTimeout (UEXT_I2C, I2C_ADDRESS, pdata, length, 0, 0, TIME_INFINITE)
#define I2C_WRITEBYTES(pdata, len) i2cMasterTransmitTimeout (UEXT_I2C, I2C_ADDRESS, pdata, length, 0, 0, gDelayForever)
#else
#error "SSD1306 board file: Unsupported I2C method"

View File

@ -16,7 +16,7 @@ CHANGE: Added GFX_RED, GFX_BLUE, GFX_GREEN etc to replace V2.x Red, Gree, Blue
CHANGE: Added GFXON/GFXOFF to replace V2.x TRUE/FALSE for configuration options.
CHANGE: Added types gI8, gU8 .. gI32, gU32 to replace V2.x int8_t etc
CHANGE: Added type gBool to replace V2.x bool_t, and values gTrue/gFalse to replace TRUE/FALSE
CHANGE: Added type gDelay to replace V2.x delaytime_t
CHANGE: Added type gDelay to replace V2.x delaytime_t and values gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE
CHANGE: Added type gTicks to replace V2.x systemticks_t
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t

View File

@ -402,7 +402,7 @@ static DECLARE_THREAD_FUNCTION(notepadThread, param) {
ncoreSpawnDrawThread(nDrawingArea, gstatusConsole);
while(1) {
pem = (GEventMouse *) geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *) geventEventWait(&gl, gDelayForever);
/* button pressed... */
if (pem->type == GEVENT_GWIN_BUTTON) {

View File

@ -436,7 +436,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_BUTTON:

View File

@ -101,7 +101,7 @@ void gwinScopeWaitForTrace(GHandle gh) {
return;
/* Wait for a set of conversions */
pd = gadcHighSpeedGetData(TIME_INFINITE);
pd = gadcHighSpeedGetData(gDelayForever);
/* Ensure we are drawing in the right area */
#if GDISP_NEED_CLIP

View File

@ -118,7 +118,7 @@ void gwinScopeWaitForTrace(GHandle gh) {
return;
/* Wait for a set of audio conversions */
paud = gaudioRecordGetData(TIME_INFINITE);
paud = gaudioRecordGetData(gDelayForever);
/* Ensure we are drawing in the right area */
#if GDISP_NEED_CLIP

View File

@ -83,7 +83,7 @@ repeatplay:
toplay = gfileGetSize(f);
while(toplay) {
// Get a buffer to put the data into
pd = gfxBufferGet(TIME_INFINITE); // This should never fail as we are waiting forever
pd = gfxBufferGet(gDelayForever); // This should never fail as we are waiting forever
// How much data can we put in
len = toplay > pd->size ? pd->size : toplay;
@ -101,7 +101,7 @@ repeatplay:
gfileClose(f);
// Wait for the play to finish
gaudioPlayWait(TIME_INFINITE);
gaudioPlayWait(gDelayForever);
gdispDrawString(0, gdispGetHeight()/2+10, "Done", font, GFX_GREEN);
// Repeat the whole thing

View File

@ -165,7 +165,7 @@ repeatplay:
gdispDrawString(0, gdispGetHeight()/2, "Playing...", font, GFX_YELLOW);
while(toplay) {
// Get a buffer to put the data into
pd = gfxBufferGet(TIME_INFINITE); // This should never fail as we are waiting forever
pd = gfxBufferGet(gDelayForever); // This should never fail as we are waiting forever
// How much data can we put in
len = toplay > pd->size ? pd->size : toplay;
@ -183,7 +183,7 @@ repeatplay:
gfileClose(f);
// Wait for the play to finish
gaudioPlayWait(TIME_INFINITE);
gaudioPlayWait(gDelayForever);
gdispDrawString(0, gdispGetHeight()/2+10, "Done", font, GFX_GREEN);
// Repeat the whole thing

View File

@ -89,12 +89,12 @@ int main(void) {
break;
}
delay = gdispImageNext(&myImage);
if (delay == TIME_INFINITE) {
if (delay == gDelayForever) {
SHOW_ERROR(GFX_GREEN);
break;
}
SHOW_ERROR(GFX_YELLOW);
if (delay != TIME_IMMEDIATE)
if (delay != gDelayNone)
gfxSleepMilliseconds(delay);
}
gdispImageClose(&myImage);

View File

@ -70,7 +70,7 @@ int main(void) {
while(1) {
// Get an Event
pk = (GEventKeyboard *)geventEventWait(&gl, TIME_INFINITE);
pk = (GEventKeyboard *)geventEventWait(&gl, gDelayForever);
if (pk->type != GEVENT_KEYBOARD)
continue;

View File

@ -76,7 +76,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_BUTTON:

View File

@ -70,7 +70,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_CHECKBOX:

View File

@ -134,7 +134,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_CHECKBOX:

View File

@ -131,7 +131,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_SLIDER:

View File

@ -85,7 +85,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_KEYBOARD:

View File

@ -72,7 +72,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
}
return 0;

View File

@ -124,7 +124,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
}

View File

@ -92,7 +92,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_RADIO:

View File

@ -84,7 +84,7 @@ int main(void) {
while(1) {
// Get an Event (assume it is a slider event)
pe = (GEventGWinSlider *)geventEventWait(&gl, TIME_INFINITE);
pe = (GEventGWinSlider *)geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_SLIDER:

View File

@ -87,7 +87,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
(void)pe;
}

View File

@ -117,7 +117,7 @@ int main(void) {
while(1) {
// Get an Event
pk = (GEventKeyboard *)geventEventWait(&gl, TIME_INFINITE);
pk = (GEventKeyboard *)geventEventWait(&gl, gDelayForever);
if (pk->type != GEVENT_KEYBOARD)
continue;

View File

@ -535,7 +535,7 @@ int main(void) {
while(1) {
// Get an Event
pe = geventEventWait(&gl, TIME_INFINITE);
pe = geventEventWait(&gl, gDelayForever);
switch(pe->type) {
case GEVENT_GWIN_BUTTON:

View File

@ -176,7 +176,7 @@ StepDeviceType:
}
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
if (isCalibrated) {
switch (CheckButtons(pem)) {
case BTN_NEXT:
@ -225,7 +225,7 @@ StepRawReading:
// Always sleep a bit first to enable other events. We actually don't
// mind missing events for this test.
gfxSleepMilliseconds(100);
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
gwinPrintf(ghc, "%u, %u z=%u b=0x%04x\n", pem->x, pem->y, pem->z, pem->buttons & ~GINPUT_MISSED_MOUSE_EVENT);
if ((pem->buttons & GMETA_MOUSE_UP))
break;
@ -265,7 +265,7 @@ StepCalibrate:
gwinPrintf(ghc, "Press and release your %s to move on to start calibration.\n", deviceText);
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
if (isCalibrated) {
switch (CheckButtons(pem)) {
case BTN_NEXT:
@ -317,7 +317,7 @@ StepMouseCoords:
// Always sleep a bit first to enable other events. We actually don't
// mind missing events for this test.
gfxSleepMilliseconds(100);
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
switch (CheckButtons(pem)) {
case BTN_NEXT:
@ -359,7 +359,7 @@ StepMovementJitter:
gwinPrintf(ghc, "Press Next or Back to continue.\n\n");
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
switch (CheckButtons(pem)) {
case BTN_NEXT:
break;
@ -402,7 +402,7 @@ StepClickJitter:
gwinPrintf(ghc, "Press Next or Back to continue.\n\n");
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
switch (CheckButtons(pem)) {
case BTN_NEXT:
break;
@ -444,7 +444,7 @@ StepDrawing:
gwinPrintf(ghc, "Press Next or Back to continue.\n\n");
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
if (pem->y < bHeight && pem->x >= swidth-2*bWidth) {
if ((pem->buttons & GMETA_MOUSE_UP)) {
if (pem->x >= swidth-bWidth)

View File

@ -101,7 +101,7 @@ int main(void) {
geventAttachSource(&gl, gs, GLISTEN_MOUSEDOWNMOVES|GLISTEN_MOUSEUPMOVES|GLISTEN_MOUSEMETA|GLISTEN_MOUSENOFILTER);
while(1) {
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
gwinPrintf(ghc, "%u, %u z=%u b=0x%04x\n", pem->x, pem->y, pem->z, pem->buttons & ~GINPUT_MISSED_MOUSE_EVENT);
// Always sleep a bit first to enable other events. We actually don't mind missing events.

View File

@ -198,7 +198,7 @@ static gBool sendpkt(uint16_t *pkt, int len) {
while(1) {
// Get a (mouse) event
pem = (GEventMouse *)geventEventWait(&gl, TIME_INFINITE);
pem = (GEventMouse *)geventEventWait(&gl, gDelayForever);
if (pem->type != GEVENT_MOUSE && pem->type != GEVENT_TOUCH)
continue;

View File

@ -544,7 +544,7 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
InvalidateRect(hWnd, &rect, FALSE);
UpdateWindow(hWnd);
#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
#if GINPUT_TOGGLE_POLL_PERIOD == gDelayForever
ginputToggleWakeup();
#endif
}
@ -567,7 +567,7 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
rect.bottom = GDISP_SCREEN_HEIGHT + WIN32_BUTTON_AREA;
InvalidateRect(hWnd, &rect, FALSE);
UpdateWindow(hWnd);
#if GINPUT_TOGGLE_POLL_PERIOD == TIME_INFINITE
#if GINPUT_TOGGLE_POLL_PERIOD == gDelayForever
ginputToggleWakeup();
#endif
}

View File

@ -10,7 +10,7 @@
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
#define GINPUT_TOGGLE_POLL_PERIOD TIME_INFINITE // We are interrupt driven (or polled - either works here)
#define GINPUT_TOGGLE_POLL_PERIOD gDelayForever // We are interrupt driven (or polled - either works here)
// This driver is unique in that it can support 8 buttons per window across multiple windows.
// GINPUT_TOGGLE_CONFIG_ENTRIES just must be less than the number of GDISP windows (GDISP_DRIVER_COUNT_WIN32).

View File

@ -13,7 +13,7 @@
// When operating in touch mode we allow sloppier clicks etc
#if 1
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
#define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click
#define GINPUT_MOUSE_CLICK_TIME gDelayForever // Long click != Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION GFXOFF
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE GFXOFF
#define GINPUT_MOUSE_READ_CYCLES 1
@ -32,7 +32,7 @@
#endif
// This driver supports both an "interrupt" mode, and a polled mode
#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread
#define GINPUT_MOUSE_POLL_PERIOD gDelayForever // Interrupt driven by the Window thread
//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven
// This driver does not require rotation of co-ordinates for orientations other than 0.

View File

@ -13,7 +13,7 @@
// When operating in touch mode we allow sloppier clicks etc
#if 1
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_MOUSE
#define GINPUT_MOUSE_CLICK_TIME TIME_INFINITE // Long click != Context Click
#define GINPUT_MOUSE_CLICK_TIME gDelayForever // Long click != Context Click
#define GINPUT_MOUSE_NEED_CALIBRATION GFXOFF
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE GFXOFF
#define GINPUT_MOUSE_READ_CYCLES 1
@ -32,7 +32,7 @@
#endif
// This driver supports both an "interrupt" mode, and a polled mode
#define GINPUT_MOUSE_POLL_PERIOD TIME_INFINITE // Interrupt driven by the Window thread
#define GINPUT_MOUSE_POLL_PERIOD gDelayForever // Interrupt driven by the Window thread
//#define GINPUT_MOUSE_POLL_PERIOD 25 // Poll driven
// This driver does not require rotation of co-ordinates for orientations other than 0.

View File

@ -214,7 +214,7 @@ void gadcHighSpeedInit(uint32_t physdev, uint32_t frequency)
#if GFX_USE_GEVENT
GSourceHandle gadcHighSpeedGetSource(void) {
if (!gtimerIsActive(&hsGTimer))
gtimerStart(&hsGTimer, HighSpeedGTimerCallback, 0, gTrue, TIME_INFINITE);
gtimerStart(&hsGTimer, HighSpeedGTimerCallback, 0, gTrue, gDelayForever);
hsFlags |= GADC_HSADC_GTIMER;
return (GSourceHandle)&hsGTimer;
}
@ -285,7 +285,7 @@ static void LowSpeedGTimerCallback(void *param) {
NonTimerData *pdata;
// Look for completed non-timer jobs and call the call-backs for each
while ((pdata = (NonTimerData *)gfxQueueGSyncGet(&lsListDone, TIME_IMMEDIATE))) {
while ((pdata = (NonTimerData *)gfxQueueGSyncGet(&lsListDone, gDelayNone))) {
pdata->callback(pdata->job.buffer, pdata->param);
gfxFree(pdata);
}
@ -315,7 +315,7 @@ void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer) {
gfxSystemUnlock();
// Wait for it to complete
gfxSemWait(&ndata.sigdone, TIME_INFINITE);
gfxSemWait(&ndata.sigdone, gDelayForever);
gfxSemDestroy(&ndata.sigdone);
}
@ -324,7 +324,7 @@ gBool gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunct
/* Start the Low Speed Timer */
if (!gtimerIsActive(&lsGTimer))
gtimerStart(&lsGTimer, LowSpeedGTimerCallback, 0, gTrue, TIME_INFINITE);
gtimerStart(&lsGTimer, LowSpeedGTimerCallback, 0, gTrue, gDelayForever);
// Prepare the job
if (!(pdata = gfxAlloc(sizeof(NonTimerData))))

View File

@ -152,7 +152,7 @@ void _gaudioDeinit(void)
GSourceHandle gaudioPlayGetSource(void) {
if (!gtimerIsActive(&playTimer))
gtimerStart(&playTimer, PlayTimerCallback, 0, gTrue, TIME_INFINITE);
gtimerStart(&playTimer, PlayTimerCallback, 0, gTrue, gDelayForever);
playFlags |= PLAYFLG_USEEVENTS;
return (GSourceHandle)&playTimer;
}
@ -209,7 +209,7 @@ void _gaudioDeinit(void)
if ((recordFlags & (RECORDFLG_RECORDING|RECORDFLG_STALLED)) == RECORDFLG_RECORDING)
gaudio_record_lld_stop();
recordFlags &= ~(RECORDFLG_RECORDING|RECORDFLG_STALLED);
while((pd = (GDataBuffer *)gfxQueueGSyncGet(&recordList, TIME_IMMEDIATE)))
while((pd = (GDataBuffer *)gfxQueueGSyncGet(&recordList, gDelayNone)))
gfxBufferRelease(pd);
}
@ -245,7 +245,7 @@ void _gaudioDeinit(void)
GSourceHandle gaudioRecordGetSource(void) {
if (!gtimerIsActive(&recordTimer))
gtimerStart(&recordTimer, RecordTimerCallback, 0, gTrue, TIME_INFINITE);
gtimerStart(&recordTimer, RecordTimerCallback, 0, gTrue, gDelayForever);
recordFlags |= RECORDFLG_USEEVENTS;
return (GSourceHandle)&recordTimer;
}

View File

@ -227,20 +227,20 @@ gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y
/**
* @brief Prepare for the next frame/page in the image file.
* @return A time in milliseconds to keep displaying the current frame before trying to draw
* the next frame. Watch out for the special values TIME_IMMEDIATE and TIME_INFINITE.
* the next frame. Watch out for the special values gDelayNone and gDelayForever.
*
* @param[in] img The image structure
*
* @pre gdispImageOpen() must have returned successfully.
*
* @note It will return TIME_IMMEDIATE if the first frame/page hasn't been drawn or if the next frame
* @note It will return gDelayNone if the first frame/page hasn't been drawn or if the next frame
* should be drawn immediately.
* @note It will return TIME_INFINITE if another image frame doesn't exist or an error has occurred.
* @note Images that support multiple pages (eg TIFF files) will return TIME_IMMEDIATE between pages
* and then TIME_INFINITE when there are no more pages.
* @note An image that displays a looped animation will never return TIME_INFINITE unless it
* @note It will return gDelayForever if another image frame doesn't exist or an error has occurred.
* @note Images that support multiple pages (eg TIFF files) will return gDelayNone between pages
* and then gDelayForever when there are no more pages.
* @note An image that displays a looped animation will never return gDelayForever unless it
* gets an error.
* @note Calling gdispImageDraw() after getting a TIME_INFINITE will go back to drawing the first
* @note Calling gdispImageDraw() after getting a gDelayForever will go back to drawing the first
* frame/page.
*/
gDelay gdispImageNext(gdispImage *img);

View File

@ -819,7 +819,7 @@ gDelay gdispImageNext_BMP(gdispImage *img) {
(void) img;
/* No more frames/pages */
return TIME_INFINITE;
return gDelayForever;
}
uint16_t gdispImageGetPaletteSize_BMP(gdispImage *img) {

View File

@ -1122,7 +1122,7 @@ gDelay gdispImageNext_GIF(gdispImage *img) {
gfileSetPos(img->f, priv->frame.posimg+1); // Skip the code size byte too
while(1) {
if (gfileRead(img->f, &blocksz, 1) != 1)
return TIME_INFINITE;
return gDelayForever;
if (!blocksz)
break;
gfileSetPos(img->f, gfileGetPos(img->f) + blocksz);
@ -1145,10 +1145,10 @@ gDelay gdispImageNext_GIF(gdispImage *img) {
case GDISP_IMAGE_ERR_NOMEMORY: // Out of Memory
case GDISP_IMAGE_ERR_UNSUPPORTED: // Unsupported
default:
return TIME_INFINITE;
return gDelayForever;
}
}
return TIME_INFINITE;
return gDelayForever;
}
#endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE && GDISP_NEED_IMAGE_GIF */

View File

@ -202,7 +202,7 @@ gDelay gdispImageNext_JPG(gdispImage *img) {
(void) img;
/* No more frames/pages */
return TIME_INFINITE;
return gDelayForever;
}
/*----------------------------------------------------------------------------/

View File

@ -144,7 +144,7 @@ gDelay gdispImageNext_NATIVE(gdispImage *img) {
(void) img;
/* No more frames/pages */
return TIME_INFINITE;
return gDelayForever;
}
#endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE && GDISP_NEED_IMAGE_NATIVE */

View File

@ -1625,7 +1625,7 @@ gDelay gdispImageNext_PNG(gdispImage *img) {
(void) img;
/* No more frames/pages */
return TIME_INFINITE;
return gDelayForever;
}
#endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE && GDISP_NEED_IMAGE_PNG */

View File

@ -142,8 +142,8 @@ void geventDetachSource(GListener *pl, GSourceHandle gsh);
* @brief Wait for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should
* be typecast to the actual event type if it needs to be processed.
* TIME_INFINITE means no timeout - wait forever for an event.
* TIME_IMMEDIATE means return immediately
* gDelayForever means no timeout - wait forever for an event.
* gDelayNone means return immediately
* @note The returned GEvent is released when this routine is called again
* or when optionally @p geventEventComplete() is called. Calling @p geventEventComplete()
* allows the GEvent object to be reused earlier which can reduce missed events. The GEvent

View File

@ -41,12 +41,12 @@ extern "C" {
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
/* This routine is provided to low level drivers to wakeup a value read from a thread context.
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = gDelayForever
*/
void ginputToggleWakeup(void);
/* This routine is provided to low level drivers to wakeup a value read from an ISR
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = gDelayForever
*/
void ginputToggleWakeupI(void);

View File

@ -99,8 +99,8 @@
* @note Your platform may use slightly different definitions to these
* @{
*/
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((gDelay)-1)
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY 1
@ -215,9 +215,9 @@
*
* @param[in] ms The number milliseconds to sleep
*
* @note Specifying TIME_IMMEDIATE will yield the current thread but return
* @note Specifying gDelayNone will yield the current thread but return
* on the next time slice.
* @note Specifying TIME_INFINITE will sleep forever.
* @note Specifying gDelayForever will sleep forever.
*
* @api
*/
@ -228,8 +228,8 @@
*
* @param[in] us The number microseconds to sleep
*
* @note Specifying TIME_IMMEDIATE will return immediately (no sleeping)
* @note Specifying TIME_INFINITE will sleep forever.
* @note Specifying gDelayNone will return immediately (no sleeping)
* @note Specifying gDelayForever will sleep forever.
*
* @api
*/
@ -372,7 +372,7 @@
/**
* @brief Test if a wait on a semaphore can be satisfied immediately
* @details Equivalent to @p gfxSemWait(psem, TIME_IMMEDIATE) except it can be called at interrupt level
* @details Equivalent to @p gfxSemWait(psem, gDelayNone) except it can be called at interrupt level
* @return gFalse if the wait would occur occurred otherwise gTrue
*
* @param[in] psem A pointer to the semaphore
@ -498,6 +498,11 @@
typedef gTicks systemticks_t;
typedef gThreadreturn threadreturn_t;
typedef gThreadpriority threadpriority_t;
#if !GFX_USE_OS_CHIBIOS
// These are defined by ChibiOS itself
#define TIME_IMMEDIATE gDelayNone
#define TIME_INFINITE gDelayForever
#endif
#endif
#endif /* _GOS_H */

View File

@ -84,8 +84,8 @@ void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz)
void gfxSleepMilliseconds(gDelay ms)
{
switch(ms) {
case TIME_IMMEDIATE: chThdYield(); return;
case TIME_INFINITE: chThdSleep(TIME_INFINITE); return;
case gDelayNone: chThdYield(); return;
case gDelayForever: chThdSleep(TIME_INFINITE); return;
default: chThdSleepMilliseconds(ms); return;
}
}
@ -93,8 +93,8 @@ void gfxSleepMilliseconds(gDelay ms)
void gfxSleepMicroseconds(gDelay ms)
{
switch(ms) {
case TIME_IMMEDIATE: return;
case TIME_INFINITE: chThdSleep(TIME_INFINITE); return;
case gDelayNone: return;
case gDelayForever: chThdSleep(TIME_INFINITE); return;
default: chThdSleepMicroseconds(ms); return;
}
}
@ -122,14 +122,14 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
{
#if CH_KERNEL_MAJOR <= 2
switch(ms) {
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != RDY_TIMEOUT;
case TIME_INFINITE: chSemWait(&psem->sem); return gTrue;
case gDelayNone: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != RDY_TIMEOUT;
case gDelayForever: chSemWait(&psem->sem); return gTrue;
default: return chSemWaitTimeout(&psem->sem, gfxMillisecondsToTicks(ms)) != RDY_TIMEOUT;
}
#else
switch(ms) {
case TIME_IMMEDIATE: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT;
case TIME_INFINITE: chSemWait(&psem->sem); return gTrue;
case gDelayNone: return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT;
case gDelayForever: chSemWait(&psem->sem); return gTrue;
default: return chSemWaitTimeout(&psem->sem, gfxMillisecondsToTicks(ms)) != MSG_TIMEOUT;
}
#endif

View File

@ -25,10 +25,8 @@
/* Type definitions */
/*===========================================================================*/
/**
* TIME_IMMEDIATE, TIME_INFINITE
* are already defined by ChibiOS
*/
#define gDelayNone TIME_IMMEDIATE
#define gDelayForever TIME_INFINITE
#if CH_KERNEL_MAJOR <= 4
typedef systime_t gDelay;

View File

@ -25,8 +25,8 @@
/* Type definitions */
/*===========================================================================*/
#define TIME_IMMEDIATE 0
#define TIME_INFINITE osWaitForever
#define gDelayNone 0
#define gDelayForever osWaitForever
typedef uint32_t gDelay;
typedef uint32_t gTicks;
typedef uint16_t gSemcount;
@ -69,7 +69,7 @@ typedef osThreadId gfxThreadHandle;
void gfxMutexInit(gfxMutex* pmutex);
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, TIME_INFINITE)
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, gDelayForever)
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);

View File

@ -25,8 +25,8 @@
/* Type definitions */
/*===========================================================================*/
#define TIME_IMMEDIATE 0
#define TIME_INFINITE osWaitForever
#define gDelayNone 0
#define gDelayForever osWaitForever
typedef uint32_t gDelay;
typedef uint32_t gTicks;
typedef uint16_t gSemcount;
@ -62,7 +62,7 @@ typedef osThreadId_t gfxThreadHandle;
void gfxMutexInit(gfxMutex* pmutex);
#define gfxMutexDestroy(pmutex) osMutexDelete(*(pmutex))
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), TIME_INFINITE)
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), gDelayForever)
#define gfxMutexExit(pmutex) osMutexRelease(*(pmutex))
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);

View File

@ -35,8 +35,8 @@ void _gosDeinit(void)
void gfxSleepMilliseconds(gDelay ms)
{
switch(ms) {
case TIME_IMMEDIATE: cyg_thread_yield(); return;
case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return;
case gDelayNone: cyg_thread_yield(); return;
case gDelayForever: cyg_thread_suspend(cyg_thread_self()); return;
default: cyg_thread_delay(gfxMillisecondsToTicks(ms)); return;
}
}
@ -44,8 +44,8 @@ void gfxSleepMilliseconds(gDelay ms)
void gfxSleepMicroseconds(gDelay ms)
{
switch(ms) {
case TIME_IMMEDIATE: return;
case TIME_INFINITE: cyg_thread_suspend(cyg_thread_self()); return;
case gDelayNone: return;
case gDelayForever: cyg_thread_suspend(cyg_thread_self()); return;
default: cyg_thread_delay(gfxMillisecondsToTicks(ms/1000)); return;
}
}
@ -67,8 +67,8 @@ void gfxSemDestroy(gfxSem *psem)
gBool gfxSemWait(gfxSem *psem, gDelay ms)
{
switch(ms) {
case TIME_IMMEDIATE: return cyg_semaphore_trywait(&psem->sem);
case TIME_INFINITE: return cyg_semaphore_wait(&psem->sem);
case gDelayNone: return cyg_semaphore_trywait(&psem->sem);
case gDelayForever: return cyg_semaphore_wait(&psem->sem);
default: return cyg_semaphore_timed_wait(&psem->sem, gfxMillisecondsToTicks(ms)+cyg_current_time());
}
}

View File

@ -18,8 +18,8 @@
/* Type definitions */
/*===========================================================================*/
#define TIME_IMMEDIATE 0
#define TIME_INFINITE 0xFFFFFFFF
#define gDelayNone 0
#define gDelayForever 0xFFFFFFFF
typedef cyg_ucount32 gDelay;
typedef cyg_tick_count_t gTicks;

View File

@ -24,8 +24,8 @@
/* Type definitions */
/*===========================================================================*/
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((gDelay)-1)
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
typedef uint32_t gDelay;
typedef portTickType gTicks;
typedef int32_t gSemcount;

View File

@ -64,11 +64,11 @@ void gfxSleepMilliseconds(gDelay ms) {
struct timespec ts;
switch(ms) {
case TIME_IMMEDIATE:
case gDelayNone:
linuxyield();
return;
case TIME_INFINITE:
case gDelayForever:
while(1)
sleep(60);
return;
@ -85,11 +85,11 @@ void gfxSleepMicroseconds(gDelay us) {
struct timespec ts;
switch(us) {
case TIME_IMMEDIATE:
case gDelayNone:
linuxyield();
return;
case TIME_INFINITE:
case gDelayForever:
while(1)
sleep(60);
return;
@ -147,10 +147,10 @@ gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
}
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
switch (ms) {
case TIME_INFINITE:
case gDelayForever:
return sem_wait(&pSem->sem) ? gFalse : gTrue;
case TIME_IMMEDIATE:
case gDelayNone:
return sem_trywait(&pSem->sem) ? gFalse : gTrue;
default:
@ -189,12 +189,12 @@ gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
pthread_mutex_lock(&pSem->mtx);
switch (ms) {
case TIME_INFINITE:
case gDelayForever:
while (!pSem->cnt)
pthread_cond_wait(&pSem->cond, &pSem->mtx);
break;
case TIME_IMMEDIATE:
case gDelayNone:
if (!pSem->cnt) {
pthread_mutex_unlock(&pSem->mtx);
return gFalse;

View File

@ -46,11 +46,11 @@ typedef pthread_mutex_t gfxMutex;
#define gfxMutexDestroy(pmtx) pthread_mutex_destroy(pmtx)
#define gfxMutexEnter(pmtx) pthread_mutex_lock(pmtx)
#define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx)
#define gfxSemWaitI(psem) gfxSemWait(psem, TIME_IMMEDIATE)
#define gfxSemWaitI(psem) gfxSemWait(psem, gDelayNone)
#define gfxSemSignalI(psem) gfxSemSignal(psem)
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((gDelay)-1)
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0

View File

@ -57,8 +57,8 @@ void gfxSleepMilliseconds(gDelay ms) {
struct timespec ts;
switch(ms) {
case TIME_IMMEDIATE: gfxYield(); return;
case TIME_INFINITE: while(1) sleep(60); return;
case gDelayNone: gfxYield(); return;
case gDelayForever: while(1) sleep(60); return;
default:
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000;
@ -71,8 +71,8 @@ void gfxSleepMicroseconds(gDelay us) {
struct timespec ts;
switch(us) {
case TIME_IMMEDIATE: gfxYield(); return;
case TIME_INFINITE: while(1) sleep(60); return;
case gDelayNone: gfxYield(); return;
case gDelayForever: while(1) sleep(60); return;
default:
ts.tv_sec = us / 1000000;
ts.tv_nsec = (us % 1000000) * 1000;
@ -135,11 +135,11 @@ void gfxSemDestroy(gfxSem *pSem) {
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
pthread_mutex_lock(&pSem->mtx);
switch (ms) {
case TIME_INFINITE:
case gDelayForever:
while (!pSem->cnt)
pthread_cond_wait(&pSem->cond, &pSem->mtx);
break;
case TIME_IMMEDIATE:
case gDelayNone:
if (!pSem->cnt) {
pthread_mutex_unlock(&pSem->mtx);
return gFalse;

View File

@ -38,11 +38,11 @@ typedef pthread_mutex_t gfxMutex;
#define gfxMutexDestroy(pmtx) pthread_mutex_destroy(pmtx)
#define gfxMutexEnter(pmtx) pthread_mutex_lock(pmtx)
#define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx)
#define gfxSemWaitI(psem) gfxSemWait(psem, TIME_IMMEDIATE)
#define gfxSemWaitI(psem) gfxSemWait(psem, gDelayNone)
#define gfxSemSignalI(psem) gfxSemSignal(psem)
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((gDelay)-1)
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0

View File

@ -14,8 +14,8 @@
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]
#define THREAD_RETURN(retval) return retval
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((gDelay)-1)
#define gDelayNone 0
#define gDelayForever ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY 2
#define NORMAL_PRIORITY 3

View File

@ -70,7 +70,7 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
gBool gfxSemWaitI(gfxSem* psem)
{
if(raw_semaphore_get((psem), TIME_IMMEDIATE)==RAW_SUCCESS)
if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
return gTrue;
return gFalse;
}

View File

@ -5,8 +5,8 @@
#include "raw_api.h"
#define TIME_IMMEDIATE (RAW_NO_WAIT)
#define TIME_INFINITE (RAW_WAIT_FOREVER)
#define gDelayNone (RAW_NO_WAIT)
#define gDelayForever (RAW_WAIT_FOREVER)
typedef uint32_t gDelay;
typedef RAW_TICK_TYPE gTicks;
typedef int32_t gSemcount;
@ -38,7 +38,7 @@ typedef RAW_TASK_OBJ* gfxThreadHandle;
#define gfxSystemUnlock() {}
#define gfxMutexInit(pmutex) raw_mutex_create(pmutex, (RAW_U8 *)"", RAW_MUTEX_INHERIT_POLICY, 3)
#define gfxMutexDestroy(pmutex) raw_mutex_delete(pmutex)
#define gfxMutexEnter(pmutex) raw_mutex_get(pmutex, TIME_INFINITE)
#define gfxMutexEnter(pmutex) raw_mutex_get(pmutex, gDelayForever)
#define gfxMutexExit(pmutex) raw_mutex_put(pmutex)
#define gfxSemInit(psem, val, limit) raw_semaphore_create(psem, "", val)
#define gfxSemDestroy(psem) raw_semaphore_delete(psem)

View File

@ -43,10 +43,10 @@ void gfxSleepMicroseconds(gDelay ms) {
LARGE_INTEGER t1, t2, tdiff;
switch(ms) {
case TIME_IMMEDIATE:
case gDelayNone:
return;
case TIME_INFINITE:
case gDelayForever:
while(1)
Sleep(1000);
return;

View File

@ -35,8 +35,8 @@ typedef int gThreadpriority;
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1];
#define THREAD_RETURN(retval) return retval
#define TIME_IMMEDIATE 0
#define TIME_INFINITE INFINITE
#define gDelayNone 0
#define gDelayForever INFINITE
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
#define LOW_PRIORITY THREAD_PRIORITY_BELOW_NORMAL
#define NORMAL_PRIORITY THREAD_PRIORITY_NORMAL
@ -60,7 +60,7 @@ typedef HANDLE gfxThreadHandle;
#define gfxMutexExit(pmutex) ReleaseMutex(*(pmutex))
#define gfxSemInit(psem, val, limit) *(psem) = CreateSemaphore(0, val, limit, 0)
#define gfxSemDestroy(psem) CloseHandle(*(psem))
#define gfxSemWaitI(psem) gfxSemWait((psem), TIME_IMMEDIATE)
#define gfxSemWaitI(psem) gfxSemWait((psem), gDelayNone)
#define gfxSemSignal(psem) ReleaseSemaphore(*(psem), 1, 0)
#define gfxSemSignalI(psem) ReleaseSemaphore(*(psem), 1, 0)
#define gfxThreadMe() GetCurrentThread()

View File

@ -56,11 +56,11 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms) {
// Convert our delay to ticks
starttm = 0;
switch (ms) {
case TIME_IMMEDIATE:
delay = TIME_IMMEDIATE;
case gDelayNone:
delay = gDelayNone;
break;
case TIME_INFINITE:
delay = TIME_INFINITE;
case gDelayForever:
delay = gDelayForever;
break;
default:
delay = gfxMillisecondsToTicks(ms);
@ -73,9 +73,9 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms) {
INTERRUPTS_ON();
// Check if we have exceeded the defined delay
switch (delay) {
case TIME_IMMEDIATE:
case gDelayNone:
return gFalse;
case