diff options
| author | inmarket <andrewh@inmarket.com.au> | 2018-06-23 13:02:07 +1000 | 
|---|---|---|
| committer | inmarket <andrewh@inmarket.com.au> | 2018-06-23 13:02:07 +1000 | 
| commit | 41271d632b74f5cf47c30d3b699eb6b2786f2136 (patch) | |
| tree | 78bcb729c6d6177ca598f28908fefd186c50e9b6 /src | |
| parent | 3b97fb798e96514057bcf17263c1e5dbdcd7da26 (diff) | |
| download | uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.tar.gz uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.tar.bz2 uGFX-41271d632b74f5cf47c30d3b699eb6b2786f2136.zip | |
Added new type definitions - moving towards V3.0
Diffstat (limited to 'src')
115 files changed, 2915 insertions, 2899 deletions
| diff --git a/src/gadc/gadc.c b/src/gadc/gadc.c index 32a30930..8e8553df 100644 --- a/src/gadc/gadc.c +++ b/src/gadc/gadc.c @@ -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, TRUE, TIME_INFINITE); +			gtimerStart(&hsGTimer, HighSpeedGTimerCallback, 0, gTrue, TIME_INFINITE);  		hsFlags |= GADC_HSADC_GTIMER;  		return (GSourceHandle)&hsGTimer;  	} @@ -319,16 +319,16 @@ void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer) {  	gfxSemDestroy(&ndata.sigdone);  } -bool_t gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param) { +gBool gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param) {  	NonTimerData *pdata;  	/* Start the Low Speed Timer */  	if (!gtimerIsActive(&lsGTimer)) -		gtimerStart(&lsGTimer, LowSpeedGTimerCallback, 0, TRUE, TIME_INFINITE); +		gtimerStart(&lsGTimer, LowSpeedGTimerCallback, 0, gTrue, TIME_INFINITE);  	// Prepare the job  	if (!(pdata = gfxAlloc(sizeof(NonTimerData)))) -		return FALSE; +		return gFalse;  	pdata->job.physdev = physdev;  	pdata->job.buffer = buffer;  	pdata->callback = fn; @@ -347,7 +347,7 @@ bool_t gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunc  		gfxQueueGSyncPutI(&lsListToDo, (gfxQueueGSyncItem *)pdata);  	}  	gfxSystemUnlock(); -	return TRUE; +	return gTrue;  }  #endif /* GFX_USE_GADC */ diff --git a/src/gadc/gadc.h b/src/gadc/gadc.h index 94321192..3e995db6 100644 --- a/src/gadc/gadc.h +++ b/src/gadc/gadc.h @@ -94,10 +94,6 @@ typedef void (*GADCISRCallbackFunction)(void);  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Initialise the high speed ADC.   * @details				Initialises but does not start the conversions. @@ -219,14 +215,14 @@ void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer);  /**   * @brief	Perform a low speed ADC conversion with callback (in a thread context) - * @details	Returns FALSE if internal memory allocation fails + * @details	Returns gFalse if internal memory allocation fails   *   * @param[in] physdev		A value passed to describe which physical ADC devices/channels to use.   * @param[in] buffer		The static buffer to put the ADC samples into.   * @param[in] fn			The callback function to call when the conversion is complete.   * @param[in] param			A parameter to pass to the callback function.   * - * @return					FALSE if no free low speed ADC slots. + * @return					gFalse if no free low speed ADC slots.   *   * @note	This may be safely called from within a GTimer callback.   * @note	The callback may take a while to occur if the high speed ADC is running as the @@ -240,11 +236,7 @@ void gadcLowSpeedGet(uint32_t physdev, adcsample_t *buffer);   *   * @api   */ -bool_t gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param); - -#ifdef __cplusplus -} -#endif +gBool gadcLowSpeedStart(uint32_t physdev, adcsample_t *buffer, GADCCallbackFunction fn, void *param);  #endif /* GFX_USE_GADC */ diff --git a/src/gaudio/gaudio.c b/src/gaudio/gaudio.c index a9f20357..8311d8cb 100644 --- a/src/gaudio/gaudio.c +++ b/src/gaudio/gaudio.c @@ -76,13 +76,13 @@ void _gaudioDeinit(void)  #if GAUDIO_NEED_PLAY -	bool_t gaudioPlayInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format) { +	gBool gaudioPlayInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format) {  		gaudioPlayStop();  		playFlags &= ~PLAYFLG_ISINIT;  		if (!gaudio_play_lld_init(channel, frequency, format)) -			return FALSE; +			return gFalse;  		playFlags |= PLAYFLG_ISINIT; -		return TRUE; +		return gTrue;  	}  	void gaudioPlay(GDataBuffer *pd) { @@ -115,13 +115,13 @@ void _gaudioDeinit(void)  			gfxBufferRelease(pd);  	} -	bool_t gaudioPlaySetVolume(uint8_t vol) { +	gBool gaudioPlaySetVolume(uint8_t vol) {  		return gaudio_play_lld_set_volume(vol);  	} -	bool_t gaudioPlayWait(delaytime_t ms) { +	gBool gaudioPlayWait(delaytime_t ms) {  		if (!(playFlags & PLAYFLG_PLAYING)) -			return TRUE; +			return gTrue;  		return gfxSemWait(&playComplete, ms);  	} @@ -152,7 +152,7 @@ void _gaudioDeinit(void)  		GSourceHandle gaudioPlayGetSource(void) {  			if (!gtimerIsActive(&playTimer)) -				gtimerStart(&playTimer, PlayTimerCallback, 0, TRUE, TIME_INFINITE); +				gtimerStart(&playTimer, PlayTimerCallback, 0, gTrue, TIME_INFINITE);  			playFlags |= PLAYFLG_USEEVENTS;  			return (GSourceHandle)&playTimer;  		} @@ -185,13 +185,13 @@ void _gaudioDeinit(void)  #endif  #if GAUDIO_NEED_RECORD -	bool_t gaudioRecordInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format) { +	gBool gaudioRecordInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format) {  		gaudioRecordStop();  		recordFlags &= ~RECORDFLG_ISINIT;  		if (!gaudio_record_lld_init(channel, frequency, format)) -			return FALSE; +			return gFalse;  		recordFlags |= RECORDFLG_ISINIT; -		return TRUE; +		return gTrue;  	}  	void gaudioRecordStart(void) { @@ -245,7 +245,7 @@ void _gaudioDeinit(void)  		GSourceHandle gaudioRecordGetSource(void) {  			if (!gtimerIsActive(&recordTimer)) -				gtimerStart(&recordTimer, RecordTimerCallback, 0, TRUE, TIME_INFINITE); +				gtimerStart(&recordTimer, RecordTimerCallback, 0, gTrue, TIME_INFINITE);  			recordFlags |= RECORDFLG_USEEVENTS;  			return (GSourceHandle)&recordTimer;  		} diff --git a/src/gaudio/gaudio.h b/src/gaudio/gaudio.h index 7473373c..a318bab5 100644 --- a/src/gaudio/gaudio.h +++ b/src/gaudio/gaudio.h @@ -93,15 +93,11 @@  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  #if GAUDIO_NEED_PLAY || defined(__DOXYGEN__)  	/**  	 * @brief		Set the audio device to play on the specified channel and with the specified  	 * 				sample frequency. -	 * @return		TRUE is successful, FALSE if the driver doesn't accept those parameters. +	 * @return		gTrue is successful, gFalse if the driver doesn't accept those parameters.  	 *  	 * @param[in] channel	The audio output channel to use. Can be set from 0 to GAUDIO_PLAY_NUM_CHANNELS - 1  	 * @param[in] frequency	The audio sample rate in samples per second @@ -114,7 +110,7 @@ extern "C" {  	 *  	 * @api  	 */ -	bool_t gaudioPlayInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format); +	gBool gaudioPlayInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format);  	/**  	 * @brief		Play the specified sample data. @@ -159,16 +155,16 @@ extern "C" {  	/**  	 * @brief				Set the output volume. -	 * @return				TRUE if successful. +	 * @return				gTrue if successful.  	 *  	 * @param[in] vol		0->255 (0 = muted)  	 * -	 * @note				Some drivers may not support this. They will return FALSE. +	 * @note				Some drivers may not support this. They will return gFalse.  	 * @note				For stereo devices, both channels are set to the same volume.  	 *  	 * @api  	 */ -	bool_t gaudioPlaySetVolume(uint8_t vol); +	gBool gaudioPlaySetVolume(uint8_t vol);  	#if GFX_USE_GEVENT || defined(__DOXYGEN__)  		/** @@ -191,19 +187,19 @@ extern "C" {  	/**  	 * @brief		Wait for any currently playing sounds to complete -	 * @return		TRUE if there is now nothing playing or FALSE if the timeout is exceeded +	 * @return		gTrue if there is now nothing playing or gFalse if the timeout is exceeded  	 *  	 * @param[in] ms	The maximum amount of time in milliseconds to wait for playing to complete.  	 *  	 * @api  	 */ -	bool_t gaudioPlayWait(delaytime_t ms); +	gBool gaudioPlayWait(delaytime_t ms);  #endif  #if GAUDIO_NEED_RECORD || defined(__DOXYGEN__)  	/**  	 * @brief		Initialise (but not start) the Audio Recording sub-system. -	 * @details		Returns FALSE for an invalid channel or other invalid parameter. +	 * @details		Returns gFalse for an invalid channel or other invalid parameter.  	 *  	 * @param[in] channel		The channel to convert. Can be set from 0 to GAUDIO_RECORD_NUM_CHANNELS - 1  	 * @param[in] frequency		The sample frequency @@ -225,11 +221,11 @@ extern "C" {  	 * 						Make sure you allocate your buffers large enough. Each channel is then interleaved  	 * 						into the provided buffer.  	 * -	 * @return				FALSE if invalid channel or parameter +	 * @return				gFalse if invalid channel or parameter  	 *  	 * @api  	 */ -	bool_t gaudioRecordInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format); +	gBool gaudioRecordInit(uint16_t channel, uint32_t frequency, ArrayDataFormat format);  	/**  	 * @brief   Start the audio recording. @@ -286,10 +282,6 @@ extern "C" {  	#endif  #endif -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GAUDIO */  #endif /* _GAUDIO_H */ diff --git a/src/gaudio/gaudio_driver_play.h b/src/gaudio/gaudio_driver_play.h index 622769f1..69e194c7 100644 --- a/src/gaudio/gaudio_driver_play.h +++ b/src/gaudio/gaudio_driver_play.h @@ -71,7 +71,7 @@ void gaudioPlayDoneI(void);  /**   * @brief				Initialise the play driver - * @return				TRUE if the channel, frequency and format are valid. + * @return				gTrue if the channel, frequency and format are valid.   *   * @param[in] channel	The channel to use (see the driver for the available channels provided)   * @param[in] frequency	The sample frequency to use @@ -81,7 +81,7 @@ void gaudioPlayDoneI(void);   *   * @api   */ -bool_t gaudio_play_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format); +gBool gaudio_play_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format);  /**   * @brief				Start the audio output playing @@ -108,16 +108,16 @@ void gaudio_play_lld_stop(void);  /**   * @brief				Set the output volume. - * @return				TRUE if successful. + * @return				gTrue if successful.   *   * @param[in] vol		0->255 (0 = muted)   * - * @note				Some drivers may not support this. They will return FALSE. + * @note				Some drivers may not support this. They will return gFalse.   * @note				For stereo devices, both channels are set to the same volume.   *   * @api   */ -bool_t gaudio_play_lld_set_volume(uint8_t vol); +gBool gaudio_play_lld_set_volume(uint8_t vol);  #ifdef __cplusplus  } diff --git a/src/gaudio/gaudio_driver_record.h b/src/gaudio/gaudio_driver_record.h index 5cbe4532..f7db3d14 100644 --- a/src/gaudio/gaudio_driver_record.h +++ b/src/gaudio/gaudio_driver_record.h @@ -71,7 +71,7 @@ extern "C" {  /**   * @brief				Initialise the record driver - * @return				TRUE if the channel, frequency and format are valid. + * @return				gTrue if the channel, frequency and format are valid.   *   * @param[in] channel	The channel to use (see the driver for the available channels provided)   * @param[in] frequency	The sample frequency to use @@ -81,7 +81,7 @@ extern "C" {   *   * @api   */ -bool_t gaudio_record_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format); +gBool gaudio_record_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format);  /**   * @brief				Start the audio recording diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c index f1df787a..38edda9c 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp.c @@ -501,7 +501,7 @@ static void line_clip(GDisplay *g) {  }  #if GDISP_STARTUP_LOGO_TIMEOUT > 0 -	static bool_t	gdispInitDone; +	static gBool	gdispInitDone;  	static void StartupLogoDisplay(GDisplay *g) {  		coord_t			x, y, w;  		const coord_t *	p; @@ -604,14 +604,14 @@ void _gdispInit(void)  				#endif  			} -			gdispInitDone = TRUE; +			gdispInitDone = gTrue;  		}  	#endif  	// Start the automatic timer flush (if required)  	#if GDISP_NEED_TIMERFLUSH  		gtimerInit(&FlushTimer); -		gtimerStart(&FlushTimer, FlushTimerFn, 0, TRUE, GDISP_NEED_TIMERFLUSH); +		gtimerStart(&FlushTimer, FlushTimerFn, 0, gTrue, GDISP_NEED_TIMERFLUSH);  	#endif  } @@ -620,9 +620,9 @@ void _gdispDeinit(void)  	/* ToDo */  } -bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) { +gBool _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) {  	#define		gd		((GDisplay *)g) -	bool_t		ret; +	gBool		ret;  	// Intialise fields  	gd->systemdisplay = systeminstance; @@ -3150,7 +3150,7 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  		return;  	} -	void gdispGDrawThickLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color, coord_t width, bool_t round) { +	void gdispGDrawThickLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color, coord_t width, gBool round) {  		coord_t dx, dy, nx = 0, ny = 0;  		/* Compute the direction vector for the line */ @@ -3345,21 +3345,21 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  			(void) count;  			((coord_t*)state)[0]++; -			return TRUE; +			return gTrue;  		}  		static bool mf_drawline_callback(mf_str line, uint16_t count, void *state) {  			#define GD	((GDisplay *)state)  				mf_render_aligned(GD->t.font, GD->t.wrapx, GD->t.wrapy, GD->t.lrj, line, count, drawcharglyph, state);  				GD->t.wrapy += GD->t.font->line_height;  			#undef GD -			return TRUE; +			return gTrue;  		}  		static bool mf_fillline_callback(mf_str line, uint16_t count, void *state) {  			#define GD	((GDisplay *)state)  				mf_render_aligned(GD->t.font, GD->t.wrapx, GD->t.wrapy, GD->t.lrj, line, count, fillcharglyph, state);  				GD->t.wrapy += GD->t.font->line_height;  			#undef GD -			return TRUE; +			return gTrue;  		}  	#endif @@ -3638,9 +3638,9 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  		// No mutex required as we only read static data  		#if GDISP_NEED_TEXT_KERNING -			return mf_get_string_width(font, str, count, TRUE); +			return mf_get_string_width(font, str, count, gTrue);  		#else -			return mf_get_string_width(font, str, count, FALSE); +			return mf_get_string_width(font, str, count, gFalse);  		#endif  	} diff --git a/src/gdisp/gdisp.h b/src/gdisp/gdisp.h index 5bf2b284..587c3115 100644 --- a/src/gdisp/gdisp.h +++ b/src/gdisp/gdisp.h @@ -225,10 +225,6 @@ extern GDisplay	*GDISP;   */  typedef color_t		pixel_t; -#ifdef __cplusplus -extern "C" { -#endif -  /* Color Utility Functions */  /** @@ -445,7 +441,7 @@ void gdispGFillArea(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, c   *			non-byte boundary (no end-of-line padding).   * @note	If GDISP_NEED_ASYNC is defined then the buffer must be static   * 			or at least retained until this call has finished the blit. You can - * 			tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE. + * 			tell when all graphics drawing is finished by @p gdispIsBusy() going gFalse.   *   * @param[in] g 		The display to use   * @param[in] x,y		The start position @@ -902,7 +898,7 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  	 *  	 * @api  	 */ -	void gdispGDrawThickLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color, coord_t width, bool_t round); +	void gdispGDrawThickLine(GDisplay *g, coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color, coord_t width, gBool round);  	#define gdispDrawThickLine(x0,y0,x1,y1,c,w,r)			gdispGDrawThickLine(GDISP,x0,y0,x1,y1,c,w,r)  #endif @@ -1109,14 +1105,14 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  	/**  	 * @brief	Add a font permanently to the font list. -	 * @returns	TRUE on success. Reasons it may fail: out of memory, if it is already on the list, it is not a font loaded in RAM. +	 * @returns	gTrue on success. Reasons it may fail: out of memory, if it is already on the list, it is not a font loaded in RAM.  	 * @pre		GDISP_NEED_TEXT must be GFXON in your gfxconf.h  	 *  	 * @param[in] font		The font to add to the font list.  	 *  	 * @api  	 */ -	bool_t gdispAddFont(font_t font); +	gBool gdispAddFont(font_t font);  #endif  /* Extra Arc Functions */ @@ -1225,10 +1221,6 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co  #define gdispGUnsetClip(g)							gdispGSetClip((g),0,0,gdispGGetWidth(g),gdispGGetHeight(g))  #define gdispUnsetClip()							gdispGUnsetClip(GDISP) -#ifdef __cplusplus -} -#endif -  #if GDISP_NEED_IMAGE || defined(__DOXYGEN__)  	#include "gdisp_image.h"  #endif diff --git a/src/gdisp/gdisp_driver.h b/src/gdisp/gdisp_driver.h index 14e019ff..dffce58d 100644 --- a/src/gdisp/gdisp_driver.h +++ b/src/gdisp/gdisp_driver.h @@ -383,7 +383,7 @@ typedef struct GDISPVMT {  	GDriverVMT	d;  		#define GDISP_VFLG_DYNAMICONLY		0x0001		// This display should never be statically initialised  		#define GDISP_VFLG_PIXMAP			0x0002		// This is a pixmap display -	bool_t (*init)(GDisplay *g); +	gBool (*init)(GDisplay *g);  	void (*deinit)(GDisplay *g);  	void (*writestart)(GDisplay *g);				// Uses p.x,p.y  p.cx,p.cy  	void (*writepos)(GDisplay *g);					// Uses p.x,p.y @@ -421,11 +421,11 @@ typedef struct GDISPVMT {  	/**  	 * @brief   Initialize the driver. -	 * @return	TRUE if successful. +	 * @return	gTrue if successful.  	 * @param[in]	g					The driver structure  	 * @param[out]	g->g				The driver must fill in the GDISPControl structure  	 */ -	LLDSPEC	bool_t gdisp_lld_init(GDisplay *g); +	LLDSPEC	gBool gdisp_lld_init(GDisplay *g);  	#if GDISP_HARDWARE_DEINIT || defined(__DOXYGEN__)  		/** @@ -724,7 +724,7 @@ typedef struct GDISPVMT {  	#ifdef __cplusplus  	extern "C" {  	#endif -		bool_t _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance); +		gBool _gdispInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance);  		void _gdispPostInitDriver(GDriver *g);  		void _gdispDeInitDriver(GDriver *g);  	#ifdef __cplusplus diff --git a/src/gdisp/gdisp_fonts.c b/src/gdisp/gdisp_fonts.c index 36e8f73f..a217c4d9 100644 --- a/src/gdisp/gdisp_fonts.c +++ b/src/gdisp/gdisp_fonts.c @@ -19,7 +19,7 @@ static const struct mf_font_list_s *fontList;  /**   * Match a pattern against the font name.   */ -static bool_t matchfont(const char *pattern, const char *name) { +static gBool matchfont(const char *pattern, const char *name) {  	while(1) {  		switch (pattern[0]) {  		case '*': @@ -34,7 +34,7 @@ static bool_t matchfont(const char *pattern, const char *name) {  			return name[0] == 0;  		default:  			if (name[0] != pattern[0]) -				return FALSE; +				return gFalse;  			pattern++;  			name++;  			break; @@ -90,14 +90,14 @@ const char *gdispGetFontName(font_t font) {  	return font->short_name;  } -bool_t gdispAddFont(font_t font) { +gBool gdispAddFont(font_t font) {  	struct mf_font_list_s *hdr;  	if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) != (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) -		return FALSE; +		return gFalse;  	if (!(hdr = gfxAlloc(sizeof(struct mf_font_list_s)))) -		return FALSE; +		return gFalse;  	if (!fontList)  		fontList = mf_get_font_list(); @@ -105,7 +105,7 @@ bool_t gdispAddFont(font_t font) {  	hdr->next = fontList;  	((struct mf_font_s *)font)->flags &= ~FONT_FLAG_UNLISTED;  	fontList = hdr; -	return TRUE; +	return gTrue;  }  #endif /* GFX_USE_GDISP && GDISP_NEED_TEXT */ diff --git a/src/gdisp/gdisp_image.c b/src/gdisp/gdisp_image.c index cc137209..ae6a1a77 100644 --- a/src/gdisp/gdisp_image.c +++ b/src/gdisp/gdisp_image.c @@ -35,7 +35,7 @@  	extern delaytime_t gdispImageNext_BMP(gdispImage *img);  	extern uint16_t gdispImageGetPaletteSize_BMP(gdispImage *img);  	extern color_t gdispImageGetPalette_BMP(gdispImage *img, uint16_t index); -	extern bool_t gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, color_t newColor); +	extern gBool gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, color_t newColor);  #endif  #if GDISP_NEED_IMAGE_JPG @@ -67,7 +67,7 @@ typedef struct gdispImageHandlers {  	delaytime_t		(*next)(gdispImage *img);					/* The next frame function */  	uint16_t		(*getPaletteSize)(gdispImage *img);			/* Retrieve the size of the palette (number of entries) */  	color_t			(*getPalette)(gdispImage *img, uint16_t index);							/* Retrieve a specific color value of the palette */ -	bool_t			(*adjustPalette)(gdispImage *img, uint16_t index, color_t newColor);	/* Replace a color value in the palette */ +	gBool			(*adjustPalette)(gdispImage *img, uint16_t index, color_t newColor);	/* Replace a color value in the palette */  } gdispImageHandlers;  static gdispImageHandlers ImageHandlers[] = { @@ -154,7 +154,7 @@ void gdispImageClose(gdispImage *img) {  	img->priv = 0;  } -bool_t gdispImageIsOpen(gdispImage *img) { +gBool gdispImageIsOpen(gdispImage *img) {  	return img && img->type != GDISP_IMAGE_TYPE_UNKNOWN && img->fns != 0;  } @@ -204,9 +204,9 @@ color_t gdispImageGetPalette(gdispImage *img, uint16_t index) {  	return img->fns->getPalette(img, index);  } -bool_t gdispImageAdjustPalette(gdispImage *img, uint16_t index, color_t newColor) { -	if (!img || !img->fns) return FALSE; -	if (!img->fns->adjustPalette) return FALSE; +gBool gdispImageAdjustPalette(gdispImage *img, uint16_t index, color_t newColor) { +	if (!img || !img->fns) return gFalse; +	if (!img->fns->adjustPalette) return gFalse;  	return img->fns->adjustPalette(img, index, newColor);  } diff --git a/src/gdisp/gdisp_image.h b/src/gdisp/gdisp_image.h index 4cd348cf..99391850 100644 --- a/src/gdisp/gdisp_image.h +++ b/src/gdisp/gdisp_image.h @@ -70,224 +70,216 @@ typedef struct gdispImage {  	void *								priv;				/* @< Don't mess with this! */  } gdispImage; -#ifdef __cplusplus -extern "C" { -#endif - -	/** -	 * @brief	Initialise a gdispImage object -	 * -	 * @param[in] img  		The image structure to initialise -	 * -	 */ -	void gdispImageInit(gdispImage *img); - -	/** -	 * @brief	Open an image using an open GFILE and get it ready for drawing -	 * @details	Determine the image format and get ready to decode the first image frame -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @param[in] img  		The image structure -	 * @param[in] f			The open GFILE stream. -	 * -	 * @pre		The GFILE must be open for reading. -	 * -	 * @note	This determines which decoder to use and then initialises all other fields -	 * 			in the gdispImage structure. -	 * @note	The image background color is set to White. -	 * @note	There are three types of return - everything OK, partial success and unrecoverable -	 * 			failures. For everything OK it returns GDISP_IMAGE_ERR_OK. A partial success can -	 * 			be distinguished from a unrecoverable failure by testing the GDISP_IMAGE_ERR_UNRECOVERABLE -	 * 			bit in the error code. -	 * 			A partial success return code means an image can still be drawn but perhaps with -	 * 			reduced functionality eg only the first page of a multi-page image. -	 * @note	@p gdispImageClose() should be called when finished with the image. This will close -	 * 			the image and its underlying GFILE file. Note that images opened with partial success -	 * 			(eg GDISP_IMAGE_ERR_UNSUPPORTED_OK) -	 * 			still need to be closed when you are finished with them. -	 */ -	gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f); +/** + * @brief	Initialise a gdispImage object + * + * @param[in] img  		The image structure to initialise + * + */ +void gdispImageInit(gdispImage *img); -	/** -	 * @brief	Open an image in a file and get it ready for drawing -	 * @details	Determine the image format and get ready to decode the first image frame -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @pre		You must have included the file-system support into GFILE that you want to use. -	 * -	 * @param[in] img  		The image structure -	 * @param[in] filename	The filename to open -	 * -	 * @note	This function just opens the GFILE using the filename and passes it to @p gdispImageOpenGFile(). -	 */ -	#define gdispImageOpenFile(img, filename)			gdispImageOpenGFile((img), gfileOpen((filename), "rb")) +/** + * @brief	Open an image using an open GFILE and get it ready for drawing + * @details	Determine the image format and get ready to decode the first image frame + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @param[in] img  		The image structure + * @param[in] f			The open GFILE stream. + * + * @pre		The GFILE must be open for reading. + * + * @note	This determines which decoder to use and then initialises all other fields + * 			in the gdispImage structure. + * @note	The image background color is set to White. + * @note	There are three types of return - everything OK, partial success and unrecoverable + * 			failures. For everything OK it returns GDISP_IMAGE_ERR_OK. A partial success can + * 			be distinguished from a unrecoverable failure by testing the GDISP_IMAGE_ERR_UNRECOVERABLE + * 			bit in the error code. + * 			A partial success return code means an image can still be drawn but perhaps with + * 			reduced functionality eg only the first page of a multi-page image. + * @note	@p gdispImageClose() should be called when finished with the image. This will close + * 			the image and its underlying GFILE file. Note that images opened with partial success + * 			(eg GDISP_IMAGE_ERR_UNSUPPORTED_OK) + * 			still need to be closed when you are finished with them. + */ +gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f); -	/** -	 * @brief	Open an image in a ChibiOS basefilestream and get it ready for drawing -	 * @details	Determine the image format and get ready to decode the first image frame -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @pre		GFILE_NEED_CHIBIOSFS and GFX_USE_OS_CHIBIOS must be GFXON. This only makes sense on the ChibiOS -	 * 			operating system. -	 * -	 * @param[in] img  				The image structure -	 * @param[in] BaseFileStreamPtr	A pointer to an open BaseFileStream -	 * -	 * @note	This function just opens the GFILE using the basefilestream and passes it to @p gdispImageOpenGFile(). -	 */ -	#define gdispImageOpenBaseFileStream(img, BaseFileStreamPtr)			gdispImageOpenGFile((img), gfileOpenBaseFileStream((BaseFileStreamPtr), "rb")) +/** + * @brief	Open an image in a file and get it ready for drawing + * @details	Determine the image format and get ready to decode the first image frame + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @pre		You must have included the file-system support into GFILE that you want to use. + * + * @param[in] img  		The image structure + * @param[in] filename	The filename to open + * + * @note	This function just opens the GFILE using the filename and passes it to @p gdispImageOpenGFile(). + */ +#define gdispImageOpenFile(img, filename)			gdispImageOpenGFile((img), gfileOpen((filename), "rb")) -	/** -	 * @brief	Open an image in memory and get it ready for drawing -	 * @details	Determine the image format and get ready to decode the first image frame -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @pre		GFILE_NEED_MEMFS must be GFXON -	 * -	 * @param[in] img  		The image structure -	 * @param[in] ptr		A pointer to the image bytes in memory -	 * -	 * @note	This function just opens the GFILE using the basefilestream and passes it to @p gdispImageOpenGFile(). -	 */ -	#define gdispImageOpenMemory(img, ptr)			gdispImageOpenGFile((img), gfileOpenMemory((void *)(ptr), "rb")) +/** + * @brief	Open an image in a ChibiOS basefilestream and get it ready for drawing + * @details	Determine the image format and get ready to decode the first image frame + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @pre		GFILE_NEED_CHIBIOSFS and GFX_USE_OS_CHIBIOS must be GFXON. This only makes sense on the ChibiOS + * 			operating system. + * + * @param[in] img  				The image structure + * @param[in] BaseFileStreamPtr	A pointer to an open BaseFileStream + * + * @note	This function just opens the GFILE using the basefilestream and passes it to @p gdispImageOpenGFile(). + */ +#define gdispImageOpenBaseFileStream(img, BaseFileStreamPtr)			gdispImageOpenGFile((img), gfileOpenBaseFileStream((BaseFileStreamPtr), "rb")) -	/** -	 * @brief	Close an image and release any dynamically allocated working storage. -	 * -	 * @param[in] img   The image structure -	 * -	 * @pre		gdispImageOpenFile() must have returned successfully. -	 * -	 * @note	Also calls the IO close function (if it hasn't already been called). -	 */ -	void gdispImageClose(gdispImage *img); +/** + * @brief	Open an image in memory and get it ready for drawing + * @details	Determine the image format and get ready to decode the first image frame + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @pre		GFILE_NEED_MEMFS must be GFXON + * + * @param[in] img  		The image structure + * @param[in] ptr		A pointer to the image bytes in memory + * + * @note	This function just opens the GFILE using the basefilestream and passes it to @p gdispImageOpenGFile(). + */ +#define gdispImageOpenMemory(img, ptr)			gdispImageOpenGFile((img), gfileOpenMemory((void *)(ptr), "rb")) -	/** -	 * @brief	Is an image open. -	 * @return	TRUE if the image is currently open. -	 * -	 * @param[in] img   The image structure -	 * -	 * @note	Be careful with calling this on an uninitialized image structure as the image -	 * 			will contain random data which may be interpreted as meaning the image -	 * 			is open. Clearing the Image structure to 0's will guarantee the image -	 * 			is seen as being closed. -	 */ -	bool_t gdispImageIsOpen(gdispImage *img); +/** + * @brief	Close an image and release any dynamically allocated working storage. + * + * @param[in] img   The image structure + * + * @pre		gdispImageOpenFile() must have returned successfully. + * + * @note	Also calls the IO close function (if it hasn't already been called). + */ +void gdispImageClose(gdispImage *img); -	/** -	 * @brief	Set the background color of the image. -	 * -	 * @param[in] img   	The image structure -	 * @param[in] bgcolor	The background color to use -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 * -	 * @note	This color is only used when an image has to restore part of the background before -	 * 			continuing with drawing that includes transparency eg some GIF animations. -	 */ -	void gdispImageSetBgColor(gdispImage *img, color_t bgcolor); +/** + * @brief	Is an image open. + * @return	gTrue if the image is currently open. + * + * @param[in] img   The image structure + * + * @note	Be careful with calling this on an uninitialized image structure as the image + * 			will contain random data which may be interpreted as meaning the image + * 			is open. Clearing the Image structure to 0's will guarantee the image + * 			is seen as being closed. + */ +gBool gdispImageIsOpen(gdispImage *img); -	/** -	 * @brief	Cache the image -	 * @details	Decodes and caches the current frame into RAM. -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @param[in] img   The image structure -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 * -	 * @note	This can use a LOT of RAM! -	 * @note	The decoder may choose to ignore the request for caching. If it does so it will -	 * 			return GDISP_IMAGE_ERR_UNSUPPORTED_OK. -	 * @note	A fatal error here does not necessarily mean that drawing the image will fail. For -	 * 			example, a GDISP_IMAGE_ERR_NOMEMORY error simply means there isn't enough RAM to -	 * 			cache the image. -	 */ -	gdispImageError gdispImageCache(gdispImage *img); +/** + * @brief	Set the background color of the image. + * + * @param[in] img   	The image structure + * @param[in] bgcolor	The background color to use + * + * @pre		gdispImageOpen() must have returned successfully. + * + * @note	This color is only used when an image has to restore part of the background before + * 			continuing with drawing that includes transparency eg some GIF animations. + */ +void gdispImageSetBgColor(gdispImage *img, color_t bgcolor); -	/** -	 * @brief	Draw the image -	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -	 * -	 * @param[in] g   	The display to draw on -	 * @param[in] img   The image structure -	 * @param[in] x,y	The screen location to draw the image -	 * @param[in] cx,cy	The area on the screen to draw -	 * @param[in] sx,sy	The image position to start drawing at -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 * -	 * @note	If sx,sy + cx,cy is outside the image boundaries the area outside the image -	 * 			is simply not drawn. -	 * @note	If @p gdispImageCache() has been called first for this frame, this routine will draw using a -	 * 			fast blit from the cached frame. If not, it reads the input and decodes it as it -	 * 			is drawing. This may be significantly slower than if the image has been cached (but -	 * 			uses a lot less RAM) -	 */ -	gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy); -	#define gdispImageDraw(img,x,y,cx,cy,sx,sy)		gdispGImageDraw(GDISP,img,x,y,cx,cy,sx,sy) +/** + * @brief	Cache the image + * @details	Decodes and caches the current frame into RAM. + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @param[in] img   The image structure + * + * @pre		gdispImageOpen() must have returned successfully. + * + * @note	This can use a LOT of RAM! + * @note	The decoder may choose to ignore the request for caching. If it does so it will + * 			return GDISP_IMAGE_ERR_UNSUPPORTED_OK. + * @note	A fatal error here does not necessarily mean that drawing the image will fail. For + * 			example, a GDISP_IMAGE_ERR_NOMEMORY error simply means there isn't enough RAM to + * 			cache the image. + */ +gdispImageError gdispImageCache(gdispImage *img); -	/** -	 * @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. -	 * -	 * @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 -	 * 			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 -	 * 			gets an error. -	 * @note	Calling gdispImageDraw() after getting a TIME_INFINITE will go back to drawing the first -	 * 			frame/page. -	 */ -	delaytime_t gdispImageNext(gdispImage *img); +/** + * @brief	Draw the image + * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. + * + * @param[in] g   	The display to draw on + * @param[in] img   The image structure + * @param[in] x,y	The screen location to draw the image + * @param[in] cx,cy	The area on the screen to draw + * @param[in] sx,sy	The image position to start drawing at + * + * @pre		gdispImageOpen() must have returned successfully. + * + * @note	If sx,sy + cx,cy is outside the image boundaries the area outside the image + * 			is simply not drawn. + * @note	If @p gdispImageCache() has been called first for this frame, this routine will draw using a + * 			fast blit from the cached frame. If not, it reads the input and decodes it as it + * 			is drawing. This may be significantly slower than if the image has been cached (but + * 			uses a lot less RAM) + */ +gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy); +#define gdispImageDraw(img,x,y,cx,cy,sx,sy)		gdispGImageDraw(GDISP,img,x,y,cx,cy,sx,sy) -	/** -	 * @brief	Get the number of entries in the color palette. -	 * @return	The number of entries in the color palette or 0 if the image doesn't use a color palette. -	 * -	 * @param[in] img	The image structure -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 */ -	uint16_t gdispImageGetPaletteSize(gdispImage *img); +/** + * @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. + * + * @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 + * 			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 + * 			gets an error. + * @note	Calling gdispImageDraw() after getting a TIME_INFINITE will go back to drawing the first + * 			frame/page. + */ +delaytime_t gdispImageNext(gdispImage *img); -	/** -	 * @brief	Get an entry in the color palette. -	 * @return	The color value at a given position in the color palette. -	 * -	 * @param[in] img	The image structure -	 * @param[in] index	The index of the color palette entry -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 * -	 * @note	This function will return 0 if the index is out of bounds or if the image doesn't use a color palette. -	 */ -	color_t gdispImageGetPalette(gdispImage *img, uint16_t index); +/** + * @brief	Get the number of entries in the color palette. + * @return	The number of entries in the color palette or 0 if the image doesn't use a color palette. + * + * @param[in] img	The image structure + * + * @pre		gdispImageOpen() must have returned successfully. + */ +uint16_t gdispImageGetPaletteSize(gdispImage *img); -	/** -	 * @brief	Modify an entry in the color palette. -	 * @return	@p TRUE on success, @p FALSE otherwise. -	 * -	 * @param[in] img		The image structure -	 * @param[in] index		The index of the color palette entry -	 * @param[in] newColor	The new color value of the specified entry -	 * -	 * @pre		gdispImageOpen() must have returned successfully. -	 * @note	This function will return @p FALSE if the index is out of bounds or if the image doesn't use a color palette. -	 */ -	bool_t gdispImageAdjustPalette(gdispImage *img, uint16_t index, color_t newColor); +/** + * @brief	Get an entry in the color palette. + * @return	The color value at a given position in the color palette. + * + * @param[in] img	The image structure + * @param[in] index	The index of the color palette entry + * + * @pre		gdispImageOpen() must have returned successfully. + * + * @note	This function will return 0 if the index is out of bounds or if the image doesn't use a color palette. + */ +color_t gdispImageGetPalette(gdispImage *img, uint16_t index); -#ifdef __cplusplus -} -#endif +/** + * @brief	Modify an entry in the color palette. + * @return	@p gTrue on success, @p gFalse otherwise. + * + * @param[in] img		The image structure + * @param[in] index		The index of the color palette entry + * @param[in] newColor	The new color value of the specified entry + * + * @pre		gdispImageOpen() must have returned successfully. + * @note	This function will return @p gFalse if the index is out of bounds or if the image doesn't use a color palette. + */ +gBool gdispImageAdjustPalette(gdispImage *img, uint16_t index, color_t newColor);  #endif /* GFX_USE_GDISP && GDISP_NEED_IMAGE */  #endif /* _GDISP_IMAGE_H */ diff --git a/src/gdisp/gdisp_image_bmp.c b/src/gdisp/gdisp_image_bmp.c index 02ae8da4..2cb00853 100644 --- a/src/gdisp/gdisp_image_bmp.c +++ b/src/gdisp/gdisp_image_bmp.c @@ -860,23 +860,23 @@ color_t gdispImageGetPalette_BMP(gdispImage *img, uint16_t index) {  	#endif  } -bool_t gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, color_t newColor) { +gBool gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, color_t newColor) {  	#if GDISP_NEED_IMAGE_BMP_1 || GDISP_NEED_IMAGE_BMP_4 || GDISP_NEED_IMAGE_BMP_8  		gdispImagePrivate_BMP *priv;  		priv = (gdispImagePrivate_BMP *)img->priv;  		if (!priv) -			return FALSE; +			return gFalse;  		if (!(priv->bmpflags & BMP_PALETTE)) -			return FALSE; +			return gFalse;  		if (index >= priv->palsize) -			return FALSE; +			return gFalse;  		priv->palette[(uint8_t)index] = newColor; -		return TRUE; +		return gTrue;  	#else  		return 0; diff --git a/src/gdisp/gdisp_image_png.c b/src/gdisp/gdisp_image_png.c index 822c7002..8032ffe6 100644 --- a/src/gdisp/gdisp_image_png.c +++ b/src/gdisp/gdisp_image_png.c @@ -138,16 +138,16 @@ static void PNG_iInit(PNG_decode *d) {  }  // Load the next byte of image data from the PNG file -static bool_t PNG_iLoadData(PNG_decode *d) { +static gBool PNG_iLoadData(PNG_decode *d) {  	uint32_t	sz;  	// Is there data still left in the buffer?  	if (d->i.buflen) -		return TRUE; +		return gTrue;  	// If we are cached then we have no more data  	if (!d->i.f) -		return FALSE; +		return gFalse;  	// Have we finished the current chunk?  	if (!d->i.chunklen) { @@ -155,7 +155,7 @@ static bool_t PNG_iLoadData(PNG_decode *d) {  			// Find a new chunk  			gfileSetPos(d->i.f, d->i.chunknext);  			if (gfileRead(d->i.f, d->i.buf, 8) != 8) -				return FALSE; +				return gFalse;  			// Calculate the chunk length and next chunk  			d->i.chunklen = gdispImageGetAlignedBE32(d->i.buf, 0); @@ -168,7 +168,7 @@ static bool_t PNG_iLoadData(PNG_decode *d) {  					break;  				goto gotchunk;  			case 0x49454E44:		// "IEND"	- All done -				return FALSE; +				return gFalse;  			}  		}  	} @@ -180,11 +180,11 @@ gotchunk:  	if (sz > GDISP_IMAGE_PNG_FILE_BUFFER_SIZE)  		sz = GDISP_IMAGE_PNG_FILE_BUFFER_SIZE;  	if (gfileRead(d->i.f, d->i.buf, sz) != sz) -		return FALSE; +		return gFalse;  	d->i.chunklen -= sz;  	d->i.buflen = sz;  	d->i.pbuf = d->i.buf; -	return TRUE; +	return gTrue;  }  // Get the last loaded byte of image data from the PNG file @@ -222,12 +222,12 @@ static void PNG_oFlush(PNG_output *o) {  }  // Start a new image line -static bool_t PNG_oStartY(PNG_output *o, coord_t y) { +static gBool PNG_oStartY(PNG_output *o, coord_t y) {  	if (y < o->sy || y >= o->sy+o->cy) -		return FALSE; +		return gFalse;  	o->ix = 0;  	o->iy = y; -	return TRUE; +	return gTrue;  }  // Feed a pixel color to the display buffer @@ -283,18 +283,18 @@ static void PNG_zInit(PNG_zinflate *z) {  }  // Get the inflate header (slightly customized for PNG validity testing) -static bool_t PNG_zGetHeader(PNG_decode *d) { +static gBool PNG_zGetHeader(PNG_decode *d) {  	if (!PNG_iLoadData(d)) -		return FALSE; +		return gFalse;  	d->z.tmp[0] = PNG_iGetByte(d);  	if (!PNG_iLoadData(d)) -		return FALSE; +		return gFalse;  	d->z.tmp[1] = PNG_iGetByte(d);  	if (gdispImageGetAlignedBE16(d->z.tmp, 0) % 31 != 0				// Must be modulo 31, the FCHECK value is made that way  			|| (d->z.tmp[0] & 0x0F) != 8 || (d->z.tmp[0] & 0x80)	// only method 8: inflate 32k sliding window  			|| (d->z.tmp[1] & 0x20))								// no preset dictionary -		return FALSE; -	return TRUE; +		return gFalse; +	return gTrue;  }  // Get a bit from the input (treated as a LSB first stream) @@ -400,7 +400,7 @@ static void PNG_zBuildFixedTrees(PNG_decode *d) {  }  // Build inflate dynamic length and distance trees -static bool_t PNG_zDecodeTrees(PNG_decode *d) { +static gBool PNG_zDecodeTrees(PNG_decode *d) {  	static const uint8_t IndexLookup[19] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };  	unsigned	hlit, hdist, hclen;  	unsigned	i, num; @@ -412,7 +412,7 @@ static bool_t PNG_zDecodeTrees(PNG_decode *d) {  	hclen	= PNG_zGetBits(d, 4) + 4;		// 4 - 19  	if ((d->z.flags & PNG_ZFLG_EOF)) -		return FALSE; +		return gFalse;  	for (i = 0; i < 19; ++i)  		d->z.tmp[i] = 0; @@ -422,7 +422,7 @@ static bool_t PNG_zDecodeTrees(PNG_decode *d) {  		d->z.tmp[IndexLookup[i]] = PNG_zGetBits(d, 3);  	if ((d->z.flags & PNG_ZFLG_EOF)) -		return FALSE; +		return gFalse;  	// Build the code length tree  	PNG_zBuildTree(&d->z.ltree, d->z.tmp, 19); @@ -431,7 +431,7 @@ static bool_t PNG_zDecodeTrees(PNG_decode *d) {  	for (num = 0; num < hlit + hdist; ) {  		symbol = PNG_zGetSymbol(d, &d->z.ltree);  		if ((d->z.flags & PNG_ZFLG_EOF)) -			return FALSE; +			return gFalse;  		switch(symbol) {  		case 16:		// Copy the previous code length 3-6 times @@ -456,33 +456,33 @@ static bool_t PNG_zDecodeTrees(PNG_decode *d) {  	// Build the trees  	PNG_zBuildTree(&d->z.ltree, d->z.tmp, hlit);  	PNG_zBuildTree(&d->z.dtree, d->z.tmp + hlit, hdist); -	return TRUE; +	return gTrue;  }  // Copy bytes from the input stream. Completing the copy completes the block. -static bool_t PNG_zCopyInput(PNG_decode *d, unsigned length) { +static gBool PNG_zCopyInput(PNG_decode *d, unsigned length) {  	// Copy the block  	while(length--) {  		if (!PNG_iLoadData(d)) {				// EOF?  			d->z.flags |= PNG_ZFLG_EOF; -			return FALSE; +			return gFalse;  		}  		d->z.buf[d->z.bufend++] = PNG_iGetByte(d);  		WRAP_ZBUF(d->z.bufend);  		if (d->z.bufend == d->z.bufpos) {		// Buffer full?  			d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_COPY;  			((unsigned *)d->z.tmp)[0] = length; -			return TRUE; +			return gTrue;  		}  	}  	// The block is done  	d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_NEW; -	return TRUE; +	return gTrue;  }  // Copy an uncompressed inflate block into the output -static bool_t PNG_zUncompressedBlock(PNG_decode *d) { +static gBool PNG_zUncompressedBlock(PNG_decode *d) {  	unsigned	length;  	// This block works on byte boundaries @@ -492,7 +492,7 @@ static bool_t PNG_zUncompressedBlock(PNG_decode *d) {  	for (length = 0; length < 4; length++) {  		if (!PNG_iLoadData(d)) {			// EOF?  			d->z.flags |= PNG_ZFLG_EOF; -			return FALSE; +			return gFalse;  		}  		d->z.tmp[length] = PNG_iGetByte(d);  	} @@ -503,7 +503,7 @@ static bool_t PNG_zUncompressedBlock(PNG_decode *d) {  	// Check length  	if ((uint16_t)length != (uint16_t)~gdispImageGetAlignedLE16(d->z.tmp, 2)) {  		d->z.flags |= PNG_ZFLG_EOF; -		return FALSE; +		return gFalse;  	}  	// Copy the block @@ -511,7 +511,7 @@ static bool_t PNG_zUncompressedBlock(PNG_decode *d) {  }  // Inflate a compressed inflate block into the output -static bool_t PNG_zInflateBlock(PNG_decode *d) { +static gBool PNG_zInflateBlock(PNG_decode *d) {  	static const uint8_t	lbits[30]	= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 6 };  	static const uint16_t	lbase[30]	= { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 323 };  	static const uint8_t	dbits[30]	= { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 }; @@ -527,7 +527,7 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {  		// Is the block done?  		if (symbol == 256) {  			d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_NEW; -			return TRUE; +			return gTrue;  		}  		if (symbol < 256) { @@ -536,7 +536,7 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {  			WRAP_ZBUF(d->z.bufend);  			if (d->z.bufend == d->z.bufpos) {								// Buffer full?  				d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_INFLATE; -				return TRUE; +				return gTrue;  			}  			continue;  		} @@ -576,21 +576,21 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {  				d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_OFFSET;  				((unsigned *)d->z.tmp)[0] = length;  				((unsigned *)d->z.tmp)[1] = offset; -				return TRUE; +				return gTrue;  			}  		}  	}  iserror:  	d->z.flags |= PNG_ZFLG_EOF; -	return FALSE; +	return gFalse;  }  // Start a new uncompressed/inflate block -static bool_t PNG_zStartBlock(PNG_decode *d) { +static gBool PNG_zStartBlock(PNG_decode *d) {  	// Check for previous error, EOF or no more blocks  	if ((d->z.flags & (PNG_ZFLG_EOF|PNG_ZFLG_FINAL))) -		return FALSE; +		return gFalse;  	// Is this the final inflate block?  	if (PNG_zGetBit(d)) @@ -601,32 +601,32 @@ static bool_t PNG_zStartBlock(PNG_decode *d) {  	case 0:			// Decompress uncompressed block  		if (!PNG_zUncompressedBlock(d)) -			return FALSE; +			return gFalse;  		break;  	case 1:			// Decompress block with fixed huffman trees  		PNG_zBuildFixedTrees(d);  		if (!PNG_zInflateBlock(d)) -			return FALSE; +			return gFalse;  		break;  	case 2:			// Decompress block with dynamic huffman trees  		if (!PNG_zDecodeTrees(d)) -			return FALSE; +			return gFalse;  		if (!PNG_zInflateBlock(d)) -			return FALSE; +			return gFalse;  		break;  	default:		// Bad block type  		// Mark it as an error  		d->z.flags |= PNG_ZFLG_EOF; -		return FALSE; +		return gFalse;  	} -	return TRUE; +	return gTrue;  }  // Resume an offset copy -static bool_t PNG_zResumeOffset(PNG_decode *d, unsigned length, unsigned offset) { +static gBool PNG_zResumeOffset(PNG_decode *d, unsigned length, unsigned offset) {  	// Copy the matching string  	while (length--) {  		d->z.buf[d->z.bufend++] = d->z.buf[offset++]; @@ -636,7 +636,7 @@ static bool_t PNG_zResumeOffset(PNG_decode *d, unsigned length, unsigned offset)  			d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_OFFSET;  			((unsigned *)d->z.tmp)[0] = length;  			((unsigned *)d->z.tmp)[1] = offset; -			return TRUE; +			return gTrue;  		}  	}  	return PNG_zInflateBlock(d); @@ -720,14 +720,14 @@ static uint8_t PNG_fCalcPath(uint16_t a, uint16_t b, uint16_t c) {  }  // Scan-line filter type 0 -static bool_t PNG_unfilter_type0(PNG_decode *d) {		// PNG filter method 0 +static gBool PNG_unfilter_type0(PNG_decode *d) {		// PNG filter method 0  	uint8_t		ft;  	unsigned	i;  	// Get the filter type and check for validity (eg not EOF)  	ft = PNG_zGetByte(d);  	if (ft > 0x04) -		return FALSE; +		return gFalse;  	// Uncompress the scan line  	for(i = 0; i < d->f.scanbytes; i++) @@ -770,7 +770,7 @@ static bool_t PNG_unfilter_type0(PNG_decode *d) {		// PNG filter method 0  		break;  	} -	return TRUE; +	return gTrue;  }  /*----------------------------------------------------------------- diff --git a/src/gdisp/gdisp_image_support.h b/src/gdisp/gdisp_image_support.h index 9fefd3d6..ab636dae 100644 --- a/src/gdisp/gdisp_image_support.h +++ b/src/gdisp/gdisp_image_support.h @@ -120,19 +120,11 @@  #endif -#ifdef __cplusplus -extern "C" { -#endif - -	void *gdispImageAlloc(gdispImage *img, size_t sz); -	void gdispImageFree(gdispImage *img, void *ptr, size_t sz); - -	#if GFX_CPU_ENDIAN == GFX_CPU_ENDIAN_UNKNOWN -		extern const uint8_t gdispImageEndianArray[4]; -	#endif +void *gdispImageAlloc(gdispImage *img, size_t sz); +void gdispImageFree(gdispImage *img, void *ptr, size_t sz); -#ifdef __cplusplus -} +#if GFX_CPU_ENDIAN == GFX_CPU_ENDIAN_UNKNOWN +	extern const uint8_t gdispImageEndianArray[4];  #endif  #endif /* _GDISP_IMAGE_SUPPORT_H */ diff --git a/src/gdisp/gdisp_pixmap.c b/src/gdisp/gdisp_pixmap.c index 45dee66b..88bd57a3 100644 --- a/src/gdisp/gdisp_pixmap.c +++ b/src/gdisp/gdisp_pixmap.c @@ -110,11 +110,11 @@ pixel_t	*gdispPixmapGetBits(GDisplay *g) {  /* Driver exported functions.                                                */  /*===========================================================================*/ -LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { +LLDSPEC gBool gdisp_lld_init(GDisplay *g) {  	// The user api function should have already allocated and initialised the pixmap  	//	structure and put it into the priv member during driver initialisation.  	if (!g->priv) -		return FALSE; +		return gFalse;  	// Initialize the GDISP structure  	//	Width and height were saved into the start of the framebuffer. @@ -126,7 +126,7 @@ LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {  	g->g.Powermode = powerOn;  	g->board = 0; -	return TRUE; +	return gTrue;  }  LLDSPEC	void gdisp_lld_deinit(GDisplay *g) { diff --git a/src/gdisp/gdisp_pixmap.h b/src/gdisp/gdisp_pixmap.h index ebf7e1db..4d5e8004 100644 --- a/src/gdisp/gdisp_pixmap.h +++ b/src/gdisp/gdisp_pixmap.h @@ -24,66 +24,58 @@  #if (GFX_USE_GDISP && GDISP_NEED_PIXMAP) || defined(__DOXYGEN__) -#ifdef __cplusplus -extern "C" { -#endif +/** + * @brief	Create an off-screen pixmap that can be drawn to just like a normal display + * + * @param[in] width  	The width of the pixmap to be created + * @param[in] height  	The height of the pixmap to be created + * + * @return 	The created GDisplay representing the pixmap or 0 if the pixmap couldn't be created. + * + * @note	Once created, an off-screen pixmap can be drawn on using the standard gdispGxxxx calls. + * @note	It must be destroyed using @p gdispDeleteOffscreenPixmap + * @note	Because the RAM for the display area is allocated, on small micros only very small pixmaps should be considered. + * 			For example a 100x100 at 16 bits per pixel would be 20K of RAM (plus some overheads). + */ +GDisplay *gdispPixmapCreate(coord_t width, coord_t height); -	/** -	 * @brief	Create an off-screen pixmap that can be drawn to just like a normal display -	 * -	 * @param[in] width  	The width of the pixmap to be created -	 * @param[in] height  	The height of the pixmap to be created -	 * -	 * @return 	The created GDisplay representing the pixmap or 0 if the pixmap couldn't be created. -	 * -	 * @note	Once created, an off-screen pixmap can be drawn on using the standard gdispGxxxx calls. -	 * @note	It must be destroyed using @p gdispDeleteOffscreenPixmap -	 * @note	Because the RAM for the display area is allocated, on small micros only very small pixmaps should be considered. -	 * 			For example a 100x100 at 16 bits per pixel would be 20K of RAM (plus some overheads). -	 */ -	GDisplay *gdispPixmapCreate(coord_t width, coord_t height); +/** + * @brief	Destroy an off-screen pixmap + * + * @param[in] g  		The pixmap virtual display to delete + * + * @note	If a normal display is passed to this routine, it will be ignored. + */ +void gdispPixmapDelete(GDisplay *g); -	/** -	 * @brief	Destroy an off-screen pixmap -	 * -	 * @param[in] g  		The pixmap virtual display to delete -	 * -	 * @note	If a normal display is passed to this routine, it will be ignored. -	 */ -	void gdispPixmapDelete(GDisplay *g); +/** + * @brief	Get a pointer to the pixels of the display surface. + * @return	The pointer to the pixmap display surface or NULL if this display is not a pixmap. + * + * @param[in] g  	The pixmap virtual display + * + * @note	The pointer returned can be used for calls to @p gdispGBlitArea() or can be read or written to directly + * 			by the application code. For any one particular pixmap the pointer will not change over the life of the pixmap + * 			(although different pixmaps will have different pixel pointers). Once a pixmap is deleted, the pixel pointer + * 			should not be used by the application. + */ +pixel_t	*gdispPixmapGetBits(GDisplay *g); +#if GDISP_NEED_PIXMAP_IMAGE || defined(__DOXYGEN__)  	/** -	 * @brief	Get a pointer to the pixels of the display surface. -	 * @return	The pointer to the pixmap display surface or NULL if this display is not a pixmap. +	 * @brief	Get a pointer to a native format gdispImage. +	 * @return	A pointer to a NATIVE format gdispImage in memory or NULL if this display is not a pixmap. +	 * @pre		GDISP_NEED_PIXAMP_IMAGE must be GFXON in your gfxconf.h  	 *  	 * @param[in] g  	The pixmap virtual display  	 * -	 * @note	The pointer returned can be used for calls to @p gdispGBlitArea() or can be read or written to directly -	 * 			by the application code. For any one particular pixmap the pointer will not change over the life of the pixmap -	 * 			(although different pixmaps will have different pixel pointers). Once a pixmap is deleted, the pixel pointer -	 * 			should not be used by the application. +	 * @return 	The pointer to the native gdispImage +	 * +	 * @note	The pointer returned can be passed to @p gdispImageOpenMemory() or to @p gfileOpenMemory(). +	 * @note	If you are just wanting to copy to a real display it is more efficient to use @p gdispGetPixmapBits() and @p gdispGBlitArea(). +	 * @note	Like @p gdispGetPixmapBits(), the pointer returned is valid for the life of the pixmap.  	 */ -	pixel_t	*gdispPixmapGetBits(GDisplay *g); - -	#if GDISP_NEED_PIXMAP_IMAGE || defined(__DOXYGEN__) -		/** -		 * @brief	Get a pointer to a native format gdispImage. -		 * @return	A pointer to a NATIVE format gdispImage in memory or NULL if this display is not a pixmap. -		 * @pre		GDISP_NEED_PIXAMP_IMAGE must be GFXON in your gfxconf.h -		 * -		 * @param[in] g  	The pixmap virtual display -		 * -		 * @return 	The pointer to the native gdispImage -		 * -		 * @note	The pointer returned can be passed to @p gdispImageOpenMemory() or to @p gfileOpenMemory(). -		 * @note	If you are just wanting to copy to a real display it is more efficient to use @p gdispGetPixmapBits() and @p gdispGBlitArea(). -		 * @note	Like @p gdispGetPixmapBits(), the pointer returned is valid for the life of the pixmap. -		 */ -		void *gdispPixmapGetMemoryImage(GDisplay *g); -	#endif - -#ifdef __cplusplus -} +	void *gdispPixmapGetMemoryImage(GDisplay *g);  #endif  #endif /* GFX_USE_GDISP && GDISP_NEED_PIXMAP */ diff --git a/src/gdriver/gdriver.h b/src/gdriver/gdriver.h index 4a1959a6..e8430fb1 100644 --- a/src/gdriver/gdriver.h +++ b/src/gdriver/gdriver.h @@ -67,7 +67,7 @@ typedef struct GDriverVMT {  	uint16_t	type;																// @< What type of driver this is  	uint16_t	flags;																// @< Flags for the driver. Meaning is specific to each driver type.  	uint32_t	objsize;															// @< How big the runtime driver structure is -	bool_t		(*init)(GDriver *driver, void *param, unsigned driverinstance, unsigned systeminstance);	// @< Initialise the driver. Returns TRUE if OK. +	gBool		(*init)(GDriver *driver, void *param, unsigned driverinstance, unsigned systeminstance);	// @< Initialise the driver. Returns gTrue if OK.  																					//		driverinstance is the instance 0..n of this driver.  																					//		systeminstance is the instance 0..n of this type of device.  																					//      The memory allocated is cleared before this call. diff --git a/src/gevent/gevent.c b/src/gevent/gevent.c index 733856c8..311d94fb 100644 --- a/src/gevent/gevent.c +++ b/src/gevent/gevent.c @@ -68,13 +68,13 @@ void geventListenerInit(GListener *pl) {  	pl->flags = 0;  } -bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, uint32_t flags) { +gBool geventAttachSource(GListener *pl, GSourceHandle gsh, uint32_t flags) {  	GSourceListener *psl, *pslfree;  	// Safety first  	if (!pl || !gsh) { -		GEVENT_ASSERT(FALSE); -		return FALSE; +		GEVENT_ASSERT(gFalse); +		return gFalse;  	}  	gfxMutexEnter(&geventMutex); @@ -87,7 +87,7 @@ bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, uint32_t flags) {  			// Just update the flags  			psl->listenflags = flags;  			gfxMutexExit(&geventMutex); -			return TRUE; +			return gTrue;  		}  		if (!pslfree && !psl->pListener)  			pslfree = psl; diff --git a/src/gevent/gevent.h b/src/gevent/gevent.h index 8b95235d..121895ba 100644 --- a/src/gevent/gevent.h +++ b/src/gevent/gevent.h @@ -77,10 +77,6 @@ typedef struct GSourceListener_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /* How to listen for events (act as a Listener)...  	1. Get handles for all the event sources you are interested in.  	2. Initialise a listener @@ -97,7 +93,7 @@ extern "C" {  			For each listener	- check the flags to see if an event should be sent.  								- use geventGetEventBuffer() to get the event buffer supplied by the listener  									and then call geventSendEvent() to send the event. -								- Note: geventGetEventBuffer() may return FALSE to indicate the listener is currently not listening and +								- Note: geventGetEventBuffer() may return gFalse to indicate the listener is currently not listening and  									therefore no event should be sent. This situation enables the source to (optionally) flag  									to the listener on its next wait that there have been missed events.  								- Note: The GSourceListener pointer (and the GEvent buffer) are only valid between @@ -121,16 +117,16 @@ void geventListenerInit(GListener *pl);   * @brief 	Attach a source to a listener   * @details	Flags are interpreted by the source when generating events for each listener.   *			If this source is already assigned to the listener it will update the flags. - *			If insufficient resources are available it will either assert or return FALSE + *			If insufficient resources are available it will either assert or return gFalse   *			depending on the value of GEVENT_ASSERT_NO_RESOURCE.   *   * @param[in] pl	The listener   * @param[in] gsh	The source which has to be attached to the listener   * @param[in] flags	The flags   * - * @return TRUE if succeeded, FALSE otherwise + * @return gTrue if succeeded, gFalse otherwise   */ -bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, uint32_t flags); +gBool geventAttachSource(GListener *pl, GSourceHandle gsh, uint32_t flags);  /**   * @brief	Detach a source from a listener @@ -236,10 +232,6 @@ void geventSendEvent(GSourceListener *psl);   */  void geventDetachSourceListeners(GSourceHandle gsh); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GEVENT */  #endif /* _GEVENT_H */ diff --git a/src/gfile/gfile.c b/src/gfile/gfile.c index 4bc39189..a0ef6071 100644 --- a/src/gfile/gfile.c +++ b/src/gfile/gfile.c @@ -135,7 +135,7 @@ GFILE *_gfileFindSlot(const char *mode) {   * IO routines   ********************************************************/ -bool_t gfileExists(const char *fname) { +gBool gfileExists(const char *fname) {  	const GFILEVMT * const *p;  	#if GFILE_ALLOW_DEVICESPECIFIC @@ -144,18 +144,18 @@ bool_t gfileExists(const char *fname) {  				if (p[0]->prefix == fname[0])  					return p[0]->exists && p[0]->exists(fname+2);  			} -			return FALSE; +			return gFalse;  		}  	#endif  	for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) {  		if (p[0]->exists && p[0]->exists(fname)) -			return TRUE; +			return gTrue;  	} -	return FALSE; +	return gFalse;  } -bool_t gfileDelete(const char *fname) { +gBool gfileDelete(const char *fname) {  	const GFILEVMT **p;  	#if GFILE_ALLOW_DEVICESPECIFIC @@ -164,15 +164,15 @@ bool_t gfileDelete(const char *fname) {  				if (p[0]->prefix == fname[0])  					return p[0]->del && p[0]->del(fname+2);  			} -			return FALSE; +			return gFalse;  		}  	#endif  	for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) {  		if (p[0]->del && p[0]->del(fname)) -			return TRUE; +			return gTrue;  	} -	return FALSE; +	return gFalse;  }  long int gfileGetFilesize(const char *fname) { @@ -196,7 +196,7 @@ long int gfileGetFilesize(const char *fname) {  	return -1;  } -bool_t gfileRename(const char *oldname, const char *newname) { +gBool gfileRename(const char *oldname, const char *newname) {  	const GFILEVMT * const *p;  	#if GFILE_ALLOW_DEVICESPECIFIC @@ -209,7 +209,7 @@ bool_t gfileRename(const char *oldname, const char *newname) {  				if (newname[0] && newname[1] == '|') {  					if (newname[0] != ch)  						// Both oldname and newname are fs specific but different ones. -						return FALSE; +						return gFalse;  					newname += 2;  				}  			} else { @@ -220,25 +220,25 @@ bool_t gfileRename(const char *oldname, const char *newname) {  				if (p[0]->prefix == ch)  					return p[0]->ren && p[0]->ren(oldname, newname);  			} -			return FALSE; +			return gFalse;  		}  	#endif  	for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) {  		if (p[0]->ren && p[0]->ren(oldname,newname)) -			return TRUE; +			return gTrue;  	} -	return FALSE; +	return gFalse;  } -static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) { +static gBool testopen(const GFILEVMT *p, GFILE *f, const char *fname) {  	// If we want write but the fs doesn't allow it then return  	if ((f->flags & GFILEFLG_WRITE) && !(p->flags & GFSFLG_WRITEABLE)) -		return FALSE; +		return gFalse;  	// Try to open  	if (!p->open || !p->open(f, fname)) -		return FALSE; +		return gFalse;  	// File is open - fill in all the details  	f->vmt = p; @@ -246,7 +246,7 @@ static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) {  	f->flags |= GFILEFLG_OPEN;  	if (p->flags & GFSFLG_SEEKABLE)  		f->flags |= GFILEFLG_CANSEEK; -	return TRUE; +	return gTrue;  }  GFILE *gfileOpen(const char *fname, const char *mode) { @@ -318,13 +318,13 @@ long int gfileGetPos(GFILE *f) {  	return f->pos;  } -bool_t gfileSetPos(GFILE *f, long int pos) { +gBool gfileSetPos(GFILE *f, long int pos) {  	if (!f || !(f->flags & GFILEFLG_OPEN)) -		return FALSE; +		return gFalse;  	if (!f->vmt->setpos || !f->vmt->setpos(f, pos)) -		return FALSE; +		return gFalse;  	f->pos = pos; -	return TRUE; +	return gTrue;  }  long int gfileGetSize(GFILE *f) { @@ -335,50 +335,50 @@ long int gfileGetSize(GFILE *f) {  	return f->vmt->getsize(f);  } -bool_t gfileEOF(GFILE *f) { +gBool gfileEOF(GFILE *f) {  	if (!f || !(f->flags & GFILEFLG_OPEN)) -		return TRUE; +		return gTrue;  	if (!f->vmt->eof) -		return FALSE; +		return gFalse;  	return f->vmt->eof(f);  } -bool_t gfileMount(char fs, const char* drive) { +gBool gfileMount(char fs, const char* drive) {  	const GFILEVMT * const *p;  	// Find the correct VMT  	for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) {  		if (p[0]->prefix == fs) {  			if (!p[0]->mount) -				return FALSE; +				return gFalse;  			return p[0]->mount(drive);  		}  	} -	return FALSE; +	return gFalse;  } -bool_t gfileUnmount(char fs, const char* drive) { +gBool gfileUnmount(char fs, const char* drive) {  	const GFILEVMT * const *p;  	// Find the correct VMT  	for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) {  		if (p[0]->prefix == fs) {  			if (!p[0]->mount) -				return FALSE; +				return gFalse;  			return p[0]->unmount(drive);  		}  	} -	return FALSE; +	return gFalse;  } -bool_t gfileSync(GFILE *f) { +gBool gfileSync(GFILE *f) {  	if (!f->vmt->sync) -		return FALSE; +		return gFalse;  	return f->vmt->sync(f);  }  #if GFILE_NEED_FILELISTS -	gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs) { +	gfileList *gfileOpenFileList(char fs, const char *path, gBool dirs) {  		const GFILEVMT * const *p;  		gfileList *		pfl; diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h index 0ae2a035..65088c03 100644 --- a/src/gfile/gfile.h +++ b/src/gfile/gfile.h @@ -42,429 +42,421 @@ extern GFILE *gfileStdOut;  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif +/** + * @brief					Check if file exists + *  + * @param[in] fname			The file name + *  + * @return					gTrue if file exists, gFalse otherwise + *  + * @api + */ +gBool		gfileExists(const char *fname); -	/** -	 * @brief					Check if file exists -	 *  -	 * @param[in] fname			The file name -	 *  -	 * @return					TRUE if file exists, FALSE otherwise -	 *  -	 * @api -	 */ -	bool_t		gfileExists(const char *fname); +/** + * @brief					Delete file + *  + * @param[in] fname			The file name + *  + * @return					gTrue on success, gFalse otherwise + *  + * @api + */ +gBool		gfileDelete(const char *fname); -	/** -	 * @brief					Delete file -	 *  -	 * @param[in] fname			The file name -	 *  -	 * @return					TRUE on success, FALSE otherwise -	 *  -	 * @api -	 */ -	bool_t		gfileDelete(const char *fname); +/** + * @brief					Get the size of a file + * @note					Please use @p gfileGetSize() if the file is opened + *  + * @param[in] fname			The file name + *  + * @return					File size on success, -1 on error + *  + * @api + */ +long int	gfileGetFilesize(const char *fname); -	/** -	 * @brief					Get the size of a file -	 * @note					Please use @p gfileGetSize() if the file is opened -	 *  -	 * @param[in] fname			The file name -	 *  -	 * @return					File size on success, -1 on error -	 *  -	 * @api -	 */ -	long int	gfileGetFilesize(const char *fname); +/** + * @brief					Rename file + * + * @param[in] oldname		The current file name + * @param[in] newname		The new name of the file + * + * @return					gTrue on success, gFalse otherwise + * + * @api + */ +gBool		gfileRename(const char *oldname, const char *newname); -	/** -	 * @brief					Rename file -	 * -	 * @param[in] oldname		The current file name -	 * @param[in] newname		The new name of the file -	 * -	 * @return					TRUE on success, FALSE otherwise -	 * -	 * @api -	 */ -	bool_t		gfileRename(const char *oldname, const char *newname); +/** + * @brief					Open file + * @details					A file must be opened before it can be accessed + * @details					The resulting GFILE will be used for all functions that access the file. + * + * @param[in] fname			The file name + * @param[in] mode			The mode. + * + * @return					Valid GFILE on success, 0 otherwise + * + * @note					The modes follow the c library fopen() standard. + * 							The valid modes are: + * 							<ul><li>r   - Open for read, the file must exist</li> + * 								<li>w   - Open for write, the file is truncated if it exists</li> + * 								<li>wx  - Open for write, the file must not exist</li> + * 								<li>a   - Open for append, the file is truncated if it exists</li> + * 								<li>ax  - Open for append, the file must not exists</li> + * 							</ul> + * 							The following flags can also be added to the above modes:<br/> + * 							<ul><li>+   - Open for both read and write</li> + * 								<li>b   - Open as a binary file rather than a text file</li> + * 							</ul> + * @note					Not all file-systems support all modes. For example, write + * 							is not available with the ROM file-system. Similarly few platforms + * 							distinguish between binary and text files. + * @note					Even though binary vs. text is relevant only for a small number of platforms + * 							the "b" flag should always be specified for binary files such as images. + * 							This ensures portability to other platforms. The extra flag will be ignored + * 							on platforms where it is not relevant. + * + * @api + */	 +GFILE *		gfileOpen(const char *fname, const char *mode); -	/** -	 * @brief					Open file -	 * @details					A file must be opened before it can be accessed -	 * @details					The resulting GFILE will be used for all functions that access the file. -	 * -	 * @param[in] fname			The file name -	 * @param[in] mode			The mode. -	 * -	 * @return					Valid GFILE on success, 0 otherwise -	 * -	 * @note					The modes follow the c library fopen() standard. -	 * 							The valid modes are: -	 * 							<ul><li>r   - Open for read, the file must exist</li> -	 * 								<li>w   - Open for write, the file is truncated if it exists</li> -	 * 								<li>wx  - Open for write, the file must not exist</li> -	 * 								<li>a   - Open for append, the file is truncated if it exists</li> -	 * 								<li>ax  - Open for append, the file must not exists</li> -	 * 							</ul> -	 * 							The following flags can also be added to the above modes:<br/> -	 * 							<ul><li>+   - Open for both read and write</li> -	 * 								<li>b   - Open as a binary file rather than a text file</li> -	 * 							</ul> -	 * @note					Not all file-systems support all modes. For example, write -	 * 							is not available with the ROM file-system. Similarly few platforms -	 * 							distinguish between binary and text files. -	 * @note					Even though binary vs. text is relevant only for a small number of platforms -	 * 							the "b" flag should always be specified for binary files such as images. -	 * 							This ensures portability to other platforms. The extra flag will be ignored -	 * 							on platforms where it is not relevant. -	 * -	 * @api -	 */	 -	GFILE *		gfileOpen(const char *fname, const char *mode); +/** + * @brief					Close file + * @details					Closes a file after is has been opened using @p gfileOpen() + * + * @param[in] f				The file + * + * @api + */ +void		gfileClose(GFILE *f); -	/** -	 * @brief					Close file -	 * @details					Closes a file after is has been opened using @p gfileOpen() -	 * -	 * @param[in] f				The file -	 * -	 * @api -	 */ -	void		gfileClose(GFILE *f); +/** + * @brief					Read from file + * @details					Reads a given amount of bytes from the file + * @details					The read/write cursor will not be reset when calling this function + * + * @param[in] f				The file + * @param[out] buf			The buffer in which to save the content that has been read from the file + * @param[in] len			Amount of bytes to read + * + * @return					Amount of bytes read + * + * @api + */ +size_t		gfileRead(GFILE *f, void *buf, size_t len); -	/** -	 * @brief					Read from file -	 * @details					Reads a given amount of bytes from the file -	 * @details					The read/write cursor will not be reset when calling this function -	 * -	 * @param[in] f				The file -	 * @param[out] buf			The buffer in which to save the content that has been read from the file -	 * @param[in] len			Amount of bytes to read -	 * -	 * @return					Amount of bytes read -	 * -	 * @api -	 */ -	size_t		gfileRead(GFILE *f, void *buf, size_t len); +/** + * @brief					Write to file + * @details					Write a given amount of bytes to the file + * @details					The read/write cursor will not be reset when calling this function + * + * @param[in] f				The file + * @param[in] buf			The buffer which contains the content that will be written to the file + * @param[in] len			Amount of bytes to write + * + * @return					Amount of bytes written + * + * @api + */ +size_t		gfileWrite(GFILE *f, const void *buf, size_t len); -	/** -	 * @brief					Write to file -	 * @details					Write a given amount of bytes to the file -	 * @details					The read/write cursor will not be reset when calling this function -	 * -	 * @param[in] f				The file -	 * @param[in] buf			The buffer which contains the content that will be written to the file -	 * @param[in] len			Amount of bytes to write -	 * -	 * @return					Amount of bytes written -	 * -	 * @api -	 */ -	size_t		gfileWrite(GFILE *f, const void *buf, size_t len); +/** + * @brief					Get the current position of the read/write cursor + * + * @param[in] f				The file + * + * @return					The current position in the file + * + * @api + */ +long int	gfileGetPos(GFILE *f); -	/** -	 * @brief					Get the current position of the read/write cursor -	 * -	 * @param[in] f				The file -	 * -	 * @return					The current position in the file -	 * -	 * @api -	 */ -	long int	gfileGetPos(GFILE *f); +/** + * @brief					Set the position of the read/write cursor + * + * @param[in] f				The file + * @param[in] pos			The position to which the cursor will be set + * + * @return					gTrue on success, gFalse otherwise + * + * @api + */ +gBool		gfileSetPos(GFILE *f, long int pos); + +/** + * @brief					Get the size of file + * @note					Please use @p gfileGetFilesize() if the file is not opened + * + * @param[in] f				The file + * + * @return					The size of the file + * + * @api + */ +long int	gfileGetSize(GFILE *f); + +/** + * @brief					Check for EOF + * @details					Checks if the cursor is at the end of the file + * + * @param[in] f				The file + * + * @return					gTrue if EOF, gFalse otherwise + * + * @api + */ +gBool		gfileEOF(GFILE *f); +/** + * @brief					Mount a logical drive (aka partition) + * + * @details					Not supported by every file system + * @details					Currently just one drive at one is supported. + * + * @param[in] fs			The file system (F for FatFS) + * @param[in] drive			The logical drive prefix + * + * @return					gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileMount(char fs, const char *drive); + +/** + * @brief					Unmount a logical drive (aka partition) + * + * @details					Does have no effect if @p gfileMount() as been called before hand + * + * @param[in] fs			The file system (F for FatFS) + * @param[in] drive			The logical drive prefix + * + * @return					gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileUnmount(char fs, const char *drive); + +/** + * @brief					Syncs the file object (flushes the buffer) + * + * @details					Not supported by every file system + * + * @param[in] f				The file + * + * @return					gTrue on success, gFalse otherwise + * + * @api + */ +gBool gfileSync(GFILE *f); + +#if GFILE_NEED_FILELISTS || defined(__DOXYGEN__)  	/** -	 * @brief					Set the position of the read/write cursor +	 * @brief				Open a file list  	 * -	 * @param[in] f				The file -	 * @param[in] pos			The position to which the cursor will be set +	 * @param[in] fs		The file system (F for FatFS) +	 * @param[in] path		Path information to pass to the file system +	 * @param[in] dirs		Pass gTrue to get directories only, gFalse to get files only  	 * -	 * @return					TRUE on success, FALSE otherwise +	 * @return				A pointer to a file list on success, NULL otherwise +	 * +	 * @note				The path parameter is handled in a file-system specific way. It could be +	 * 						treated as a directory name, it may be treated as a file pattern, or it +	 * 						may be ignored. Passing NULL will always return the full list of files +	 * 						in at least the top level directory. +	 * @note				For file systems that do not support directories, passing gTrue for dirs +	 * 						will return an error. +	 * @note				You must call @p gfileCloseFileList() when you have finished with the +	 * 						file list in order to free resources.  	 *  	 * @api  	 */ -	bool_t		gfileSetPos(GFILE *f, long int pos); +	gfileList *gfileOpenFileList(char fs, const char *path, gBool dirs);  	/** -	 * @brief					Get the size of file -	 * @note					Please use @p gfileGetFilesize() if the file is not opened +	 * @brief				Get the next file in a file list. +	 * +	 * @param[in] pfl		Pointer to a file list returned by @p gfileOpenFileList()  	 * -	 * @param[in] f				The file +	 * @return				A pointer to a file (or directory) name. Returns NULL if there are no more.  	 * -	 * @return					The size of the file +	 * @note				The file name may contain the full directory path or may not depending +	 * 						on how the file system treats directories. +	 * @note				The returned buffer may be destroyed by the next call to any of +	 * 						@p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). +	 * 						Do not use this pointer after one of those calls.  	 *  	 * @api  	 */ -	long int	gfileGetSize(GFILE *f); +	const char *gfileReadFileList(gfileList *pfl);  	/** -	 * @brief					Check for EOF -	 * @details					Checks if the cursor is at the end of the file +	 * @brief				Close a file list.  	 * -	 * @param[in] f				The file -	 * -	 * @return					TRUE if EOF, FALSE otherwise +	 * @param[in] pfl		Pointer to a file list returned by @p gfileOpenFileList()  	 *  	 * @api  	 */ -	bool_t		gfileEOF(GFILE *f); +	void gfileCloseFileList(gfileList *pfl); +#endif +#if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__)  	/** -	 * @brief					Mount a logical drive (aka partition) +	 * @brief					Open file from a ChibiOS FileStream  	 * -	 * @details					Not supported by every file system -	 * @details					Currently just one drive at one is supported. +	 * @param[in] FileStreamPtr	The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE +	 * @param[in] mode			The mode.  	 * -	 * @param[in] fs			The file system (F for FatFS) -	 * @param[in] drive			The logical drive prefix +	 * @return					Valid GFILE on success, 0 otherwise  	 * -	 * @return					TRUE on success, FALSE otherwise +	 * @note					The modes are the same modes as in @p gfileOpen(). The +	 * 							open mode is NOT compared against the FileStream capabilities. +	 * @note					Supported operations are: read, write, getpos, setpos, eof and getsize  	 *  	 * @api  	 */ -	bool_t gfileMount(char fs, const char *drive); +	GFILE *		gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode); +	#define gfileOpenBaseFileStream(f,m)	gfileOpenChibiOSFileStream(f,m) +#endif +#if GFILE_NEED_MEMFS || defined(__DOXYGEN__)  	/** -	 * @brief					Unmount a logical drive (aka partition) +	 * @brief					Open file from a memory pointer  	 * -	 * @details					Does have no effect if @p gfileMount() as been called before hand +	 * @param[in] memptr		The pointer to the memory +	 * @param[in] mode			The mode.  	 * -	 * @param[in] fs			The file system (F for FatFS) -	 * @param[in] drive			The logical drive prefix +	 * @return					Valid GFILE on success, 0 otherwise  	 * -	 * @return					TRUE on success, FALSE otherwise +	 * @note					The modes are the same modes as in @p gfileOpen(). Note there is +	 * 							no concept of file-size. Be careful not to overwrite other memory or +	 * 							to read from inaccessible sections of memory. +	 * @note					Supported operations are: read, write, getpos, setpos  	 *  	 * @api  	 */ -	bool_t gfileUnmount(char fs, const char *drive); +	GFILE *		gfileOpenMemory(void *memptr, const char *mode); +#endif +#if GFILE_NEED_STRINGS || defined(__DOXYGEN__)  	/** -	 * @brief					Syncs the file object (flushes the buffer) +	 * @brief					Open file from a null terminated C string  	 * -	 * @details					Not supported by every file system +	 * @param[in] str			The pointer to the string or string buffer +	 * @param[in] mode			The mode  	 * -	 * @param[in] f				The file +	 * @return					Valid GFILE on success, 0 otherwise  	 * -	 * @return					TRUE on success, FALSE otherwise +	 * @note					The modes are the same modes as in @p gfileOpen(). Note there is +	 * 							no concept of file-size. Be careful not to overwrite other memory or +	 * 							to read from inaccessible sections of memory. +	 * @note					Reading will return EOF when the NULL character is reached. +	 * @note					Writing will always place a NULL in the next character effectively terminating the +	 * 							string at the character just written. +	 * @note					Supported operations are: read, write, append, getpos, setpos +	 * @note					Be careful with setpos and getpos. They do not check for the end of the string. +	 * @note					Reading and Writing will read/write a maximum of one character at a time.  	 *  	 * @api  	 */ -	bool_t gfileSync(GFILE *f); - -	#if GFILE_NEED_FILELISTS || defined(__DOXYGEN__) -		/** -		 * @brief				Open a file list -		 * -		 * @param[in] fs		The file system (F for FatFS) -		 * @param[in] path		Path information to pass to the file system -		 * @param[in] dirs		Pass TRUE to get directories only, FALSE to get files only -		 * -		 * @return				A pointer to a file list on success, NULL otherwise -		 * -		 * @note				The path parameter is handled in a file-system specific way. It could be -		 * 						treated as a directory name, it may be treated as a file pattern, or it -		 * 						may be ignored. Passing NULL will always return the full list of files -		 * 						in at least the top level directory. -		 * @note				For file systems that do not support directories, passing TRUE for dirs -		 * 						will return an error. -		 * @note				You must call @p gfileCloseFileList() when you have finished with the -		 * 						file list in order to free resources. -		 * -		 * @api -		 */ -		gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs); - -		/** -		 * @brief				Get the next file in a file list. -		 * -		 * @param[in] pfl		Pointer to a file list returned by @p gfileOpenFileList() -		 * -		 * @return				A pointer to a file (or directory) name. Returns NULL if there are no more. -		 * -		 * @note				The file name may contain the full directory path or may not depending -		 * 						on how the file system treats directories. -		 * @note				The returned buffer may be destroyed by the next call to any of -		 * 						@p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). -		 * 						Do not use this pointer after one of those calls. -		 * -		 * @api -		 */ -		const char *gfileReadFileList(gfileList *pfl); - -		/** -		 * @brief				Close a file list. -		 * -		 * @param[in] pfl		Pointer to a file list returned by @p gfileOpenFileList() -		 * -		 * @api -		 */ -		void gfileCloseFileList(gfileList *pfl); -	#endif - -	#if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__) -		/** -		 * @brief					Open file from a ChibiOS FileStream -		 * -		 * @param[in] FileStreamPtr	The BaseFileStream (ChibiOS V2) or FileStream (ChibiOS V3) to open as a GFILE -		 * @param[in] mode			The mode. -		 * -		 * @return					Valid GFILE on success, 0 otherwise -		 * -		 * @note					The modes are the same modes as in @p gfileOpen(). The -		 * 							open mode is NOT compared against the FileStream capabilities. -		 * @note					Supported operations are: read, write, getpos, setpos, eof and getsize -		 * -		 * @api -		 */ -		GFILE *		gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode); -		#define gfileOpenBaseFileStream(f,m)	gfileOpenChibiOSFileStream(f,m) -	#endif - -	#if GFILE_NEED_MEMFS || defined(__DOXYGEN__) -		/** -		 * @brief					Open file from a memory pointer -		 * -		 * @param[in] memptr		The pointer to the memory -		 * @param[in] mode			The mode. -		 * -		 * @return					Valid GFILE on success, 0 otherwise -		 * -		 * @note					The modes are the same modes as in @p gfileOpen(). Note there is -		 * 							no concept of file-size. Be careful not to overwrite other memory or -		 * 							to read from inaccessible sections of memory. -		 * @note					Supported operations are: read, write, getpos, setpos -		 * -		 * @api -		 */ -		GFILE *		gfileOpenMemory(void *memptr, const char *mode); -	#endif - -	#if GFILE_NEED_STRINGS || defined(__DOXYGEN__) -		/** -		 * @brief					Open file from a null terminated C string -		 * -		 * @param[in] str			The pointer to the string or string buffer -		 * @param[in] mode			The mode -		 * -		 * @return					Valid GFILE on success, 0 otherwise -		 * -		 * @note					The modes are the same modes as in @p gfileOpen(). Note there is -		 * 							no concept of file-size. Be careful not to overwrite other memory or -		 * 							to read from inaccessible sections of memory. -		 * @note					Reading will return EOF when the NULL character is reached. -		 * @note					Writing will always place a NULL in the next character effectively terminating the -		 * 							string at the character just written. -		 * @note					Supported operations are: read, write, append, getpos, setpos -		 * @note					Be careful with setpos and getpos. They do not check for the end of the string. -		 * @note					Reading and Writing will read/write a maximum of one character at a time. -		 * -		 * @api -		 */ -		GFILE *		gfileOpenString(char *str, const char *mode); -	#endif +	GFILE *		gfileOpenString(char *str, const char *mode); +#endif -	#if GFILE_NEED_PRINTG || defined(__DOXYGEN__) -		#include <stdarg.h> - -		int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); -		int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); -		#define vfprintg(f,m,a)			vfnprintg(f,0,m,a) -		#define fprintg(f,m,...)		fnprintg(f,0,m,__VA_ARGS__) -		#define vprintg(m,a)			vfnprintg(gfileStdOut,0,m,a) -		#define printg(m,...)			fnprintg(gfileStdOut,0,m,__VA_ARGS__) - -		#if GFILE_NEED_STRINGS -			int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); -			int snprintg(char *buf, int maxlen, const char *fmt, ...); -			#define vsprintg(s,m,a)		vsnprintg(s,0,m,a) -			#define sprintg(s,m,...)	snprintg(s,0,m,__VA_ARGS__) -		#endif +#if GFILE_NEED_PRINTG || defined(__DOXYGEN__) +	#include <stdarg.h> + +	int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); +	int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); +	#define vfprintg(f,m,a)			vfnprintg(f,0,m,a) +	#define fprintg(f,m,...)		fnprintg(f,0,m,__VA_ARGS__) +	#define vprintg(m,a)			vfnprintg(gfileStdOut,0,m,a) +	#define printg(m,...)			fnprintg(gfileStdOut,0,m,__VA_ARGS__) + +	#if GFILE_NEED_STRINGS +		int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); +		int snprintg(char *buf, int maxlen, const char *fmt, ...); +		#define vsprintg(s,m,a)		vsnprintg(s,0,m,a) +		#define sprintg(s,m,...)	snprintg(s,0,m,__VA_ARGS__)  	#endif +#endif -	#if GFILE_NEED_SCANG || defined(__DOXYGEN__) -		#include <stdarg.h> - -		int vfscang(GFILE *f, const char *fmt, va_list arg); -		int fscang(GFILE *f, const char *fmt, ...); -		#define vscang(f,a)			vfscang(gfileStdIn,f,a) -		#define scang(f,...)		fscang(gfileStdIn,f,__VA_ARGS__) +#if GFILE_NEED_SCANG || defined(__DOXYGEN__) +	#include <stdarg.h> -		#if GFILE_NEED_STRINGS -			int vsscang(const char *buf, const char *fmt, va_list arg); -			int sscang(const char *buf, const char *fmt, ...); -		#endif -	#endif +	int vfscang(GFILE *f, const char *fmt, va_list arg); +	int fscang(GFILE *f, const char *fmt, ...); +	#define vscang(f,a)			vfscang(gfileStdIn,f,a) +	#define scang(f,...)		fscang(gfileStdIn,f,__VA_ARGS__) -	#if GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) -		// Needed routines and definitions -		size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f); -		size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f); -		int gstdioGetpos(GFILE *f, long int *pos); -		int gstdioSeek(GFILE *f, size_t offset, int origin); -		#define SEEK_SET	0 -		#define SEEK_CUR	1 -		#define SEEK_END	2 - -		// Stdio emulation -		#define stdin					gfileStdIn -		#define stdout					gfileStdOut -		#define stderr					gfileStdErr -		#define FOPEN_MAX				GFILE_MAX_GFILES -		#define TMP_MAX					GFILE_MAX_GFILES -		#define FILENAME_MAX			256						// Use a relatively small number for an embedded platform -		#define L_tmpnam				FILENAME_MAX -		#define P_tmpdir				"/tmp/" -		#define FILE					GFILE -		#define fopen(n,m)				gfileOpen(n,m) -		#define fclose(f)				gfileClose(f) -		#define fread(p,sz,cnt,f)		gstdioRead(p,sz,cnt,f) -		#define fwrite(p,sz,cnt,f)		gstdioWrite(p,sz,cnt,f) -		#define fseek(f,ofs,org)		gstdioSeek(f,ofs,org) -		#define remove(n)				(!gfileDelete(n)) -		#define rename(o,n)				(!gfileRename(o,n)) -		#define fflush(f)				(0) -		#define ftell(f)				gfileGetPos(f) -		#define fpos_t					long int -		#define fgetpos(f,pos)			gstdioGetpos(f,pos) -		#define fsetpos(f, pos)			(!gfileSetPos(f, *pos)) -		#define rewind(f)				gfileSetPos(f, 0); -		#define feof(f)					gfileEOF(f) -		#define vfprintf(f,m,a)			vfnprintg(f,0,m,a) -		#define fprintf(f,m,...)		fnprintg(f,0,m,__VA_ARGS__) -		#define vprintf(m,a)			vfnprintg(gfileStdOut,0,m,a) -		#define printf(m,...)			fnprintg(gfileStdOut,0,m,__VA_ARGS__) -		#define vsnprintf(s,n,m,a)		vsnprintg(s,n,m,a) -		#define snprintf(s,n,m,...)		snprintg(s,n,m,__VA_ARGS__) -		#define vsprintf(s,m,a)			vsnprintg(s,0,m,a) -		#define sprintf(s,m,...)		snprintg(s,0,m,__VA_ARGS__) - -		//TODO -		//void clearerr ( FILE * stream ); -		//int ferror ( FILE * stream ); -		//FILE * tmpfile ( void );		// Auto-deleting -		//char * tmpnam ( char * str ); -		//char * mktemp (char *template); -		//FILE * freopen ( const char * filename, const char * mode, FILE * stream ); -		//setbuf -		//setvbuf -		//fflush -		//fgetc -		//fgets -		//fputc -		//fputs -		//getc -		//getchar -		//puts -		//ungetc -		//void perror (const char * str); +	#if GFILE_NEED_STRINGS +		int vsscang(const char *buf, const char *fmt, va_list arg); +		int sscang(const char *buf, const char *fmt, ...);  	#endif +#endif -#ifdef __cplusplus -} +#if GFILE_NEED_STDIO && !defined(GFILE_NEED_STDIO_MUST_BE_OFF) +	// Needed routines and definitions +	size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f); +	size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f); +	int gstdioGetpos(GFILE *f, long int *pos); +	int gstdioSeek(GFILE *f, size_t offset, int origin); +	#define SEEK_SET	0 +	#define SEEK_CUR	1 +	#define SEEK_END	2 + +	// Stdio emulation +	#define stdin					gfileStdIn +	#define stdout					gfileStdOut +	#define stderr					gfileStdErr +	#define FOPEN_MAX				GFILE_MAX_GFILES +	#define TMP_MAX					GFILE_MAX_GFILES +	#define FILENAME_MAX			256						// Use a relatively small number for an embedded platform +	#define L_tmpnam				FILENAME_MAX +	#define P_tmpdir				"/tmp/" +	#define FILE					GFILE +	#define fopen(n,m)				gfileOpen(n,m) +	#define fclose(f)				gfileClose(f) +	#define fread(p,sz,cnt,f)		gstdioRead(p,sz,cnt,f) +	#define fwrite(p,sz,cnt,f)		gstdioWrite(p,sz,cnt,f) +	#define fseek(f,ofs,org)		gstdioSeek(f,ofs,org) +	#define remove(n)				(!gfileDelete(n)) +	#define rename(o,n)				(!gfileRename(o,n)) +	#define fflush(f)				(0) +	#define ftell(f)				gfileGetPos(f) +	#define fpos_t					long int +	#define fgetpos(f,pos)			gstdioGetpos(f,pos) +	#define fsetpos(f, pos)			(!gfileSetPos(f, *pos)) +	#define rewind(f)				gfileSetPos(f, 0); +	#define feof(f)					gfileEOF(f) +	#define vfprintf(f,m,a)			vfnprintg(f,0,m,a) +	#define fprintf(f,m,...)		fnprintg(f,0,m,__VA_ARGS__) +	#define vprintf(m,a)			vfnprintg(gfileStdOut,0,m,a) +	#define printf(m,...)			fnprintg(gfileStdOut,0,m,__VA_ARGS__) +	#define vsnprintf(s,n,m,a)		vsnprintg(s,n,m,a) +	#define snprintf(s,n,m,...)		snprintg(s,n,m,__VA_ARGS__) +	#define vsprintf(s,m,a)			vsnprintg(s,0,m,a) +	#define sprintf(s,m,...)		snprintg(s,0,m,__VA_ARGS__) + +	//TODO +	//void clearerr ( FILE * stream ); +	//int ferror ( FILE * stream ); +	//FILE * tmpfile ( void );		// Auto-deleting +	//char * tmpnam ( char * str ); +	//char * mktemp (char *template); +	//FILE * freopen ( const char * filename, const char * mode, FILE * stream ); +	//setbuf +	//setvbuf +	//fflush +	//fgetc +	//fgets +	//fputc +	//fputs +	//getc +	//getchar +	//puts +	//ungetc +	//void perror (const char * str);  #endif  #endif /* GFX_USE_GFILE */ diff --git a/src/gfile/gfile_fatfs_wrapper.c b/src/gfile/gfile_fatfs_wrapper.c index 0156c42b..7f3a3e39 100644 --- a/src/gfile/gfile_fatfs_wrapper.c +++ b/src/gfile/gfile_fatfs_wrapper.c @@ -49,8 +49,8 @@  	int ff_req_grant(_SYNC_t sobj)  	{  		if (gfxSemWait( (gfxSem*)&sobj, (delaytime_t)_FS_TIMEOUT) ) -			return TRUE; -		return FALSE; +			return gTrue; +		return gFalse;  	}  	/*------------------------------------------------------------------------*/ diff --git a/src/gfile/gfile_fs.h b/src/gfile/gfile_fs.h index c2337283..5b1f4fdc 100644 --- a/src/gfile/gfile_fs.h +++ b/src/gfile/gfile_fs.h @@ -34,7 +34,7 @@ struct GFILE {  struct gfileList {  	const struct GFILEVMT *	vmt; -	bool_t					dirs; +	gBool					dirs;  };  typedef struct GFILEVMT { @@ -46,22 +46,22 @@ typedef struct GFILEVMT {  		#define GFSFLG_SMALL			0x0020  		#define GFSFLG_TEXTMODES		0x0040  	char					prefix; -	bool_t		(*del)		(const char *fname); -	bool_t		(*exists)	(const char *fname); +	gBool		(*del)		(const char *fname); +	gBool		(*exists)	(const char *fname);  	long int	(*filesize)	(const char *fname); -	bool_t		(*ren)		(const char *oldname, const char *newname); -	bool_t		(*open)		(GFILE *f, const char *fname); +	gBool		(*ren)		(const char *oldname, const char *newname); +	gBool		(*open)		(GFILE *f, const char *fname);  	void		(*close)	(GFILE *f);  	int			(*read)		(GFILE *f, void *buf, int size);  	int			(*write)	(GFILE *f, const void *buf, int size); -	bool_t		(*setpos)	(GFILE *f, long int pos); +	gBool		(*setpos)	(GFILE *f, long int pos);  	long int	(*getsize)	(GFILE *f); -	bool_t		(*eof)		(GFILE *f); -	bool_t		(*mount)	(const char *drive); -	bool_t		(*unmount)	(const char *drive); -	bool_t		(*sync)		(GFILE *f); +	gBool		(*eof)		(GFILE *f); +	gBool		(*mount)	(const char *drive); +	gBool		(*unmount)	(const char *drive); +	gBool		(*sync)		(GFILE *f);  	#if GFILE_NEED_FILELISTS -		gfileList *	(*flopen)	(const char *path, bool_t dirs); +		gfileList *	(*flopen)	(const char *path, gBool dirs);  		const char *(*flread)	(gfileList *pfl);  		void		(*flclose)	(gfileList *pfl);  	#endif diff --git a/src/gfile/gfile_fs_chibios.c b/src/gfile/gfile_fs_chibios.c index 78681a90..35b4061c 100644 --- a/src/gfile/gfile_fs_chibios.c +++ b/src/gfile/gfile_fs_chibios.c @@ -18,9 +18,9 @@  static void ChibiOSBFSClose(GFILE *f);  static int ChibiOSBFSRead(GFILE *f, void *buf, int size);  static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size); -static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos); +static gBool ChibiOSBFSSetpos(GFILE *f, long int pos);  static long int ChibiOSBFSGetsize(GFILE *f); -static bool_t ChibiOSBFSEof(GFILE *f); +static gBool ChibiOSBFSEof(GFILE *f);  static const GFILEVMT FsCHIBIOSVMT = {  	GFSFLG_SEEKABLE|GFSFLG_WRITEABLE,					// flags @@ -52,12 +52,12 @@ static int ChibiOSBFSRead(GFILE *f, void *buf, int size) {  static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) {  	return fileStreamWrite(((FileStream *)f->obj), (uint8_t *)buf, size);  } -static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) { +static gBool ChibiOSBFSSetpos(GFILE *f, long int pos) {  	fileStreamSeek(((FileStream *)f->obj), pos); -	return TRUE; +	return gTrue;  }  static long int ChibiOSBFSGetsize(GFILE *f) { return fileStreamGetSize(((FileStream *)f->obj)); } -static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); } +static gBool ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); }  GFILE *		gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode) {  	GFILE *			f; diff --git a/src/gfile/gfile_fs_fatfs.c b/src/gfile/gfile_fs_fatfs.c index 7f67cd76..03c8d2e9 100644 --- a/src/gfile/gfile_fs_fatfs.c +++ b/src/gfile/gfile_fs_fatfs.c @@ -20,22 +20,22 @@   * The FAT file-system VMT   ********************************************************/ -static bool_t fatfsDel(const char* fname); -static bool_t fatfsExists(const char* fname); +static gBool fatfsDel(const char* fname); +static gBool fatfsExists(const char* fname);  static long int fatfsFileSize(const char* fname); -static bool_t fatfsRename(const char* oldname, const char* newname); -static bool_t fatfsOpen(GFILE* f, const char* fname); +static gBool fatfsRename(const char* oldname, const char* newname); +static gBool fatfsOpen(GFILE* f, const char* fname);  static void fatfsClose(GFILE* f);  static int fatfsRead(GFILE* f, void* buf, int size);  static int fatfsWrite(GFILE* f, const void* buf, int size); -static bool_t fatfsSetPos(GFILE* f, long int pos); +static gBool fatfsSetPos(GFILE* f, long int pos);  static long int fatfsGetSize(GFILE* f); -static bool_t fatfsEOF(GFILE* f); -static bool_t fatfsMount(const char* drive); -static bool_t fatfsUnmount(const char* drive); -static bool_t fatfsSync(GFILE* f); +static gBool fatfsEOF(GFILE* f); +static gBool fatfsMount(const char* drive); +static gBool fatfsUnmount(const char* drive); +static gBool fatfsSync(GFILE* f);  #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 -	static gfileList *fatfsFlOpen(const char *path, bool_t dirs); +	static gfileList *fatfsFlOpen(const char *path, gBool dirs);  	static const char *fatfsFlRead(gfileList *pfl);  	static void fatfsFlClose(gfileList *pfl);  #endif @@ -75,7 +75,7 @@ typedef struct fatfsList {  } fatfsList;  // optimize these later on. Use an array to have multiple FatFS -static bool_t fatfs_mounted = FALSE; +static gBool fatfs_mounted = gFalse;  static FATFS fatfs_fs;  static BYTE fatfs_flags2mode(GFILE* f) @@ -95,27 +95,27 @@ static BYTE fatfs_flags2mode(GFILE* f)  	return mode;  } -static bool_t fatfsDel(const char* fname) +static gBool fatfsDel(const char* fname)  {  	FRESULT ferr;  	ferr = f_unlink( (const TCHAR*)fname );  	if (ferr != FR_OK) -		return FALSE; +		return gFalse; -	return TRUE; +	return gTrue;  } -static bool_t fatfsExists(const char* fname) +static gBool fatfsExists(const char* fname)  {  	FRESULT ferr;  	FILINFO fno;  	ferr = f_stat( (const TCHAR*)fname, &fno);  	if (ferr != FR_OK) -		return FALSE; +		return gFalse; -	return TRUE; +	return gTrue;  }  static long int fatfsFileSize(const char* fname) @@ -130,34 +130,34 @@ static long int fatfsFileSize(const char* fname)  	return (long int)fno.fsize;  } -static bool_t fatfsRename(const char* oldname, const char* newname) +static gBool fatfsRename(const char* oldname, const char* newname)  {  	FRESULT ferr;  	ferr = f_rename( (const TCHAR*)oldname, (const TCHAR*)newname );  	if (ferr != FR_OK) -		return FALSE; +		return gFalse; -	return TRUE; +	return gTrue;  } -static bool_t fatfsOpen(GFILE* f, const char* fname) +static gBool fatfsOpen(GFILE* f, const char* fname)  {  	FIL* fd;  	#if !GFILE_NEED_NOAUTOMOUNT  		if (!fatfs_mounted && !fatfsMount("")) -			return FALSE; +			return gFalse;  	#endif  	if (!(fd = gfxAlloc(sizeof(FIL)))) -		return FALSE; +		return gFalse;  	if (f_open(fd, fname, fatfs_flags2mode(f)) != FR_OK) {  		gfxFree(fd);  		f->obj = 0; -		return FALSE; +		return gFalse;  	}  	f->obj = (void*)fd; @@ -169,7 +169,7 @@ static bool_t fatfsOpen(GFILE* f, const char* fname)  		}  	#endif -	return TRUE;	 +	return gTrue;	  }  static void fatfsClose(GFILE* f) @@ -201,15 +201,15 @@ static int fatfsWrite(GFILE* f, const void* buf, int size)  	return wr;  } -static bool_t fatfsSetPos(GFILE* f, long int pos) +static gBool fatfsSetPos(GFILE* f, long int pos)  {  	FRESULT ferr;  	ferr = f_lseek( (FIL*)f->obj, (DWORD)pos );  	if (ferr != FR_OK) -		return FALSE; +		return gFalse; -	return TRUE; +	return gTrue;  }  static long int fatfsGetSize(GFILE* f) @@ -217,56 +217,56 @@ static long int fatfsGetSize(GFILE* f)  	return (long int)f_size( (FIL*)f->obj );  } -static bool_t fatfsEOF(GFILE* f) +static gBool fatfsEOF(GFILE* f)  {  	if ( f_eof( (FIL*)f->obj ) != 0) -		return TRUE; +		return gTrue;  	else -		return FALSE; +		return gFalse;  } -static bool_t fatfsMount(const char* drive) +static gBool fatfsMount(const char* drive)  {  	FRESULT ferr;  	if (!fatfs_mounted) {  		ferr = f_mount(&fatfs_fs, drive, 1);  		if (ferr !=  FR_OK) -			return FALSE; -		fatfs_mounted = TRUE; -		return TRUE; +			return gFalse; +		fatfs_mounted = gTrue; +		return gTrue;  	} -	return FALSE; +	return gFalse;  } -static bool_t fatfsUnmount(const char* drive) +static gBool fatfsUnmount(const char* drive)  {  	(void)drive;  	if (fatfs_mounted) {  		// FatFS does not provide an unmount routine. -		fatfs_mounted = FALSE; -		return TRUE; +		fatfs_mounted = gFalse; +		return gTrue;  	} -	return FALSE; +	return gFalse;  } -static bool_t fatfsSync(GFILE *f) +static gBool fatfsSync(GFILE *f)  {  	FRESULT ferr;  	ferr = f_sync( (FIL*)f->obj );  	if (ferr != FR_OK) { -		return FALSE; +		return gFalse;  	} -	return TRUE; +	return gTrue;  }  #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 -	static gfileList *fatfsFlOpen(const char *path, bool_t dirs) { +	static gfileList *fatfsFlOpen(const char *path, gBool dirs) {  		fatfsList	*p;  		(void) dirs; diff --git a/src/gfile/gfile_fs_mem.c b/src/gfile/gfile_fs_mem.c index 4aad43fe..1f6fd050 100644 --- a/src/gfile/gfile_fs_mem.c +++ b/src/gfile/gfile_fs_mem.c @@ -19,7 +19,7 @@  static int MEMRead(GFILE *f, void *buf, int size);  static int MEMWrite(GFILE *f, const void *buf, int size); -static bool_t MEMSetpos(GFILE *f, long int pos); +static gBool MEMSetpos(GFILE *f, long int pos);  static const GFILEVMT FsMemVMT = {  	GFSFLG_SEEKABLE|GFSFLG_WRITEABLE,					// flags @@ -41,10 +41,10 @@ static int MEMWrite(GFILE *f, const void *buf, int size) {  	memcpy(((char *)f->obj)+f->pos, buf, size);  	return size;  } -static bool_t MEMSetpos(GFILE *f, long int pos) { +static gBool MEMSetpos(GFILE *f, long int pos) {  	(void) f;  	(void) pos; -	return TRUE; +	return gTrue;  }  GFILE *	gfileOpenMemory(void *memptr, const char *mode) { diff --git a/src/gfile/gfile_fs_native.c b/src/gfile/gfile_fs_native.c index d1e2a1fc..a9bc5065 100644 --- a/src/gfile/gfile_fs_native.c +++ b/src/gfile/gfile_fs_native.c @@ -22,19 +22,19 @@  #include <sys/types.h>  #include <sys/stat.h> -static bool_t NativeDel(const char *fname); -static bool_t NativeExists(const char *fname); +static gBool NativeDel(const char *fname); +static gBool NativeExists(const char *fname);  static long int	NativeFilesize(const char *fname); -static bool_t NativeRen(const char *oldname, const char *newname); -static bool_t NativeOpen(GFILE *f, const char *fname); +static gBool NativeRen(const char *oldname, const char *newname); +static gBool NativeOpen(GFILE *f, const char *fname);  static void NativeClose(GFILE *f);  static int NativeRead(GFILE *f, void *buf, int size);  static int NativeWrite(GFILE *f, const void *buf, int size); -static bool_t NativeSetpos(GFILE *f, long int pos); +static gBool NativeSetpos(GFILE *f, long int pos);  static long int NativeGetsize(GFILE *f); -static bool_t NativeEof(GFILE *f); +static gBool NativeEof(GFILE *f);  #if GFILE_NEED_FILELISTS -	static gfileList *NativeFlOpen(const char *path, bool_t dirs); +	static gfileList *NativeFlOpen(const char *path, gBool dirs);  	static const char *NativeFlRead(gfileList *pfl);  	static void NativeFlClose(gfileList *pfl);  #endif @@ -95,33 +95,33 @@ static void Native_flags2mode(char *buf, uint16_t flags) {  	*buf++ = 0;  } -static bool_t NativeDel(const char *fname)							{ return remove(fname) ? FALSE : TRUE; } +static gBool NativeDel(const char *fname)							{ return remove(fname) ? gFalse : gTrue; }  static void NativeClose(GFILE *f)									{ fclose((FILE *)f->obj); }  static int NativeRead(GFILE *f, void *buf, int size)				{ return fread(buf, 1, size, (FILE *)f->obj); }  static int NativeWrite(GFILE *f, const void *buf, int size)			{ return fwrite(buf, 1, size, (FILE *)f->obj); } -static bool_t NativeSetpos(GFILE *f, long int pos)					{ return fseek((FILE *)f->obj, pos, SEEK_SET) ?  FALSE : TRUE; } -static bool_t NativeEof(GFILE *f)									{ return feof((FILE *)f->obj) ? TRUE : FALSE; } -static bool_t NativeRen(const char *oldname, const char *newname)	{ return rename(oldname, newname) ? FALSE : TRUE; } -static bool_t NativeExists(const char *fname) { +static gBool NativeSetpos(GFILE *f, long int pos)					{ return fseek((FILE *)f->obj, pos, SEEK_SET) ?  gFalse : gTrue; } +static gBool NativeEof(GFILE *f)									{ return feof((FILE *)f->obj) ? gTrue : gFalse; } +static gBool NativeRen(const char *oldname, const char *newname)	{ return rename(oldname, newname) ? gFalse : gTrue; } +static gBool NativeExists(const char *fname) {  	// We define access this way so we don't have to include <unistd.h> which may  	//	(and does under windows) contain conflicting definitions for types such as uint16_t.  	extern int access(const char *pathname, int mode); -	return access(fname, 0) ? FALSE : TRUE; +	return access(fname, 0) ? gFalse : gTrue;  }  static long int	NativeFilesize(const char *fname) {  	struct stat st;  	if (stat(fname, &st)) return -1;  	return st.st_size;  } -static bool_t NativeOpen(GFILE *f, const char *fname) { +static gBool NativeOpen(GFILE *f, const char *fname) {  	FILE *fd;  	char mode[5];  	Native_flags2mode(mode, f->flags);  	if (!(fd = fopen(fname, mode))) -		return FALSE; +		return gFalse;  	f->obj = (void *)fd; -	return TRUE; +	return gTrue;  }  static long int NativeGetsize(GFILE *f) {  	struct stat st; @@ -135,10 +135,10 @@ static long int NativeGetsize(GFILE *f) {  			gfileList			fl;  			HANDLE				d;  			WIN32_FIND_DATA		f; -			bool_t				first; +			gBool				first;  		} NativeFileList; -		static gfileList *NativeFlOpen(const char *path, bool_t dirs) { +		static gfileList *NativeFlOpen(const char *path, gBool dirs) {  			NativeFileList		*p;  			(void)				dirs; @@ -148,7 +148,7 @@ static long int NativeGetsize(GFILE *f) {  				gfxFree(p);  				return 0;  			} -			p->first = TRUE; +			p->first = gTrue;  			return &p->fl;  		} @@ -157,7 +157,7 @@ static long int NativeGetsize(GFILE *f) {  			while(1) {  				if (!nfl->first && !FindNextFile(nfl->d, &nfl->f))  					return 0; -				nfl->first = FALSE; +				nfl->first = gFalse;  				if (nfl->f.cFileName[0] == '.')  					continue;  				if (nfl->fl.dirs) { @@ -186,7 +186,7 @@ static long int NativeGetsize(GFILE *f) {  			struct dirent *		f;  		} NativeFileList; -		static gfileList *NativeFlOpen(const char *path, bool_t dirs) { +		static gfileList *NativeFlOpen(const char *path, gBool dirs) {  			NativeFileList		*p;  			(void)				dirs; diff --git a/src/gfile/gfile_fs_petitfs.c b/src/gfile/gfile_fs_petitfs.c index 553c29ff..84405f25 100644 --- a/src/gfile/gfile_fs_petitfs.c +++ b/src/gfile/gfile_fs_petitfs.c @@ -16,12 +16,12 @@  #include "gfile_fs.h"  #include "gfile_petitfs_wrapper.h" -static bool_t petitfsExists(const char* fname); -static bool_t petitfsOpen(GFILE* f, const char* fname); +static gBool petitfsExists(const char* fname); +static gBool petitfsOpen(GFILE* f, const char* fname);  static int petitfsRead(GFILE* f, void* buf, int size); -static bool_t petitfsSetPos(GFILE* f, long int pos); +static gBool petitfsSetPos(GFILE* f, long int pos);  #if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1 -	static gfileList *petitfsFlOpen(const char *path, bool_t dirs); +	static gfileList *petitfsFlOpen(const char *path, gBool dirs);  	static const char *petitfsFlRead(gfileList *pfl);  	static void petitfsFlClose(gfileList *pfl);  #endif @@ -58,38 +58,38 @@ typedef struct petitfsList {  } petitfsList;  // optimize these later on. Use an array to have multiple -static bool_t petitfs_mounted = FALSE; +static gBool petitfs_mounted = gFalse;  static FATFS petitfs_fs; -static bool_t petitfsExists(const char* fname) +static gBool petitfsExists(const char* fname)  {  	// Mount first  	if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK) -		return FALSE; +		return gFalse;  	// Open  	if (pf_open(fname) != FR_OK) -		return FALSE; +		return gFalse; -	return TRUE; +	return gTrue;  } -static bool_t petitfsOpen(GFILE* f, const char* fname) +static gBool petitfsOpen(GFILE* f, const char* fname)  {  	// No writing  	if ((f->flags & GFILEFLG_WRITE)) -		return FALSE; +		return gFalse;  	// Mount first  	if (!petitfs_mounted && pf_mount(&petitfs_fs) != FR_OK) -		return FALSE; +		return gFalse;  	// Open  	if (pf_open(fname) != FR_OK) -		return FALSE; +		return gFalse;  	f->obj = &petitfs_fs; -	return TRUE;	 +	return gTrue;	  }  static int petitfsRead(GFILE* f, void* buf, int size) @@ -103,14 +103,14 @@ static int petitfsRead(GFILE* f, void* buf, int size)  	return br;  } -static bool_t petitfsSetPos(GFILE* f, long int pos) +static gBool petitfsSetPos(GFILE* f, long int pos)  {  	(void)	f;  	return pf_lseek((DWORD)pos) == FR_OK;  }  #if GFILE_NEED_FILELISTS -	static gfileList *petitfsFlOpen(const char *path, bool_t dirs) { +	static gfileList *petitfsFlOpen(const char *path, gBool dirs) {  		petitfsList	*p;  		(void) dirs; diff --git a/src/gfile/gfile_fs_rom.c b/src/gfile/gfile_fs_rom.c index ec07ec34..578a28e5 100644 --- a/src/gfile/gfile_fs_rom.c +++ b/src/gfile/gfile_fs_rom.c @@ -42,16 +42,16 @@ typedef struct ROMFileList {  } ROMFileList; -static bool_t ROMExists(const char *fname); +static gBool ROMExists(const char *fname);  static long int	ROMFilesize(const char *fname); -static bool_t ROMOpen(GFILE *f, const char *fname); +static gBool ROMOpen(GFILE *f, const char *fname);  static void ROMClose(GFILE *f);  static int ROMRead(GFILE *f, void *buf, int size); -static bool_t ROMSetpos(GFILE *f, long int pos); +static gBool ROMSetpos(GFILE *f, long int pos);  static long int ROMGetsize(GFILE *f); -static bool_t ROMEof(GFILE *f); +static gBool ROMEof(GFILE *f);  #if GFILE_NEED_FILELISTS -	static gfileList *ROMFlOpen(const char *path, bool_t dirs); +	static gfileList *ROMFlOpen(const char *path, gBool dirs);  	static const char *ROMFlRead(gfileList *pfl);  	static void ROMFlClose(gfileList *pfl);  #endif @@ -79,7 +79,7 @@ static const ROMFS_DIRENTRY *ROMFindFile(const char *fname)  	return p;  } -static bool_t ROMExists(const char *fname) +static gBool ROMExists(const char *fname)  {  	return ROMFindFile(fname) != 0;  } @@ -92,13 +92,13 @@ static long int	ROMFilesize(const char *fname)  	return p->size;  } -static bool_t ROMOpen(GFILE *f, const char *fname) +static gBool ROMOpen(GFILE *f, const char *fname)  {  	const ROMFS_DIRENTRY *p; -	if (!(p = ROMFindFile(fname))) return FALSE; +	if (!(p = ROMFindFile(fname))) return gFalse;  	f->obj = (void *)p; -	return TRUE; +	return gTrue;  }  static void ROMClose(GFILE *f) @@ -118,7 +118,7 @@ static int ROMRead(GFILE *f, void *buf, int size)  	return size;  } -static bool_t ROMSetpos(GFILE *f, long int pos) +static gBool ROMSetpos(GFILE *f, long int pos)  {  	return pos <= ((const ROMFS_DIRENTRY *)f->obj)->size;  } @@ -128,13 +128,13 @@ static long int ROMGetsize(GFILE *f)  	return ((const ROMFS_DIRENTRY *)f->obj)->size;  } -static bool_t ROMEof(GFILE *f) +static gBool ROMEof(GFILE *f)  {  	return f->pos >= ((const ROMFS_DIRENTRY *)f->obj)->size;  }  #if GFILE_NEED_FILELISTS -	static gfileList *ROMFlOpen(const char *path, bool_t dirs) { +	static gfileList *ROMFlOpen(const char *path, gBool dirs) {  		ROMFileList *	p;  		(void)			path; diff --git a/src/gfile/gfile_printg.c b/src/gfile/gfile_printg.c index 8f9d2570..697593d3 100644 --- a/src/gfile/gfile_printg.c +++ b/src/gfile/gfile_printg.c @@ -56,7 +56,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {  	int		ret;  	char	*p, *s, c, filler;  	int		i, precision, width; -	bool_t	is_long, left_align; +	gBool	is_long, left_align;  	long	l;  	#if GFILE_ALLOW_FLOATS  		float	fpv; @@ -81,14 +81,14 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {  		fmt++;  		p = s = tmpbuf; -		left_align = FALSE; +		left_align = gFalse;  		filler = ' ';  		width = 0;  		precision = 0;  		if (*fmt == '-') {  			fmt++; -			left_align = TRUE; +			left_align = gTrue;  		}  		if (*fmt == '0') {  			fmt++; @@ -119,7 +119,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {  		}  		/* Long modifier.*/  		if (c == 'l' || c == 'L') { -			is_long = TRUE; +			is_long = gTrue;  			if (*fmt)  				c = *fmt++;  		} @@ -194,7 +194,7 @@ int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg) {  		i = (int)(p - s);  		if ((width -= i) < 0)  			width = 0; -		if (left_align == FALSE) +		if (!left_align)  			width = -width;  		if (width < 0) {  			if (*s == '-' && filler == '0') { diff --git a/src/gfile/gfile_scang.c b/src/gfile/gfile_scang.c index a79cc6a3..8e1ee69c 100644 --- a/src/gfile/gfile_scang.c +++ b/src/gfile/gfile_scang.c @@ -27,7 +27,7 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) {  	int		res, width, size, base;  	unsigned long num;  	char	c; -	bool_t	assign, negate; +	gBool	assign, negate;  	char	*p;  	for(res = 0; *fmt; fmt++) { @@ -37,15 +37,15 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) {  		case '%':  			fmt++; -			assign = TRUE; -			negate = FALSE; +			assign = gTrue; +			negate = gFalse;  			width = 0;  			size = 1;  			num = 0;  			if (*fmt == '*') {  				fmt++; -				assign = FALSE; +				assign = gFalse;  			}  			while(*fmt >= '0' && *fmt <= '9')  				width = width * 10 + (*fmt++ - '0'); @@ -145,7 +145,7 @@ int vfscang(GFILE *f, const char *fmt, va_list arg) {  					break;  				}  				if (c == '-' && *fmt != 'u') { -					negate = TRUE; +					negate = gTrue;  					if ((width && !--width) || !gfileRead(f, &c, 1))			return res;  				}  				if (base == -1) { @@ -15,7 +15,7 @@  #include "../gfx.h" -static bool_t gfxInitDone = FALSE; +static gBool gfxInitDone = gFalse;  /* These init functions are defined by each module but not published */  extern void _gosInit(void); @@ -84,7 +84,7 @@ void gfxInit(void)  	/* Ensure we only initialise once */  	if (gfxInitDone)  		return; -	gfxInitDone = TRUE; +	gfxInitDone = gTrue;  	// These must be initialised in the order of their dependancies @@ -141,7 +141,7 @@ void gfxDeinit(void)  {  	if (!gfxInitDone)  		return; -	gfxInitDone = FALSE; +	gfxInitDone = gFalse;  	// We deinitialise the opposite way as we initialised  	#if GFX_USE_GWIN diff --git a/src/gfx.h b/src/gfx.h new file mode 100644 index 00000000..cb92a10c --- /dev/null +++ b/src/gfx.h @@ -0,0 +1,238 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + *              http://ugfx.org/license.html + */ + +/** + * @file    gfx.h + * @brief   GFX system header file. + * + * @addtogroup GFX + * + * @brief	Main module to glue all the others together + * + * @{ + */ + +#ifndef _GFX_H +#define _GFX_H + +// Everything here is C, not C++ +#ifdef __cplusplus +extern "C" { +#endif + +// ------------------------------ Initial preparation --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_PREP + +// Compiling stages +#define GFX_COMPILESTAGE_USERPROGRAM		0		// Compiling the user program +#define GFX_COMPILESTAGE_PREP				1		// gfx.h: Initial preparation +#define GFX_COMPILESTAGE_USERCONFIG			2		// gfx.h: Load the user configuration +#define GFX_COMPILESTAGE_COMPILECONFIG		3		// gfx.h: Determine build environment info - COMPILER, CPU etc +#define GFX_COMPILESTAGE_OPTIONS			3		// gfx.h: Enumerate all options +#define GFX_COMPILESTAGE_DRIVERCONFIG		4		// gfx.h: Load driver configuration +#define GFX_COMPILESTAGE_DRIVERAPI			5		// gfx.h: Load driver public api +#define GFX_COMPILESTAGE_RULES				6		// gfx.h: Apply configuration rules +#define GFX_COMPILESTAGE_APIDEFS			7		// gfx.h: Define API definitions +#define GFX_COMPILESTAGE_COMPILEDRIVERS		100		// gfx.c: Compile drivers +#define GFX_COMPILESTAGE_COMPILECAPI		101		// gfx.c: Compile the uGFX C API +#define GFX_COMPILESTAGE_COMPILECPPAPI		102		// gfx.cpp: Compile the uGFX C++ API + +// ------------------------------ Load the user configuration --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_USERCONFIG + +// Definitions for option configuration +#define GFXOFF		(0) +#define GFXON		(-1) + +// gfxconf.h is the user's project configuration for the GFX system. +#include "gfxconf.h" + +// ------------------------------ Determine build environment info - COMPILER, CPU etc --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_COMPILECONFIG + +/** + * @name    GFX compatibility options + * @{ + */ +	/** +	 * @brief   Include the uGFX V2.x API +	 * @details	Defaults to GFXON +	 */ +	#ifndef GFX_COMPAT_V2 +		#define GFX_COMPAT_V2				GFXON +	#endif +/** @} */ + +#if GFX_COMPAT_V2 +	// These need to be defined here for compatibility with V2.x user config files +	#if !defined(FALSE) +		#define FALSE       0 +	#endif +	#if !defined(TRUE) +		#define TRUE        -1 +	#endif +#endif + +// Are we in the uGFX library implementation itself? - not API documented +#ifndef GFX_COMPILE_INTERNAL_API +	#define GFX_COMPILE_INTERNAL_API		GFXOFF +#endif + +// Macro concatination and strify - not API documented +#define GFXCAT(a, b)	a ## b +#define GFXCATX(a, b)	GFXCAT(a, b) +#define GFXSTR(a)		#a +#define GFXSTRX(a)		GFXSTR(a) + +// Include Compiler and CPU support +#include "gfx_compilers.h" + +// Include standard types +#include "gfx_types.h" + +// Public uGFX API calling convention +#ifndef GFXAPI +	#define GFXAPI +#endif + +// Public uGFX API callback convention +#ifndef GFXUSERFN +	#define GFXUSERFN		GFXAPI +#endif + +// Private uGFX API calling convention +#if GFX_COMPILE_INTERNAL_API && !defined(GFXINTERNAL) +	#define GFXINTERNAL +#endif + +// ------------------------------ Enumerate all options --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_OPTIONS + +/** + * Get all the options for each sub-system. + */ +#include "gfx_options.h" +#include "gos/gos_options.h" +#include "gdriver/gdriver_options.h" +#include "gfile/gfile_options.h" +#include "gmisc/gmisc_options.h" +#include "gtrans/gtrans_options.h" +#include "gqueue/gqueue_options.h" +#include "gevent/gevent_options.h" +#include "gtimer/gtimer_options.h" +#include "gdisp/gdisp_options.h" +#include "gwin/gwin_options.h" +#include "ginput/ginput_options.h" +#include "gadc/gadc_options.h" +#include "gaudio/gaudio_options.h" + +// ------------------------------ Load driver configuration --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_DRIVERCONFIG + +// ------------------------------ Apply configuration rules --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_RULES + +/** + * Interdependency safety checks on the sub-systems. + * These must be in dependency order. + */ +#ifndef GFX_DISPLAY_RULE_WARNINGS +	#define GFX_DISPLAY_RULE_WARNINGS	GFXOFF +#endif +#include "gwin/gwin_rules.h" +#include "ginput/ginput_rules.h" +#include "gdisp/gdisp_rules.h" +#include "gaudio/gaudio_rules.h" +#include "gadc/gadc_rules.h" +#include "gevent/gevent_rules.h" +#include "gtimer/gtimer_rules.h" +#include "gqueue/gqueue_rules.h" +#include "gmisc/gmisc_rules.h" +#include "gtrans/gtrans_rules.h" +#include "gfile/gfile_rules.h" +#include "gdriver/gdriver_rules.h" +#include "gos/gos_rules.h" + +// ------------------------------ Define API definitions --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_APIDEFS + +/** + *  Include the sub-system header files + */ +#include "gos/gos.h" +#if GFX_COMPILE_INTERNAL_API +	#include "gdriver/gdriver.h" +#endif +#include "gfile/gfile.h" +#include "gmisc/gmisc.h" +#include "gtrans/gtrans.h" +#include "gqueue/gqueue.h" +#include "gevent/gevent.h" +#include "gtimer/gtimer.h" +#include "gdisp/gdisp.h" +#include "gwin/gwin.h" +#include "ginput/ginput.h" +#include "gadc/gadc.h" +#include "gaudio/gaudio.h" + +/** + * @brief	The one call to start it all + * + * @note	This will initialise each sub-system that has been turned on. + * 			For example, if GFX_USE_GDISP is defined then display will be initialised + * 			and cleared to black. + * @note	If you define GFX_OS_NO_INIT as GFXON in your gfxconf.h file then ugfx doesn't try to + * 			initialise the operating system for you when you call @p gfxInit(). + * @note	If you define GFX_OS_EXTRA_INIT_FUNCTION in your gfxconf.h file the macro is the + * 			name of a void function with no parameters that is called immediately after + * 			operating system initialisation (whether or not GFX_OS_NO_INIT is set). + * @note	If you define GFX_OS_EXTRA_DEINIT_FUNCTION in your gfxconf.h file the macro is the + * 			name of a void function with no parameters that is called immediately before + * 			operating system de-initialisation (as ugfx is exiting). + * @note	If GFX_OS_CALL_UGFXMAIN is set uGFXMain() is called after all initialisation is complete. + * + * @api + */ +void GFXAPI gfxInit(void); + +/** + * @brief	The one call to end it all + * + * @note	This will de-initialise each sub-system that has been turned on. + * + * @api + */ +void GFXAPI gfxDeinit(void); + +#if GFX_OS_CALL_UGFXMAIN || defined(__DOXYGEN__) +	/** +	 * @brief	The user supplied function containing all the user uGFX application code. +	 * +	 * @note	This is called by gfxInit() and is expected to never return. +	 * 			It is defined by the user. +	 * +	 * @pre		GFX_OS_CALL_UGFXMAIN is GFXON +	 */ +	void GFXUSERFN uGFXMain(void); +#endif + +// ------------------------------ Compiling the user program --------------------------------- +#undef  GFX_COMPILESTAGE +#define GFX_COMPILESTAGE				GFX_COMPILESTAGE_USERPROGRAM + +#ifdef __cplusplus +} +#endif +#endif /* _GFX_H */ +/** @} */ diff --git a/src/gfx_options.h b/src/gfx_options.h new file mode 100644 index 00000000..608180ff --- /dev/null +++ b/src/gfx_options.h @@ -0,0 +1,145 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + *              http://ugfx.org/license.html + */ + +/** + * @file    gfx_options.h + * @brief   GFX system options. + * + * @addtogroup GFX + * @{ + */ + +/** + * @name    GFX sub-systems that can be turned on + * @{ + */ +	/** +	 * @brief   GFX Driver API +	 * @details	Defaults to GFXON +	 * @note	Not much useful can be done without a driver +	 */ +	#ifndef GFX_USE_GDRIVER +		#define GFX_USE_GDRIVER	GFXON +	#endif +	/** +	 * @brief   GFX Graphics Display Basic API +	 * @details	Defaults to GFXOFF +	 * @note	Also add the specific hardware driver to your makefile. +	 * 			Eg.  include $(GFXLIB)/drivers/gdisp/Nokia6610/driver.mk +	 */ +	#ifndef GFX_USE_GDISP +		#define GFX_USE_GDISP	GFXOFF +	#endif +	/** +	 * @brief   GFX Graphics Windowing API +	 * @details	Defaults to GFXOFF +	 * @details	Extends the GDISP API to add the concept of graphic windows. +	 * @note	Also supports high-level "window" objects such as console windows, +	 * 			buttons, graphing etc +	 */ +	#ifndef GFX_USE_GWIN +		#define GFX_USE_GWIN	GFXOFF +	#endif +	/** +	 * @brief   GFX Event API +	 * @details	Defaults to GFXOFF +	 * @details	Defines the concept of a "Source" that can send "Events" to "Listeners". +	 */ +	#ifndef GFX_USE_GEVENT +		#define GFX_USE_GEVENT	GFXOFF +	#endif +	/** +	 * @brief   GFX Timer API +	 * @details	Defaults to GFXOFF +	 * @details	Provides thread context timers - both one-shot and periodic. +	 */ +	#ifndef GFX_USE_GTIMER +		#define GFX_USE_GTIMER	GFXOFF +	#endif +	/** +	 * @brief   GFX Queue API +	 * @details	Defaults to GFXOFF +	 * @details	Provides queue management. +	 */ +	#ifndef GFX_USE_GQUEUE +		#define GFX_USE_GQUEUE	GFXOFF +	#endif +	/** +	 * @brief   GFX Input Device API +	 * @details	Defaults to GFXOFF +	 * @note	Also add the specific hardware drivers to your makefile. +	 * 			Eg. +	 * 				include $(GFXLIB)/drivers/ginput/toggle/Pal/driver.mk +	 * 			and... +	 * 				include $(GFXLIB)/drivers/ginput/touch/MCU/driver.mk +	 */ +	#ifndef GFX_USE_GINPUT +		#define GFX_USE_GINPUT	GFXOFF +	#endif +	/** +	 * @brief   GFX Generic Periodic ADC API +	 * @details	Defaults to GFXOFF +	 */ +	#ifndef GFX_USE_GADC +		#define GFX_USE_GADC	GFXOFF +	#endif +	/** +	 * @brief   GFX Audio API +	 * @details	Defaults to GFXOFF +	 * @note	Also add the specific hardware drivers to your makefile. +	 * 			Eg. +	 * 				include $(GFXLIB)/drivers/gaudio/GADC/driver.mk +	 */ +	#ifndef GFX_USE_GAUDIO +		#define GFX_USE_GAUDIO	GFXOFF +	#endif +	/** +	 * @brief   GFX Miscellaneous Routines API +	 * @details	Defaults to GFXOFF +	 * @note	Turning this on without turning on any GMISC_NEED_xxx macros will result +	 * 			in no extra code being compiled in. GMISC is made up from the sum of its +	 * 			parts. +	 */ +	#ifndef GFX_USE_GMISC +		#define GFX_USE_GMISC	GFXOFF +	#endif +	/** +	 * @brief   GFX File API +	 * @details	Defaults to GFXOFF +	 */ +	#ifndef GFX_USE_GFILE +		#define GFX_USE_GFILE	GFXOFF +	#endif +	/** +	 * @brief   GFX Translation Support API +	 * @details	Defaults to GFXOFF +	 */ +	#ifndef GFX_USE_GTRANS +		#define GFX_USE_GTRANS	GFXOFF +	#endif +/** @} */ + +/** + * @name    GFX compatibility options + * @{ + */ +	/** +	 * @brief   Include the uGFX V2.x Old Colors +	 * @details	Defaults to GFXON +	 * @pre		Requires GFX_COMPAT_V2 to be GFXON +	 * @note	The old color definitions (particularly Red, Green & Blue) can +	 *			cause symbol conflicts with many platforms eg Win32, STM32 HAL etc. +	 *			Although officially these symbols are part of the V2.x API, this +	 *			option allows them to be turned off even when the rest of the V2.x +	 *			API is turned on. +	 */ +	#ifndef GFX_COMPAT_OLDCOLORS +		#define GFX_COMPAT_OLDCOLORS		GFXON +	#endif +/** @} */ + +/** @} */ diff --git a/src/gfx_types.h b/src/gfx_types.h new file mode 100644 index 00000000..f6b2ee0f --- /dev/null +++ b/src/gfx_types.h @@ -0,0 +1,165 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + *              http://ugfx.org/license.html + */ + +// Safety first! +#if (!defined(__STDC__) || !__STDC__) && !defined(__cplusplus) && !defined(_MSC_VER) +	#error "K&R C Compilers are not supported. Try turning on ANSI C compliance or at least defining macro __STDC__=1" +#endif + +// This guarantees definition (even in C89) of: +//	offsetof(s, m)		- required and compiler dependant +//	size_t				- we try not to use this in uGFX as it may be 64 bit +//	NULL				- globally useful +//	ptrdiff_t			- globally useful + +#include <stddef.h> + +#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) ) +	#include <stdint.h> +	typedef int_least8_t			gI8; +	typedef uint_least8_t			gU8; +	typedef int_least16_t			gI16; +	typedef uint_least16_t			gU16; +	typedef int_least32_t			gI32; +	typedef uint_least32_t			gU32; + +	#define GI8_C(v) 	 			INT8_C(v) +	#define GU8_C(v)  				UINT8_C(v) +	#define GI16_C(v) 				INT16_C(v) +	#define GU16_C(v)  				UINT16_C(v) +	#define GI32_C(v) 				INT32_C(v) +	#define GU32_C(v)  				UINT32_C(v) + +	#ifdef INT64_C +		typedef int_least64_t		gI64; +		typedef uint_least64_t		gU64; +		#define GI64_C(v) 			INT64_C(v) +		#define GU64_C(v)  			UINT64_C(v) +		#define GFX_TYPE_64			GFXON +	#else +		#define GFX_TYPE_64			GFXOFF +	#endif + +#elif defined(_MSC_VER) +	#if (_MSC_VER < 1300) +		typedef signed   char		gI8; +		typedef unsigned char		gU8; +		typedef signed   short		gI16; +		typedef unsigned short		gU16; +		typedef signed   int		gI32; +		typedef unsigned int		gU32; +	#else +		typedef signed   __int8		gI8; +		typedef unsigned __int8		gU8; +		typedef signed   __int16	gI16; +		typedef unsigned __int16	gU16; +		typedef signed   __int32	gI32; +		typedef unsigned __int32	gU32; +	#endif +	typedef signed   __int64		gI64; +	typedef unsigned __int64		gU64; + +	#define GI8_C(v)  				v ## i8 +	#define GU8_C(v)  				v ## ui8 +	#define GI16_C(v) 				v ## i16 +	#define GU16_C(v) 				v ## ui16 +	#define GI32_C(v) 				v ## i32 +	#define GU32_C(v) 				v ## ui32 +	#define GI64_C(v) 				v ## i64 +	#define GU64_C(v) 				v ## ui64 + +	#define GFX_TYPE_64				GFXON + +/*#elif defined(__GNUC__) || defined(__GNUG__) +	typedef __INT8_TYPE__	int8_t; +	typedef __UINT8_TYPE__	uint8_t; +	typedef __INT16_TYPE__	int16_t; +	typedef __UINT16_TYPE__	uint16_t; +	typedef __INT32_TYPE__	int32_t; +	typedef __UINT32_TYPE__	uint32_t; +*/ +#else +	#include <limits.h> + +	/* char's are the smallest common type definition */ +	typedef signed   char			gI8; +	typedef unsigned char			gU8; +	#define GI8_C(v)	  			v +	#define GU8_C(v)  				v ## U + +	/* +	 *  Deduce the type assignments from limits.h under the assumption that +	 *  integer sizes in bits are powers of 2, and follow the ANSI +	 *  definitions. +	 */ +	#if defined(SHRT_MAX) && SHRT_MAX >= 0x7FFF +		typedef signed   short		gI16 +		typedef unsigned short		gU16 +	#else +		typedef signed   int		gI16 +		typedef unsigned int		gU16 +	#endif +	#define GI16_C(v)	  			v +	#define GU16_C(v)  				v ## U + +	#if defined(INT_MAX) && INT_MAX >= 0x7FFFFFFL +		typedef signed   int		gI32 +		typedef unsigned int		gU32 +		#define GI32_C(v)	  		v +		#define GU32_C(v)  			v ## U +	#else +		typedef signed   long		gI32 +		typedef unsigned long		gU32 +		#define GI32_C(v)	  		v ## L +		#define GU32_C(v)  			v ## UL +	#endif + +	#if defined(__GNUC__) && !defined(vxWorks) +		#define GFX_TYPE_64				GFXON +		__extension__ typedef long long	gI64; +		__extension__ typedef unsigned long long gU64; +		#define GI64_C(v)				v ## LL +		#define GU64_C(v)				v ## ULL +	#elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) +		#define GFX_TYPE_64				GFXON +		typedef long long				gI64; +		typedef unsigned long long		gU64; +		#define GI64_C(v)				v ## LL +		#define GU64_C(v)				v ## ULL +	#elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) +		#define GFX_TYPE_64				GFXON +		typedef signed   __int64		gI64; +		typedef unsigned __int64		gU64; +	#else +		#define GFX_TYPE_64				GFXOFF +	#endif +#endif + +typedef void *				gPtr; +typedef ptrdiff_t			gPtrDiff; +typedef gI8					gBool; +#define gTrue				(-1) +#define gFalse				(0) + +#if GFX_COMPAT_V2 +	/* Is stdint.h already included? */ +	#ifndef INT16_C +		typedef gI8			int8_t; +		typedef gU8			uint8_t; +		typedef gI16		int16_t; +		typedef gU16		uint16_t; +		typedef gI32		int32_t; +		typedef gU32		uint32_t; +	#endif +	typedef gI8				bool_t; +	#ifndef TRUE +		#define TRUE		gTrue +	#endif +	#ifndef FALSE +		#define FALSE		gFalse +	#endif +#endif diff --git a/src/ginput/ginput_dial.c b/src/ginput/ginput_dial.c index 0d853498..164b5e17 100644 --- a/src/ginput/ginput_dial.c +++ b/src/ginput/ginput_dial.c @@ -80,7 +80,7 @@ GSourceHandle ginputGetDial(uint16_t instance) {  			pds->lastvalue = 0;  		}  		ginput_lld_dial_init(); -		gtimerStart(&DialTimer, (GTimerFunction)ginput_lld_dial_poll, DialCallback, TRUE, GINPUT_DIAL_POLL_PERIOD); +		gtimerStart(&DialTimer, (GTimerFunction)ginput_lld_dial_poll, DialCallback, gTrue, GINPUT_DIAL_POLL_PERIOD);  	}  	// OK - return this input @@ -137,16 +137,16 @@ void ginputSetDialSensitivity(uint16_t instance, uint16_t diff) {   * @param[in] instance	The ID of the dial input instance   * @param[in] pdial		The dial event struct   * - * @return	Returns FALSE on an error (eg invalid instance) + * @return	Returns gFalse on an error (eg invalid instance)   */ -bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial) { +gBool ginputGetDialStatus(uint16_t instance, GEventDial *pdial) {  	if (instance >= GINPUT_DIAL_NUM_PORTS) -		return FALSE; +		return gFalse;  	pdial->type = GEVENT_DIAL;  	pdial->instance = instance;  	pdial->value = DialStatus[instance].lastvalue;  	pdial->maxvalue = DialStatus[instance].max; -	return TRUE; +	return gTrue;  }  #endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */ diff --git a/src/ginput/ginput_dial.h b/src/ginput/ginput_dial.h index 77c1b05c..af93391e 100644 --- a/src/ginput/ginput_dial.h +++ b/src/ginput/ginput_dial.h @@ -44,67 +44,59 @@ typedef struct GEventDial_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif - -	/** -	 * @brief	Create a dial input instance -	 * -	 * @param[in] instance	The ID of the dial input instance (from 0 to 9999) -	 * -	 * @return	The soure handle of the created dial instance -	 */ -	GSourceHandle ginputGetDial(uint16_t instance);				 -	 -	/** -	 * @brief	Reset the value back to the hardware default -	 * -	 * @param[in] instance	The ID of the dial input instance -	 */ -	void ginputResetDialRange(uint16_t instance);				 +/** + * @brief	Create a dial input instance + * + * @param[in] instance	The ID of the dial input instance (from 0 to 9999) + * + * @return	The soure handle of the created dial instance + */ +GSourceHandle ginputGetDial(uint16_t instance);				 -	/** -	 * @brief	Get the maximum value -	 * @details	The readings are scaled to be 0 ... max. -	 * -	 * @param[in] instance	The ID of the dial input instance -	 * -	 * @return	The maximum value -	 */ -	uint16_t ginputGetDialRange(uint16_t instance); +/** + * @brief	Reset the value back to the hardware default + * + * @param[in] instance	The ID of the dial input instance + */ +void ginputResetDialRange(uint16_t instance);				 -	/** -	 * @brief	Set the maximum value -	 * @details	The readings are scaled to be 0 ... max. -	 * -	 * @param[in] instance	The ID of the dial input instance -	 * @param[in] max		The maximum value to be set -	 */ -	void ginputSetDialRange(uint16_t instance, uint16_t max); +/** + * @brief	Get the maximum value + * @details	The readings are scaled to be 0 ... max. + * + * @param[in] instance	The ID of the dial input instance + * + * @return	The maximum value + */ +uint16_t ginputGetDialRange(uint16_t instance); -	/** -	 * @brief	Set the level change required before a dial even is generated (threshold) -	 * @note	This is done after range scaling -	 * -	 * @param[in] instance	The ID of the dial input instance -	 * @param[in] diff		The amount of level changes -	 */ -	void ginputSetDialSensitivity(uint16_t instance, uint16_t diff); -																	 -	/** -	 * @brief	Get the current dial status -	 * -	 * @param[in] instance	The ID of the dial input instance -	 * @param[in] pdial		The dial event struct -	 * -	 * @return	Returns FALSE on an error (eg invalid instance) -	 */ -	bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial); +/** + * @brief	Set the maximum value + * @details	The readings are scaled to be 0 ... max. + * + * @param[in] instance	The ID of the dial input instance + * @param[in] max		The maximum value to be set + */ +void ginputSetDialRange(uint16_t instance, uint16_t max); -#ifdef __cplusplus -} -#endif +/** + * @brief	Set the level change required before a dial even is generated (threshold) + * @note	This is done after range scaling + * + * @param[in] instance	The ID of the dial input instance + * @param[in] diff		The amount of level changes + */ +void ginputSetDialSensitivity(uint16_t instance, uint16_t diff); +																 +/** + * @brief	Get the current dial status + * + * @param[in] instance	The ID of the dial input instance + * @param[in] pdial		The dial event struct + * + * @return	Returns gFalse on an error (eg invalid instance) + */ +gBool ginputGetDialStatus(uint16_t instance, GEventDial *pdial);  #endif /* GINPUT_NEED_DIAL */ diff --git a/src/ginput/ginput_driver_keyboard.h b/src/ginput/ginput_driver_keyboard.h index 1e0c6c2a..1d9fabf9 100644 --- a/src/ginput/ginput_driver_keyboard.h +++ b/src/ginput/ginput_driver_keyboard.h @@ -41,7 +41,7 @@ typedef struct GKeyboardVMT {  		#define GKEYBOARD_VFLG_NOPOLL			0x0001		// Do not poll this device - it is purely interrupt driven  		#define GKEYBOARD_VFLG_DYNAMICONLY		0x8000		// This keyboard driver should not be statically initialized eg Win32  	const uint8_t *	defLayout;								// The default keyboard layout -	bool_t	(*init)(GKeyboard *m, unsigned driverinstance);	// Required +	gBool	(*init)(GKeyboard *m, unsigned driverinstance);	// Required  	void	(*deinit)(GKeyboard *m);						// Optional  	int		(*getdata)(GKeyboard *k, uint8_t *pch, int sz);	// Required. Get zero or more scancode bytes. Returns the number of scancode bytes returns  	void	(*putdata)(GKeyboard *k, char ch);				// Optional. Send a single byte to the keyboard. @@ -70,13 +70,13 @@ extern "C" {  	 * @param[in] driverinstance	The driver instance		ToDo: Add some more details  	 * @param[in] systeminstance	The mouse instance		ToDo: Add some more details  	 * -	 * @return	TRUE on success, FALSE otherwise +	 * @return	gTrue on success, gFalse otherwise  	 * @note	This routine is provided by the high level code for  	 * 			use in the driver VMT's GMouseVMT.d structure.  	 *  	 * @notapi  	 */ -	bool_t _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance); +	gBool _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance);  	/**  	 * @brief	Routine that is called after initialization diff --git a/src/ginput/ginput_driver_mouse.h b/src/ginput/ginput_driver_mouse.h index 858d847a..ac5fb02d 100644 --- a/src/ginput/ginput_driver_mouse.h +++ b/src/ginput/ginput_driver_mouse.h @@ -85,11 +85,11 @@ typedef struct GMouseVMT {  	GMouseJitter	pen_jitter;								// PEN MODE: Jitter settings  	GMouseJitter	finger_jitter;							// FINGER MODE: Jitter settings -	bool_t	(*init)(GMouse *m, unsigned driverinstance);	// Required +	gBool	(*init)(GMouse *m, unsigned driverinstance);	// Required  	void	(*deinit)(GMouse *m);							// Optional -	bool_t	(*get)(GMouse *m, GMouseReading *prd);			// Required +	gBool	(*get)(GMouse *m, GMouseReading *prd);			// Required  	void	(*calsave)(GMouse *m, const void *buf, size_t sz);	// Optional -	bool_t	(*calload)(GMouse *m, void *buf, size_t sz);	// Optional +	gBool	(*calload)(GMouse *m, void *buf, size_t sz);	// Optional  } GMouseVMT;  #define gmvmt(m)		((const GMouseVMT const *)((m)->d.vmt)) @@ -115,13 +115,13 @@ extern "C" {  	 * @param[in] driverinstance	The driver instance		ToDo: Add some more details  	 * @param[in] systeminstance	The mouse instance		ToDo: Add some more details  	 * -	 * @return	TRUE on success, FALSE otherwise +	 * @return	gTrue on success, gFalse otherwise  	 * @note	This routine is provided by the high level code for  	 * 			use in the driver VMT's GMouseVMT.d structure.  	 *  	 * @notapi  	 */ -	bool_t _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, unsigned systeminstance); +	gBool _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, unsigned systeminstance);  	/**  	 * @brief	Routine that is called after initialization diff --git a/src/ginput/ginput_keyboard.c b/src/ginput/ginput_keyboard.c index 68f05cea..b50cbc24 100644 --- a/src/ginput/ginput_keyboard.c +++ b/src/ginput/ginput_keyboard.c @@ -492,7 +492,7 @@ void _gkeyboardDeinit(void) {  	gtimerDeinit(&KeyboardTimer);  } -bool_t _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) { +gBool _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance) {  	#define k   ((GKeyboard *)g)  	(void) param;  	(void) systeminstance; @@ -502,13 +502,13 @@ bool_t _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, un  	// Init the mouse  	if (!gkvmt(k)->init((GKeyboard *)g, driverinstance)) -		return FALSE; +		return gFalse;  	// Ensure the Poll timer is started  	if (!gtimerIsActive(&KeyboardTimer)) -		gtimerStart(&KeyboardTimer, KeyboardPoll, 0, TRUE, GINPUT_KEYBOARD_POLL_PERIOD); +		gtimerStart(&KeyboardTimer, KeyboardPoll, 0, gTrue, GINPUT_KEYBOARD_POLL_PERIOD); -	return TRUE; +	return gTrue;  	#undef k  } @@ -532,7 +532,7 @@ GSourceHandle ginputGetKeyboard(unsigned instance) {  	return (GSourceHandle)gdriverGetInstance(GDRIVER_TYPE_KEYBOARD, instance);  } -bool_t ginputGetKeyboardStatus(unsigned instance, GEventKeyboard *pe) { +gBool ginputGetKeyboardStatus(unsigned instance, GEventKeyboard *pe) {  	GKeyboard *k;  	// Win32 threads don't seem to recognise priority and/or pre-emption @@ -540,26 +540,26 @@ bool_t ginputGetKeyboardStatus(unsigned instance, GEventKeyboard *pe) {  	gfxSleepMilliseconds(1);  	if (!(k = (GKeyboard *)gdriverGetInstance(GDRIVER_TYPE_KEYBOARD, instance))) -		return FALSE; +		return gFalse;  	pe->type = GEVENT_KEYBOARD;  	// TODO -	return TRUE; +	return gTrue;  }  #if !GKEYBOARD_LAYOUT_OFF -	bool_t ginputSetKeyboardLayout(unsigned instance, const void *pLayout) { +	gBool ginputSetKeyboardLayout(unsigned instance, const void *pLayout) {  		GKeyboard *k;  		if (!(k = (GKeyboard *)gdriverGetInstance(GDRIVER_TYPE_KEYBOARD, instance))) -			return FALSE; +			return gFalse;  		if (pLayout)  			k->pLayout = pLayout;  		else  			k->pLayout = gkvmt(k)->defLayout; -		return TRUE; +		return gTrue;  	}  #endif diff --git a/src/ginput/ginput_keyboard.h b/src/ginput/ginput_keyboard.h index a80e23d0..61a7a8af 100644 --- a/src/ginput/ginput_keyboard.h +++ b/src/ginput/ginput_keyboard.h @@ -175,47 +175,39 @@ typedef struct GEventKeyboard_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif +/** + * @brief	Create a keyboard input instance + * + * @param[in] instance	The ID of the keyboard input instance (from 0 to 9999) + * + * @return	The source handle of the created input instance + */ +GSourceHandle ginputGetKeyboard(unsigned instance); + +#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__)  	/** -	 * @brief	Create a keyboard input instance +	 * @brief	Get the current keyboard status  	 * -	 * @param[in] instance	The ID of the keyboard input instance (from 0 to 9999) +	 * @param[in] instance	The ID of the keyboard input instance +	 * @param[in] pkeyboard	The keyboard event struct  	 * -	 * @return	The source handle of the created input instance +	 * @return Returns gFalse on an error (eg invalid instance)  	 */ -	GSourceHandle ginputGetKeyboard(unsigned instance); -	 -	#if GINPUT_NEED_KEYBOARD || defined(__DOXYGEN__) +	gBool ginputGetKeyboardStatus(unsigned instance, GEventKeyboard *pkeyboard); +	#if !GKEYBOARD_LAYOUT_OFF || defined(__DOXYGEN__)  		/** -		 * @brief	Get the current keyboard status +		 * @brief	Set the keyboard layout  		 *  		 * @param[in] instance	The ID of the keyboard input instance -		 * @param[in] pkeyboard	The keyboard event struct +		 * @param[in] pLayout	The keyboard layout micro-code. Passing NULL defaults to the driver's default layout.  		 * -		 * @return Returns FALSE on an error (eg invalid instance) +		 * @return Returns gFalse on an error (eg invalid instance)  		 */ -		bool_t ginputGetKeyboardStatus(unsigned instance, GEventKeyboard *pkeyboard); - -		#if !GKEYBOARD_LAYOUT_OFF || defined(__DOXYGEN__) -			/** -			 * @brief	Set the keyboard layout -			 * -			 * @param[in] instance	The ID of the keyboard input instance -			 * @param[in] pLayout	The keyboard layout micro-code. Passing NULL defaults to the driver's default layout. -			 * -			 * @return Returns FALSE on an error (eg invalid instance) -			 */ -			bool_t ginputSetKeyboardLayout(unsigned instance, const void *pLayout); -		#endif -	#endif /* GINPUT_NEED_KEYBOARD */ - -#ifdef __cplusplus -} -#endif +		gBool ginputSetKeyboardLayout(unsigned instance, const void *pLayout); +	#endif +#endif /* GINPUT_NEED_KEYBOARD */  #endif /* _GINPUT_KEYBOARD_H */  /** @} */ diff --git a/src/ginput/ginput_mouse.c b/src/ginput/ginput_mouse.c index 356ad11e..ca032623 100644 --- a/src/ginput/ginput_mouse.c +++ b/src/ginput/ginput_mouse.c @@ -676,7 +676,7 @@ void _gmouseDeinit(void) {  	gtimerDeinit(&MouseTimer);  } -bool_t _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, unsigned systeminstance) { +gBool _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, unsigned systeminstance) {      #define m   ((GMouse *)g)      (void) systeminstance; @@ -691,13 +691,13 @@ bool_t _gmouseInitDriver(GDriver *g, void *display, unsigned driverinstance, uns  	// Init the mouse      if (!gmvmt(m)->init((GMouse *)g, driverinstance)) -        return FALSE; +        return gFalse;  	// Ensure the Poll timer is started  	if (!gtimerIsActive(&MouseTimer)) -		gtimerStart(&MouseTimer, MousePoll, 0, TRUE, GINPUT_MOUSE_POLL_PERIOD); +		gtimerStart(&MouseTimer, MousePoll, 0, gTrue, GINPUT_MOUSE_POLL_PERIOD); -    return TRUE; +    return gTrue;      #undef m  } @@ -759,7 +759,7 @@ GDisplay *ginputGetMouseDisplay(unsigned instance) {  	return m->display;  } -bool_t ginputGetMouseStatus(unsigned instance, GEventMouse *pe) { +gBool ginputGetMouseStatus(unsigned instance, GEventMouse *pe) {  	GMouse *m;  	// Win32 threads don't seem to recognise priority and/or pre-emption @@ -767,11 +767,11 @@ bool_t ginputGetMouseStatus(unsigned instance, GEventMouse *pe) {  	gfxSleepMilliseconds(1);  	if (!(m = (GMouse *)gdriverGetInstance(GDRIVER_TYPE_MOUSE, instance))) -		return FALSE; +		return gFalse;  	#if !GINPUT_TOUCH_NOCALIBRATE_GUI  		if ((m->flags & GMOUSE_FLG_IN_CAL)) -			return FALSE; +			return gFalse;  	#endif  	#if !GINPUT_TOUCH_NOTOUCH @@ -784,11 +784,11 @@ bool_t ginputGetMouseStatus(unsigned instance, GEventMouse *pe) {  	pe->z = m->r.z;  	pe->buttons = m->r.buttons;  	pe->display = m->display; -	return TRUE; +	return gTrue;  }  #if !GINPUT_TOUCH_NOTOUCH -	void ginputSetFingerMode(unsigned instance, bool_t on) { +	void ginputSetFingerMode(unsigned instance, gBool on) {  		GMouse *m;  		if (!(m = (GMouse *)gdriverGetInstance(GDRIVER_TYPE_MOUSE, instance))) diff --git a/src/ginput/ginput_mouse.h b/src/ginput/ginput_mouse.h index 8d8b3b9a..0d641d90 100644 --- a/src/ginput/ginput_mouse.h +++ b/src/ginput/ginput_mouse.h @@ -77,111 +77,103 @@ typedef struct GEventMouse_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif - -	/** -	 * @brief	Get the Source handler for a mouse using the instance number -	 * -	 * @param[in] instance		The mouse instance number -	 * -	 * @return		The source handle of the mouse or NULL -	 * @note		You can use the special value of GMOUSE_ALL_INSTANCES to -	 * 				get a source handle that returns events for all mice rather -	 * 				than a specific mouse. Using GMOUSE_ALL_INSTANCES will always -	 * 				return a valid spurce handle even if there are currently no mice -	 * 				in the system. -	 */ -	GSourceHandle ginputGetMouse(unsigned instance); - -	/** -	 * @brief	Should this device be in Pen mode or Finger mode -	 * @note	A touch device (and even theoritically a mouse) can operate -	 * 			in either pen or finger mode. In finger mode typically a -	 * 			touch device will be far more tolerant of movement and other -	 * 			inaccuracies. Each driver specifies its own tolerances for -	 * 			pen versus finger mode. -	 * -	 * @param[in] instance		The ID of the mouse input instance -	 * @param[in] on			If true then finger mode is turned on. -	 */ -	void ginputSetFingerMode(unsigned instance, bool_t on); - -	/** -	 * @brief	Assign the display associated with the mouse -	 * @note	This only needs to be called if the mouse is associated with a display -	 * 			other than the current default display. It must be called before -	 * 			@p ginputGetMouse() if the new display is to be used during the calibration -	 * 			process. Other than calibration the display is used for range checking, -	 * 			and may also be used to display a mouse pointer. -	 * -	 * @param[in] instance		The ID of the mouse input instance -	 * @param[in] g				The GDisplay to which this mouse belongs -	 */ -	void ginputSetMouseDisplay(unsigned instance, GDisplay *g); - -	/** -	 * @brief	Get the display currently associated with the mouse -	 * @return	A pointer to the display -	 * -	 * @param[in] instance		The ID of the mouse input instance -	 */ -	GDisplay *ginputGetMouseDisplay(unsigned instance); - -	/** -	 * @brief	Get the current mouse position and button status -	 * @note	Unlinke a listener event, this status cannot record meta events such as -	 *			"CLICK". -	 * -	 * @param[in] instance	The ID of the mouse input instance -	 * @param[in] pmouse	The mouse event -	 * -	 * @return	FALSE on an error (eg. invalid instance) -	 */ -	bool_t ginputGetMouseStatus(unsigned instance, GEventMouse *pmouse); - -	/** -	 * @brief	Performs a calibration -	 * -	 * @param[in] instance	The ID of the mouse input instance -	 * -	 * @return	The calibration error squared if calibration fails, or 0 on success or if the driver dosen't need calibration. -	 * @note	An invalid instance will also return 0. -	 */ -	uint32_t ginputCalibrateMouse(unsigned instance); - -    /** -     * @brief   Load a set of mouse calibration data -     * @return  A pointer to the data or NULL on failure -     * -	 * @param[in] instance		The mouse input instance number -	 * @param[in] data			Where the data should be placed -	 * @param[in] sz    		The size in bytes of the data to retrieve. -	 * -     * @note    This routine is provided by the user application. It is only -     *          called if GINPUT_TOUCH_USER_CALIBRATION_LOAD has been set to GFXON in the -     *          users gfxconf.h file. -     */ -    bool_t LoadMouseCalibration(unsigned instance, void *data, size_t sz); - -    /** -     * @brief   Save a set of mouse calibration data -     * @return  TRUE if the save operation was successful. -     * -	 * @param[in] instance		The mouse input instance number -	 * @param[in] data          The data to save -	 * @param[in] sz    		The size in bytes of the data to retrieve. -	 * -     * @note    This routine is provided by the user application. It is only -     *          called if GINPUT_TOUCH_USER_CALIBRATION_SAVE has been set to GFXON in the -     *          users gfxconf.h file. -     */ -    bool_t SaveMouseCalibration(unsigned instance, const void *data, size_t sz); - -#ifdef __cplusplus -} -#endif +/** + * @brief	Get the Source handler for a mouse using the instance number + * + * @param[in] instance		The mouse instance number + * + * @return		The source handle of the mouse or NULL + * @note		You can use the special value of GMOUSE_ALL_INSTANCES to + * 				get a source handle that returns events for all mice rather + * 				than a specific mouse. Using GMOUSE_ALL_INSTANCES will always + * 				return a valid spurce handle even if there are currently no mice + * 				in the system. + */ +GSourceHandle ginputGetMouse(unsigned instance); + +/** + * @brief	Should this device be in Pen mode or Finger mode + * @note	A touch device (and even theoritically a mouse) can operate + * 			in either pen or finger mode. In finger mode typically a + * 			touch device will be far more tolerant of movement and other + * 			inaccuracies. Each driver specifies its own tolerances for + * 			pen versus finger mode. + * + * @param[in] instance		The ID of the mouse input instance + * @param[in] on			If true then finger mode is turned on. + */ +void ginputSetFingerMode(unsigned instance, gBool on); + +/** + * @brief	Assign the display associated with the mouse + * @note	This only needs to be called if the mouse is associated with a display + * 			other than the current default display. It must be called before + * 			@p ginputGetMouse() if the new display is to be used during the calibration + * 			process. Other than calibration the display is used for range checking, + * 			and may also be used to display a mouse pointer. + * + * @param[in] instance		The ID of the mouse input instance + * @param[in] g				The GDisplay to which this mouse belongs + */ +void ginputSetMouseDisplay(unsigned instance, GDisplay *g); + +/** + * @brief	Get the display currently associated with the mouse + * @return	A pointer to the display + * + * @param[in] instance		The ID of the mouse input instance + */ +GDisplay *ginputGetMouseDisplay(unsigned instance); + +/** + * @brief	Get the current mouse position and button status + * @note	Unlinke a listener event, this status cannot record meta events such as + *			"CLICK". + * + * @param[in] instance	The ID of the mouse input instance + * @param[in] pmouse	The mouse event + * + * @return	gFalse on an error (eg. invalid instance) + */ +gBool ginputGetMouseStatus(unsigned instance, GEventMouse *pmouse); + +/** + * @brief	Performs a calibration + * + * @param[in] instance	The ID of the mouse input instance + * + * @return	The calibration error squared if calibration fails, or 0 on success or if the driver dosen't need calibration. + * @note	An invalid instance will also return 0. + */ +uint32_t ginputCalibrateMouse(unsigned instance); + +/** + * @brief   Load a set of mouse calibration data + * @return  A pointer to the data or NULL on failure + * + * @param[in] instance		The mouse input instance number + * @param[in] data			Where the data should be placed + * @param[in] sz    		The size in bytes of the data to retrieve. + * + * @note    This routine is provided by the user application. It is only + *          called if GINPUT_TOUCH_USER_CALIBRATION_LOAD has been set to GFXON in the + *          users gfxconf.h file. + */ +gBool LoadMouseCalibration(unsigned instance, void *data, size_t sz); + +/** + * @brief   Save a set of mouse calibration data + * @return  gTrue if the save operation was successful. + * + * @param[in] instance		The mouse input instance number + * @param[in] data          The data to save + * @param[in] sz    		The size in bytes of the data to retrieve. + * + * @note    This routine is provided by the user application. It is only + *          called if GINPUT_TOUCH_USER_CALIBRATION_SAVE has been set to GFXON in the + *          users gfxconf.h file. + */ +gBool SaveMouseCalibration(unsigned instance, const void *data, size_t sz);  #endif /* GINPUT_NEED_MOUSE */ diff --git a/src/ginput/ginput_toggle.c b/src/ginput/ginput_toggle.c index eb65d6e0..592d6b18 100644 --- a/src/ginput/ginput_toggle.c +++ b/src/ginput/ginput_toggle.c @@ -71,14 +71,14 @@ static void TogglePoll(void *param) {  						if ((psl->listenflags & GLISTEN_TOGGLE_ON)) {  							pe->type = GEVENT_TOGGLE;  							pe->instance = i; -							pe->on = TRUE; +							pe->on = gTrue;  							geventSendEvent(psl);  						}  					} else {  						if ((psl->listenflags & GLISTEN_TOGGLE_OFF)) {  							pe->type = GEVENT_TOGGLE;  							pe->instance = i; -							pe->on = FALSE; +							pe->on = gFalse;  							geventSendEvent(psl);  						}  					} @@ -102,7 +102,7 @@ GSourceHandle ginputGetToggle(uint16_t instance) {  	if (!gtimerIsActive(&ToggleTimer)) {  		for(ptc = GInputToggleConfigTable; ptc < GInputToggleConfigTable+sizeof(GInputToggleConfigTable)/sizeof(GInputToggleConfigTable[0]); ptc++)  			ginput_lld_toggle_init(ptc); -		gtimerStart(&ToggleTimer, TogglePoll, 0, TRUE, GINPUT_TOGGLE_POLL_PERIOD); +		gtimerStart(&ToggleTimer, TogglePoll, 0, gTrue, GINPUT_TOGGLE_POLL_PERIOD);  	}  	// OK - return this input @@ -110,7 +110,7 @@ GSourceHandle ginputGetToggle(uint16_t instance) {  }  // If invert is true, invert the on/off sense for the toggle -void ginputInvertToggle(uint16_t instance, bool_t invert) { +void ginputInvertToggle(uint16_t instance, gBool invert) {  	if (instance >= GINPUT_TOGGLE_NUM_PORTS)  		return;  	if (invert) { @@ -127,19 +127,19 @@ void ginputInvertToggle(uint16_t instance, bool_t invert) {  }  /* Get the current toggle status. - *	Returns FALSE on error (eg invalid instance) + *	Returns gFalse on error (eg invalid instance)   */ -bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) { +gBool ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) {  	// Win32 threads don't seem to recognise priority and/or pre-emption  	// so we add a sleep here to prevent 100% polled applications from locking up.  	gfxSleepMilliseconds(1);  	if (instance >= GINPUT_TOGGLE_NUM_PORTS) -		return FALSE; +		return gFalse;  	ptoggle->type = GEVENT_TOGGLE;  	ptoggle->instance = instance; -	ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? TRUE : FALSE; -	return TRUE; +	ptoggle->on = (ToggleStatus[instance].status & GINPUT_TOGGLE_ISON) ? gTrue : gFalse; +	return gTrue;  }  /* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */ diff --git a/src/ginput/ginput_toggle.h b/src/ginput/ginput_toggle.h index 7d028301..a8719db6 100644 --- a/src/ginput/ginput_toggle.h +++ b/src/ginput/ginput_toggle.h @@ -48,7 +48,7 @@  typedef struct GEventToggle_t {  	GEventType		type;				// The type of this event (GEVENT_TOGGLE)  	uint16_t		instance;			// The toggle instance -	bool_t			on;					// True if the toggle/button is on +	gBool			on;					// True if the toggle/button is on  	} GEventToggle;  // Toggle Listen Flags - passed to geventAddSourceToListener() @@ -59,40 +59,32 @@ typedef struct GEventToggle_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif +/** + * @brief	Create a toggle input instance + * + * @param[in] instance	The ID of the toggle input instance (from 0 to 9999) + * + * @return	The source handle of the created instance + */ +GSourceHandle ginputGetToggle(uint16_t instance);	 -	/** -	 * @brief	Create a toggle input instance -	 * -	 * @param[in] instance	The ID of the toggle input instance (from 0 to 9999) -	 * -	 * @return	The source handle of the created instance -	 */ -	GSourceHandle ginputGetToggle(uint16_t instance);	 - -	/**  -	 * @brief	Can be used to invert the sense of a toggle -	 * -	 * @param[in] instance	The ID of the toggle input instance -	 * @param[in] invert	If TRUE, will be inverted -	 */ -	void ginputInvertToggle(uint16_t instance, bool_t invert); - -	/** -	 * @brief	Get the current toggle status -	 * -	 * @param[in] instance	The ID of the toggle input instance -	 * @param[in] ptoggle	The toggle event struct -	 * -	 * @return Returns FALSE on an error (eg invalid instance) -	 */ -	bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle); - -#ifdef __cplusplus -} -#endif +/**  + * @brief	Can be used to invert the sense of a toggle + * + * @param[in] instance	The ID of the toggle input instance + * @param[in] invert	If gTrue, will be inverted + */ +void ginputInvertToggle(uint16_t instance, gBool invert); + +/** + * @brief	Get the current toggle status + * + * @param[in] instance	The ID of the toggle input instance + * @param[in] ptoggle	The toggle event struct + * + * @return Returns gFalse on an error (eg invalid instance) + */ +gBool ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle);  #endif /* GINPUT_NEED_TOGGLE */ diff --git a/src/gmisc/gmisc.h b/src/gmisc/gmisc.h index 21178774..8d767270 100644 --- a/src/gmisc/gmisc.h +++ b/src/gmisc/gmisc.h @@ -90,10 +90,6 @@ typedef int32_t	fixed;  #if GFX_USE_GMISC || defined(__DOXYGEN__) -#ifdef __cplusplus -extern "C" { -#endif -  #if GMISC_NEED_ARRAYOPS || defined(__DOXYGEN__)  	/**  	 * @brief				Convert from one array format to another array format. @@ -476,17 +472,13 @@ extern "C" {  	 * @param[in] cnt			The number of points in the point array @p pntarray  	 * @param[in] p				The point to test  	 * -	 * @return	@p TRUE if the point @p p is inside or on the edge of the polygon @p pntarray, @p FALSE otherwise. +	 * @return	@p gTrue if the point @p p is inside or on the edge of the polygon @p pntarray, @p gFalse otherwise.  	 *  	 * @api  	 */ -	bool_t gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p); +	gBool gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p);  #endif // GMISC_NEED_HITTEST_POLY -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_MISC */  #endif /* _GMISC_H */ diff --git a/src/gmisc/gmisc_hittest.c b/src/gmisc/gmisc_hittest.c index f84a66cf..6e977cb2 100644 --- a/src/gmisc/gmisc_hittest.c +++ b/src/gmisc/gmisc_hittest.c @@ -64,7 +64,7 @@ static char _pointCrossingSegment(const point *a, const point *b, const point *c      return -1;  } -bool_t gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p) { +gBool gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p) {      unsigned i = 0;      uint8_t nbrIntersection = 0;      int8_t crossResult; @@ -80,7 +80,7 @@ bool_t gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p) {          /* Point on the edge of the polygon */          if (crossResult == 0) { -            return TRUE; +            return gTrue;          }          /* Point crossing the polygon */          else if(crossResult == 1) { @@ -98,18 +98,18 @@ bool_t gmiscHittestPoly(const point *pntarray, unsigned cnt, const point *p) {      }      if (crossResult == 0) { -        return TRUE; +        return gTrue;      } else if(crossResult == 1) {          nbrIntersection++;      }      /* If we cross an even pair of segments, we are outside */      if (nbrIntersection % 2 == 0) { -        return FALSE; +        return gFalse;      }      /* Else we are inside the polygon */ -    return TRUE; +    return gTrue;  }  #endif // GMISC_NEED_HITTEST_POLY diff --git a/src/gos/gos.h b/src/gos/gos.h index 9ba12889..f68c9fda 100644 --- a/src/gos/gos.h +++ b/src/gos/gos.h @@ -28,16 +28,28 @@  	/**  	 * @name	Various integer sizes -	 * @note	Your platform may use slightly different definitions to these +	 * @note	Your platform may define these differently to these. +	 * @note	These sizes are guaranteed minimum sizes for the type. It might actually be larger. +	 *			eg gI8 may actually be 9 bits. +	 * @{ +	 */ +	typedef unsigned char	gBool; +	typedef signed char		gI8; +	typedef unsigned char	gU8; +	typedef short			gI16; +	typedef unsigned short	gU16; +	typedef long			gI32; +	typedef unsigned long	gU32; +	/** @} */ +	 +	/** +	 * @name	More integer sizes +	 * @pre		These are only available if GFX_TYPE_64 is GFXON as not all compilers support 64 bit. +	 * @note	GFX_TYPE_64 is set to GFXON or GFXOFF by the compiler detector. It is not a user configuration macro.  	 * @{  	 */ -	typedef unsigned char	bool_t; -	typedef char			int8_t; -	typedef unsigned char	uint8_t; -	typedef short			int16_t; -	typedef unsigned short	uint16_t; -	typedef long			int32_t; -	typedef unsigned long	uint32_t; +	typedef long long		gI64; +	typedef unsigned long long	gU64;  	/** @} */  	/** @@ -45,7 +57,6 @@  	 * @note	Your platform may use slightly different definitions to these  	 * @{  	 */ -	typedef unsigned long	size_t;  	typedef unsigned long	delaytime_t;  	typedef unsigned long	systemticks_t;  	typedef short			semcount_t; @@ -118,10 +129,6 @@  	/* Function declarations.                                                    */  	/*===========================================================================*/ -	#ifdef __cplusplus -	extern "C" { -	#endif -  	/**  	 * @brief	Halt the GFX application due to an error.  	 * @@ -354,26 +361,26 @@  	 * @brief	Wait on a semaphore  	 * @details	The semaphore counter is decreased and if the result becomes negative the thread waits for it to become  	 * 				non-negative again -	 * @return	FALSE if the wait timeout occurred otherwise TRUE +	 * @return	gFalse if the wait timeout occurred otherwise gTrue  	 *  	 * @param[in] psem		A pointer to the semaphore  	 * @param[in] ms		The maximum time to wait for the semaphore  	 *  	 * @api  	 */ -	bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); +	gBool gfxSemWait(gfxSem *psem, delaytime_t ms);  	/**  	 * @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 -	 * @return	FALSE if the wait would occur occurred otherwise TRUE +	 * @return	gFalse if the wait would occur occurred otherwise gTrue  	 *  	 * @param[in] psem		A pointer to the semaphore  	 *  	 * @iclass  	 * @api  	 */ -	bool_t gfxSemWaitI(gfxSem *psem); +	gBool gfxSemWaitI(gfxSem *psem);  	/**  	 * @brief	Signal a semaphore @@ -446,10 +453,6 @@  	 */  	void gfxThreadClose(gfxThreadHandle thread); -	#ifdef __cplusplus -	} -	#endif -  /**   * All the above was just for the doxygen documentation. All the implementation of the above   * (without any of the documentation overheads) is in the files below. diff --git a/src/gos/gos_arduino.h b/src/gos/gos_arduino.h index a9b0c140..b14f812a 100644 --- a/src/gos/gos_arduino.h +++ b/src/gos/gos_arduino.h @@ -31,29 +31,8 @@  /* Type definitions                                                          */  /*===========================================================================*/ -typedef unsigned char	bool_t; - -#if 0 -	// Already defined by Arduino -	typedef signed char		int8_t; -	typedef unsigned char	uint8_t; -	typedef signed short	int16_t; -	typedef unsigned short	uint16_t; -	typedef signed int		int32_t; -	typedef unsigned int	uint32_t; -	typedef uint32_t		size_t; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -	void gfxHalt(const char *msg); -	void gfxExit(void); - -#ifdef __cplusplus -} -#endif +void gfxHalt(const char *msg); +void gfxExit(void);  /*===========================================================================*/  /* Use the generic thread handling and heap handling                         */ diff --git a/src/gos/gos_chibios.c b/src/gos/gos_chibios.c index cb2193fe..725a8763 100644 --- a/src/gos/gos_chibios.c +++ b/src/gos/gos_chibios.c @@ -120,34 +120,34 @@ void gfxSemDestroy(gfxSem *psem)  	chSemReset(&psem->sem, 1);  } -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) +gBool gfxSemWait(gfxSem *psem, delaytime_t 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 TRUE; +		case TIME_INFINITE:		chSemWait(&psem->sem);	return gTrue;  		default:				return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != RDY_TIMEOUT;  		}  	#elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)  		switch(ms) {  		case TIME_IMMEDIATE:	return chSemWaitTimeout(&psem->sem, TIME_IMMEDIATE) != MSG_TIMEOUT; -		case TIME_INFINITE:		chSemWait(&psem->sem);	return TRUE; +		case TIME_INFINITE:		chSemWait(&psem->sem);	return gTrue;  		default:				return chSemWaitTimeout(&psem->sem, MS2ST(ms)) != MSG_TIMEOUT;  		}  	#endif  } -bool_t gfxSemWaitI(gfxSem *psem) +gBool gfxSemWaitI(gfxSem *psem)  {  	#if (CH_KERNEL_MAJOR == 2) || (CH_KERNEL_MAJOR == 3)  		if (psem->sem.s_cnt <= 0) -			return FALSE; +			return gFalse;  	#elif (CH_KERNEL_MAJOR == 4)  		if (psem->sem.cnt <= 0) -			return FALSE; +			return gFalse;  	#endif  	chSemFastWaitI(&psem->sem); -	return TRUE; +	return gTrue;  }  void gfxSemSignal(gfxSem *psem) diff --git a/src/gos/gos_chibios.h b/src/gos/gos_chibios.h index cb683631..7c0d1447 100644 --- a/src/gos/gos_chibios.h +++ b/src/gos/gos_chibios.h @@ -26,20 +26,10 @@  /*===========================================================================*/  /** - * bool_t, - * int8_t, uint8_t, - * int16_t, uint16_t, - * int32_t, uint32_t, - * size_t - * TRUE, FALSE   * TIME_IMMEDIATE, TIME_INFINITE   * are already defined by ChibiOS   */ -#if (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4) -	typedef char	bool_t; -#endif -  typedef systime_t	delaytime_t;  typedef systime_t	systemticks_t;  typedef cnt_t		semcount_t; @@ -66,7 +56,7 @@ typedef tprio_t		threadpriority_t;  #elif (CH_KERNEL_MAJOR == 3) || (CH_KERNEL_MAJOR == 4)  	#undef DECLARE_THREAD_STACK  	#define DECLARE_THREAD_STACK(a, b)  THD_WORKING_AREA(a, b) -	 +  	typedef struct {  		semaphore_t	sem;  		semcount_t	limit; @@ -81,10 +71,6 @@ typedef tprio_t		threadpriority_t;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  // First the kernel version specific ones  #if CH_KERNEL_MAJOR == 2  	#define gfxSystemTicks()			chTimeNow() @@ -113,8 +99,8 @@ void gfxSleepMilliseconds(delaytime_t ms);  void gfxSleepMicroseconds(delaytime_t ms);  void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem *psem); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem *psem); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem *psem);  void gfxSemSignal(gfxSem *psem);  void gfxSemSignalI(gfxSem *psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); @@ -122,9 +108,5 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_  #define gfxThreadMe()				chThdSelf()  #define gfxThreadClose(thread)		(void)thread -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_CHIBIOS */  #endif /* _GOS_CHIBIOS_H */ diff --git a/src/gos/gos_cmsis.c b/src/gos/gos_cmsis.c index 2798dcba..5859752b 100644 --- a/src/gos/gos_cmsis.c +++ b/src/gos/gos_cmsis.c @@ -61,16 +61,16 @@ void gfxSemDestroy(gfxSem* psem)  	osSemaphoreDelete(psem->id);  } -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms) +gBool gfxSemWait(gfxSem* psem, delaytime_t ms)  {  	if (osSemaphoreWait(psem->id, ms) > 0) {  		psem->available++; -		return TRUE; +		return gTrue;  	} -	return FALSE; +	return gFalse;  } -bool_t gfxSemWaitI(gfxSem* psem) +gBool gfxSemWaitI(gfxSem* psem)  {  	return gfxSemWait(psem, 0);  } diff --git a/src/gos/gos_cmsis.h b/src/gos/gos_cmsis.h index aad4cb84..72b59ce9 100644 --- a/src/gos/gos_cmsis.h +++ b/src/gos/gos_cmsis.h @@ -15,7 +15,6 @@  #if GFX_USE_OS_CMSIS -#include <stdbool.h>  #include "cmsis_os.h"  #ifndef GFX_OS_HEAP_SIZE @@ -26,8 +25,6 @@  /* Type definitions                                                          */  /*===========================================================================*/ -typedef bool				bool_t; -  #define TIME_IMMEDIATE		0  #define TIME_INFINITE		osWaitForever  typedef uint32_t			delaytime_t; @@ -62,10 +59,6 @@ typedef osThreadId			gfxThreadHandle;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  #define gfxExit()					os_error(0)  #define gfxHalt(msg)				os_error(1)  #define gfxSystemTicks()			osKernelSysTick() @@ -81,8 +74,8 @@ void gfxMutexInit(gfxMutex* pmutex);  void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem* psem); -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem* psem); +gBool gfxSemWait(gfxSem* psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem* psem);  void gfxSemSignal(gfxSem* psem);  void gfxSemSignalI(gfxSem* psem); @@ -91,10 +84,6 @@ gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_  #define gfxThreadMe()				osThreadGetId()  #define gfxThreadClose(thread)		{} -#ifdef __cplusplus -} -#endif -  /*===========================================================================*/  /* Use the generic heap handling                                             */  /*===========================================================================*/ diff --git a/src/gos/gos_cmsis2.c b/src/gos/gos_cmsis2.c index ca2d6eb6..46ee79cb 100644 --- a/src/gos/gos_cmsis2.c +++ b/src/gos/gos_cmsis2.c @@ -69,11 +69,11 @@ void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)  	*psem = osSemaphoreNew(limit, val, NULL);  } -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms) +gBool gfxSemWait(gfxSem* psem, delaytime_t ms)  {  	if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK) -		return TRUE; -	return FALSE; +		return gTrue; +	return gFalse;  }  gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param) diff --git a/src/gos/gos_cmsis2.h b/src/gos/gos_cmsis2.h index 1f4eab5e..7504d530 100644 --- a/src/gos/gos_cmsis2.h +++ b/src/gos/gos_cmsis2.h @@ -15,7 +15,6 @@  #if GFX_USE_OS_CMSIS2 -#include <stdbool.h>  #include "cmsis_os2.h"  #ifndef GFX_OS_HEAP_SIZE @@ -26,8 +25,6 @@  /* Type definitions                                                          */  /*===========================================================================*/ -typedef bool				bool_t; -  #define TIME_IMMEDIATE		0  #define TIME_INFINITE		osWaitForever  typedef uint32_t			delaytime_t; @@ -55,10 +52,6 @@ typedef osThreadId_t		gfxThreadHandle;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  #define gfxExit()					os_error(0)  #define gfxHalt(msg)				os_error(1)  #define gfxSystemTicks()			osKernelGetTickCount() @@ -74,7 +67,7 @@ void gfxMutexInit(gfxMutex* pmutex);  void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);  #define gfxSemDestroy(psem)		osSemaphoreDelete(*(psem)) -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms); +gBool gfxSemWait(gfxSem* psem, delaytime_t ms);  #define gfxSemWaitI(psem)		gfxSemWait((psem), 0)  #define gfxSemSignal(psem)		osSemaphoreRelease(*(psem))  #define gfxSemSignalI(psem)		osSemaphoreRelease(*(psem)) @@ -84,10 +77,6 @@ gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_  #define gfxThreadMe()				osThreadGetId()  #define gfxThreadClose(thread)		{} -#ifdef __cplusplus -} -#endif -  /*===========================================================================*/  /* Use the generic heap handling                                             */  /*===========================================================================*/ diff --git a/src/gos/gos_ecos.c b/src/gos/gos_ecos.c index a2af5dbf..2f875f0f 100644 --- a/src/gos/gos_ecos.c +++ b/src/gos/gos_ecos.c @@ -64,7 +64,7 @@ void gfxSemDestroy(gfxSem *psem)  	cyg_semaphore_destroy(&psem->sem);  } -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) +gBool gfxSemWait(gfxSem *psem, delaytime_t ms)  {  	switch(ms) {  	case TIME_IMMEDIATE:	return cyg_semaphore_trywait(&psem->sem); @@ -73,7 +73,7 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)  	}  } -bool_t gfxSemWaitI(gfxSem *psem) +gBool gfxSemWaitI(gfxSem *psem)  {  	return cyg_semaphore_trywait(&psem->sem);  } diff --git a/src/gos/gos_ecos.h b/src/gos/gos_ecos.h index b03243f3..910924c0 100644 --- a/src/gos/gos_ecos.h +++ b/src/gos/gos_ecos.h @@ -18,15 +18,6 @@  /* Type definitions                                                          */  /*===========================================================================*/ -typedef cyg_bool_t			bool_t; -typedef cyg_int8			int8_t; -typedef cyg_uint8	 		uint8_t; -typedef cyg_int16	 		int16_t; -typedef cyg_uint16	 		uint16_t; -typedef cyg_int32 			int32_t; -typedef cyg_uint32 			uint32_t; -typedef cyg_uint32 			size_t; -  #define TIME_IMMEDIATE		0  #define TIME_INFINITE		0xFFFFFFFF @@ -58,10 +49,6 @@ typedef cyg_mutex_t		gfxMutex;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  #define gfxSystemTicks()			cyg_current_time()  #define gfxExit()					exit(0)  #define gfxHalt(msg)				exit(-1) @@ -85,8 +72,8 @@ void gfxSleepMicroseconds(delaytime_t ms);  void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem *psem); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem *psem); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem *psem);  void gfxSemSignal(gfxSem *psem);  void gfxSemSignalI(gfxSem *psem); @@ -95,9 +82,5 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_  #define gfxThreadMe()				cyg_thread_self()  #define gfxThreadClose(thread)		(void)thread -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_ECOS */  #endif /* _GOS_ECOS_H */ diff --git a/src/gos/gos_freertos.c b/src/gos/gos_freertos.c index ff424e70..025d57b2 100644 --- a/src/gos/gos_freertos.c +++ b/src/gos/gos_freertos.c @@ -117,20 +117,20 @@ void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)  	#endif  } -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms) +gBool gfxSemWait(gfxSem* psem, delaytime_t ms)  {  	if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS) -		return TRUE; -	return FALSE; +		return gTrue; +	return gFalse;  } -bool_t gfxSemWaitI(gfxSem* psem) +gBool gfxSemWaitI(gfxSem* psem)  {  	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;  	if (xSemaphoreTakeFromISR(*psem, &xHigherPriorityTaskWoken) == pdTRUE) -		return TRUE; -	return FALSE; +		return gTrue; +	return gFalse;  }  void gfxSemSignal(gfxSem* psem) diff --git a/src/gos/gos_freertos.h b/src/gos/gos_freertos.h index 87ef8163..e7ee43b8 100644 --- a/src/gos/gos_freertos.h +++ b/src/gos/gos_freertos.h @@ -24,29 +24,8 @@  /* Type definitions                                                          */  /*===========================================================================*/ -/* Additional types are required when FreeRTOS 7.x is used */ -#if !defined(tskKERNEL_VERSION_MAJOR) && !tskKERNEL_VERSION_MAJOR == 8 -	typedef signed char					int8_t -	typedef unsigned char				uint8_t -	typedef signed int					int16_t -	typedef unsigned int				uint16_t -	typedef signed long int				int32_t -	typedef unsigned long int			uint32_t -	typedef signed long long int		int64_t -	typedef unsigned long long int		uint64_t -#endif - -/** - * bool_t, - * int8_t, uint8_t, - * int16_t, uint16_t, - * int32_t, uint32_t, - * size_t - * are already defined by FreeRTOS - */  #define TIME_IMMEDIATE		0  #define TIME_INFINITE		((delaytime_t)-1) -typedef int8_t				bool_t;  typedef uint32_t			delaytime_t;  typedef portTickType		systemticks_t;  typedef int32_t				semcount_t; @@ -71,10 +50,6 @@ typedef xTaskHandle				gfxThreadHandle;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  #define gfxHalt(msg)				{while(1);}  #define gfxExit()					{while(1);}  #define gfxAlloc(sz)				pvPortMalloc(sz) @@ -96,8 +71,8 @@ void gfxSleepMicroseconds(delaytime_t ms);  void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);  #define gfxSemDestroy(psem)			vSemaphoreDelete(*(psem)) -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem* psem); +gBool gfxSemWait(gfxSem* psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem* psem);  void gfxSemSignal(gfxSem* psem);  void gfxSemSignalI(gfxSem* psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); @@ -108,9 +83,5 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_  #endif  #define gfxThreadClose(thread) -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_FREERTOS */  #endif /* _GOS_CHIBIOS_H */ diff --git a/src/gos/gos_linux.c b/src/gos/gos_linux.c index bd4e0060..7e71ca95 100644 --- a/src/gos/gos_linux.c +++ b/src/gos/gos_linux.c @@ -145,13 +145,13 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  	void gfxSemDestroy(gfxSem *pSem) {  		sem_destroy(&pSem->sem);  	} -	bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) { +	gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {  		switch (ms) {  		case TIME_INFINITE: -			return sem_wait(&pSem->sem) ? FALSE : TRUE; +			return sem_wait(&pSem->sem) ? gFalse : gTrue;  		case TIME_IMMEDIATE: -			return sem_trywait(&pSem->sem) ? FALSE : TRUE; +			return sem_trywait(&pSem->sem) ? gFalse : gTrue;  		default:  			{ @@ -160,7 +160,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  				clock_gettime(CLOCK_REALTIME, &tm);  				tm.tv_sec += ms / 1000;  				tm.tv_nsec += (ms % 1000) * 1000000; -				return sem_timedwait(&pSem->sem, &tm) ? FALSE : TRUE; +				return sem_timedwait(&pSem->sem, &tm) ? gFalse : gTrue;  			}  		}  	} @@ -185,7 +185,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  		pthread_mutex_destroy(&pSem->mtx);  		pthread_cond_destroy(&pSem->cond);  	} -	bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) { +	gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {  		pthread_mutex_lock(&pSem->mtx);  		switch (ms) { @@ -197,7 +197,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  			case TIME_IMMEDIATE:  				if (!pSem->cnt) {  					pthread_mutex_unlock(&pSem->mtx); -					return FALSE; +					return gFalse;  				}  				break; @@ -211,11 +211,11 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  					while (!pSem->cnt) {  						// We used to test the return value for ETIMEDOUT. This doesn't  						//	work in some current pthread libraries which return -1 instead -						//	and set errno to ETIMEDOUT. So, we will return FALSE on any error +						//	and set errno to ETIMEDOUT. So, we will return gFalse on any error  						//	including a ETIMEDOUT.  						if (pthread_cond_timedwait(&pSem->cond, &pSem->mtx, &tm)) {  							pthread_mutex_unlock(&pSem->mtx); -							return FALSE; +							return gFalse;  						}  					}  				} @@ -224,7 +224,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {  		pSem->cnt--;  		pthread_mutex_unlock(&pSem->mtx); -		return TRUE; +		return gTrue;  	}  	void gfxSemSignal(gfxSem *pSem) {  		pthread_mutex_lock(&pSem->mtx); diff --git a/src/gos/gos_linux.h b/src/gos/gos_linux.h index f1973615..3d463226 100644 --- a/src/gos/gos_linux.h +++ b/src/gos/gos_linux.h @@ -17,16 +17,12 @@  #include <sys/types.h>  #include <stdlib.h> -#include <stdint.h>  #include <pthread.h>  #if GFX_USE_POSIX_SEMAPHORES  	#include <semaphore.h>  #endif -/* Already defined int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, size_t */ - -typedef int8_t				bool_t;  typedef unsigned long		systemticks_t;  typedef void *				threadreturn_t;  typedef unsigned long		delaytime_t; @@ -78,10 +74,6 @@ typedef pthread_mutex_t		gfxMutex;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  void gfxYield(void);  void gfxHalt(const char *msg);  void gfxSleepMilliseconds(delaytime_t ms); @@ -91,15 +83,11 @@ void gfxSystemLock(void);  void gfxSystemUnlock(void);  void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem *psem); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms);  void gfxSemSignal(gfxSem *psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);  threadreturn_t gfxThreadWait(gfxThreadHandle thread); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_LINUX */  #endif /* _GOS_LINUX_H */ diff --git a/src/gos/gos_nios.h b/src/gos/gos_nios.h index 75bf5676..3ef7756f 100644 --- a/src/gos/gos_nios.h +++ b/src/gos/gos_nios.h @@ -10,29 +10,16 @@  #if GFX_USE_OS_NIOS -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h>  #include <sys/alt_alarm.h>  typedef alt_u32 systemticks_t;  typedef alt_u32 delaytime_t; -typedef unsigned char bool_t; - -#ifdef __cplusplus -extern "C" { -#endif  void gfxHalt(const char* msg);  void gfxExit(void);  systemticks_t gfxSystemTicks(void);  systemticks_t gfxMillisecondsToTicks(delaytime_t ms); -#ifdef __cplusplus -} -#endif - -  // Use the generic thread handling and heap handling  #define GOS_NEED_X_THREADS	GFXON  #define GOS_NEED_X_HEAP		GFXON diff --git a/src/gos/gos_osx.c b/src/gos/gos_osx.c index 56d64d98..a09647ee 100644 --- a/src/gos/gos_osx.c +++ b/src/gos/gos_osx.c @@ -132,7 +132,7 @@ void gfxSemDestroy(gfxSem *pSem) {  	pthread_cond_destroy(&pSem->cond);  } -bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) { +gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {  	pthread_mutex_lock(&pSem->mtx);  	switch (ms) {  	case TIME_INFINITE: @@ -142,7 +142,7 @@ bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) {  	case TIME_IMMEDIATE:  		if (!pSem->cnt) {  			pthread_mutex_unlock(&pSem->mtx); -			return FALSE; +			return gFalse;  		}  		break;  	default: @@ -156,11 +156,11 @@ bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) {  			while (!pSem->cnt) {  				// We used to test the return value for ETIMEDOUT. This doesn't  				//	work in some current pthread libraries which return -1 instead -				//	and set errno to ETIMEDOUT. So, we will return FALSE on any error +				//	and set errno to ETIMEDOUT. So, we will return gFalse on any error  				//	including a ETIMEDOUT.  				if (pthread_cond_timedwait(&pSem->cond, &pSem->mtx, &tm)) {  					pthread_mutex_unlock(&pSem->mtx); -					return FALSE; +					return gFalse;  				}  			}  		} @@ -168,7 +168,7 @@ bool_t gfxSemWait(gfxSem *pSem, delaytime_t ms) {  	}  	pSem->cnt--;  	pthread_mutex_unlock(&pSem->mtx); -	return TRUE; +	return gTrue;  }  void gfxSemSignal(gfxSem *pSem) { diff --git a/src/gos/gos_osx.h b/src/gos/gos_osx.h index 94c67eab..6b5a762a 100644 --- a/src/gos/gos_osx.h +++ b/src/gos/gos_osx.h @@ -11,13 +11,9 @@  #if GFX_USE_OS_OSX  #include <sys/types.h> -#include <stdint.h>  #include <pthread.h>  #include <stdlib.h> -/* Already defined int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, size_t */ - -typedef int8_t				bool_t;  typedef unsigned long		systemticks_t;  typedef void *				threadreturn_t;  typedef unsigned long		delaytime_t; @@ -63,10 +59,6 @@ typedef struct gfxSem {  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  void gfxHalt(const char *msg);  void gfxSleepMilliseconds(delaytime_t ms);  void gfxSleepMicroseconds(delaytime_t ms); @@ -75,14 +67,10 @@ void gfxSystemLock(void);  void gfxSystemUnlock(void);  void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem *psem); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms);  void gfxSemSignal(gfxSem *psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);  threadreturn_t gfxThreadWait(gfxThreadHandle thread); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_OSX */  #endif /* _GOS_OSX_H */ diff --git a/src/gos/gos_qt.cpp b/src/gos/gos_qt.cpp index c6eb6f8d..4171d4fe 100644 --- a/src/gos/gos_qt.cpp +++ b/src/gos/gos_qt.cpp @@ -165,12 +165,12 @@ void gfxSemDestroy(gfxSem *psem)      delete static_cast<QSemaphore*>(*psem);  } -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) +gBool gfxSemWait(gfxSem *psem, delaytime_t ms)  {      return static_cast<QSemaphore*>(*psem)->tryAcquire(1, ms);  } -bool_t gfxSemWaitI(gfxSem *psem) +gBool gfxSemWaitI(gfxSem *psem)  {      return static_cast<QSemaphore*>(*psem)->tryAcquire(1);  } diff --git a/src/gos/gos_qt.h b/src/gos/gos_qt.h index 75947242..367e2a87 100644 --- a/src/gos/gos_qt.h +++ b/src/gos/gos_qt.h @@ -10,10 +10,6 @@  #if GFX_USE_OS_QT -#include <stdint.h> -#include <stddef.h> -#include <stdbool.h> -  #define DECLARE_THREAD_FUNCTION(fnName, param)	threadreturn_t fnName(void *param)  #define DECLARE_THREAD_STACK(name, sz)          uint8_t name[0]  #define THREAD_RETURN(retval)					return retval @@ -25,7 +21,6 @@  #define NORMAL_PRIORITY				3  #define HIGH_PRIORITY				4 -typedef bool bool_t;  typedef int systemticks_t;  typedef int delaytime_t;  typedef void* gfxMutex; @@ -35,10 +30,6 @@ typedef int threadreturn_t;  typedef int threadpriority_t;  typedef void* gfxThreadHandle; -#ifdef __cplusplus -extern "C" { -#endif -  void _gosInit();  void _gosDeinit(); @@ -60,8 +51,8 @@ void gfxMutexEnter(gfxMutex *pmutex);  void gfxMutexExit(gfxMutex *pmutex);  void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);  void gfxSemDestroy(gfxSem *psem); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem *psem); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem *psem);  void gfxSemSignal(gfxSem *psem);  void gfxSemSignalI(gfxSem *psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); @@ -69,9 +60,5 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread);  gfxThreadHandle gfxThreadMe(void);  void gfxThreadClose(gfxThreadHandle thread); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_QT */  #endif /* _GOS_QT_H */ diff --git a/src/gos/gos_raw32.h b/src/gos/gos_raw32.h index 5ff38028..6b6bce93 100644 --- a/src/gos/gos_raw32.h +++ b/src/gos/gos_raw32.h @@ -29,42 +29,8 @@  /* Type definitions                                                          */  /*===========================================================================*/ -typedef unsigned char	bool_t; - -#if __STDC_VERSION__ >= 199901L -	#include <stdint.h> -#elif defined(__GNUC__) || defined(__GNUG__) -	typedef __INT8_TYPE__	int8_t; -	typedef __UINT8_TYPE__	uint8_t; -	typedef __INT16_TYPE__	int16_t; -	typedef __UINT16_TYPE__	uint16_t; -	typedef __INT32_TYPE__	int32_t; -	typedef __UINT32_TYPE__	uint32_t; -#else -	typedef signed char		int8_t; -	typedef unsigned char	uint8_t; -	typedef signed short	int16_t; -	typedef unsigned short	uint16_t; -	typedef signed int		int32_t; -	typedef unsigned int	uint32_t; -#endif - -#if defined(__STDC__) -	#include <stddef.h> -#else -	typedef uint32_t		size_t; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -	void gfxHalt(const char *msg); -	void gfxExit(void); - -#ifdef __cplusplus -} -#endif +void gfxHalt(const char *msg); +void gfxExit(void);  /*===========================================================================*/  /* Use the generic thread handling and heap handling                         */ diff --git a/src/gos/gos_rawrtos.c b/src/gos/gos_rawrtos.c index 8ff53883..fd50a3f7 100644 --- a/src/gos/gos_rawrtos.c +++ b/src/gos/gos_rawrtos.c @@ -59,20 +59,20 @@ void gfxSleepMicroseconds(delaytime_t us)  	raw_sleep(ticks);  } -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms) +gBool gfxSemWait(gfxSem* psem, delaytime_t ms)  {  	systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;  	if(!ticks)ticks=1;  	if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS) -		return TRUE; -	return FALSE; +		return gTrue; +	return gFalse;  } -bool_t gfxSemWaitI(gfxSem* psem) +gBool gfxSemWaitI(gfxSem* psem)  {  	if(raw_semaphore_get((psem), TIME_IMMEDIATE)==RAW_SUCCESS) -		return TRUE; -	return FALSE; +		return gTrue; +	return gFalse;  }  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) diff --git a/src/gos/gos_rawrtos.h b/src/gos/gos_rawrtos.h index d1026c9d..8dc5549e 100644 --- a/src/gos/gos_rawrtos.h +++ b/src/gos/gos_rawrtos.h @@ -4,17 +4,14 @@  #if GFX_USE_OS_RAWRTOS  #include "raw_api.h" -#include <stdint.h>  #define TIME_IMMEDIATE		(RAW_NO_WAIT)  #define TIME_INFINITE		(RAW_WAIT_FOREVER) -typedef int8_t				bool_t;  typedef uint32_t			delaytime_t;  typedef RAW_TICK_TYPE		systemticks_t;  typedef int32_t				semcount_t;  typedef uint32_t			threadreturn_t;  typedef RAW_U8				threadpriority_t; -typedef uint32_t			size_t;  #define MAX_SEMAPHORE_COUNT	RAW_SEMAPHORE_COUNT  #define LOW_PRIORITY		(CONFIG_RAW_PRIO_MAX-2) @@ -53,7 +50,7 @@ typedef RAW_TASK_OBJ*		gfxThreadHandle;  extern RAW_VOID *raw_malloc(RAW_U32 size);  extern RAW_VOID raw_free(void *ptr);  extern RAW_VOID *raw_calloc(RAW_U32 nmemb, RAW_U32 size); -	 +  extern RAW_U16 raw_sleep(RAW_TICK_TYPE dly);  extern RAW_TICK_TYPE  raw_system_time_get(void); @@ -68,8 +65,8 @@ extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);  void gfxSleepMilliseconds(delaytime_t ms);  void gfxSleepMicroseconds(delaytime_t us); -bool_t gfxSemWait(gfxSem* psem, delaytime_t ms); -bool_t gfxSemWaitI(gfxSem* psem); +gBool gfxSemWait(gfxSem* psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem* psem);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);  #endif diff --git a/src/gos/gos_win32.c b/src/gos/gos_win32.c index 1aa13dd6..11b2e0aa 100644 --- a/src/gos/gos_win32.c +++ b/src/gos/gos_win32.c @@ -74,7 +74,7 @@ void gfxSystemUnlock(void) {  	ReleaseMutex(SystemMutex);  } -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) { +gBool gfxSemWait(gfxSem *psem, delaytime_t ms) {  	return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;  } diff --git a/src/gos/gos_win32.h b/src/gos/gos_win32.h index 62602ad3..3cdd5214 100644 --- a/src/gos/gos_win32.h +++ b/src/gos/gos_win32.h @@ -25,21 +25,6 @@  #include <malloc.h> -/* Stop cygwin from defining these types */ -#define __int8_t_defined - -/** - * size_t - * TRUE, FALSE - * are already defined by Win32 - */ -typedef __int8				bool_t; -typedef __int8				int8_t; -typedef unsigned __int8		uint8_t; -typedef __int16				int16_t; -typedef unsigned __int16	uint16_t; -typedef __int32				int32_t; -typedef unsigned __int32	uint32_t;  typedef DWORD				delaytime_t;  typedef DWORD				systemticks_t;  typedef LONG				semcount_t; @@ -85,22 +70,14 @@ typedef HANDLE gfxThreadHandle;  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  void gfxHalt(const char *msg);  void gfxSleepMicroseconds(delaytime_t ms); -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWait(gfxSem *psem, delaytime_t ms);  void gfxSystemLock(void);  void gfxSystemUnlock(void);  gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);  threadreturn_t gfxThreadWait(gfxThreadHandle thread); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_OS_WIN32 */  #endif /* _GOS_WIN32_H */ diff --git a/src/gos/gos_x_heap.h b/src/gos/gos_x_heap.h index 0fbfc905..1434b991 100644 --- a/src/gos/gos_x_heap.h +++ b/src/gos/gos_x_heap.h @@ -14,31 +14,23 @@  /* Type definitions                                                          */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { +#if GFX_OS_HEAP_SIZE != 0 || defined(__DOXYGEN__) +	/** +	 * @brief	Take a chunk of memory and add it to the available heap +	 * @note	Memory added must obviously not already be on the heap. +	 * @note	It is allowable to add multiple non-contiguous blocks of memory +	 * 			to the heap. If however it is contiguous with a previously added block +	 * 			it will get merged with the existing block in order to allow +	 * 			allocations that span the boundary. +	 * @pre		GFX_OS_HEAP_SIZE != 0 and an operating system that uses the +	 * 			internal ugfx heap allocator rather than its own allocator. +	 */ +	void gfxAddHeapBlock(void *ptr, size_t sz);  #endif -	#if GFX_OS_HEAP_SIZE != 0 || defined(__DOXYGEN__) -		/** -		 * @brief	Take a chunk of memory and add it to the available heap -		 * @note	Memory added must obviously not already be on the heap. -		 * @note	It is allowable to add multiple non-contiguous blocks of memory -		 * 			to the heap. If however it is contiguous with a previously added block -		 * 			it will get merged with the existing block in order to allow -		 * 			allocations that span the boundary. -		 * @pre		GFX_OS_HEAP_SIZE != 0 and an operating system that uses the -		 * 			internal ugfx heap allocator rather than its own allocator. -		 */ -		void gfxAddHeapBlock(void *ptr, size_t sz); -	#endif - -	void *gfxAlloc(size_t sz); -	void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz); -	void gfxFree(void *ptr); - -#ifdef __cplusplus -} -#endif +void *gfxAlloc(size_t sz); +void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz); +void gfxFree(void *ptr);  #endif /* GOS_NEED_X_HEAP */  #endif /* _GOS_X_HEAP_H */ diff --git a/src/gos/gos_x_threads.c b/src/gos/gos_x_threads.c index 52afd5c1..efff9f20 100644 --- a/src/gos/gos_x_threads.c +++ b/src/gos/gos_x_threads.c @@ -50,7 +50,7 @@ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit) {  	psem->limit = limit;  } -bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) { +gBool gfxSemWait(gfxSem *psem, delaytime_t ms) {  	systemticks_t	starttm, delay;  	// Convert our delay to ticks @@ -74,12 +74,12 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) {  		// Check if we have exceeded the defined delay  		switch (delay) {  		case TIME_IMMEDIATE: -			return FALSE; +			return gFalse;  		case TIME_INFINITE:  			break;  		default:  			if (gfxSystemTicks() - starttm >= delay) -				return FALSE; +				return gFalse;  			break;  		}  		gfxYield(); @@ -87,14 +87,14 @@ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms) {  	}  	psem->cnt--;  	INTERRUPTS_ON(); -	return TRUE; +	return gTrue;  } -bool_t gfxSemWaitI(gfxSem *psem) { +gBool gfxSemWaitI(gfxSem *psem) {  	if (psem->cnt <= 0) -		return FALSE; +		return gFalse;  	psem->cnt--; -	return TRUE; +	return gTrue;  }  void gfxSemSignal(gfxSem *psem) { @@ -243,7 +243,7 @@ static thread		mainthread;				// The main thread context  	 * MACROS:  	 *  	 *	AUTO_DETECT_STACKFRAME	GFXON/GFXOFF			- GFXON to auto-detect stack frame structure -	 *	STACK_DIR_UP			Macro/bool_t		- GFXON if the stack grows up instead of down +	 *	STACK_DIR_UP			Macro/gBool		- GFXON if the stack grows up instead of down  	 *	MASK1					Macro/uint32_t		- The 1st mask of jmp_buf elements that need relocation  	 *	MASK2					Macro/uint32_t		- The 2nd mask of jmp_buf elements that need relocation  	 *	STACK_BASE				Macro/size_t		- The base of the stack frame relative to the local variables @@ -275,7 +275,7 @@ static thread		mainthread;				// The main thread context  			jmp_buf		cxt;  		} saveloc; -		static bool_t		stackdirup; +		static gBool		stackdirup;  		static uint32_t		jmpmask1;  		static uint32_t		jmpmask2;  		static size_t		stackbase; @@ -384,7 +384,7 @@ static thread		mainthread;				// The main thread context  			}  		#endif  	} -	static void _gfxXSwitch(thread *oldt, thread *newt, bool_t doBuildFrame) { +	static void _gfxXSwitch(thread *oldt, thread *newt, gBool doBuildFrame) {  		// Save the old context  		if (CXT_SAVE(oldt->cxt)) return; @@ -415,8 +415,8 @@ static thread		mainthread;				// The main thread context  		CXT_RESTORE(newt->cxt, 1);  	} -	#define _gfxTaskSwitch(oldt, newt)		_gfxXSwitch(oldt, newt, FALSE) -	#define _gfxStartThread(oldt, newt)		_gfxXSwitch(oldt, newt, TRUE) +	#define _gfxTaskSwitch(oldt, newt)		_gfxXSwitch(oldt, newt, gFalse) +	#define _gfxStartThread(oldt, newt)		_gfxXSwitch(oldt, newt, gTrue)  #endif  #undef GFX_THREADS_DONE diff --git a/src/gos/gos_x_threads.h b/src/gos/gos_x_threads.h index 546e9e13..7f7b57e7 100644 --- a/src/gos/gos_x_threads.h +++ b/src/gos/gos_x_threads.h @@ -49,52 +49,44 @@ typedef struct {  typedef uint32_t		gfxMutex;  typedef void *			gfxThreadHandle; -#ifdef __cplusplus -extern "C" { -#endif - -	// Required timing functions - supplied by the user or the operating system -	systemticks_t gfxSystemTicks(void); -	systemticks_t gfxMillisecondsToTicks(delaytime_t ms); - -	// Sleep Functions -	void gfxSleepMilliseconds(delaytime_t ms); -	void gfxSleepMicroseconds(delaytime_t ms); -	void gfxYield(void); - -	// System Locking -	void gfxSystemLock(void); -	void gfxSystemUnlock(void); - -	// Mutexes -	void gfxMutexInit(gfxMutex *pmutex); -	#define gfxMutexDestroy(pmutex) -	void gfxMutexEnter(gfxMutex *pmutex); -	void gfxMutexExit(gfxMutex *pmutex); - -	// Semaphores -	void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit); -	#define gfxSemDestroy(psem) -	bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); -	bool_t gfxSemWaitI(gfxSem *psem); -	void gfxSemSignal(gfxSem *psem); -	void gfxSemSignalI(gfxSem *psem); - -	// Threads -	gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); -	#define gfxThreadClose(thread) -	threadreturn_t gfxThreadWait(gfxThreadHandle thread); -	gfxThreadHandle gfxThreadMe(void); - -	/** The following is not part of the public ugfx API as some operating systems -	 * 	simply do not provide this capability. -	 * 	For RAW32 we need it anyway so we might as well declare it here. -	 */ -	void gfxThreadExit(threadreturn_t ret); - -#ifdef __cplusplus -} -#endif +// Required timing functions - supplied by the user or the operating system +systemticks_t gfxSystemTicks(void); +systemticks_t gfxMillisecondsToTicks(delaytime_t ms); + +// Sleep Functions +void gfxSleepMilliseconds(delaytime_t ms); +void gfxSleepMicroseconds(delaytime_t ms); +void gfxYield(void); + +// System Locking +void gfxSystemLock(void); +void gfxSystemUnlock(void); + +// Mutexes +void gfxMutexInit(gfxMutex *pmutex); +#define gfxMutexDestroy(pmutex) +void gfxMutexEnter(gfxMutex *pmutex); +void gfxMutexExit(gfxMutex *pmutex); + +// Semaphores +void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit); +#define gfxSemDestroy(psem) +gBool gfxSemWait(gfxSem *psem, delaytime_t ms); +gBool gfxSemWaitI(gfxSem *psem); +void gfxSemSignal(gfxSem *psem); +void gfxSemSignalI(gfxSem *psem); + +// Threads +gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); +#define gfxThreadClose(thread) +threadreturn_t gfxThreadWait(gfxThreadHandle thread); +gfxThreadHandle gfxThreadMe(void); + +/** The following is not part of the public ugfx API as some operating systems + * 	simply do not provide this capability. + * 	For RAW32 we need it anyway so we might as well declare it here. + */ +void gfxThreadExit(threadreturn_t ret);  #endif /* GOS_NEED_X_THREADS */  #endif /* _GOS_X_THREADS_H */ diff --git a/src/gos/gos_zephyr.h b/src/gos/gos_zephyr.h index 0acb2c43..07f9107b 100644 --- a/src/gos/gos_zephyr.h +++ b/src/gos/gos_zephyr.h @@ -10,99 +10,79 @@  #if GFX_USE_OS_ZEPHYR
 -// #include <stdbool.h>
 -// #include <stdint.h>
 -
  #include <zephyr.h>
 -	/*===========================================================================*/
 -	/* Type definitions                                                          */
 -	/*===========================================================================*/
 -
 -	typedef bool	bool_t;
 -	typedef s8_t	int8_t;
 -	typedef u8_t	uint8_t;
 -	typedef s16_t	int16_t;
 -	typedef u16_t	uint16_t;
 -	typedef s32_t	int32_t;
 -	typedef u32_t	uint32_t;
 -
 -	// typedef unsigned long	size_t;
 -	typedef s32_t 	delaytime_t;
 -	typedef u32_t	systemticks_t;
 -	typedef u32_t	semcount_t;
 -	typedef void	threadreturn_t;
 -	typedef int	threadpriority_t;
 -
 -	#define DECLARE_THREAD_FUNCTION(fnName, param)\
 -		threadreturn_t fnName(void* param, void* p2, void* p3)
 -
 -	#define DECLARE_THREAD_STACK(name, sz)\
 -		K_THREAD_STACK_DEFINE(name, sz)
 -
 -	#define THREAD_RETURN(retval)		return
 -
 -	#define TIME_IMMEDIATE			K_NO_WAIT
 -	#define TIME_INFINITE			K_FOREVER
 -	#define MAX_SEMAPHORE_COUNT		((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
 -	#define LOW_PRIORITY			CONFIG_NUM_PREEMPT_PRIORITIES-1
 -	#define NORMAL_PRIORITY			1
 -	#define HIGH_PRIORITY			0
 -
 -	typedef struct k_sem gfxSem;
 -
 -	typedef struct k_mutex gfxMutex;
 -
 -	typedef k_tid_t gfxThreadHandle;
 -
 -	/*===========================================================================*/
 -	/* Function declarations.                                                    */
 -	/*===========================================================================*/
 -
 -	#ifdef __cplusplus
 -	extern "C" {
 -	#endif
 -
 -	#define gfxHalt(msg)	do{}while(0)
 -	#define gfxExit()		do{}while(0)
 -
 -	// Don't forget to set CONFIG_HEAP_MEM_POOL_SIZE
 -	 #define gfxAlloc(sz)					k_malloc(sz)
 -	 #define gfxFree(ptr)					k_free(ptr)
 -	 #define gfxRealloc(ptr, oldsz, newsz)	do{}while(0)
 -
 -	 #define gfxYield()						k_yield()
 -	 #define gfxSleepMilliseconds(ms)		k_sleep(ms)
 -	 #define gfxSleepMicroseconds(us)		do{}while(0)
 -	 #define gfxMillisecondsToTicks(ms)		CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000
 -	 systemticks_t gfxSystemTicks();
 -
 -	 #define gfxSystemLock()		k_sched_lock()
 -	 #define gfxSystemUnlock()		k_sched_unlock()
 -
 -	 #define gfxMutexInit(pmutex)		k_mutex_init(pmutex)
 -	 #define gfxMutexDestroy(pmutex)	do{}while(0)
 -	 #define gfxMutexEnter(pmutex)		k_mutex_lock(pmutex, K_FOREVER)
 -	 #define gfxMutexExit(pmutex)		k_mutex_unlock(pmutex)
 -
 -	 #define gfxSemInit(psem, val, limit) 	k_sem_init(psem, val, limit)
 -	 #define gfxSemDestroy(psem)			do{}while(0)
 -	 #define gfxSemWait(psem, ms)  			(k_sem_take(psem, ms) == 0) ? TRUE : FALSE
 -	 #define gfxSemWaitI(psem) 				(k_sem_take(psem, K_NO_WAIT) == 0) ? TRUE : FALSE
 -	 #define gfxSemSignal(psem)				k_sem_give(psem)
 -	 #define gfxSemSignalI(psem)			k_sem_give(psem)
 -	 #define gfxSemCounter(psem)			k_sem_count_get(psem)
 -	 #define gfxSemCounterI(psem)			k_sem_count_get(psem)
 -
 -	#define gfxThreadCreate(stackarea, stacksz, prio, fn, param)\
 -		k_thread_spawn(stackarea, stacksz, fn, param, NULL, NULL, prio, 0, K_NO_WAIT)
 -	#define gfxThreadWait(thread)		0
 -	#define gfxThreadMe()				k_current_get()
 -	#define gfxThreadClose(thread)		k_thread_abort(thread)
 -
 -	#ifdef __cplusplus
 -	}
 -	#endif
 +/*===========================================================================*/
 +/* Type definitions                                                          */
 +/*===========================================================================*/
 +
 +typedef s32_t 	delaytime_t;
 +typedef u32_t	systemticks_t;
 +typedef u32_t	semcount_t;
 +typedef void	threadreturn_t;
 +typedef int	threadpriority_t;
 +
 +#define DECLARE_THREAD_FUNCTION(fnName, param)\
 +	threadreturn_t fnName(void* param, void* p2, void* p3)
 +
 +#define DECLARE_THREAD_STACK(name, sz)\
 +	K_THREAD_STACK_DEFINE(name, sz)
 +
 +#define THREAD_RETURN(retval)		return
 +
 +#define TIME_IMMEDIATE			K_NO_WAIT
 +#define TIME_INFINITE			K_FOREVER
 +#define MAX_SEMAPHORE_COUNT		((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
 +#define LOW_PRIORITY			CONFIG_NUM_PREEMPT_PRIORITIES-1
 +#define NORMAL_PRIORITY			1
 +#define HIGH_PRIORITY			0
 +
 +typedef struct k_sem gfxSem;
 +
 +typedef struct k_mutex gfxMutex;
 +
 +typedef k_tid_t gfxThreadHandle;
 +
 +/*===========================================================================*/
 +/* Function declarations.                                                    */
 +/*===========================================================================*/
 +
 +#define gfxHalt(msg)	do{}while(0)
 +#define gfxExit()		do{}while(0)
 +
 +// Don't forget to set CONFIG_HEAP_MEM_POOL_SIZE
 +#define gfxAlloc(sz)					k_malloc(sz)
 +#define gfxFree(ptr)					k_free(ptr)
 +#define gfxRealloc(ptr, oldsz, newsz)	do{}while(0)
 +
 +#define gfxYield()						k_yield()
 +#define gfxSleepMilliseconds(ms)		k_sleep(ms)
 +#define gfxSleepMicroseconds(us)		do{}while(0)
 +#define gfxMillisecondsToTicks(ms)		CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000
 +systemticks_t gfxSystemTicks();
 +
 +#define gfxSystemLock()					k_sched_lock()
 +#define gfxSystemUnlock()				k_sched_unlock()
 +
 +#define gfxMutexInit(pmutex)			k_mutex_init(pmutex)
 +#define gfxMutexDestroy(pmutex)			do{}while(0)
 +#define gfxMutexEnter(pmutex)			k_mutex_lock(pmutex, K_FOREVER)
 +#define gfxMutexExit(pmutex)			k_mutex_unlock(pmutex)
 +
 +#define gfxSemInit(psem, val, limit) 	k_sem_init(psem, val, limit)
 +#define gfxSemDestroy(psem)				do{}while(0)
 +#define gfxSemWait(psem, ms)  			(k_sem_take(psem, ms) == 0) ? gTrue : gFalse
 +#define gfxSemWaitI(psem) 				(k_sem_take(psem, K_NO_WAIT) == 0) ? gTrue : gFalse
 +#define gfxSemSignal(psem)				k_sem_give(psem)
 +#define gfxSemSignalI(psem)				k_sem_give(psem)
 +#define gfxSemCounter(psem)				k_sem_count_get(psem)
 +#define gfxSemCounterI(psem)			k_sem_count_get(psem)
 +
 +#define gfxThreadCreate(stackarea, stacksz, prio, fn, param)\
 +	k_thread_spawn(stackarea, stacksz, fn, param, NULL, NULL, prio, 0, K_NO_WAIT)
 +#define gfxThreadWait(thread)			0
 +#define gfxThreadMe()					k_current_get()
 +#define gfxThreadClose(thread)			k_thread_abort(thread)
  #endif /* GFX_USE_OS_ZEPHYR */
  #endif /* _GOS_H */
 diff --git a/src/gqueue/gqueue.c b/src/gqueue/gqueue.c index e9143654..0e4c7020 100644 --- a/src/gqueue/gqueue.c +++ b/src/gqueue/gqueue.c @@ -133,8 +133,8 @@ void _gqueueDeinit(void)  		}  	} -	bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) { -		bool_t	res; +	gBool gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) { +		gBool	res;  		gfxSystemLock();  		res = gfxQueueASyncIsInI(pqueue, pitem); @@ -142,14 +142,14 @@ void _gqueueDeinit(void)  		return res;  	} -	bool_t gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) { +	gBool gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem) {  		gfxQueueASyncItem *pi;  		for(pi = pqueue->head; pi; pi = pi->next) {  			if (pi == pitem) -				return TRUE; +				return gTrue;  		} -		return FALSE; +		return gFalse;  	}  #endif @@ -271,8 +271,8 @@ void _gqueueDeinit(void)  		}  	} -	bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) { -		bool_t		res; +	gBool gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) { +		gBool		res;  		gfxSystemLock();  		res = gfxQueueGSyncIsInI(pqueue, pitem); @@ -280,14 +280,14 @@ void _gqueueDeinit(void)  		return res;  	} -	bool_t gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) { +	gBool gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem) {  		gfxQueueGSyncItem *pi;  		for(pi = pqueue->head; pi; pi = pi->next) {  			if (pi == pitem) -				return TRUE; +				return gTrue;  		} -		return FALSE; +		return gFalse;  	}  #endif @@ -320,7 +320,7 @@ void _gqueueDeinit(void)  		return pi;  	} -	bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) { +	gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {  		if (!pitem) return;				// Safety  		gfxSemInit(&pitem->sem, 0, 1);  		pitem->next = 0; @@ -339,7 +339,7 @@ void _gqueueDeinit(void)  		return gfxSemWait(&pitem->sem, ms);  	} -	bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) { +	gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {  		if (!pitem) return;				// Safety  		gfxSemInit(&pitem->sem, 0, 1); @@ -355,7 +355,7 @@ void _gqueueDeinit(void)  		return gfxSemWait(&pitem->sem, ms);  	} -	bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) { +	gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) {  		if (!pitem) return;				// Safety  		gfxSemInit(&pitem->sem, 0, 1); @@ -409,8 +409,8 @@ void _gqueueDeinit(void)  		gfxSystemUnlock();  	} -	bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) { -		bool_t	res; +	gBool gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) { +		gBool	res;  		gfxSystemLock();  		res = gfxQueueFSyncIsInI(pqueue, pitem); @@ -418,30 +418,30 @@ void _gqueueDeinit(void)  		return res;  	} -	bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) { +	gBool gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem) {  		gfxQueueASyncItem *pi;  		for(pi = pqueue->head; pi; pi = pi->next) {  			if (pi == pitem) -				return TRUE; +				return gTrue;  		} -		return FALSE; +		return gFalse;  	}  #endif  #if GQUEUE_NEED_BUFFERS -	bool_t gfxBufferAlloc(unsigned num, size_t size) { +	gBool gfxBufferAlloc(unsigned num, size_t size) {  		GDataBuffer *pd;  		if (num < 1) -			return FALSE; +			return gFalse;  		// Round up to a multiple of 4 to prevent problems with structure alignment  		size = (size + 3) & ~0x03;  		// Allocate the memory  		if (!(pd = gfxAlloc((size+sizeof(GDataBuffer)) * num))) -			return FALSE; +			return gFalse;  		// Add each of them to our free list  		for(;num--; pd = (GDataBuffer *)((char *)(pd+1)+size)) { @@ -449,14 +449,14 @@ void _gqueueDeinit(void)  			gfxBufferRelease(pd);  		} -		return TRUE; +		return gTrue;  	}  	void gfxBufferRelease(GDataBuffer *pd)		{ gfxQueueGSyncPut(&bufferFreeList, (gfxQueueGSyncItem *)pd); }  	void gfxBufferReleaseI(GDataBuffer *pd)		{ gfxQueueGSyncPutI(&bufferFreeList, (gfxQueueGSyncItem *)pd); }  	GDataBuffer *gfxBufferGet(delaytime_t ms)	{ return (GDataBuffer *)gfxQueueGSyncGet(&bufferFreeList, ms); }  	GDataBuffer *gfxBufferGetI(void)			{ return (GDataBuffer *)gfxQueueGSyncGetI(&bufferFreeList); } -	bool_t gfxBufferIsAvailable(void)			{ return bufferFreeList.head != 0; } +	gBool gfxBufferIsAvailable(void)			{ return bufferFreeList.head != 0; }  #endif diff --git a/src/gqueue/gqueue.h b/src/gqueue/gqueue.h index 40a41bce..c0da77d9 100644 --- a/src/gqueue/gqueue.h +++ b/src/gqueue/gqueue.h @@ -85,10 +85,6 @@ typedef struct GDataBuffer {  /* Function declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @name	Initialisation functions   * @brief	Initialise a queue. @@ -145,7 +141,7 @@ gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms);  /**   * @name	Put() Functions   * @brief	Put an item on the end of the queue. - * @return	none for ASync and GSync queues; For FSync queues - FALSE on timeout, otherwise TRUE + * @return	none for ASync and GSync queues; For FSync queues - gFalse on timeout, otherwise gTrue   *   * @param[in]	pqueue	A pointer to the queue   * @param[in]	pitem	A pointer to the queue item @@ -163,7 +159,7 @@ void gfxQueueASyncPut(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);  void gfxQueueASyncPutI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);  void gfxQueueGSyncPut(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);  void gfxQueueGSyncPutI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem); -bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms); +gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);  /** @} */  /** @@ -183,7 +179,7 @@ bool_t gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delayti  /**   * @name	Push() Functions   * @brief	Push an item into the start of the queue. - * @return	none for ASync and GSync queues; For FSync queues - FALSE on timeout, otherwise TRUE + * @return	none for ASync and GSync queues; For FSync queues - gFalse on timeout, otherwise gTrue   *   * @param[in]	pqueue	A pointer to the queue   * @param[in]	pitem	A pointer to the queue item @@ -201,13 +197,13 @@ void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);  void gfxQueueASyncPushI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);  void gfxQueueGSyncPush(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);  void gfxQueueGSyncPushI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem); -bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms); +gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);  /** @} */  /**   * @name	Insert() Functions   * @brief	Insert an item on the queue after the specified item. - * @return	none for ASync and GSync queues; For FSync queues - FALSE on timeout, otherwise TRUE + * @return	none for ASync and GSync queues; For FSync queues - gFalse on timeout, otherwise gTrue   *   * @param[in]	pqueue	A pointer to the queue   * @param[in]	pitem	A pointer to the queue item @@ -227,7 +223,7 @@ void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQue  void gfxQueueASyncInsertI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter);  void gfxQueueGSyncInsert(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter);  void gfxQueueGSyncInsertI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter); -bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms); +gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms);  /** @} */  /** @@ -256,7 +252,7 @@ void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem);  /**   * @name	isEmpty() Functions   * @brief	Is the queue empty? - * @return	TRUE if the queue is empty + * @return	gTrue if the queue is empty   *   * @param[in]	pqueue	A pointer to the queue   * @@ -276,7 +272,7 @@ void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem);  /**   * @name	IsInQueue() Functions   * @brief	Is an item in the queue? - * @return	TRUE if the item is in the queue? + * @return	gTrue if the item is in the queue?   *   * @param[in]	pqueue	A pointer to the queue   * @param[in]	pitem	A pointer to the queue item @@ -287,12 +283,12 @@ void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem);   * @api   * @{   */ -bool_t gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem); -bool_t gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem); -bool_t gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem); -bool_t gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem); -bool_t gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem); -bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem); +gBool gfxQueueASyncIsIn(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem); +gBool gfxQueueASyncIsInI(gfxQueueASync *pqueue, const gfxQueueASyncItem *pitem); +gBool gfxQueueGSyncIsIn(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem); +gBool gfxQueueGSyncIsInI(gfxQueueGSync *pqueue, const gfxQueueGSyncItem *pitem); +gBool gfxQueueFSyncIsIn(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem); +gBool gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem);  /** @} */  /** @@ -348,7 +344,7 @@ bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem)  /**   * @name		BufferAlloc() Functions   * @brief		Allocate some buffers and put them on the free list - * @return		TRUE is it succeeded. FALSE on allocation failure. + * @return		gTrue is it succeeded. gFalse on allocation failure.   *   * @param[in] num	The number of buffers to allocate   * @param[in] size	The size (in bytes) of each buffer @@ -356,18 +352,18 @@ bool_t gfxQueueFSyncIsInI(gfxQueueFSync *pqueue, const gfxQueueFSyncItem *pitem)   * @api   * @{   */ -bool_t gfxBufferAlloc(unsigned num, size_t size); +gBool gfxBufferAlloc(unsigned num, size_t size);  /** @} */  /**   * @name		BufferIsAvailable() Functions   * @brief		Is there one or more buffers currently available on the free list - * @return		TRUE if there are buffers in the free list + * @return		gTrue if there are buffers in the free list   *   * @api   * @{   */ -bool_t gfxBufferIsAvailable(void); +gBool gfxBufferIsAvailable(void);  /** @} */  /** @@ -402,11 +398,6 @@ void gfxBufferRelease(GDataBuffer *pd);  void gfxBufferReleaseI(GDataBuffer *pd);  /** @} */ - -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GQUEUE */  #endif /* _GQUEUE_H */  /** @} */ diff --git a/src/gtimer/gtimer.c b/src/gtimer/gtimer.c index 22ec9ed2..7ae0b652 100644 --- a/src/gtimer/gtimer.c +++ b/src/gtimer/gtimer.c @@ -136,7 +136,7 @@ void gtimerDeinit(GTimer* pt)  	gtimerStop(pt);  } -void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec) { +void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, delaytime_t millisec) {  	gfxMutexEnter(&mutex);  	// Start our thread if not already going @@ -205,8 +205,8 @@ void gtimerStop(GTimer *pt) {  	gfxMutexExit(&mutex);  } -bool_t gtimerIsActive(GTimer *pt) { -	return (pt->flags & GTIMER_FLG_SCHEDULED) ? TRUE : FALSE; +gBool gtimerIsActive(GTimer *pt) { +	return (pt->flags & GTIMER_FLG_SCHEDULED) ? gTrue : gFalse;  }  void gtimerJab(GTimer *pt) { diff --git a/src/gtimer/gtimer.h b/src/gtimer/gtimer.h index cecf8e70..402c3f1e 100644 --- a/src/gtimer/gtimer.h +++ b/src/gtimer/gtimer.h @@ -63,10 +63,6 @@ typedef struct GTimer_t {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Initialise a timer   * @@ -91,7 +87,7 @@ void gtimerDeinit(GTimer* pt);   * @param[in] pt	Pointer to a GTimer structure   * @param[in] fn		The callback function   * @param[in] param		The parameter to pass to the callback function - * @param[in] periodic	Is the timer a periodic timer? FALSE is a once-only timer. + * @param[in] periodic	Is the timer a periodic timer? gFalse is a once-only timer.   * @param[in] millisec	The timer period. The following special values are allowed:   *							TIME_IMMEDIATE	causes the callback function to be called asap.   *											A periodic timer with this value will fire once only. @@ -114,7 +110,7 @@ void gtimerDeinit(GTimer* pt);   *   * @api   */ -void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec); +void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, delaytime_t millisec);  /**   * @brief   Stop a timer (periodic or otherwise) @@ -132,11 +128,11 @@ void gtimerStop(GTimer *pt);   *   * @param[in] pt		Pointer to a GTimer structure   * - * @return	TRUE if active, FALSE otherwise + * @return	gTrue if active, gFalse otherwise   *   * @api   */ -bool_t gtimerIsActive(GTimer *pt); +gBool gtimerIsActive(GTimer *pt);  /**   * @brief   			Jab a timer causing the current period to immediate expire @@ -169,10 +165,6 @@ void gtimerJab(GTimer *pt);   */  void gtimerJabI(GTimer *pt); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GTIMER */  #endif /* _GTIMER_H */ diff --git a/src/gtrans/gtrans.h b/src/gtrans/gtrans.h index da3cae5e..49d5d168 100644 --- a/src/gtrans/gtrans.h +++ b/src/gtrans/gtrans.h @@ -31,10 +31,6 @@ typedef struct transTable {  	const char** strings;	/**< The translated strings */  } transTable; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief A wrapper macro to make writing and reading translatable applications easier.   */ @@ -84,10 +80,6 @@ void gtransSetBaseLanguage(const transTable* const translation);   */  void gtransSetLanguage(const transTable* const translation); -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GTRANS */  #endif /* _TRANS_H */ diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index 2de0c125..7bc257bf 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -121,7 +121,7 @@ void _gwinDestroy(GHandle gh, GRedrawMethod how) {  		return;  	// Make the window invisible -	gwinSetVisible(gh, FALSE); +	gwinSetVisible(gh, gFalse);  	// Make sure it is flushed first - must be REDRAW_WAIT or REDRAW_INSESSION  	_gwinFlushRedraws(how); @@ -209,12 +209,12 @@ const char *gwinGetClassName(GHandle gh) {  	return gh->vmt->classname;  } -bool_t gwinGetVisible(GHandle gh) { -	return (gh->flags & GWIN_FLG_SYSVISIBLE) ? TRUE : FALSE; +gBool gwinGetVisible(GHandle gh) { +	return (gh->flags & GWIN_FLG_SYSVISIBLE) ? gTrue : gFalse;  } -bool_t gwinGetEnabled(GHandle gh) { -	return (gh->flags & GWIN_FLG_SYSENABLED) ? TRUE : FALSE; +gBool gwinGetEnabled(GHandle gh) { +	return (gh->flags & GWIN_FLG_SYSENABLED) ? gTrue : gFalse;  }  #if GDISP_NEED_TEXT @@ -395,7 +395,7 @@ void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coor  		gdispGFillConvexPoly(gh->display, tx+gh->x, ty+gh->y, pntarray, cnt, gh->color);  		_gwinDrawEnd(gh);  	} -	void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round) { +	void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, gBool round) {  		if (!_gwinDrawStart(gh)) return;  		gdispGDrawThickLine(gh->display, gh->x+x0, gh->y+y0, gh->x+x1, gh->y+y1, gh->color, width, round);  		_gwinDrawEnd(gh); diff --git a/src/gwin/gwin.h b/src/gwin/gwin.h index 54421bd4..79768366 100644 --- a/src/gwin/gwin.h +++ b/src/gwin/gwin.h @@ -77,7 +77,7 @@ typedef struct GWindowInit {  	coord_t			y;								/**< The initial position relative to its parent */  	coord_t			width;							/**< The width */  	coord_t			height;							/**< The height */ -	bool_t			show;							/**< Should the window be visible initially */ +	gBool			show;							/**< Should the window be visible initially */  	#if GWIN_NEED_CONTAINERS  		GHandle		parent;							/**< The parent - must be a container or NULL */  	#endif @@ -89,10 +89,6 @@ typedef struct GWindowInit {   */  typedef enum { GWIN_NORMAL, GWIN_MAXIMIZE, GWIN_MINIMIZE } GWindowMinMax; -#ifdef __cplusplus -extern "C" { -#endif -  /*-------------------------------------------------   * Window Manager functions   *-------------------------------------------------*/ @@ -122,978 +118,974 @@ extern "C" {   * Functions that affect all windows   *-------------------------------------------------*/ +/** + * @brief	Clear a GWindowInit structure to all zero's + * @note	This function is provided just to prevent problems + * 			on operating systems where using memset() causes issues + * 			in the users application. + * + * @param[in] pwi	The GWindowInit structure to clear + * + * @api + */ +void gwinClearInit(GWindowInit *pwi); + +/** + * @brief	Set the default foreground color for all new GWIN windows + * + * @param[in] clr	The color to be set + * + * @api + */ +void gwinSetDefaultColor(color_t clr); + +/** + * @brief	Get the default foreground color for all new GWIN windows + * + * @return	The current default color for all new GWIN windows + * + * @api + */ +color_t gwinGetDefaultColor(void); + +/** + * @brief	Set the default background color for all new GWIN windows + * + * @param[in] bgclr	The background color + * + * @api + */ +void gwinSetDefaultBgColor(color_t bgclr); + +/** + * @brief	Get the default background color for all new GWIN windows + * + * @return	The current default background color for all new GWIN windows + * + * @api + */ +color_t gwinGetDefaultBgColor(void); + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__)  	/** -	 * @brief	Clear a GWindowInit structure to all zero's -	 * @note	This function is provided just to prevent problems -	 * 			on operating systems where using memset() causes issues -	 * 			in the users application. +	 * @brief	Set the default font for all new GWIN windows  	 * -	 * @param[in] pwi	The GWindowInit structure to clear +	 * @param[in] font	The new font to be set  	 *  	 * @api  	 */ -	void gwinClearInit(GWindowInit *pwi); +	void gwinSetDefaultFont(font_t font);  	/** -	 * @brief	Set the default foreground color for all new GWIN windows +	 * @brief	Get the current default font  	 * -	 * @param[in] clr	The color to be set +	 * @return	The current default font  	 *  	 * @api  	 */ -	void gwinSetDefaultColor(color_t clr); +	font_t gwinGetDefaultFont(void); +#endif + +/*------------------------------------------------- +* Base functions +*-------------------------------------------------*/ + +/** + * @brief   Create a basic window. + * @return  NULL if there is no resultant drawing area, otherwise a window handle. + * + * @param[in] g			The GDisplay to display this window on + * @param[in] pgw		The window structure to initialize. If this is NULL the structure is dynamically allocated. + * @param[in] pInit		How to initialise the window + * + * @note				The drawing color and the background color get set to the current defaults. If you haven't called + * 						@p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are GFX_WHITE and GFX_BLACK respectively. + * @note				The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there + * 						is no default font and text drawing operations will no nothing. + * @note				A basic window does not save the drawing state. It is not automatically redrawn if the window is moved or + * 						its visibility state is changed. + * + * @api + */ +GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit); +#define gwinWindowCreate(pgw, pInit)		gwinGWindowCreate(GDISP, pgw, pInit); + +/** + * @brief   Destroy a window (of any type). Releases any dynamically allocated memory. + * + * @param[in] gh		The window handle + * + * @api + */ +void gwinDestroy(GHandle gh); + +/** + * @brief	Get the real class name of the GHandle + * @details	Returns a string describing the object class. + * + * @param[in] gh	The window + * + * @return	A string describing the object class. + * + * @api + */ +const char* gwinGetClassName(GHandle gh); + +/** + * @brief	Get an ID that uniquely describes the class of the GHandle + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetClassID(gh)		((void *)((gh)->vmt)) + +/** + * @brief	Get the X coordinate of the window + * @details	Returns the X coordinate of the origin of the window. + *			The coordinate is relative to the physical screen zero point. + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetScreenX(gh)			((gh)->x) + +/** + * @brief	Get the Y coordinate of the window + * @details	Returns the Y coordinate of the origin of the window. + *			The coordinate is relative to the physical screen zero point. + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetScreenY(gh)			((gh)->y) + +/** + * @brief	Get the width of the window + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetWidth(gh)			((gh)->width) + +/** + * @brief	Get the height of the window + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetHeight(gh)			((gh)->height) + +/** + * @brief	Set foreground color + * @details Set the color which will be used to draw + * + * @param[in] gh	The window + * @param[in] clr	The color to be set + * + * @api + */ +#define gwinSetColor(gh, clr)		(gh)->color = (clr) + +/** + * @brief	Set background color + * @details	Set the color which will be used as background + * @note	gwinClear() must be called to set the background color + * + * @param[in] gh	The window + * @param[in] bgclr	The background color + * + * @api + */ +#define gwinSetBgColor(gh, bgclr)	(gh)->bgcolor = (bgclr) + +/** + * @brief	Get the foreground color of a window + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetColor(gh)			(gh)->color +/** + * @brief	Get the background color of a window + * + * @param[in] gh	The window + * + * @api + */ +#define gwinGetBgColor(gh)			(gh)->bgcolor + +/** + * @brief	Sets whether a window is visible or not + * + * @param[in] gh		The window + * @param[in] visible	Whether the window should be visible or not + * + * @note	When a window is marked as not visible, drawing operations + * 			on the window do nothing. + * @note	When a window is marked as visible, it is not automatically + * 			redrawn as many window types don't remember their drawing state. + * 			Widgets such as Buttons, Sliders etc will be redrawn. + * @note	If there is no window manager in use, when a window is marked + * 			as not visible, nothing is done to remove the window from the screen. + * 			When there is a window manager, it is up to the window manager to + * 			handle what happens. + * @note	Even when you mark a window as visible, it may still not be displayed + * 			if it's parent is invisible. When the parent becomes visible this child + * 			will automatically be shown because it is already marked as visible. + * + * @api + */ +void gwinSetVisible(GHandle gh, gBool visible); + +/** + * @brief	Makes a widget become visible + * + * @param[in] gh		The window handle + * + * @api + */ +#define gwinShow(gh)		gwinSetVisible(gh, gTrue) + +/** + * @brief	Makes a widget become invisible + * + * @param[in] gh		The window handle + * + * @api + */ +#define gwinHide(gh)		gwinSetVisible(gh, gFalse) + +/** + * @brief	Gets the visibility of a window + * @return	gTrue if visible + * + * @note	It is possible for a child to be marked as visible by @p gwinSetVisible() + * 			but for this call to return gFalse if one of its parents are not visible. + * + * @param[in] gh		The window + * + * @api + */ +gBool gwinGetVisible(GHandle gh); + +/** + * @brief	Enable or disable a window + * + * @param[in] gh		The window handle + * @param[in] enabled	Enable or disable the window + * + * @note	The window is automatically redrawn if it supports self-redrawing. + * @note	Even when you mark a window as enabled, it may still remain disabled + * 			if it's parent is disabled. When the parent becomes enabled this child + * 			will automatically be enabled because it is already marked as enabled. + * + * @api + */ +void gwinSetEnabled(GHandle gh, gBool enabled); + +/** + * @brief	Enables a widget + * + * @param[in] gh		The window handle + * + * @api + */ +#define gwinEnable(gh)		gwinSetEnabled(gh, gTrue) + +/** + * @brief	Disables a widget + * + * @param[in] gh		The window handle + * + * @api + */ +#define gwinDisable(gh)		gwinSetEnabled(gh, gFalse) + +/** + * @brief	Gets the enabled state of a window + * @return	gTrue if enabled + * + * @note	It is possible for a child to be marked as enabled by @p gwinSetEnabled() + * 			but for this call to return gFalse if one of its parents are not enabled. + * + * @param[in] gh		The window + * + * @api + */ +gBool gwinGetEnabled(GHandle gh); + +/** + * @brief	Move a window + * + * @param[in] gh		The window + * @param[in] x, y		The new position (screen relative) for this window + * + * @note	The final window position may not be the requested position. Windows + * 			are clipped to the screen area and the window manager may also affect the position. + * @note	The window is redrawn if it is visible. See the comments in @p gwinSetVisible() + * 			with regard to what can be redrawn and what can't. + * @note	It is up to the window manager to determine what happens with the screen area + * 			uncovered by moving the window. When there is no window manager, nothing + * 			is done with the uncovered area. + * + * @api + */ +void gwinMove(GHandle gh, coord_t x, coord_t y); + +/** + * @brief	Resize a window + * + * @param[in] gh				The window + * @param[in] width, height		The new size of the window + * + * @note	The final window size may not be the requested size. Windows + * 			are clipped to the screen area and the window manager may also affect the size. + * @note	The window is redrawn if it is visible. See the comments in @p gwinSetVisible() + * 			with regard to what can be redrawn and what can't. + * @note	It is up to the window manager to determine what happens with any screen area + * 			uncovered by resizing the window. When there is no window manager, nothing + * 			is done with the uncovered area. + * + * @api + */ +void gwinResize(GHandle gh, coord_t width, coord_t height); + +/** + * @brief	Redraw a window + * + * @param[in] gh				The window + * + * @note	This is normally never required as windows and widgets will redraw as required. + * 			Note that some windows are incapable of redrawing themselves as they don't save + * 			their drawing state. + * + * @api + */ +void gwinRedraw(GHandle gh); + +#if GWIN_NEED_WINDOWMANAGER || defined (__DOXYGEN__)  	/** -	 * @brief	Get the default foreground color for all new GWIN windows +	 * @brief	Redraw a display +	 * +	 * @param[in] g				The display to redraw. Passing NULL will redraw all displays. +	 * @param[in] preserve		Should the redraw try to preserve existing screen data for those +	 * 							windows that can't redraw themselves?  	 * -	 * @return	The current default color for all new GWIN windows +	 * @note	This is normally never required as windows and widgets will redraw as required. +	 * @note	Some windows are incapable of redrawing themselves as they don't save +	 * 			their drawing state. +	 * @note	This does not clear the background - just redraws the gwin windows (where possible)  	 *  	 * @api  	 */ -	color_t gwinGetDefaultColor(void); +	void gwinRedrawDisplay(GDisplay *g, gBool preserve);  	/** -	 * @brief	Set the default background color for all new GWIN windows +	 * @brief	Minimize, Maximize or Restore a window +	 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON  	 * -	 * @param[in] bgclr	The background color +	 * @param[in] gh				The window +	 * @param[in] minmax			The new minimized/maximized state +	 * +	 * @note	The final window state may not be the requested state. Window Managers +	 * 			do not need to implement changing the minmax state. If there is no +	 * 			window manager this call is ignored. +	 * @note	The window is redrawn if it is changed. See the comments in @p gwinSetVisible() +	 * 			with regard to what can be redrawn and what can't. +	 * @note	It is up to the window manager to determine what happens with any screen area +	 * 			uncovered by resizing the window. +	 * @note	When a window is minimised it may be asked to draw the window or the window +	 * 			manager may draw the minimised window.  	 *  	 * @api  	 */ -	void gwinSetDefaultBgColor(color_t bgclr); +	void gwinSetMinMax(GHandle gh, GWindowMinMax minmax);  	/** -	 * @brief	Get the default background color for all new GWIN windows +	 * @brief	Get the Minimized/Maximized state of a window +	 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON  	 * -	 * @return	The current default background color for all new GWIN windows +	 * @param[in] gh				The window +	 * +	 * @return	GWIN_NORMAL, GWIN_MAXIMIZE or GWIN_MINIMIZE  	 *  	 * @api  	 */ -	color_t gwinGetDefaultBgColor(void); - -	#if GDISP_NEED_TEXT || defined(__DOXYGEN__) -		/** -		 * @brief	Set the default font for all new GWIN windows -		 * -		 * @param[in] font	The new font to be set -		 * -		 * @api -		 */ -		void gwinSetDefaultFont(font_t font); - -		/** -		 * @brief	Get the current default font -		 * -		 * @return	The current default font -		 * -		 * @api -		 */ -		font_t gwinGetDefaultFont(void); -	#endif - -/*------------------------------------------------- - * Base functions - *-------------------------------------------------*/ +	GWindowMinMax gwinGetMinMax(GHandle gh);  	/** -	 * @brief   Create a basic window. -	 * @return  NULL if there is no resultant drawing area, otherwise a window handle. +	 * @brief	Raise a window to the top of the z-order +	 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON  	 * -	 * @param[in] g			The GDisplay to display this window on -	 * @param[in] pgw		The window structure to initialize. If this is NULL the structure is dynamically allocated. -	 * @param[in] pInit		How to initialise the window +	 * @param[in] gh				The window  	 * -	 * @note				The drawing color and the background color get set to the current defaults. If you haven't called -	 * 						@p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are GFX_WHITE and GFX_BLACK respectively. -	 * @note				The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there -	 * 						is no default font and text drawing operations will no nothing. -	 * @note				A basic window does not save the drawing state. It is not automatically redrawn if the window is moved or -	 * 						its visibility state is changed. +	 * @note	The window z-order is only supported by some window managers. See the comments +	 * 			in @p gwinSetVisible() with regard to what can be redrawn and what can't.  	 *  	 * @api  	 */ -	GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit); -	#define gwinWindowCreate(pgw, pInit)		gwinGWindowCreate(GDISP, pgw, pInit); +	void gwinRaise(GHandle gh);  	/** -	 * @brief   Destroy a window (of any type). Releases any dynamically allocated memory. +	 * @brief	Get the next window in the z-order +	 * @return	The next window or NULL if no more windows  	 * -	 * @param[in] gh		The window handle +	 * @param[in] gh		The previous window or NULL to get the first window +	 * +	 * @note	This returns the next window in the system from top to bottom. +	 * @note	Where there are parent child relationships, this ignores them +	 * 			and will list all windows in the system. There is no defined +	 * 			order between children of siblings and they can in fact be mixed +	 * 			in order. The only relationship honored is that parents will be +	 * 			listed before their children.  	 *  	 * @api  	 */ -	void gwinDestroy(GHandle gh); +	GHandle gwinGetNextWindow(GHandle gh);  	/** -	 * @brief	Get the real class name of the GHandle -	 * @details	Returns a string describing the object class. +	 * @brief	Set a window or widget to flash  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] flash		Enable or disable the flashing of the window  	 * -	 * @return	A string describing the object class. +	 * @note	The window is automatically redrawn if it supports self-redrawing. +	 * @note	When a window is set to flash, its appearance changes in some +	 * 			way every flash period (GWIN_FLASHING_PERIOD). How its appearance +	 * 			changes depends on the draw for each window/widget. +	 * +	 * @pre		Requires GWIN_NEED_FLASHING to be GFXON  	 *  	 * @api  	 */ -	const char* gwinGetClassName(GHandle gh); +	void gwinSetFlashing(GHandle gh, gBool flash);  	/** -	 * @brief	Get an ID that uniquely describes the class of the GHandle +	 * @brief	Enables flashing of a window or widget  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle  	 *  	 * @api  	 */ -	#define gwinGetClassID(gh)		((void *)((gh)->vmt)) +	#define gwinFlash(gh)		gwinSetFlashing(gh, gTrue)  	/** -	 * @brief	Get the X coordinate of the window -	 * @details	Returns the X coordinate of the origin of the window. -	 *			The coordinate is relative to the physical screen zero point. +	 * @brief	Disables a widget  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle  	 *  	 * @api  	 */ -	#define gwinGetScreenX(gh)			((gh)->x) +	#define gwinNoFlash(gh)		gwinSetFlashing(gh, gFalse) +#endif +#if GDISP_NEED_TEXT || defined(__DOXYGEN__)  	/** -	 * @brief	Get the Y coordinate of the window -	 * @details	Returns the Y coordinate of the origin of the window. -	 *			The coordinate is relative to the physical screen zero point. +	 * @brief   Set the current font for this window.  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] font		The font to use for text functions  	 *  	 * @api  	 */ -	#define gwinGetScreenY(gh)			((gh)->y) +	void gwinSetFont(GHandle gh, font_t font); +#endif + +/*------------------------------------------------- +* Drawing functions +*-------------------------------------------------*/ + +/** + * @brief   Clear the window + * @note	Uses the current background color to clear the window + * + * @param[in] gh		The window handle + * + * @api + */ +void gwinClear(GHandle gh); + +/** + * @brief   Set a pixel in the window + * @note	Uses the current foreground color to set the pixel + * @note	May leave GDISP clipping to this window's dimensions + * + * @param[in] gh		The window handle + * @param[in] x,y		The coordinates of the pixel + * + * @api + */ +void gwinDrawPixel(GHandle gh, coord_t x, coord_t y); + +/** + * @brief   Draw a line in the window + * @note	Uses the current foreground color to draw the line + * @note	May leave GDISP clipping to this window's dimensions + * + * @param[in] gh		The window handle + * @param[in] x0,y0		The start position + * @param[in] x1,y1 	The end position + * + * @api + */ +void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1); +/** + * @brief   Draw a box in the window + * @note	Uses the current foreground color to draw the box + * @note	May leave GDISP clipping to this window's dimensions + * + * @param[in] gh		The window handle + * @param[in] x,y		The start position + * @param[in] cx,cy		The size of the box (outside dimensions) + * + * @api + */ +void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy); + +/** + * @brief   Fill an rectangular area in the window + * @note	Uses the current foreground color to fill the box + * @note	May leave GDISP clipping to this window's dimensions + * + * @param[in] gh		The window handle + * @param[in] x,y		The start position + * @param[in] cx,cy		The size of the box (outside dimensions) + * + * @api + */ +void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy); + +/** + * @brief   Fill an area in the window using the supplied bitmap. + * @details The bitmap is in the pixel format specified by the low level driver + * @note	If GDISP_NEED_ASYNC is defined then the buffer must be static + * 			or at least retained until this call has finished the blit. You can + * 			tell when all graphics drawing is finished by @p gdispIsBusy() going gFalse. + * @note	May leave GDISP clipping to this window's dimensions + * + * @param[in] gh		The window handle + * @param[in] x, y		The start filled area + * @param[in] cx, cy	The width and height to be filled + * @param[in] srcx, srcy	The bitmap position to start the fill from + * @param[in] srccx		The width of a line in the bitmap. + * @param[in] buffer	The pixels to use to fill the area. + * + * @api + */ +void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); + +/*------------------------------------------------- +* Circle, ellipse, arc and arc-sectors functions +*-------------------------------------------------*/ + +#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__)  	/** -	 * @brief	Get the width of the window +	 * @brief   Draw a circle in the window. +	 * @note	Uses the current foreground color to draw the circle +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] x, y		The center of the circle +	 * @param[in] radius	The radius of the circle  	 *  	 * @api  	 */ -	#define gwinGetWidth(gh)			((gh)->width) +	void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);  	/** -	 * @brief	Get the height of the window +	 * @brief   Draw a filled circle in the window. +	 * @note	Uses the current foreground color to draw the filled circle +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] x, y		The center of the circle +	 * @param[in] radius	The radius of the circle  	 *  	 * @api  	 */ -	#define gwinGetHeight(gh)			((gh)->height) +	void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius); +#endif +#if GDISP_NEED_DUALCIRCLE || defined(__DOXYGEN__)  	/** -	 * @brief	Set foreground color -	 * @details Set the color which will be used to draw +	 * @brief   Draw two filled circles with the same centre in the window. +	 * @note	Uses the current foreground color to draw the inner circle +	 * @note	Uses the current background color to draw the outer circle +	 * @note	May leave GDISP clipping to this window's dimensions +	 * @pre		GDISP_NEED_DUALCIRCLE must be GFXON in your gfxconf.h  	 * -	 * @param[in] gh	The window -	 * @param[in] clr	The color to be set +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center of the circle +	 * @param[in] radius1	The radius of the larger circle +	 * @param[in] radius2	The radius of the smaller circle  	 *  	 * @api  	 */ -	#define gwinSetColor(gh, clr)		(gh)->color = (clr) +	void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, coord_t radius2); +#endif +#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__)  	/** -	 * @brief	Set background color -	 * @details	Set the color which will be used as background -	 * @note	gwinClear() must be called to set the background color +	 * @brief   Draw an ellipse. +	 * @note	Uses the current foreground color to draw the ellipse +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh	The window -	 * @param[in] bgclr	The background color +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center of the ellipse +	 * @param[in] a,b		The dimensions of the ellipse  	 *  	 * @api  	 */ -	#define gwinSetBgColor(gh, bgclr)	(gh)->bgcolor = (bgclr) +	void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);  	/** -	 * @brief	Get the foreground color of a window +	 * @brief   Draw an filled ellipse. +	 * @note	Uses the current foreground color to draw the filled ellipse +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center of the ellipse +	 * @param[in] a,b		The dimensions of the ellipse  	 *  	 * @api  	 */ -	#define gwinGetColor(gh)			(gh)->color +	void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b); +#endif -	/** -	 * @brief	Get the background color of a window +#if GDISP_NEED_ARC || defined(__DOXYGEN__) +	/* +	 * @brief	Draw an arc in the window. +	 * @note	Uses the current foreground color to draw the arc +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh	The window +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center point +	 * @param[in] radius	The radius of the arc +	 * @param[in] start		The start angle (0 to 360) +	 * @param[in] end		The end angle (0 to 360)  	 *  	 * @api  	 */ -	#define gwinGetBgColor(gh)			(gh)->bgcolor +	void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle); -	/** -	 * @brief	Sets whether a window is visible or not -	 * -	 * @param[in] gh		The window -	 * @param[in] visible	Whether the window should be visible or not -	 * -	 * @note	When a window is marked as not visible, drawing operations -	 * 			on the window do nothing. -	 * @note	When a window is marked as visible, it is not automatically -	 * 			redrawn as many window types don't remember their drawing state. -	 * 			Widgets such as Buttons, Sliders etc will be redrawn. -	 * @note	If there is no window manager in use, when a window is marked -	 * 			as not visible, nothing is done to remove the window from the screen. -	 * 			When there is a window manager, it is up to the window manager to -	 * 			handle what happens. -	 * @note	Even when you mark a window as visible, it may still not be displayed -	 * 			if it's parent is invisible. When the parent becomes visible this child -	 * 			will automatically be shown because it is already marked as visible. +	/* +	 * @brief	Draw a filled arc in the window. +	 * @note	Uses the current foreground color to draw the filled arc +	 * @note	May leave GDISP clipping to this window's dimensions +	 * +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center point +	 * @param[in] radius	The radius of the arc +	 * @param[in] start		The start angle (0 to 360) +	 * @param[in] end		The end angle (0 to 360)  	 *  	 * @api  	 */ -	void gwinSetVisible(GHandle gh, bool_t visible); +	void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle); -	/** -	 * @brief	Makes a widget become visible +	/* +	 * @brief	Draw a thick arc in the window. +	 * @note	Uses the current foreground color to draw the thick arc +	 * @note	May leave GDISP clipping to this window's dimensions  	 *  	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center point +	 * @param[in] startradius	The inner radius of the thick arc +	 * @param[in] endradius		The outer radius of the thick arc +	 * @param[in] startangle	The start angle (0 to 360) +	 * @param[in] endangle		The end angle (0 to 360)  	 *  	 * @api  	 */ -	#define gwinShow(gh)		gwinSetVisible(gh, TRUE) +	void gwinDrawThickArc(GHandle gh, coord_t x, coord_t y, coord_t startradius, coord_t endradius, coord_t startangle, coord_t endangle); +#endif -	/** -	 * @brief	Makes a widget become invisible +#if GDISP_NEED_ARCSECTORS || defined(__DOXYGEN__) +	/* +	 * @brief	Draw a selection of 45 degree arcs of a circle in the window. +	 * @note	Uses the current foreground color to draw the arc sector +	 * @note	May leave GDISP clipping to this window's dimensions  	 *  	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center of the circle +	 * @param[in] radius	The radius of the circle +	 * @param[in] sectors	Bits determine which sectors are drawn. +	 * 						Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows: +	 *  						bit 0 - upper right right		  ----- +	 *  						bit 1 - upper upper right		 /2   1\ +	 *  						bit 2 - upper upper left		/3     0\ +	 *  						bit 3 - upper left  left		\4     7/ +	 *  						bit 4 - lower left  left		 \5   6/ +	 *  						bit 5 - lower lower left		  ----- +	 *  						bit 6 - lower lower right +	 *  						bit 7 - lower left  left  	 *  	 * @api  	 */ -	#define gwinHide(gh)		gwinSetVisible(gh, FALSE) +	void gwinDrawArcSectors(GHandle gh, coord_t x, coord_t y, coord_t radius, uint8_t sectors); -	/** -	 * @brief	Gets the visibility of a window -	 * @return	TRUE if visible -	 * -	 * @note	It is possible for a child to be marked as visible by @p gwinSetVisible() -	 * 			but for this call to return FALSE if one of its parents are not visible. +	/* +	 * @brief	Draw a filled selection of 45 degree arcs of a circle in the window. +	 * @note	Uses the current foreground color to draw the arc sector +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh		The window +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The center of the circle +	 * @param[in] radius	The radius of the circle +	 * @param[in] sectors	Bits determine which sectors are drawn. +	 * 						Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows: +	 *  						bit 0 - upper right right		  ----- +	 *  						bit 1 - upper upper right		 /2   1\ +	 *  						bit 2 - upper upper left		/3     0\ +	 *  						bit 3 - upper left  left		\4     7/ +	 *  						bit 4 - lower left  left		 \5   6/ +	 *  						bit 5 - lower lower left		  ----- +	 *  						bit 6 - lower lower right +	 *  						bit 7 - lower left  left  	 *  	 * @api  	 */ -	bool_t gwinGetVisible(GHandle gh); +	void gwinFillArcSectors(GHandle gh, coord_t x, coord_t y, coord_t radius, uint8_t sectors); +#endif +/*------------------------------------------------- +* Pixel read-back functions +*-------------------------------------------------*/ + +#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__)  	/** -	 * @brief	Enable or disable a window +	 * @brief   Get the color of a pixel in the window. +	 * @return  The color of the pixel. +	 * @note	May leave GDISP clipping to this window's dimensions  	 *  	 * @param[in] gh		The window handle -	 * @param[in] enabled	Enable or disable the window -	 * -	 * @note	The window is automatically redrawn if it supports self-redrawing. -	 * @note	Even when you mark a window as enabled, it may still remain disabled -	 * 			if it's parent is disabled. When the parent becomes enabled this child -	 * 			will automatically be enabled because it is already marked as enabled. +	 * @param[in] x,y		The position in the window  	 *  	 * @api  	 */ -	void gwinSetEnabled(GHandle gh, bool_t enabled); +	color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y); +#endif + +/*------------------------------------------------- +* Text functions +*-------------------------------------------------*/ +#if GDISP_NEED_TEXT || defined(__DOXYGEN__)  	/** -	 * @brief	Enables a widget +	 * @brief   Draw a text character at the specified position in the window. +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character +	 * @note	May leave GDISP clipping to this window's dimensions  	 *  	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text +	 * @param[in] c			The character to draw  	 *  	 * @api  	 */ -	#define gwinEnable(gh)		gwinSetEnabled(gh, TRUE) +	void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c);  	/** -	 * @brief	Disables a widget +	 * @brief   Draw a text character with a filled background at the specified position in the window. +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color +	 * @note	May leave GDISP clipping to this window's dimensions  	 *  	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text +	 * @param[in] c			The character to draw  	 *  	 * @api  	 */ -	#define gwinDisable(gh)		gwinSetEnabled(gh, FALSE) +	void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c);  	/** -	 * @brief	Gets the enabled state of a window -	 * @return	TRUE if enabled -	 * -	 * @note	It is possible for a child to be marked as enabled by @p gwinSetEnabled() -	 * 			but for this call to return FALSE if one of its parents are not enabled. +	 * @brief   Draw a text string in the window +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @param[in] gh		The window +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text +	 * @param[in] str		The string to draw  	 *  	 * @api  	 */ -	bool_t gwinGetEnabled(GHandle gh); +	void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str);  	/** -	 * @brief	Move a window -	 * -	 * @param[in] gh		The window -	 * @param[in] x, y		The new position (screen relative) for this window +	 * @brief   Draw a text string with a filled background in the window +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @note	The final window position may not be the requested position. Windows -	 * 			are clipped to the screen area and the window manager may also affect the position. -	 * @note	The window is redrawn if it is visible. See the comments in @p gwinSetVisible() -	 * 			with regard to what can be redrawn and what can't. -	 * @note	It is up to the window manager to determine what happens with the screen area -	 * 			uncovered by moving the window. When there is no window manager, nothing -	 * 			is done with the uncovered area. +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text +	 * @param[in] str		The string to draw  	 *  	 * @api  	 */ -	void gwinMove(GHandle gh, coord_t x, coord_t y); +	void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str);  	/** -	 * @brief	Resize a window -	 * -	 * @param[in] gh				The window -	 * @param[in] width, height		The new size of the window +	 * @brief   Draw a text string verticly centered within the specified box. +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character. +	 * @note    The specified box does not need to align with the window box +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @note	The final window size may not be the requested size. Windows -	 * 			are clipped to the screen area and the window manager may also affect the size. -	 * @note	The window is redrawn if it is visible. See the comments in @p gwinSetVisible() -	 * 			with regard to what can be redrawn and what can't. -	 * @note	It is up to the window manager to determine what happens with any screen area -	 * 			uncovered by resizing the window. When there is no window manager, nothing -	 * 			is done with the uncovered area. +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text (need to define top-right or base-line - check code) +	 * @param[in] cx,cy		The width and height of the box +	 * @param[in] str		The string to draw +	 * @param[in] justify	Justify the text left, center or right within the box  	 *  	 * @api  	 */ -	void gwinResize(GHandle gh, coord_t width, coord_t height); +	void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);  	/** -	 * @brief	Redraw a window -	 * -	 * @param[in] gh				The window +	 * @brief   Draw a text string verticly centered within the specified filled box. +	 * @pre		The font must have been set. +	 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color +	 * @note    The entire box is filled. Note this box does not need to align with the window box +	 * @note	May leave GDISP clipping to this window's dimensions  	 * -	 * @note	This is normally never required as windows and widgets will redraw as required. -	 * 			Note that some windows are incapable of redrawing themselves as they don't save -	 * 			their drawing state. +	 * @param[in] gh		The window handle +	 * @param[in] x,y		The position for the text (need to define top-right or base-line - check code) +	 * @param[in] cx,cy		The width and height of the box +	 * @param[in] str		The string to draw +	 * @param[in] justify	Justify the text left, center or right within the box  	 *  	 * @api  	 */ -	void gwinRedraw(GHandle gh); - -	#if GWIN_NEED_WINDOWMANAGER || defined (__DOXYGEN__) -		/** -		 * @brief	Redraw a display -		 * -		 * @param[in] g				The display to redraw. Passing NULL will redraw all displays. -		 * @param[in] preserve		Should the redraw try to preserve existing screen data for those -		 * 							windows that can't redraw themselves? -		 * -		 * @note	This is normally never required as windows and widgets will redraw as required. -		 * @note	Some windows are incapable of redrawing themselves as they don't save -		 * 			their drawing state. -		 * @note	This does not clear the background - just redraws the gwin windows (where possible) -		 * -		 * @api -		 */ -		void gwinRedrawDisplay(GDisplay *g, bool_t preserve); - -		/** -		 * @brief	Minimize, Maximize or Restore a window -		 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON -		 * -		 * @param[in] gh				The window -		 * @param[in] minmax			The new minimized/maximized state -		 * -		 * @note	The final window state may not be the requested state. Window Managers -		 * 			do not need to implement changing the minmax state. If there is no -		 * 			window manager this call is ignored. -		 * @note	The window is redrawn if it is changed. See the comments in @p gwinSetVisible() -		 * 			with regard to what can be redrawn and what can't. -		 * @note	It is up to the window manager to determine what happens with any screen area -		 * 			uncovered by resizing the window. -		 * @note	When a window is minimised it may be asked to draw the window or the window -		 * 			manager may draw the minimised window. -		 * -		 * @api -		 */ -		void gwinSetMinMax(GHandle gh, GWindowMinMax minmax); - -		/** -		 * @brief	Get the Minimized/Maximized state of a window -		 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON -		 * -		 * @param[in] gh				The window -		 * -		 * @return	GWIN_NORMAL, GWIN_MAXIMIZE or GWIN_MINIMIZE -		 * -		 * @api -		 */ -		GWindowMinMax gwinGetMinMax(GHandle gh); - -		/** -		 * @brief	Raise a window to the top of the z-order -		 * @pre		GWIN_NEED_WINDOWMANAGER must be GFXON -		 * -		 * @param[in] gh				The window -		 * -		 * @note	The window z-order is only supported by some window managers. See the comments -		 * 			in @p gwinSetVisible() with regard to what can be redrawn and what can't. -		 * -		 * @api -		 */ -		void gwinRaise(GHandle gh); - -		/** -		 * @brief	Get the next window in the z-order -		 * @return	The next window or NULL if no more windows -		 * -		 * @param[in] gh		The previous window or NULL to get the first window -		 * -		 * @note	This returns the next window in the system from top to bottom. -		 * @note	Where there are parent child relationships, this ignores them -		 * 			and will list all windows in the system. There is no defined -		 * 			order between children of siblings and they can in fact be mixed -		 * 			in order. The only relationship honored is that parents will be -		 * 			listed before their children. -		 * -		 * @api -		 */ -		GHandle gwinGetNextWindow(GHandle gh); - -		/** -		 * @brief	Set a window or widget to flash -		 * -		 * @param[in] gh		The window handle -		 * @param[in] flash		Enable or disable the flashing of the window -		 * -		 * @note	The window is automatically redrawn if it supports self-redrawing. -		 * @note	When a window is set to flash, its appearance changes in some -		 * 			way every flash period (GWIN_FLASHING_PERIOD). How its appearance -		 * 			changes depends on the draw for each window/widget. -		 * -		 * @pre		Requires GWIN_NEED_FLASHING to be GFXON -		 * -		 * @api -		 */ -		void gwinSetFlashing(GHandle gh, bool_t flash); - -		/** -		 * @brief	Enables flashing of a window or widget -		 * -		 * @param[in] gh		The window handle -		 * -		 * @api -		 */ -		#define gwinFlash(gh)		gwinSetFlashing(gh, TRUE) - -		/** -		 * @brief	Disables a widget -		 * -		 * @param[in] gh		The window handle -		 * -		 * @api -		 */ -		#define gwinNoFlash(gh)		gwinSetFlashing(gh, FALSE) -	#endif - -	#if GDISP_NEED_TEXT || defined(__DOXYGEN__) -		/** -		 * @brief   Set the current font for this window. -		 * -		 * @param[in] gh		The window handle -		 * @param[in] font		The font to use for text functions -		 * -		 * @api -		 */ -		void gwinSetFont(GHandle gh, font_t font); -	#endif +	void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify); +#endif  /*------------------------------------------------- - * Drawing functions - *-------------------------------------------------*/ +* Polygon functions +*-------------------------------------------------*/ +#if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__)  	/** -	 * @brief   Clear the window -	 * @note	Uses the current background color to clear the window +	 * @brief   Draw an enclosed polygon (convex, non-convex or complex). +	 * +	 * @note	Uses the current foreground color.  	 *  	 * @param[in] gh		The window handle +	 * @param[in] tx, ty	Transform all points in pntarray by tx, ty +	 * @param[in] pntarray	An array of points +	 * @param[in] cnt		The number of points in the array  	 *  	 * @api  	 */ -	void gwinClear(GHandle gh); +	void gwinDrawPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt);  	/** -	 * @brief   Set a pixel in the window -	 * @note	Uses the current foreground color to set the pixel -	 * @note	May leave GDISP clipping to this window's dimensions +	 * @brief   Fill a convex polygon +	 * @details Doesn't handle non-convex or complex polygons. +	 * +	 * @note	Uses the current foreground color.  	 *  	 * @param[in] gh		The window handle -	 * @param[in] x,y		The coordinates of the pixel +	 * @param[in] tx, ty	Transform all points in pntarray by tx, ty +	 * @param[in] pntarray	An array of points +	 * @param[in] cnt		The number of points in the array +	 * +	 * @note	Convex polygons are those that have no internal angles. That is; +	 * 			you can draw a line from any point on the polygon to any other point +	 * 			on the polygon without it going outside the polygon. In our case we generalise +	 * 			this a little by saying that an infinite horizontal line (at any y value) will cross +	 * 			no more than two edges on the polygon. Some non-convex polygons do fit this criteria +	 * 			and can therefore be drawn. +	 * @note	This routine is designed to be very efficient with even simple display hardware.  	 *  	 * @api  	 */ -	void gwinDrawPixel(GHandle gh, coord_t x, coord_t y); +	void gwinFillConvexPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt);  	/** -	 * @brief   Draw a line in the window +	 * @brief	Draw a thick line in the window +	 * @details	The line thickness is specified in pixels. The line ends can +	 *		be selected to be either flat or round. +	 * @note	Uses gdispGFillConvexPoly() internally to perform the drawing.  	 * @note	Uses the current foreground color to draw the line -	 * @note	May leave GDISP clipping to this window's dimensions -	 * +	 *   	 * @param[in] gh		The window handle  	 * @param[in] x0,y0		The start position -	 * @param[in] x1,y1 	The end position -	 * +	 * @param[in] x1,y1		The end position +	 * @param[in] width		The width of the line +	 * @param[in] round		Use round ends for the line +	 *   	 * @api  	 */ -	void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1); +	void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, gBool round); +#endif -	/** -	 * @brief   Draw a box in the window -	 * @note	Uses the current foreground color to draw the box -	 * @note	May leave GDISP clipping to this window's dimensions -	 * -	 * @param[in] gh		The window handle -	 * @param[in] x,y		The start position -	 * @param[in] cx,cy		The size of the box (outside dimensions) -	 * -	 * @api -	 */ -	void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy); +/*------------------------------------------------- +* Image functions +*-------------------------------------------------*/ +#if GDISP_NEED_IMAGE || defined(__DOXYGEN__)  	/** -	 * @brief   Fill an rectangular area in the window -	 * @note	Uses the current foreground color to fill the box -	 * @note	May leave GDISP clipping to this window's dimensions +	 * @brief	Draw the image +	 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code.  	 *  	 * @param[in] gh		The window handle -	 * @param[in] x,y		The start position -	 * @param[in] cx,cy		The size of the box (outside dimensions) +	 * @param[in] img   	The image structure +	 * @param[in] x,y		The window location to draw the image +	 * @param[in] cx,cy		The area on the screen to draw +	 * @param[in] sx,sy		The image position to start drawing at  	 * -	 * @api -	 */ -	void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy); - -	/** -	 * @brief   Fill an area in the window using the supplied bitmap. -	 * @details The bitmap is in the pixel format specified by the low level driver -	 * @note	If GDISP_NEED_ASYNC is defined then the buffer must be static -	 * 			or at least retained until this call has finished the blit. You can -	 * 			tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE. -	 * @note	May leave GDISP clipping to this window's dimensions +	 * @pre		gdispImageOpen() must have returned successfully.  	 * -	 * @param[in] gh		The window handle -	 * @param[in] x, y		The start filled area -	 * @param[in] cx, cy	The width and height to be filled -	 * @param[in] srcx, srcy	The bitmap position to start the fill from -	 * @param[in] srccx		The width of a line in the bitmap. -	 * @param[in] buffer	The pixels to use to fill the area. +	 * @note	If sx,sy + cx,cy is outside the image boundaries the area outside the image +	 * 			is simply not drawn. +	 * @note	If @p gdispImageCache() has been called first for this frame, this routine will draw using a +	 * 			fast blit from the cached frame. If not, it reads the input and decodes it as it +	 * 			is drawing. This may be significantly slower than if the image has been cached (but +	 * 			uses a lot less RAM)  	 *  	 * @api  	 */ -	void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer); - -/*------------------------------------------------- - * Circle, ellipse, arc and arc-sectors functions - *-------------------------------------------------*/ - -	#if GDISP_NEED_CIRCLE || defined(__DOXYGEN__) -		/** -		 * @brief   Draw a circle in the window. -		 * @note	Uses the current foreground color to draw the circle -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x, y		The center of the circle -		 * @param[in] radius	The radius of the circle -		 * -		 * @api -		 */ -		void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius); - -		/** -		 * @brief   Draw a filled circle in the window. -		 * @note	Uses the current foreground color to draw the filled circle -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x, y		The center of the circle -		 * @param[in] radius	The radius of the circle -		 * -		 * @api -		 */ -		void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius); -	#endif - -	#if GDISP_NEED_DUALCIRCLE || defined(__DOXYGEN__) -		/** -		 * @brief   Draw two filled circles with the same centre in the window. -		 * @note	Uses the current foreground color to draw the inner circle -		 * @note	Uses the current background color to draw the outer circle -		 * @note	May leave GDISP clipping to this window's dimensions -		 * @pre		GDISP_NEED_DUALCIRCLE must be GFXON in your gfxconf.h -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center of the circle -		 * @param[in] radius1	The radius of the larger circle -		 * @param[in] radius2	The radius of the smaller circle -		 * -		 * @api -		 */ -		void gwinFillDualCircle(GHandle gh, coord_t x, coord_t y, coord_t radius1, coord_t radius2); -	#endif - -	#if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__) -		/** -		 * @brief   Draw an ellipse. -		 * @note	Uses the current foreground color to draw the ellipse -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center of the ellipse -		 * @param[in] a,b		The dimensions of the ellipse -		 * -		 * @api -		 */ -		void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b); - -		/** -		 * @brief   Draw an filled ellipse. -		 * @note	Uses the current foreground color to draw the filled ellipse -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center of the ellipse -		 * @param[in] a,b		The dimensions of the ellipse -		 * -		 * @api -		 */ -		void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b); -	#endif - -	#if GDISP_NEED_ARC || defined(__DOXYGEN__) -		/* -		 * @brief	Draw an arc in the window. -		 * @note	Uses the current foreground color to draw the arc -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center point -		 * @param[in] radius	The radius of the arc -		 * @param[in] start		The start angle (0 to 360) -		 * @param[in] end		The end angle (0 to 360) -		 * -		 * @api -		 */ -		void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle); - -		/* -		 * @brief	Draw a filled arc in the window. -		 * @note	Uses the current foreground color to draw the filled arc -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center point -		 * @param[in] radius	The radius of the arc -		 * @param[in] start		The start angle (0 to 360) -		 * @param[in] end		The end angle (0 to 360) -		 * -		 * @api -		 */ -		void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle); - -		/* -		 * @brief	Draw a thick arc in the window. -		 * @note	Uses the current foreground color to draw the thick arc -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center point -		 * @param[in] startradius	The inner radius of the thick arc -		 * @param[in] endradius		The outer radius of the thick arc -		 * @param[in] startangle	The start angle (0 to 360) -		 * @param[in] endangle		The end angle (0 to 360) -		 * -		 * @api -		 */ -		void gwinDrawThickArc(GHandle gh, coord_t x, coord_t y, coord_t startradius, coord_t endradius, coord_t startangle, coord_t endangle); -	#endif - -	#if GDISP_NEED_ARCSECTORS || defined(__DOXYGEN__) -		/* -		 * @brief	Draw a selection of 45 degree arcs of a circle in the window. -		 * @note	Uses the current foreground color to draw the arc sector -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center of the circle -		 * @param[in] radius	The radius of the circle -		 * @param[in] sectors	Bits determine which sectors are drawn. -		 * 						Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows: -		 *  						bit 0 - upper right right		  ----- -		 *  						bit 1 - upper upper right		 /2   1\ -		 *  						bit 2 - upper upper left		/3     0\ -		 *  						bit 3 - upper left  left		\4     7/ -		 *  						bit 4 - lower left  left		 \5   6/ -		 *  						bit 5 - lower lower left		  ----- -		 *  						bit 6 - lower lower right -		 *  						bit 7 - lower left  left -		 * -		 * @api -		 */ -		void gwinDrawArcSectors(GHandle gh, coord_t x, coord_t y, coord_t radius, uint8_t sectors); - -		/* -		 * @brief	Draw a filled selection of 45 degree arcs of a circle in the window. -		 * @note	Uses the current foreground color to draw the arc sector -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The center of the circle -		 * @param[in] radius	The radius of the circle -		 * @param[in] sectors	Bits determine which sectors are drawn. -		 * 						Bits go anti-clockwise from the 0 degree mark (y = 0, x is positive), as follows: -		 *  						bit 0 - upper right right		  ----- -		 *  						bit 1 - upper upper right		 /2   1\ -		 *  						bit 2 - upper upper left		/3     0\ -		 *  						bit 3 - upper left  left		\4     7/ -		 *  						bit 4 - lower left  left		 \5   6/ -		 *  						bit 5 - lower lower left		  ----- -		 *  						bit 6 - lower lower right -		 *  						bit 7 - lower left  left -		 * -		 * @api -		 */ -		void gwinFillArcSectors(GHandle gh, coord_t x, coord_t y, coord_t radius, uint8_t sectors); -	#endif - -/*------------------------------------------------- - * Pixel read-back functions - *-------------------------------------------------*/ - -	#if GDISP_NEED_PIXELREAD || defined(__DOXYGEN__) -		/** -		 * @brief   Get the color of a pixel in the window. -		 * @return  The color of the pixel. -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position in the window -		 * -		 * @api -		 */ -		color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y); -	#endif - -/*------------------------------------------------- - * Text functions - *-------------------------------------------------*/ - -	#if GDISP_NEED_TEXT || defined(__DOXYGEN__) -		/** -		 * @brief   Draw a text character at the specified position in the window. -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text -		 * @param[in] c			The character to draw -		 * -		 * @api -		 */ -		void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c); - -		/** -		 * @brief   Draw a text character with a filled background at the specified position in the window. -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text -		 * @param[in] c			The character to draw -		 * -		 * @api -		 */ -		void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c); - -		/** -		 * @brief   Draw a text string in the window -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text -		 * @param[in] str		The string to draw -		 * -		 * @api -		 */ -		void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str); - -		/** -		 * @brief   Draw a text string with a filled background in the window -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text -		 * @param[in] str		The string to draw -		 * -		 * @api -		 */ -		void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str); - -		/** -		 * @brief   Draw a text string verticly centered within the specified box. -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character. -		 * @note    The specified box does not need to align with the window box -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text (need to define top-right or base-line - check code) -		 * @param[in] cx,cy		The width and height of the box -		 * @param[in] str		The string to draw -		 * @param[in] justify	Justify the text left, center or right within the box -		 * -		 * @api -		 */ -		void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify); - -		/** -		 * @brief   Draw a text string verticly centered within the specified filled box. -		 * @pre		The font must have been set. -		 * @note	Uses the current foreground color to draw the character and fills the background using the background drawing color -		 * @note    The entire box is filled. Note this box does not need to align with the window box -		 * @note	May leave GDISP clipping to this window's dimensions -		 * -		 * @param[in] gh		The window handle -		 * @param[in] x,y		The position for the text (need to define top-right or base-line - check code) -		 * @param[in] cx,cy		The width and height of the box -		 * @param[in] str		The string to draw -		 * @param[in] justify	Justify the text left, center or right within the box -		 * -		 * @api -		 */ -		void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify); -	#endif - -/*------------------------------------------------- - * Polygon functions - *-------------------------------------------------*/ - -	#if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__) -		/** -		 * @brief   Draw an enclosed polygon (convex, non-convex or complex). -		 * -		 * @note	Uses the current foreground color. -		 * -		 * @param[in] gh		The window handle -		 * @param[in] tx, ty	Transform all points in pntarray by tx, ty -		 * @param[in] pntarray	An array of points -		 * @param[in] cnt		The number of points in the array -		 * -		 * @api -		 */ -		void gwinDrawPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt); - -		/** -		 * @brief   Fill a convex polygon -		 * @details Doesn't handle non-convex or complex polygons. -		 * -		 * @note	Uses the current foreground color. -		 * -		 * @param[in] gh		The window handle -		 * @param[in] tx, ty	Transform all points in pntarray by tx, ty -		 * @param[in] pntarray	An array of points -		 * @param[in] cnt		The number of points in the array -		 * -		 * @note	Convex polygons are those that have no internal angles. That is; -		 * 			you can draw a line from any point on the polygon to any other point -		 * 			on the polygon without it going outside the polygon. In our case we generalise -		 * 			this a little by saying that an infinite horizontal line (at any y value) will cross -		 * 			no more than two edges on the polygon. Some non-convex polygons do fit this criteria -		 * 			and can therefore be drawn. -		 * @note	This routine is designed to be very efficient with even simple display hardware. -		 * -		 * @api -		 */ -		void gwinFillConvexPoly(GHandle gh, coord_t tx, coord_t ty, const point *pntarray, unsigned cnt); -	 -		/** -		 * @brief	Draw a thick line in the window -		 * @details	The line thickness is specified in pixels. The line ends can -		 *		be selected to be either flat or round. -		 * @note	Uses gdispGFillConvexPoly() internally to perform the drawing. -		 * @note	Uses the current foreground color to draw the line -		 *  -		 * @param[in] gh		The window handle -		 * @param[in] x0,y0		The start position -		 * @param[in] x1,y1		The end position -		 * @param[in] width		The width of the line -		 * @param[in] round		Use round ends for the line -		 *  -		 * @api -		 */ -		void gwinDrawThickLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1, coord_t width, bool_t round); -	#endif - -/*------------------------------------------------- - * Image functions - *-------------------------------------------------*/ - -	#if GDISP_NEED_IMAGE || defined(__DOXYGEN__) -		/** -		 * @brief	Draw the image -		 * @return	GDISP_IMAGE_ERR_OK (0) on success or an error code. -		 * -		 * @param[in] gh		The window handle -		 * @param[in] img   	The image structure -		 * @param[in] x,y		The window location to draw the image -		 * @param[in] cx,cy		The area on the screen to draw -		 * @param[in] sx,sy		The image position to start drawing at -		 * -		 * @pre		gdispImageOpen() must have returned successfully. -		 * -		 * @note	If sx,sy + cx,cy is outside the image boundaries the area outside the image -		 * 			is simply not drawn. -		 * @note	If @p gdispImageCache() has been called first for this frame, this routine will draw using a -		 * 			fast blit from the cached frame. If not, it reads the input and decodes it as it -		 * 			is drawing. This may be significantly slower than if the image has been cached (but -		 * 			uses a lot less RAM) -		 * -		 * @api -		 */ -		gdispImageError gwinDrawImage(GHandle gh, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy); -	#endif - -#ifdef __cplusplus -} +	gdispImageError gwinDrawImage(GHandle gh, gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);  #endif  /*------------------------------------------------- - * Additional functionality - *-------------------------------------------------*/ +* Additional functionality +*-------------------------------------------------*/ -	/* Include widgets */ -	#if GWIN_NEED_WIDGET || defined(__DOXYGEN__) -		#include "gwin_widget.h" -	#endif +/* Include widgets */ +#if GWIN_NEED_WIDGET || defined(__DOXYGEN__) +	#include "gwin_widget.h" +#endif -	/* Include containers */ -	#if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) -		#include "gwin_container.h" -	#endif +/* Include containers */ +#if GWIN_NEED_CONTAINERS || defined(__DOXYGEN__) +	#include "gwin_container.h" +#endif -	/* Include vanilla window objects */ -	#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__) -		#include "gwin_console.h" -	#endif -	#if GWIN_NEED_GRAPH || defined(__DOXYGEN__) -		#include "gwin_graph.h" -	#endif -	#if GWIN_NEED_IMAGE || defined(__DOXYGEN__) -		#include "gwin_image.h" -	#endif -	#if GWIN_NEED_GL3D || defined(__DOXYGEN__) -		#include "gwin_gl3d.h" -	#endif +/* Include vanilla window objects */ +#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__) +	#include "gwin_console.h" +#endif +#if GWIN_NEED_GRAPH || defined(__DOXYGEN__) +	#include "gwin_graph.h" +#endif +#if GWIN_NEED_IMAGE || defined(__DOXYGEN__) +	#include "gwin_image.h" +#endif +#if GWIN_NEED_GL3D || defined(__DOXYGEN__) +	#include "gwin_gl3d.h" +#endif  #endif /* GFX_USE_GWIN */ diff --git a/src/gwin/gwin_button.c b/src/gwin/gwin_button.c index 8b3a2b6b..618c78b2 100644 --- a/src/gwin/gwin_button.c +++ b/src/gwin/gwin_button.c @@ -145,11 +145,11 @@ GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gw, const GWidgetInit *pIn  	return (GHandle)gw;  } -bool_t gwinButtonIsPressed(GHandle gh) { +gBool gwinButtonIsPressed(GHandle gh) {  	if (gh->vmt != (gwinVMT *)&buttonVMT) -		return FALSE; +		return gFalse; -	return (gh->flags & GBUTTON_FLG_PRESSED) ? TRUE : FALSE; +	return (gh->flags & GBUTTON_FLG_PRESSED) ? gTrue : gFalse;  }  /*---------------------------------------------------------- diff --git a/src/gwin/gwin_button.h b/src/gwin/gwin_button.h index ba3bc354..ebbd88cb 100644 --- a/src/gwin/gwin_button.h +++ b/src/gwin/gwin_button.h @@ -58,10 +58,6 @@ typedef struct GButtonObject {  	#endif  } GButtonObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a button widget.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -87,13 +83,13 @@ GHandle gwinGButtonCreate(GDisplay *g, GButtonObject *gb, const GWidgetInit *pIn  /**   * @brief	Is the button current pressed - * @return	TRUE if the button is pressed + * @return	gTrue if the button is pressed   *   * @param[in] gh	The window handle (must be a button widget)   *   * @api   */ -bool_t gwinButtonIsPressed(GHandle gh); +gBool gwinButtonIsPressed(GHandle gh);  /**   * @defgroup Renderings_Button Renderings @@ -222,10 +218,6 @@ void gwinButtonDraw_Normal(GWidgetObject *gw, void *param);  #endif  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_BUTTON_H */  /** @} */ diff --git a/src/gwin/gwin_checkbox.c b/src/gwin/gwin_checkbox.c index 1b3d395a..21d2ba86 100644 --- a/src/gwin/gwin_checkbox.c +++ b/src/gwin/gwin_checkbox.c @@ -33,7 +33,7 @@ static void SendCheckboxEvent(GWidgetObject *gw) {  			continue;  		pce->type = GEVENT_GWIN_CHECKBOX;  		pce->gwin = &gw->g; -		pce->isChecked = (gw->g.flags & GCHECKBOX_FLG_CHECKED) ? TRUE : FALSE; +		pce->isChecked = (gw->g.flags & GCHECKBOX_FLG_CHECKED) ? gTrue : gFalse;  		#if GWIN_WIDGET_TAGS  			pce->tag = gw->tag;  		#endif @@ -139,7 +139,7 @@ GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit  	return (GHandle)gb;  } -void gwinCheckboxCheck(GHandle gh, bool_t isChecked) { +void gwinCheckboxCheck(GHandle gh, gBool isChecked) {  	if (gh->vmt != (gwinVMT *)&checkboxVMT)  		return; @@ -154,11 +154,11 @@ void gwinCheckboxCheck(GHandle gh, bool_t isChecked) {  	SendCheckboxEvent((GWidgetObject *)gh);  } -bool_t gwinCheckboxIsChecked(GHandle gh) { +gBool gwinCheckboxIsChecked(GHandle gh) {  	if (gh->vmt != (gwinVMT *)&checkboxVMT) -		return FALSE; +		return gFalse; -	return (gh->flags & GCHECKBOX_FLG_CHECKED) ? TRUE : FALSE; +	return (gh->flags & GCHECKBOX_FLG_CHECKED) ? gTrue : gFalse;  }  /*---------------------------------------------------------- @@ -242,7 +242,7 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {  		#if GWIN_NEED_FLASHING  			// Flash the on and off state. -			pcol = _gwinGetFlashedColor(gw, pcol, TRUE); +			pcol = _gwinGetFlashedColor(gw, pcol, gTrue);  		#endif  		gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter); @@ -263,7 +263,7 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param) {  		#if GWIN_NEED_FLASHING  			// Flash the on and off state. -			pcol = _gwinGetFlashedColor(gw, pcol, TRUE); +			pcol = _gwinGetFlashedColor(gw, pcol, gTrue);  		#endif  		/* Fill the box blended from variants of the fill color */ diff --git a/src/gwin/gwin_checkbox.h b/src/gwin/gwin_checkbox.h index 2fba95c1..ebab833d 100644 --- a/src/gwin/gwin_checkbox.h +++ b/src/gwin/gwin_checkbox.h @@ -42,7 +42,7 @@ typedef struct GEventGWinCheckbox {  	#if GWIN_WIDGET_TAGS  		WidgetTag	tag;			// The checkbox tag  	#endif -	bool_t			isChecked;		// Is the checkbox currently checked or unchecked? +	gBool			isChecked;		// Is the checkbox currently checked or unchecked?  } GEventGWinCheckbox;  /** @@ -61,10 +61,6 @@ typedef struct GCheckboxObject {  	#endif  } GCheckboxObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a checkbox window.   * @return				NULL if there is no resultant drawing area, otherwise a window handle. @@ -92,21 +88,21 @@ GHandle gwinGCheckboxCreate(GDisplay *g, GCheckboxObject *gb, const GWidgetInit   * @brief	Set the state of a checkbox   *   * @param[in] gh		The window handle (must be a checkbox window) - * @param[in] isChecked	TRUE to set the check, FALSE to uncheck. + * @param[in] isChecked	gTrue to set the check, gFalse to uncheck.   *   * @api   */ -void gwinCheckboxCheck(GHandle gh, bool_t isChecked); +void gwinCheckboxCheck(GHandle gh, gBool isChecked);  /**   * @brief	Get the state of a checkbox - * @return	TRUE if the checkbox is currently checked + * @return	gTrue if the checkbox is currently checked   *   * @param[in] gh	The window handle (must be a checkbox window)   *   * @api   */ -bool_t gwinCheckboxIsChecked(GHandle gh); +gBool gwinCheckboxIsChecked(GHandle gh);  /**   * @defgroup Renderings_Checkbox Renderings @@ -156,10 +152,6 @@ void gwinCheckboxDraw_CheckOnRight(GWidgetObject *gw, void *param);  void gwinCheckboxDraw_Button(GWidgetObject *gw, void *param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_CHECKBOX_H */  /** @} */ diff --git a/src/gwin/gwin_class.h b/src/gwin/gwin_class.h index 4b173e3c..c161c0f6 100644 --- a/src/gwin/gwin_class.h +++ b/src/gwin/gwin_class.h @@ -154,7 +154,7 @@ typedef struct gwinVMT {  	typedef struct gwmVMT {  		void (*Init)		(void);									/**< The window manager has just been set as the current window manager */  		void (*DeInit)		(void);									/**< The window manager has just been removed as the current window manager */ -		bool_t (*Add)		(GHandle gh, const GWindowInit *pInit);	/**< A window has been added */ +		gBool (*Add)		(GHandle gh, const GWindowInit *pInit);	/**< A window has been added */  		void (*Delete)		(GHandle gh);							/**< A window has been deleted */  		void (*Redraw)		(GHandle gh);							/**< A window needs to be redraw (or undrawn) */  		void (*Size)		(GHandle gh, coord_t w, coord_t h);		/**< A window wants to be resized */ @@ -168,14 +168,10 @@ typedef struct gwinVMT {  	 * @brief	The current window manager  	 */  	extern	GWindowManager	*_GWINwm; -	extern	bool_t			_gwinFlashState; +	extern	gBool			_gwinFlashState;  #endif -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief	Initialise (and allocate if necessary) the base GWIN object   * @@ -220,7 +216,7 @@ typedef enum GRedrawMethod { REDRAW_WAIT, REDRAW_NOWAIT, REDRAW_INSESSION }	GRed   * @note	This call will attempt to flush any pending redraws   * 			in the system. The doWait parameter tells this call   * 			how to handle someone already holding the drawing lock. - * 			If doWait is TRUE it waits to obtain the lock. If FALSE + * 			If doWait is gTrue it waits to obtain the lock. If gFalse   * 			and the drawing lock is free then the redraw is done   * 			immediately. If the drawing lock was taken it will postpone the flush   * 			on the basis that someone else will do it for us later. @@ -231,13 +227,13 @@ void _gwinFlushRedraws(GRedrawMethod how);  /**   * @brief	Obtain a drawing session - * @return	TRUE if the drawing session was obtained, FALSE if the window is not visible + * @return	gTrue if the drawing session was obtained, gFalse if the window is not visible   *   * @param[in]	gh		The window   *   * @note	This function blocks until a drawing session is available if the window is visible   */ -bool_t _gwinDrawStart(GHandle gh); +gBool _gwinDrawStart(GHandle gh);  /**   * @brief	Release a drawing session @@ -261,12 +257,12 @@ void _gwinDestroy(GHandle gh, GRedrawMethod how);  /**   * @brief	Add a window to the window manager and set its position and size - * @return	TRUE if successful + * @return	gTrue if successful   *   * @param[in]	gh		The window   * @param[in]	pInit	The window init structure   */ -bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit); +gBool _gwinWMAdd(GHandle gh, const GWindowInit *pInit);  #if GWIN_NEED_WIDGET || defined(__DOXYGEN__)  	/** @@ -391,7 +387,7 @@ bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit);  		 * @param[in]	flashOffState	Whether the off-state should be flashed as well. If false, only the  		 * 								pressed color set is flashed.  		 */ -		const GColorSet *_gwinGetFlashedColor(GWidgetObject *gw, const GColorSet *pcol, bool_t flashOffState); +		const GColorSet *_gwinGetFlashedColor(GWidgetObject *gw, const GColorSet *pcol, gBool flashOffState);  	#endif  #else  	#define _gwinFixFocus(gh) @@ -446,10 +442,6 @@ bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit);  #endif -#ifdef __cplusplus -} -#endif -  #endif /* GFX_USE_GWIN */  #endif /* _CLASS_GWIN_H */ diff --git a/src/gwin/gwin_console.c b/src/gwin/gwin_console.c index 2d99b153..7bd0780e 100644 --- a/src/gwin/gwin_console.c +++ b/src/gwin/gwin_console.c @@ -79,7 +79,7 @@  #if GWIN_CONSOLE_ESCSEQ  	// Convert escape sequences to attributes -	static bool_t ESCtoAttr(char c, uint8_t *pattr) { +	static gBool ESCtoAttr(char c, uint8_t *pattr) {  		uint8_t		attr;  		attr = pattr[0]; @@ -105,12 +105,12 @@  			attr &= ~ESC_BOLD;  			break;  		default: -			return FALSE; +			return gFalse;  		}  		if (attr == pattr[0]) -			return FALSE; +			return gFalse;  		pattr[0] = attr; -		return TRUE; +		return gTrue;  	}  	static color_t ESCPrintColor(GConsoleObject *gcw) { @@ -348,7 +348,7 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p  	#if GWIN_CONSOLE_USE_HISTORY  		gc->buffer = 0;  		#if GWIN_CONSOLE_HISTORY_ATCREATE -			gwinConsoleSetBuffer(&gc->g, TRUE); +			gwinConsoleSetBuffer(&gc->g, gTrue);  		#endif  	#endif @@ -376,11 +376,11 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p  #endif  #if GWIN_CONSOLE_USE_HISTORY -	bool_t gwinConsoleSetBuffer(GHandle gh, bool_t onoff) { +	gBool gwinConsoleSetBuffer(GHandle gh, gBool onoff) {  		#define gcw		((GConsoleObject *)gh)  		if (gh->vmt != &consoleVMT) -			return FALSE; +			return gFalse;  		// Do we want the buffer turned off?  		if (!onoff) { @@ -388,12 +388,12 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p  				gfxFree(gcw->buffer);  				gcw->buffer = 0;  			} -			return FALSE; +			return gFalse;  		}  		// Is the buffer already on?  		if (gcw->buffer) -			return TRUE; +			return gTrue;  		// Get the number of characters that fit in the x direction  		#if GWIN_CONSOLE_HISTORY_AVERAGING @@ -408,12 +408,12 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p  		// Allocate the buffer  		if (!(gcw->buffer = gfxAlloc(gcw->bufsize))) -			return FALSE; +			return gFalse;  		// All good!  		gh->flags &= ~GCONSOLE_FLG_OVERRUN;  		gcw->bufpos = 0; -		return TRUE; +		return gTrue;  		#undef gcw  	} @@ -676,7 +676,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  	va_list ap;  	char *p, *s, c, filler;  	int i, precision, width; -	bool_t is_long, left_align; +	gBool is_long, left_align;  	long l;  	#if GWIN_CONSOLE_USE_FLOAT  		float f; @@ -689,7 +689,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		return;  	va_start(ap, fmt); -	while (TRUE) { +	while (gTrue) {  		c = *fmt++;  		if (c == 0) {  			va_end(ap); @@ -702,10 +702,10 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		p = tmpbuf;  		s = tmpbuf; -		left_align = FALSE; +		left_align = gFalse;  		if (*fmt == '-') {  			fmt++; -			left_align = TRUE; +			left_align = gTrue;  		}  		filler = ' ';  		if (*fmt == '0') { @@ -714,7 +714,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		}  		width = 0; -		while (TRUE) { +		while (gTrue) {  			c = *fmt++;  			if (c >= '0' && c <= '9')  				c -= '0'; @@ -726,7 +726,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		}  		precision = 0;  		if (c == '.') { -			while (TRUE) { +			while (gTrue) {  				c = *fmt++;  				if (c >= '0' && c <= '9')  					c -= '0'; @@ -739,7 +739,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		}  		/* Long modifier.*/  		if (c == 'l' || c == 'L') { -			is_long = TRUE; +			is_long = gTrue;  			if (*fmt)  				c = *fmt++;  		} @@ -808,7 +808,7 @@ void gwinPrintf(GHandle gh, const char *fmt, ...) {  		i = (int)(p - s);  		if ((width -= i) < 0)  			width = 0; -		if (left_align == FALSE) +		if (!left_align)  			width = -width;  		if (width < 0) {  			if (*s == '-' && filler == '0') { diff --git a/src/gwin/gwin_console.h b/src/gwin/gwin_console.h index fcfca35e..208ab16b 100644 --- a/src/gwin/gwin_console.h +++ b/src/gwin/gwin_console.h @@ -54,10 +54,6 @@ typedef struct GConsoleObject {  } GConsoleObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a console window.   * @details	A console window allows text to be written. @@ -102,15 +98,15 @@ GHandle gwinGConsoleCreate(GDisplay *g, GConsoleObject *gc, const GWindowInit *p  	 * @pre		GWIN_CONSOLE_USE_HISTORY must be set to GFXON in your gfxconf.h  	 *  	 * @param[in] gh		The window handle (must be a console window) -	 * @param[in] onoff		If TRUE a buffer is allocated to maintain console text -	 * 						when the console is obscured or invisible. If FALSE, then +	 * @param[in] onoff		If gTrue a buffer is allocated to maintain console text +	 * 						when the console is obscured or invisible. If gFalse, then  	 * 						any existing buffer is deallocated.  	 * @note	When the history buffer is turned on, scrolling is implemented using the  	 * 			history buffer.  	 * -	 * @return	TRUE if the history buffer is now turned on. +	 * @return	gTrue if the history buffer is now turned on.  	 */ -	bool_t gwinConsoleSetBuffer(GHandle gh, bool_t onoff); +	gBool gwinConsoleSetBuffer(GHandle gh, gBool onoff);  #endif  /** @@ -172,9 +168,5 @@ void gwinPutCharArray(GHandle gh, const char *str, size_t n);   */  void gwinPrintf(GHandle gh, const char *fmt, ...); -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_CONSOLE_H */  /** @} */ diff --git a/src/gwin/gwin_container.h b/src/gwin/gwin_container.h index 9020c73e..a4a3afa2 100644 --- a/src/gwin/gwin_container.h +++ b/src/gwin/gwin_container.h @@ -46,10 +46,6 @@ typedef GWidgetObject GContainerObject;   * won't support it even with special flags.   */ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief	Get the first child window   * @@ -182,10 +178,6 @@ void gwinContainerDraw_Transparent(GWidgetObject *gw, void *param);  /** @} */ -#ifdef __cplusplus -} -#endif -  /* Include extra container types */  #if GWIN_NEED_FRAME || defined(__DOXYGEN__)  	#include "gwin_frame.h" diff --git a/src/gwin/gwin_frame.h b/src/gwin/gwin_frame.h index 06488321..7d60773c 100644 --- a/src/gwin/gwin_frame.h +++ b/src/gwin/gwin_frame.h @@ -50,10 +50,6 @@  typedef GContainerObject GFrameObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a frame widget   * @@ -138,10 +134,6 @@ void gwinFrameDraw_Transparent(GWidgetObject *gw, void *param);  #endif /* GDISP_NEED_IMAGE */  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_FRAME_H */  /** @} */ diff --git a/src/gwin/gwin_gl3d.c b/src/gwin/gwin_gl3d.c index c9db1a3b..4c3f0f7f 100644 --- a/src/gwin/gwin_gl3d.c +++ b/src/gwin/gwin_gl3d.c @@ -35,7 +35,7 @@ static const gwinVMT gl3dVMT = {  		0,						// The after-clear routine  }; -static bool_t	haveGLwindow = FALSE; +static gBool	haveGLwindow = gFalse;  GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gl, const GWindowInit *pInit) {  	ZBuffer *	zb; @@ -71,7 +71,7 @@ GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gl, const GWindowInit *pInit)      glViewport(0, 0, gl->g.width, gl->g.height); -    haveGLwindow = TRUE; +    haveGLwindow = gTrue;  	gwinSetVisible((GHandle)gl, pInit->show);  	return (GHandle)gl;  } @@ -79,7 +79,7 @@ GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gl, const GWindowInit *pInit)  static void gl3dDestroy(GWindowObject *gh) {  	(void) gh;      glClose(); -    haveGLwindow = FALSE; +    haveGLwindow = gFalse;  }  static void gl3dRedraw(GWindowObject *gh) { diff --git a/src/gwin/gwin_gl3d.h b/src/gwin/gwin_gl3d.h index 5dbfa893..205e681c 100644 --- a/src/gwin/gwin_gl3d.h +++ b/src/gwin/gwin_gl3d.h @@ -38,10 +38,6 @@ typedef struct GGL3DObject {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a gl3d window.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -64,10 +60,6 @@ GHandle gwinGGL3DCreate(GDisplay *g, GGL3DObject *gg, const GWindowInit *pInit);  /* Include the gl interface */  #include "../../3rdparty/tinygl-0.4-ugfx/include/GL/gl.h" -#ifdef __cplusplus -} -#endif -  #endif	/* _GWIN_GL3D_H */  /** @} */ diff --git a/src/gwin/gwin_graph.h b/src/gwin/gwin_graph.h index 76059a6f..7c893d5b 100644 --- a/src/gwin/gwin_graph.h +++ b/src/gwin/gwin_graph.h @@ -85,10 +85,6 @@ typedef struct GGraphObject {  /* External declarations.                                                    */  /*===========================================================================*/ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a graph window.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -180,10 +176,6 @@ void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y);   */  void gwinGraphDrawPoints(GHandle gh, const point *points, unsigned count); -#ifdef __cplusplus -} -#endif -  #endif	/* _GWIN_GRAPH_H */  /** @} */ diff --git a/src/gwin/gwin_image.c b/src/gwin/gwin_image.c index 855eecc9..a4cc5028 100644 --- a/src/gwin/gwin_image.c +++ b/src/gwin/gwin_image.c @@ -108,7 +108,7 @@ static void ImageRedraw(GHandle gh) {  			// Fall through  		default:  			// Start the timer to draw the next frame of the animation -			gtimerStart(&gw->timer, ImageTimer, (void*)gh, FALSE, delay); +			gtimerStart(&gw->timer, ImageTimer, (void*)gh, gFalse, delay);  			break;  		}  	#endif @@ -139,20 +139,20 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) {  	return (GHandle)gobj;  } -bool_t gwinImageOpenGFile(GHandle gh, GFILE *f) { +gBool gwinImageOpenGFile(GHandle gh, GFILE *f) {  	// is it a valid handle?  	if (gh->vmt != (gwinVMT *)&imageVMT) -		return FALSE; +		return gFalse;  	if (gdispImageIsOpen(&gw->image))  		gdispImageClose(&gw->image);  	if ((gdispImageOpenGFile(&gw->image, f) & GDISP_IMAGE_ERR_UNRECOVERABLE)) -		return FALSE; +		return gFalse;  	_gwinUpdate(gh); -	return TRUE; +	return gTrue;  }  gdispImageError gwinImageCache(GHandle gh) { diff --git a/src/gwin/gwin_image.h b/src/gwin/gwin_image.h index b45629ee..2cf00761 100644 --- a/src/gwin/gwin_image.h +++ b/src/gwin/gwin_image.h @@ -40,10 +40,6 @@ typedef struct GImageObject {  	#endif  } GImageObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create an image widget.   * @details				Display's a picture. @@ -63,18 +59,18 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *widget, GWindowInit *pInit);  /**   * @brief				Opens the image using a GFILE - * @return				TRUE if the image can be opened + * @return				gTrue if the image can be opened   *   * @param[in] gh		The widget (must be an image widget)   * @param[in] f			The open (for reading) GFILE to use   *   * @api   */ -bool_t gwinImageOpenGFile(GHandle gh, GFILE *f); +gBool gwinImageOpenGFile(GHandle gh, GFILE *f);  /**   * @brief				Opens the image using the specified filename - * @return				TRUE if the open succeeds + * @return				gTrue if the open succeeds   *   * @param[in] gh		The widget (must be an image widget)   * @param[in] filename	The filename to open @@ -87,7 +83,7 @@ bool_t gwinImageOpenGFile(GHandle gh, GFILE *f);  	 * @brief				Sets the input routines that support reading the image from memory  	 *						in RAM or flash.  	 * @pre					GFILE_NEED_MEMFS must be GFXON -	 * @return				TRUE if the IO open function succeeds +	 * @return				gTrue if the IO open function succeeds  	 *  	 * @param[in] gh		The widget (must be an image widget)  	 * @param[in] ptr		A pointer to the image in RAM or Flash @@ -98,7 +94,7 @@ bool_t gwinImageOpenGFile(GHandle gh, GFILE *f);  /**   * @brief				Sets the input routines that support reading the image from a BaseFileStream (eg. an SD-Card). - * @return				TRUE if the IO open function succeeds + * @return				gTrue if the IO open function succeeds   * @pre					GFILE_NEED_CHIBIOSFS and GFX_USE_OS_CHIBIOS must be GFXON   *   * @param[in] gh		The widget (must be an image widget) @@ -120,10 +116,6 @@ bool_t gwinImageOpenGFile(GHandle gh, GFILE *f);   */  gdispImageError gwinImageCache(GHandle gh); -#ifdef __cplusplus -} -#endif -  #endif // _GWIN_IMAGE_H  /** @} */ diff --git a/src/gwin/gwin_keyboard.h b/src/gwin/gwin_keyboard.h index f98d6570..0f4185ab 100644 --- a/src/gwin/gwin_keyboard.h +++ b/src/gwin/gwin_keyboard.h @@ -64,10 +64,6 @@ typedef struct GKeyboardObject {  	uint32_t				key;  } GKeyboardObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a keyboard widget.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -138,9 +134,5 @@ void gwinKeyboardDraw_Normal(GWidgetObject *gw, void *param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_KEYBOARD_H */  /** @} */ diff --git a/src/gwin/gwin_label.c b/src/gwin/gwin_label.c index e6e31eec..b522768a 100644 --- a/src/gwin/gwin_label.c +++ b/src/gwin/gwin_label.c @@ -105,7 +105,7 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)  	return (GHandle)widget;  } -void gwinLabelSetBorder(GHandle gh, bool_t border) { +void gwinLabelSetBorder(GHandle gh, gBool border) {  	// is it a valid handle?  	if (gh->vmt != (gwinVMT *)&labelVMT)  		return; diff --git a/src/gwin/gwin_label.h b/src/gwin/gwin_label.h index 66c4d97d..77bf5364 100644 --- a/src/gwin/gwin_label.h +++ b/src/gwin/gwin_label.h @@ -53,10 +53,6 @@ typedef struct GLabelObject {  	#endif  } GLabelObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a label widget.   * @details				A label widget is a simple window which has a static text. @@ -80,7 +76,7 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);   *   * @api   */ -void gwinLabelSetBorder(GHandle gh, bool_t border); +void gwinLabelSetBorder(GHandle gh, gBool border);  #if GWIN_LABEL_ATTRIBUTE || defined(__DOXYGEN__)  	/** @@ -159,9 +155,5 @@ void gwinLabelDrawJustifiedCenter(GWidgetObject *gw, void *param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif // _GWIN_LABEL_H  /** @} */ diff --git a/src/gwin/gwin_list.c b/src/gwin/gwin_list.c index 5866603c..a14da805 100644 --- a/src/gwin/gwin_list.c +++ b/src/gwin/gwin_list.c @@ -297,7 +297,7 @@ static const gwidgetVMT listVMT = {  	#endif  }; -GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool_t multiselect) { +GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, gBool multiselect) {  	if (!(gobj = (GListObject *)_gwidgetCreate(g, &gobj->w, pInit, &listVMT)))  		return 0; @@ -315,7 +315,7 @@ GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool  	return (GHandle)gobj;  } -void gwinListEnableRender(GHandle gh, bool_t ena) { +void gwinListEnableRender(GHandle gh, gBool ena) {  	// is it a valid handle?  	if (gh->vmt != (gwinVMT *)&listVMT)  		return; @@ -348,7 +348,7 @@ void gwinListSetScroll(GHandle gh, scroll_t flag) {  	}  } -int gwinListAddItem(GHandle gh, const char* text, bool_t useAlloc) { +int gwinListAddItem(GHandle gh, const char* text, gBool useAlloc) {  	ListItem	*newItem;  	// is it a valid handle? @@ -391,7 +391,7 @@ int gwinListAddItem(GHandle gh, const char* text, bool_t useAlloc) {  	return gh2obj->cnt-1;  } -void gwinListItemSetText(GHandle gh, int item, const char* text, bool_t useAlloc) { +void gwinListItemSetText(GHandle gh, int item, const char* text, gBool useAlloc) {  	const gfxQueueASyncItem		*qi;  	int							i;  	ListItem					*newItem; @@ -578,23 +578,23 @@ uint16_t gwinListItemGetParam(GHandle gh, int item) {  	return 0;  } -bool_t gwinListItemIsSelected(GHandle gh, int item) { +gBool gwinListItemIsSelected(GHandle gh, int item) {  	const gfxQueueASyncItem	*	qi;  	int							i;  	// is it a valid handle?  	if (gh->vmt != (gwinVMT *)&listVMT) -		return FALSE; +		return gFalse;  	// watch out for an invalid item  	if (item < 0 || item > (gh2obj->cnt) - 1) -		return FALSE; +		return gFalse;  	for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) {  		if (i == item) -			return (qi2li->flags &  GLIST_FLG_SELECTED) ? TRUE : FALSE; +			return (qi2li->flags &  GLIST_FLG_SELECTED) ? gTrue : gFalse;  	} -	return FALSE; +	return gFalse;  }  int gwinListItemCount(GHandle gh) { @@ -617,7 +617,7 @@ const char* gwinListGetSelectedText(GHandle gh) {  	return gwinListItemGetText(gh, gwinListGetSelected(gh));  } -void gwinListSetSelected(GHandle gh, int item, bool_t doSelect) { +void gwinListSetSelected(GHandle gh, int item, gBool doSelect) {  	const gfxQueueASyncItem   *   qi;  	int                     i; diff --git a/src/gwin/gwin_list.h b/src/gwin/gwin_list.h index 041bbb68..9bd7075d 100644 --- a/src/gwin/gwin_list.h +++ b/src/gwin/gwin_list.h @@ -104,11 +104,6 @@ typedef struct ListItem {  	#endif  } ListItem; - -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a list widget   * @@ -127,13 +122,13 @@ extern "C" {   * @param[in] g			The GDisplay to display this window on   * @param[in] widget	The GListObject structure to initialize. If this is NULL, the structure is dynamically allocated.   * @param[in] pInit		The initialization parameters to use - * @param[in] multiselect	If TRUE the list is multi-select instead of single-select. + * @param[in] multiselect	If gTrue the list is multi-select instead of single-select.   *   * @return				NULL if there is no resulting drawing area, otherwise a window handle.   *   * @api   */ -GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bool_t multiselect); +GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, gBool multiselect);  #define gwinListCreate(w, pInit, m)			gwinGListCreate(GDISP, w, pInit, m)  /** @@ -144,11 +139,11 @@ GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bo   *						by temporarely disabling the render using this function.   *   * @param[in] gh		The widget handle (must be a list handle) - * @param[in] ena		TRUE or FALSE + * @param[in] ena		gTrue or gFalse   *   * @api   */ -void gwinListEnableRender(GHandle gh, bool_t ena); +void gwinListEnableRender(GHandle gh, gBool ena);  /**   * @brief				Change the behaviour of the scroll bar @@ -170,13 +165,13 @@ void gwinListSetScroll(GHandle gh, scroll_t flag);   *   * @param[in] gh		The widget handle (must be a list handle)   * @param[in] text		The string which shall be displayed in the list afterwards - * @param[in] useAlloc	If set to TRUE, the string will be dynamically allocated. A static buffer must be passed otherwise + * @param[in] useAlloc	If set to gTrue, the string will be dynamically allocated. A static buffer must be passed otherwise   *   * @return				The current ID of the item. The ID might change if you remove items from the middle of the list   *   * @api   */ -int gwinListAddItem(GHandle gh, const char* text, bool_t useAlloc); +int gwinListAddItem(GHandle gh, const char* text, gBool useAlloc);  /**   * @brief				Set the custom parameter of an item with a given ID @@ -184,11 +179,11 @@ int gwinListAddItem(GHandle gh, const char* text, bool_t useAlloc);   * @param[in] gh		The widget handle (must be a list handle)   * @param[in] item		The item ID   * @param[in] text		The text to replace the existing text - * @param[in] useAlloc	If set to TRUE, the string will be dynamically allocated. A static buffer must be passed otherwise + * @param[in] useAlloc	If set to gTrue, the string will be dynamically allocated. A static buffer must be passed otherwise   *   * @api   */ -void gwinListItemSetText(GHandle gh, int item, const char* text, bool_t useAlloc); +void gwinListItemSetText(GHandle gh, int item, const char* text, gBool useAlloc);  /**   * @brief				Get the name behind an item with a given ID @@ -273,11 +268,11 @@ int gwinListItemCount(GHandle gh);   * @param[in] gh		The widget handle (must be a list handle)   * @param[in] item		The item ID   * - * @return				TRUE if the item is selected, FALSE otherwise + * @return				gTrue if the item is selected, gFalse otherwise   *   * @api   */ -bool_t gwinListItemIsSelected(GHandle gh, int item); +gBool gwinListItemIsSelected(GHandle gh, int item);  /**   * @brief				Get the ID of the selected item @@ -312,7 +307,7 @@ const char* gwinListGetSelectedText(GHandle gh);   *   * @param[in] gh		The widget handle (must be a list handle)   * @param[in] item		The item ID - * @param[in] doSelect	TRUE to select the item or FALSE to deselect the item + * @param[in] doSelect	gTrue to select the item or gFalse to deselect the item   *   * @note				Changing the selection using this api call will NOT send the list selection   * 						change event. @@ -323,7 +318,7 @@ const char* gwinListGetSelectedText(GHandle gh);   * 						are selected, even in single-select mode.   * @api   */ -void gwinListSetSelected(GHandle gh, int item, bool_t doSelect); +void gwinListSetSelected(GHandle gh, int item, gBool doSelect);  /**   * @brief				Scroll the list so the specified item is in view @@ -396,10 +391,6 @@ void gwinListDefaultDraw(GWidgetObject* gw, void* param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif // _GWIN_LIST_H  /** @} */ diff --git a/src/gwin/gwin_progressbar.c b/src/gwin/gwin_progressbar.c index ce11934f..23d1b4c7 100644 --- a/src/gwin/gwin_progressbar.c +++ b/src/gwin/gwin_progressbar.c @@ -201,7 +201,7 @@ void gwinProgressbarDecrement(GHandle gh) {  		if (gh->vmt != (gwinVMT *)&progressbarVMT)  			return; -		gtimerStart(&gsw->gt, _progressbarCallback, gh, TRUE, delay); +		gtimerStart(&gsw->gt, _progressbarCallback, gh, gTrue, delay);  		#undef gsw  	} diff --git a/src/gwin/gwin_progressbar.h b/src/gwin/gwin_progressbar.h index 95feaf4a..aa4deb2d 100644 --- a/src/gwin/gwin_progressbar.h +++ b/src/gwin/gwin_progressbar.h @@ -36,10 +36,6 @@ typedef struct GProgressbarObject {  	#endif  } GProgressbarObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a progressbar window.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -221,9 +217,5 @@ void gwinProgressbarDraw_Std(GWidgetObject *gw, void *param);  #endif /* GDISP_NEED_IMAGE */  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_PROGRESSBAR_H */  /** @} */ diff --git a/src/gwin/gwin_radio.c b/src/gwin/gwin_radio.c index 8e0b4e64..d3747762 100644 --- a/src/gwin/gwin_radio.c +++ b/src/gwin/gwin_radio.c @@ -154,11 +154,11 @@ void gwinRadioPress(GHandle gh) {  	SendRadioEvent((GWidgetObject *)gh);  } -bool_t gwinRadioIsPressed(GHandle gh) { +gBool gwinRadioIsPressed(GHandle gh) {  	if (gh->vmt != (gwinVMT *)&radioVMT) -		return FALSE; +		return gFalse; -	return (gh->flags & GRADIO_FLG_PRESSED) ? TRUE : FALSE; +	return (gh->flags & GRADIO_FLG_PRESSED) ? gTrue : gFalse;  }  GHandle gwinRadioGetActive(uint16_t group) { @@ -224,7 +224,7 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {  		#if GWIN_NEED_FLASHING  			// Flash only the on state. -			pcol = _gwinGetFlashedColor(gw, pcol, FALSE); +			pcol = _gwinGetFlashedColor(gw, pcol, gFalse);  		#endif  		gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width-1, gw->g.height-1, gw->text, gw->g.font, pcol->text, pcol->fill, justifyCenter); @@ -243,7 +243,7 @@ void gwinRadioDraw_Radio(GWidgetObject *gw, void *param) {  		#if GWIN_NEED_FLASHING  			// Flash only the on state. -			pcol = _gwinGetFlashedColor(gw, pcol, FALSE); +			pcol = _gwinGetFlashedColor(gw, pcol, gFalse);  		#endif  		if ((gw->g.flags & GRADIO_FLG_PRESSED)) { diff --git a/src/gwin/gwin_radio.h b/src/gwin/gwin_radio.h index 514620c1..2328f95c 100644 --- a/src/gwin/gwin_radio.h +++ b/src/gwin/gwin_radio.h @@ -65,10 +65,6 @@ typedef struct GRadioObject {  	uint16_t			group;  } GRadioObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a radio widget.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -106,13 +102,13 @@ void gwinRadioPress(GHandle gh);  /**   * @brief	Is the radio button currently pressed - * @return	TRUE if the button is pressed + * @return	gTrue if the button is pressed   *   * @param[in] gh	The window handle (must be a radio widget)   *   * @api   */ -bool_t gwinRadioIsPressed(GHandle gh); +gBool gwinRadioIsPressed(GHandle gh);  /**   * @brief	Find the currently pressed radio button in the specified group @@ -177,9 +173,5 @@ void gwinRadioDraw_Button(GWidgetObject *gw, void *param);  void gwinRadioDraw_Tab(GWidgetObject *gw, void *param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_RADIO_H */  /** @} */ diff --git a/src/gwin/gwin_slider.c b/src/gwin/gwin_slider.c index d2e671b1..d3316bc2 100644 --- a/src/gwin/gwin_slider.c +++ b/src/gwin/gwin_slider.c @@ -326,7 +326,7 @@ void gwinSliderSetPosition(GHandle gh, int pos) {  	#undef gsw  } -void gwinSliderSendExtendedEvents(GHandle gh, bool_t enabled) { +void gwinSliderSendExtendedEvents(GHandle gh, gBool enabled) {  	if (gh->vmt != (gwinVMT *)&sliderVMT)  		return; diff --git a/src/gwin/gwin_slider.h b/src/gwin/gwin_slider.h index c388417d..588a39e8 100644 --- a/src/gwin/gwin_slider.h +++ b/src/gwin/gwin_slider.h @@ -69,10 +69,6 @@ typedef struct GSliderObject {  	int					pos;  } GSliderObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief   Create a slider window.   * @return  NULL if there is no resultant drawing area, otherwise a window handle. @@ -143,14 +139,14 @@ void gwinSliderSetPosition(GHandle gh, int pos);   * @brief   Should the slider send extended events.   *   * @param[in] gh		The window handle (must be a slider window) - * @param[in] enabled	TRUE to enable extended events, FALSE to disable them + * @param[in] enabled	gTrue to enable extended events, gFalse to disable them   *   * @note	The slider by default will only send slider events with an action of GSLIDER_EVENT_SET.   * 			This call can be used to enable other slider action's to be sent as events   *   * @api   */ -void gwinSliderSendExtendedEvents(GHandle gh, bool_t enabled); +void gwinSliderSendExtendedEvents(GHandle gh, gBool enabled);  /**   * @defgroup Renderings_Slider Renderings @@ -199,9 +195,5 @@ void gwinSliderDraw_Image(GWidgetObject *gw, void *param);  #endif /* GDISP_NEED_IMAGE */  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_SLIDER_H */  /** @} */ diff --git a/src/gwin/gwin_tabset.c b/src/gwin/gwin_tabset.c index 0bb18c18..43718391 100644 --- a/src/gwin/gwin_tabset.c +++ b/src/gwin/gwin_tabset.c @@ -108,7 +108,7 @@ static const gcontainerVMT tabpageVMT = {  	0,									// A child has been deleted (optional)  }; -void gwinTabsetSetTitle(GHandle gh, const char *title, bool_t useAlloc) { +void gwinTabsetSetTitle(GHandle gh, const char *title, gBool useAlloc) {  	if (gh->vmt != (gwinVMT *)&tabpageVMT)  		return; @@ -305,7 +305,7 @@ GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, ui  // API calls  /////////////////////////////////////////////////////////////////////////////////////////////////// -GHandle gwinTabsetAddTab(GHandle gh, const char *title, bool_t useAlloc) { +GHandle gwinTabsetAddTab(GHandle gh, const char *title, gBool useAlloc) {  	GWidgetInit		wi;  	if (gh->vmt != (gwinVMT *)&tabsetVMT) diff --git a/src/gwin/gwin_tabset.h b/src/gwin/gwin_tabset.h index 90d9eb3b..8c07c7d2 100644 --- a/src/gwin/gwin_tabset.h +++ b/src/gwin/gwin_tabset.h @@ -60,10 +60,6 @@ typedef struct GTabsetObject {  	coord_t				border_top;  	} GTabsetObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a tabset widget   * @@ -89,11 +85,11 @@ GHandle gwinGTabsetCreate(GDisplay *g, GTabsetObject *fo, GWidgetInit *pInit, ui   *   * @param[in] gh		The tabset handle   * @param[in] title		The text to set. This must be a constant string unless useAlloc is set. - * @param[in] useAlloc	If TRUE the string specified will be copied into dynamically allocated memory. + * @param[in] useAlloc	If gTrue the string specified will be copied into dynamically allocated memory.   *   * @api   */ -GHandle gwinTabsetAddTab(GHandle gh, const char *title, bool_t useAlloc); +GHandle gwinTabsetAddTab(GHandle gh, const char *title, gBool useAlloc);  /**   * @brief   			Delete a tab-page. @@ -144,14 +140,14 @@ GHandle gwinTabsetGetTabByTitle(GHandle gh, const char *title);   *   * @param[in] gh		The tab-page handle (NB: Use the page handle NOT the tabset handle)   * @param[in] title		The text to set. This must be a constant string unless useAlloc is set. - * @param[in] useAlloc	If TRUE the string specified will be copied into dynamically allocated memory. + * @param[in] useAlloc	If gTrue the string specified will be copied into dynamically allocated memory.   *   * @note				This function should be used to change the text associated with a tab-page   * 						rather than @p gwinSetText().   *   * @api   */ -void gwinTabsetSetTitle(GHandle gh, const char *title, bool_t useAlloc); +void gwinTabsetSetTitle(GHandle gh, const char *title, gBool useAlloc);  /**   * @brief   Get the title of a tab-page. @@ -232,10 +228,6 @@ void gwinTabsetDraw_Transparent(GWidgetObject *gw, void *param);  #endif /* GDISP_NEED_IMAGE */  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif /* _GWIN_TABSET_H */  /** @} */ diff --git a/src/gwin/gwin_textedit.c b/src/gwin/gwin_textedit.c index 61c28c66..1cc168f1 100644 --- a/src/gwin/gwin_textedit.c +++ b/src/gwin/gwin_textedit.c @@ -53,7 +53,7 @@ static void TextEditRemoveChar(GHandle gh) {  	gh2obj->w.text = p;  } -static bool_t TextEditAddChars(GHandle gh, unsigned cnt) { +static gBool TextEditAddChars(GHandle gh, unsigned cnt) {  	char		*p;  	const char	*q;  	unsigned	sz; @@ -65,21 +65,21 @@ static bool_t TextEditAddChars(GHandle gh, unsigned cnt) {  	if (!(gh->flags & GWIN_FLG_ALLOCTXT)) {  		if (!(p = gfxAlloc(sz+cnt))) -			return FALSE; +			return gFalse;  		memcpy(p, gh2obj->w.text, pos);  		memcpy(p+pos+cnt, gh2obj->w.text+pos, sz-pos);  		gh->flags |= GWIN_FLG_ALLOCTXT;  		gh2obj->w.text = p;  	} else {  		if (!(p = gfxRealloc((char *)gh2obj->w.text, sz, sz+cnt))) -			return FALSE; +			return gFalse;  		gh2obj->w.text = p;  		q = p+pos;  		p += sz;  		while(--p >= q)  			p[cnt] = p[0];  	} -	return TRUE; +	return gTrue;  }  // Function that allows to set the cursor to any position in the string diff --git a/src/gwin/gwin_textedit.h b/src/gwin/gwin_textedit.h index 0fdcc843..ea501caa 100644 --- a/src/gwin/gwin_textedit.h +++ b/src/gwin/gwin_textedit.h @@ -40,10 +40,6 @@ typedef struct GTexteditObject {  	uint16_t		cursorPos;  } GTexteditObject; -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief				Create a TextEdit widget   * @details				A TextEdit widget is a rectangular box which allows the user to input data through a keyboard. @@ -116,9 +112,5 @@ void gwinTexteditDefaultDraw(GWidgetObject* gw, void* param);  /** @} */ -#ifdef __cplusplus -} -#endif -  #endif // _GWIN_TEXTEDIT_H  /** @} */ diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c index 38b4e236..d4865935 100644 --- a/src/gwin/gwin_widget.c +++ b/src/gwin/gwin_widget.c @@ -238,12 +238,12 @@ static void gwidgetEvent(void *param, GEvent *pe) {  		return _widgetInFocus;
  	}
 -	bool_t gwinSetFocus(GHandle gh) {
 +	gBool gwinSetFocus(GHandle gh) {
  		GHandle	oldFocus;
  		// Do we already have the focus?
  		if (gh == _widgetInFocus)
 -			return TRUE;
 +			return gTrue;
  		// The new window must be NULLL or a visible enabled widget with a keyboard handler
  		if (!gh || ((gh->flags & (GWIN_FLG_WIDGET|GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED|GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE)) == (GWIN_FLG_WIDGET|GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED|GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE)
 @@ -253,20 +253,20 @@ static void gwidgetEvent(void *param, GEvent *pe) {  			_widgetInFocus = gh;
  			if (oldFocus)	_gwinUpdate(oldFocus);
  			if (gh)			_gwinUpdate(gh);
 -			return TRUE;
 +			return gTrue;
  		}
 -		return FALSE;
 +		return gFalse;
  	}
  	void _gwinMoveFocus(void) {
  		GHandle	gh;
 -		bool_t	looponce;
 +		gBool	looponce;
  		// Find a new focus window (one may or may not exist).
 -		looponce = FALSE;
 +		looponce = gFalse;
  		for(gh = gwinGetNextWindow(_widgetInFocus); ; gh = gwinGetNextWindow(gh)) {
  			if (!gh && !looponce) {
 -				looponce = TRUE;
 +				looponce = gTrue;
  				gh = gwinGetNextWindow(0);
  			}
  			if (gwinSetFocus(gh))
 @@ -494,7 +494,7 @@ void gwinWidgetClearInit(GWidgetInit *pwi) {  		*p++ = 0;
  }
 -void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll) {
 +void gwinSetDefaultStyle(const GWidgetStyle *pstyle, gBool updateAll) {
  	if (!pstyle)
  		pstyle = &BlackWidgetStyle;
 @@ -521,7 +521,7 @@ const GWidgetStyle *gwinGetDefaultStyle(void) {  	return defaultStyle;
  }
 -void gwinSetText(GHandle gh, const char *text, bool_t useAlloc) {
 +void gwinSetText(GHandle gh, const char *text, gBool useAlloc) {
  	if (!(gh->flags & GWIN_FLG_WIDGET))
  		return;
 @@ -595,12 +595,12 @@ const char *gwinGetText(GHandle gh) {  	return gw->text;
  }
 -bool_t gwinIsWidget(GHandle gh) {
 +gBool gwinIsWidget(GHandle gh) {
  	if (gh->flags & GWIN_FLG_WIDGET) {
 -		return TRUE;
 +		return gTrue;
  	}
 -	return FALSE;
 +	return gFalse;
  }
  void gwinSetStyle(GHandle gh, const GWidgetStyle *pstyle) {
 @@ -630,39 +630,39 @@ void gwinSetCustomDraw(GHandle gh, CustomWidgetDrawFunction fn, void *param) {  	_gwinUpdate(gh);
  }
 -bool_t gwinAttachListener(GListener *pl) {
 +gBool gwinAttachListener(GListener *pl) {
  	return geventAttachSource(pl, GWIDGET_SOURCE, 0);
  }
  #if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
 -	bool_t DEPRECATED("This call can now be removed. Attaching the mouse to GWIN is now automatic.") gwinAttachMouse(uint16_t instance) {
 +	gBool DEPRECATED("This call can now be removed. Attaching the mouse to GWIN is now automatic.") gwinAttachMouse(uint16_t instance) {
  		// This is now a NULL event because we automatically attach to all mice in the system.
  		(void) instance;
 -		return TRUE;
 +		return gTrue;
  	}
  #endif
  #if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
 -	bool_t gwinAttachToggle(GHandle gh, uint16_t role, uint16_t instance) {
 +	gBool gwinAttachToggle(GHandle gh, uint16_t role, uint16_t instance) {
  		GSourceHandle	gsh;
  		uint16_t		oi;
  		// Is this a widget
  		if (!(gh->flags & GWIN_FLG_WIDGET))
 -			return FALSE;
 +			return gFalse;
  		// Is the role valid
  		if (role >= wvmt->toggleroles)
 -			return FALSE;
 +			return gFalse;
  		// Is this a valid device
  		if (!(gsh = ginputGetToggle(instance)))
 -			return FALSE;
 +			return gFalse;
  		// Is this already done?
  		oi = wvmt->ToggleGet(gw, role);
  		if (instance == oi)
 -			return TRUE;
 +			return gTrue;
  		// Remove the old instance
  		if (oi != GWIDGET_NO_INSTANCE) {
 @@ -676,16 +676,16 @@ bool_t gwinAttachListener(GListener *pl) {  		return geventAttachSource(&gl, gsh, GLISTEN_TOGGLE_ON|GLISTEN_TOGGLE_OFF);
  	}
 -	bool_t gwinDetachToggle(GHandle gh, uint16_t role) {
 +	gBool gwinDetachToggle(GHandle gh, uint16_t role) {
  		uint16_t		oi;
  		// Is this a widget
  		if (!(gh->flags & GWIN_FLG_WIDGET))
 -			return FALSE;
 +			return gFalse;
  		// Is the role valid
  		if (role >= ((gwidgetVMT *)gh->vmt)->toggleroles)
 -			return FALSE;
 +			return gFalse;
  		oi = ((gwidgetVMT *)gh->vmt)->ToggleGet(gw, role);
 @@ -695,31 +695,31 @@ bool_t gwinAttachListener(GListener *pl) {  			if (!FindToggleUser(oi))
  				geventDetachSource(&gl, ginputGetToggle(oi));
  		}
 -		return TRUE;
 +		return gTrue;
  	}
  #endif
  #if GFX_USE_GINPUT && GINPUT_NEED_DIAL
 -	bool_t gwinAttachDial(GHandle gh, uint16_t role, uint16_t instance) {
 +	gBool gwinAttachDial(GHandle gh, uint16_t role, uint16_t instance) {
  		GSourceHandle	gsh;
  		uint16_t		oi;
  		if (!(gh->flags & GWIN_FLG_WIDGET))
 -			return FALSE;
 +			return gFalse;
  		// Is the role valid
  		if (role >= wvmt->dialroles)
 -			return FALSE;
 +			return gFalse;
  		// Is this a valid device
  		if (!(gsh = ginputGetDial(instance)))
 -			return FALSE;
 +			return gFalse;
  		// Is this already done?
  		oi = wvmt->DialGet(gw, role);
  		if (instance == oi)
 -			return TRUE;
 +			return gTrue;
  		// Remove the old instance
  		if (oi != GWIDGET_NO_INSTANCE) {
 diff --git a/src/gwin/gwin_widget.h b/src/gwin/gwin_widget.h index 58c71b16..c74eb877 100644 --- a/src/gwin/gwin_widget.h +++ b/src/gwin/gwin_widget.h @@ -90,7 +90,7 @@ typedef uint16_t	WidgetTag;   * 			to clear it.   * @note	The text element must be static string (not stack allocated). If you want to use   * 			a dynamic string (eg a stack allocated string) use NULL for this member and then call - * 			@p gwinSetText() with useAlloc set to TRUE. + * 			@p gwinSetText() with useAlloc set to gTrue.   *   * @{   */ @@ -168,10 +168,6 @@ typedef struct GEventGWin {  #define GEVENT_GWIN_CTRL_FIRST	(GEVENT_GWIN_FIRST+0x40)  /** @} */ -#ifdef __cplusplus -extern "C" { -#endif -  /**   * @brief	Clear a GWidgetInit structure to all zero's   * @note	This function is provided just to prevent problems @@ -188,7 +184,7 @@ void gwinWidgetClearInit(GWidgetInit *pwi);   * @brief   Set the default style for widgets created hereafter.   *   * @param[in] pstyle	The default style. Passing NULL uses the system compiled style. - * @param[in] updateAll	If TRUE then all existing widgets that are using the current default style + * @param[in] updateAll	If gTrue then all existing widgets that are using the current default style   * 						will be updated to use this new style. Widgets that have custom styles different   * 						from the default style will not be updated.   * @@ -196,7 +192,7 @@ void gwinWidgetClearInit(GWidgetInit *pwi);   *   * @api   */ -void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll); +void gwinSetDefaultStyle(const GWidgetStyle *pstyle, gBool updateAll);  /**   * @brief   Get the current default style. @@ -212,14 +208,14 @@ const GWidgetStyle *gwinGetDefaultStyle(void);   *   * @param[in] gh		The widget handle   * @param[in] text		The text to set. This must be a constant string unless useAlloc is set. - * @param[in] useAlloc	If TRUE the string specified will be copied into dynamically allocated memory. + * @param[in] useAlloc	If gTrue the string specified will be copied into dynamically allocated memory.   *   * @note				The widget is automatically redrawn   * @note				Non-widgets will ignore this call.   *   * @api   */ -void gwinSetText(GHandle gh, const char *text, bool_t useAlloc); +void gwinSetText(GHandle gh, const char *text, gBool useAlloc);  /**   * @brief   Get the text of a widget. @@ -254,11 +250,11 @@ const char *gwinGetText(GHandle gh);   *   * @param[in] gh		The handle to check.   * - * @return	TRUE if the passed handle is a widget handle. FALSE otherwise. + * @return	gTrue if the passed handle is a widget handle. gFalse otherwise.   *   * @api   */ -bool_t gwinIsWidget(GHandle gh); +gBool gwinIsWidget(GHandle gh);  #if GWIN_WIDGET_TAGS || defined(__DOXYGEN__)  	/** @@ -328,22 +324,22 @@ void gwinSetCustomDraw(GHandle gh, CustomWidgetDrawFunction fn, void *param);  /**   * @brief	Attach a Listener to listen for widget events - * @return	TRUE on success + * @return	gTrue on success   *   * @param[in] pl		The listener   *   * @api   */ -bool_t gwinAttachListener(GListener *pl); +gBool gwinAttachListener(GListener *pl);  #if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) || defined(__DOXYGEN__) -	bool_t DEPRECATED("This call can now be removed. Attaching the mouse to GWIN is now automatic.") gwinAttachMouse(uint16_t instance); +	gBool DEPRECATED("This call can now be removed. Attaching the mouse to GWIN is now automatic.") gwinAttachMouse(uint16_t instance);  #endif  #if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)  	/**  	 * @brief	Attach a toggle to a widget -	 * @return	TRUE on success +	 * @return	gTrue on success  	 *  	 * @param[in] gh		The widget handle  	 * @param[in] role		The function the toggle will perform for the widget @@ -351,31 +347,31 @@ bool_t gwinAttachListener(GListener *pl);  	 *  	 * @note		See the documentation on the specific widget to see the possible  	 * 				values for the role parameter. If it is out of range, this function -	 * 				will return FALSE +	 * 				will return gFalse  	 *  	 * @api  	 */ -	bool_t gwinAttachToggle(GHandle gh, uint16_t role, uint16_t instance); +	gBool gwinAttachToggle(GHandle gh, uint16_t role, uint16_t instance);  	/**  	 * @brief	Detach a toggle from a widget -	 * @return	TRUE on success +	 * @return	gTrue on success  	 *  	 * @param[in] gh		The widget handle  	 * @param[in] role		The function the toggle will perform for the widget  	 *  	 * @note		See the documentation on the specific widget to see the possible  	 * 				values for the role parameter. If it is out of range, this function -	 * 				will return FALSE +	 * 				will return gFalse  	 *  	 * @api  	 */ -	bool_t gwinDetachToggle(GHandle gh, uint16_t role); +	gBool gwinDetachToggle(GHandle gh, uint16_t role);  #endif  #if (GFX_USE_GINPUT && GINPUT_NEED_DIAL) || defined(__DOXYGEN__)  	/**  	 * @brief	Attach a toggle to a widget -	 * @return	TRUE on success +	 * @return	gTrue on success  	 *  	 * @param[in] gh		The widget handle  	 * @param[in] role		The function the dial will perform for the widget @@ -383,17 +379,17 @@ bool_t gwinAttachListener(GListener *pl);  	 *  	 * @note		See the documentation on the specific widget to see the possible  	 * 				values for the role parameter. If it is out of range, this function -	 * 				will return FALSE +	 * 				will return gFalse  	 *  	 * @api  	 */ -	bool_t gwinAttachDial(GHandle gh, uint16_t role, uint16_t instance); +	gBool gwinAttachDial(GHandle gh, uint16_t role, uint16_t instance);  #endif  #if (GFX_USE_GINPUT && GINPUT_NEED_KEYBOARD) || GWIN_NEED_KEYBOARD || defined(__DOXYGEN__)  	/**  	 * @brief	Set the keyboard focus to a specific window -	 * @return	Returns TRUE if the focus could be set to that window +	 * @return	Returns gTrue if the focus could be set to that window  	 *  	 * @param[in] gh	The window  	 * @@ -402,7 +398,7 @@ bool_t gwinAttachListener(GListener *pl);  	 *  	 * @api  	 */ -	bool_t gwinSetFocus(GHandle gh); +	gBool gwinSetFocus(GHandle gh);  	/**  	 * @brief	Get the widget that is currently in focus @@ -417,11 +413,7 @@ bool_t gwinAttachListener(GListener *pl);  	GHandle gwinGetFocus(void);  #else  	#define gwinGetFocus()		(0) -	#define gwinSetFocus(gh)	(FALSE) -#endif - -#ifdef __cplusplus -} +	#define gwinSetFocus(gh)	(gFalse)  #endif  /* Include extra widget types */ diff --git a/src/gwin/gwin_wm.c b/src/gwin/gwin_wm.c index 7f251a70..6761180f 100644 --- a/src/gwin/gwin_wm.c +++ b/src/gwin/gwin_wm.c @@ -34,11 +34,11 @@  		gfxMutexDestroy(&gmutex);  	} -	bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit) { +	gBool _gwinWMAdd(GHandle gh, const GWindowInit *pInit) {  		gh->x = gh->y = gh->width = gh->height = 0;  		gwinMove(gh, pInit->x, pInit->y);  		gwinResize(gh, pInit->width, pInit->height); -		return TRUE; +		return gTrue;  	}  	void _gwinFlushRedraws(GRedrawMethod how) { @@ -83,12 +83,12 @@  		gh->flags &= ~(GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW);  	} -	bool_t _gwinDrawStart(GHandle gh) { +	gBool _gwinDrawStart(GHandle gh) {  		if (!(gh->flags & GWIN_FLG_SYSVISIBLE)) -			return FALSE; +			return gFalse;  		getLock(gh); -		return TRUE; +		return gTrue;  	}  	void _gwinDrawEnd(GHandle gh) { @@ -96,7 +96,7 @@  		exitLock(gh);  	} -	void gwinSetVisible(GHandle gh, bool_t visible) { +	void gwinSetVisible(GHandle gh, gBool visible) {  		if (visible) {  			if (!(gh->flags & GWIN_FLG_VISIBLE)) {  				gh->flags |= (GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE|GWIN_FLG_BGREDRAW); @@ -111,7 +111,7 @@  		}  	} -	void gwinSetEnabled(GHandle gh, bool_t enabled) { +	void gwinSetEnabled(GHandle gh, gBool enabled) {  		if (enabled) {  			if (!(gh->flags & GWIN_FLG_ENABLED)) {  				gh->flags |= (GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED); @@ -161,7 +161,7 @@  // The default window manager  extern const GWindowManager	GNullWindowManager;  GWindowManager *			_GWINwm; -bool_t						_gwinFlashState; +gBool						_gwinFlashState;  static gfxSem				gwinsem;  static gfxQueueASync		_GWINList;  #if GWIN_NEED_FLASHING @@ -190,7 +190,7 @@ void _gwmInit(void)  	#endif  	#if !GWIN_REDRAW_IMMEDIATE  		gtimerInit(&RedrawTimer); -		gtimerStart(&RedrawTimer, RedrawTimerFn, 0, TRUE, TIME_INFINITE); +		gtimerStart(&RedrawTimer, RedrawTimerFn, 0, gTrue, TIME_INFINITE);  	#endif  	_GWINwm = (GWindowManager *)&GNullWindowManager;  	_GWINwm->vmt->Init(); @@ -366,11 +366,11 @@ void _gwinUpdate(GHandle gh) {  	}  #endif -bool_t _gwinDrawStart(GHandle gh) { +gBool _gwinDrawStart(GHandle gh) {  	// This test should occur inside the lock. We do this  	//	here as well as an early out (more efficient).  	if (!(gh->flags & GWIN_FLG_SYSVISIBLE)) -		return FALSE; +		return gFalse;  	// Obtain the drawing lock  	gfxSemWait(&gwinsem, TIME_INFINITE); @@ -378,14 +378,14 @@ bool_t _gwinDrawStart(GHandle gh) {  	// Re-test visibility as we may have waited a while  	if (!(gh->flags & GWIN_FLG_SYSVISIBLE)) {  		_gwinDrawEnd(gh); -		return FALSE; +		return gFalse;  	}  	// OK - we are ready to draw.  	#if GDISP_NEED_CLIP  		gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height);  	#endif -	return TRUE; +	return gTrue;  }  void _gwinDrawEnd(GHandle gh) { @@ -401,19 +401,19 @@ void _gwinDrawEnd(GHandle gh) {  	gfxSemSignal(&gwinsem);  } -bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit) { +gBool _gwinWMAdd(GHandle gh, const GWindowInit *pInit) {  	#if GWIN_NEED_CONTAINERS  		// Save the parent  		gh->parent = pInit->parent;  		// Ensure the display is consistent with any parents  		if (gh->parent && (!(gh->parent->flags & GWIN_FLG_CONTAINER) || gh->display != gh->parent->display)) -			return FALSE; +			return gFalse;  	#endif  	// Add to the window manager  	if (!_GWINwm->vmt->Add(gh, pInit)) -		return FALSE; +		return gFalse;  	#if GWIN_NEED_CONTAINERS  		// Notify the parent it has been added @@ -421,7 +421,7 @@ bool_t _gwinWMAdd(GHandle gh, const GWindowInit *pInit) {  			((gcontainerVMT *)gh->parent->vmt)->NotifyAdd(gh->parent, gh);  	#endif -	return TRUE; +	return gTrue;  }  void gwinSetWindowManager(struct GWindowManager *gwm) { @@ -448,7 +448,7 @@ void gwinRedraw(GHandle gh) {  }  #if GWIN_NEED_CONTAINERS -	void gwinSetVisible(GHandle gh, bool_t visible) { +	void gwinSetVisible(GHandle gh, gBool visible) {  		if (visible) {  			// Mark us as visible  			gh->flags |= GWIN_FLG_VISIBLE; @@ -463,7 +463,7 @@ void gwinRedraw(GHandle gh) {  			TriggerRedraw();  	}  #else -	void gwinSetVisible(GHandle gh, bool_t visible) { +	void gwinSetVisible(GHandle gh, gBool visible) {  		if (visible) {  			if (!(gh->flags & GWIN_FLG_VISIBLE)) {  				gh->flags |= (GWIN_FLG_VISIBLE|GWIN_FLG_SYSVISIBLE|GWIN_FLG_NEEDREDRAW|GWIN_FLG_BGREDRAW); @@ -491,7 +491,7 @@ void gwinRedraw(GHandle gh) {  #if GWIN_NEED_CONTAINERS  	// These two sub-functions set/clear system enable recursively. -	void gwinSetEnabled(GHandle gh, bool_t enabled) { +	void gwinSetEnabled(GHandle gh, gBool enabled) {  		if (enabled) {  			// Mark us as enabled  			gh->flags |= GWIN_FLG_ENABLED; @@ -530,7 +530,7 @@ void gwinRedraw(GHandle gh) {  		}  	}  #else -	void gwinSetEnabled(GHandle gh, bool_t enabled) { +	void gwinSetEnabled(GHandle gh, gBool enabled) {  		if (enabled) {  			if (!(gh->flags & GWIN_FLG_ENABLED)) {  				gh->flags |= (GWIN_FLG_ENABLED|GWIN_FLG_SYSENABLED); @@ -577,7 +577,7 @@ GWindowMinMax gwinGetMinMax(GHandle gh) {  	return GWIN_NORMAL;  } -void gwinRedrawDisplay(GDisplay *g, bool_t preserve) { +void gwinRedrawDisplay(GDisplay *g, gBool preserve) {  	GHandle	gh;  	for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) { @@ -631,7 +631,7 @@ GHandle gwinGetNextWindow(GHandle gh) {  			gtimerStop(&FlashTimer);  	} -	void gwinSetFlashing(GHandle gh, bool_t flash) { +	void gwinSetFlashing(GHandle gh, gBool flash) {  		// Start flashing?  		if (flash) { @@ -642,9 +642,9 @@ GHandle gwinGetNextWindow(GHandle gh) {  				RedrawPending |= DOREDRAW_FLASHRUNNING;  				// Ensure we start the timer with flash bit on -				_gwinFlashState = FALSE; +				_gwinFlashState = gFalse;  				FlashTimerFn(0);														// First flash -				gtimerStart(&FlashTimer, FlashTimerFn, 0, TRUE, GWIN_FLASHING_PERIOD);	// Subsequent flashes +				gtimerStart(&FlashTimer, FlashTimerFn, 0, gTrue, GWIN_FLASHING_PERIOD);	// Subsequent flashes  			}  		// Stop flashing? @@ -656,7 +656,7 @@ GHandle gwinGetNextWindow(GHandle gh) {  	}  	#if GWIN_NEED_WIDGET -		const GColorSet *_gwinGetFlashedColor(GWidgetObject *gw, const GColorSet *pcol, bool_t flashOffState) { +		const GColorSet *_gwinGetFlashedColor(GWidgetObject *gw, const GColorSet *pcol, gBool flashOffState) {  			// Does the flashing state affect the current colors?  			if ((gw->g.flags & GWIN_FLG_FLASHING) && _gwinFlashState) { @@ -688,7 +688,7 @@ GHandle gwinGetNextWindow(GHandle gh) {  static void WM_Init(void);  static void WM_DeInit(void); -static bool_t WM_Add(GHandle gh, const GWindowInit *pInit); +static gBool WM_Add(GHandle gh, const GWindowInit *pInit);  static void WM_Delete(GHandle gh);  static void WM_Redraw(GHandle gh);  static void WM_Size(GHandle gh, coord_t w, coord_t h); @@ -726,7 +726,7 @@ static void WM_DeInit(void) {  	// A full window manager would remove any borders etc  } -static bool_t WM_Add(GHandle gh, const GWindowInit *pInit) { +static gBool WM_Add(GHandle gh, const GWindowInit *pInit) {  	// Note the window will not currently be marked as visible  	// Put it on the end of the queue @@ -737,7 +737,7 @@ static bool_t WM_Add(GHandle gh, const GWindowInit *pInit) {  	gh->x = gh->y = 0;  	WM_Move(gh, pInit->x, pInit->y);  	WM_Size(gh, pInit->width, pInit->height); -	return TRUE; +	return gTrue;  }  static void WM_Delete(GHandle gh) { @@ -860,7 +860,7 @@ static void WM_Size(GHandle gh, coord_t w, coord_t h) {  		} else {  			// We need to make this window invisible and ensure that has been drawn -			gwinSetVisible(gh, FALSE); +			gwinSetVisible(gh, gFalse);  			_gwinFlushRedraws(REDRAW_WAIT);  			// Resize @@ -878,7 +878,7 @@ static void WM_Size(GHandle gh, coord_t w, coord_t h) {  			#endif  			// Mark it visible again in its new location -			gwinSetVisible(gh, TRUE); +			gwinSetVisible(gh, gTrue);  		}  	} else {  		gh->width = w; gh->height = h; @@ -941,7 +941,7 @@ static void WM_Move(GHandle gh, coord_t x, coord_t y) {  	// Clear the old area and then redraw  	if ((gh->flags & GWIN_FLG_SYSVISIBLE)) {  		// We need to make this window invisible and ensure that has been drawn -		gwinSetVisible(gh, FALSE); +		gwinSetVisible(gh, gFalse);  		_gwinFlushRedraws(REDRAW_WAIT);  		// Do the move @@ -959,7 +959,7 @@ static void WM_Move(GHandle gh, coord_t x, coord_t y) {  			}  		#endif -		gwinSetVisible(gh, TRUE); +		gwinSetVisible(gh, gTrue);  	} else {  		u = gh->x; gh->x = x;  		v = gh->y; gh->y = y; @@ -996,13 +996,13 @@ static void WM_Raise(GHandle gh) {  		if ((gh->flags & GWIN_FLG_CONTAINER)) {  			GHandle		gx;  			GHandle		child; -			bool_t		restart; +			gBool		restart;  			// Raise the children too  			// Note: Children can also have their own children so after each move we have to start again.  			for (gx = gwinGetNextWindow(0); gx; gx = gwinGetNextWindow(gx)) {  				if ((gx->flags & GWIN_FLG_CONTAINER)) { -					restart = FALSE; +					restart = gFalse;  					for (child = gwinGetNextWindow(0); child && child != gx; child = gwinGetNextWindow(child)) {  						if (child->parent == gx) {  							// Oops - this child is behind its parent. Move it to the front. @@ -1012,7 +1012,7 @@ static void WM_Raise(GHandle gh) {  							// Restart at the front of the list for this parent container as we have moved this child  							// to the end of the list. We also need to restart everything once this container is done.  							child = 0; -							restart = TRUE; +							restart = gTrue;  						}  					}  					if (restart) | 
