aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gadc/gadc.h4
-rw-r--r--include/gaudin/gaudin.h4
-rw-r--r--include/gdisp/fonts.h1
-rw-r--r--include/gdisp/gdisp.h31
-rw-r--r--include/gdisp/image.h42
-rw-r--r--include/gdisp/lld/gdisp_lld_msgs.h24
-rw-r--r--include/gevent/gevent.h11
-rw-r--r--include/gfx.h43
-rw-r--r--include/gfx_rules.h68
-rw-r--r--include/gmisc/gmisc.h96
-rw-r--r--include/gmisc/options.h26
-rw-r--r--include/gos/chibios.h124
-rw-r--r--include/gos/gos.h483
-rw-r--r--include/gos/options.h66
-rw-r--r--include/gos/posix.h31
-rw-r--r--include/gos/win32.h31
-rw-r--r--include/gtimer/gtimer.h6
-rw-r--r--include/gwin/console.h32
18 files changed, 1014 insertions, 109 deletions
diff --git a/include/gadc/gadc.h b/include/gadc/gadc.h
index af43ce06..6da63a15 100644
--- a/include/gadc/gadc.h
+++ b/include/gadc/gadc.h
@@ -179,7 +179,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn);
/**
* @brief Allow retrieving of results from the high speed ADC using a Binary Semaphore and a static event buffer.
*
- * @param[in] pbsem The binary semaphore is signaled when data is available.
+ * @param[in] pbsem The semaphore is signaled when data is available.
* @param[in] pEvent The static event buffer to place the result information.
*
* @note Passing a NULL for pbsem or pEvent will turn off signalling via this method as will calling
@@ -189,7 +189,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn);
*
* @api
*/
-void gadcHighSpeedSetBSem(BinarySemaphore *pbsem, GEventADC *pEvent);
+void gadcHighSpeedSetBSem(gfxSem *pbsem, GEventADC *pEvent);
/**
* @brief Start the high speed ADC conversions.
diff --git a/include/gaudin/gaudin.h b/include/gaudin/gaudin.h
index 0a530cf9..7175f631 100644
--- a/include/gaudin/gaudin.h
+++ b/include/gaudin/gaudin.h
@@ -136,7 +136,7 @@ bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer,
/**
* @brief Allow retrieving of results from the audio input using a Binary Semaphore and a static event buffer.
*
- * @param[in] pbsem The binary semaphore is signaled when data is available.
+ * @param[in] pbsem The semaphore is signaled when data is available.
* @param[in] pEvent The static event buffer to place the result information.
*
* @note Passing a NULL for pbsem or pEvent will turn off signalling via this method.
@@ -145,7 +145,7 @@ bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer,
*
* @api
*/
-void gaudinSetBSem(BinarySemaphore *pbsem, GEventAudioIn *pEvent);
+void gaudinSetBSem(gfxSem *pbsem, GEventAudioIn *pEvent);
/**
* @brief Start the audio input conversions.
diff --git a/include/gdisp/fonts.h b/include/gdisp/fonts.h
index ca175b77..881b90ad 100644
--- a/include/gdisp/fonts.h
+++ b/include/gdisp/fonts.h
@@ -12,7 +12,6 @@
* by the low level drivers that need to understand a font.
*
* @addtogroup GDISP
- *
* @{
*/
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h
index 8c14ca9f..c005f1e3 100644
--- a/include/gdisp/gdisp.h
+++ b/include/gdisp/gdisp.h
@@ -45,20 +45,6 @@ typedef int16_t coord_t;
/*===========================================================================*/
/**
- * @brief The type for a fixed point coordinate.
- * @details The top 16 bits are the integer component, the bottom 16 bits are the real component.
- */
-typedef int32_t fpcoord_t;
-
-/**
- * @brief Macros to convert to and from a fixed point coord.
- * @{
- */
-#define COORD2FP(x) ((fpcoord_t)(x)<<16)
-#define FP2COORD(x) ((coord_t)((x)>>16))
-/* @} */
-
-/**
* @brief Type for a 2D point on the screen.
*/
typedef struct point_t {
@@ -318,19 +304,6 @@ extern "C" {
/* Base Functions */
/**
- * @brief GDISP Driver initialization.
- * @details Must be called before any other gdisp function.
- *
- * @note This function is NOT currently implicitly invoked by @p halInit().
- * It must be called manually.
- *
- * @return True if succeeded, False otherwise
- *
- * @api
- */
- bool_t gdispInit(void);
-
- /**
* @brief Test if the GDISP engine is currently drawing.
* @note This function will always return FALSE if
* GDISP_NEED_ASYNC is not defined.
@@ -568,7 +541,6 @@ extern "C" {
#if GDISP_NEED_CONTROL || defined(__DOXYGEN__)
/**
* @brief Control hardware specific parts of the display. eg powermodes, backlight etc
- * @pre The GDISP unit must have been initialised using @p gdispInit().
* @note Depending on the hardware implementation this function may not
* support some codes. They will be ignored.
*
@@ -585,7 +557,6 @@ extern "C" {
#if GDISP_NEED_QUERY || defined(__DOXYGEN__)
/**
* @brief Query a property of the display.
- * @pre The GDISP unit must have been initialised using @p gdispInit().
* @note The result must be typecast to the correct type.
* @note An unsupported query will return (void *)-1.
*
@@ -601,7 +572,7 @@ extern "C" {
#include "gdisp/lld/gdisp_lld.h"
/* The same as above but use the low level driver directly if no multi-thread support is needed */
- #define gdispInit(gdisp) gdisp_lld_init()
+ #define _gdispInit(gdisp) gdisp_lld_init()
#define gdispIsBusy() FALSE
#define gdispClear(color) gdisp_lld_clear(color)
#define gdispDrawPixel(x, y, color) gdisp_lld_draw_pixel(x, y, color)
diff --git a/include/gdisp/image.h b/include/gdisp/image.h
index f169a0f1..5dcd9c56 100644
--- a/include/gdisp/image.h
+++ b/include/gdisp/image.h
@@ -129,19 +129,21 @@ extern "C" {
*/
bool_t gdispImageSetMemoryReader(gdispImage *img, const void *memimage);
- /**
- * @brief Sets the io fields in the image structure to routines
- * that support reading from an image stored on a BaseFileStream (eg SDCard).
- *
- * @return TRUE if the IO open function succeeds
- *
- * @param[in] img The image structure
- * @param[in] BaseFileStreamPtr A pointer to the (open) BaseFileStream object.
- *
- */
- bool_t gdispImageSetBaseFileStreamReader(gdispImage *img, void *BaseFileStreamPtr);
+ #if GFX_USE_OS_CHIBIOS || defined(__DOXYGEN__)
+ /**
+ * @brief Sets the io fields in the image structure to routines
+ * that support reading from an image stored on a BaseFileStream (eg SDCard).
+ *
+ * @return TRUE if the IO open function succeeds
+ *
+ * @param[in] img The image structure
+ * @param[in] BaseFileStreamPtr A pointer to the (open) BaseFileStream object.
+ *
+ */
+ bool_t gdispImageSetBaseFileStreamReader(gdispImage *img, void *BaseFileStreamPtr);
+ #endif
- #if defined(WIN32) || defined(__DOXYGEN__)
+ #if defined(WIN32) || GFX_USE_OS_WIN32 || GFX_USE_OS_POSIX || defined(__DOXYGEN__)
/**
* @brief Sets the io fields in the image structure to routines
* that support reading from an image stored in Win32 simulators native
@@ -154,7 +156,9 @@ extern "C" {
* @param[in] filename The filename to open
*
*/
- bool_t gdispImageSetSimulFileReader(gdispImage *img, const char *filename);
+ bool_t gdispImageSetFileReader(gdispImage *img, const char *filename);
+ /* Old definition */
+ #define gdispImageSetSimulFileReader(img, fname) gdispImageSetFileReader(img, fname)
#endif
/**
@@ -261,7 +265,7 @@ extern "C" {
* @note Calling gdispImageDraw() after getting a TIME_INFINITE will go back to drawing the first
* frame/page.
*/
- systime_t gdispImageNext(gdispImage *img);
+ delaytime_t gdispImageNext(gdispImage *img);
#if GDISP_NEED_IMAGE_NATIVE
/**
@@ -283,7 +287,7 @@ extern "C" {
void gdispImageClose_NATIVE(gdispImage *img);
gdispImageError gdispImageCache_NATIVE(gdispImage *img);
gdispImageError gdispImageDraw_NATIVE(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
- systime_t gdispImageNext_NATIVE(gdispImage *img);
+ delaytime_t gdispImageNext_NATIVE(gdispImage *img);
/* @} */
#endif
@@ -299,7 +303,7 @@ extern "C" {
void gdispImageClose_GIF(gdispImage *img);
gdispImageError gdispImageCache_GIF(gdispImage *img);
gdispImageError gdispImageDraw_GIF(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
- systime_t gdispImageNext_GIF(gdispImage *img);
+ delaytime_t gdispImageNext_GIF(gdispImage *img);
/* @} */
#endif
@@ -315,7 +319,7 @@ extern "C" {
void gdispImageClose_BMP(gdispImage *img);
gdispImageError gdispImageCache_BMP(gdispImage *img);
gdispImageError gdispImageDraw_BMP(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
- systime_t gdispImageNext_BMP(gdispImage *img);
+ delaytime_t gdispImageNext_BMP(gdispImage *img);
/* @} */
#endif
@@ -331,7 +335,7 @@ extern "C" {
void gdispImageClose_JPG(gdispImage *img);
gdispImageError gdispImageCache_JPG(gdispImage *img);
gdispImageError gdispImageDraw_JPG(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
- systime_t gdispImageNext_JPG(gdispImage *img);
+ delaytime_t gdispImageNext_JPG(gdispImage *img);
/* @} */
#endif
@@ -347,7 +351,7 @@ extern "C" {
void gdispImageClose_PNG(gdispImage *img);
gdispImageError gdispImageCache_PNG(gdispImage *img);
gdispImageError gdispImageDraw_PNG(gdispImage *img, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t sx, coord_t sy);
- systime_t gdispImageNext_PNG(gdispImage *img);
+ delaytime_t gdispImageNext_PNG(gdispImage *img);
/* @} */
#endif
diff --git a/include/gdisp/lld/gdisp_lld_msgs.h b/include/gdisp/lld/gdisp_lld_msgs.h
index de3d3035..91d8ed97 100644
--- a/include/gdisp/lld/gdisp_lld_msgs.h
+++ b/include/gdisp/lld/gdisp_lld_msgs.h
@@ -59,26 +59,34 @@ typedef enum gdisp_msgaction {
} gdisp_msgaction_t;
typedef union gdisp_lld_msg {
- gdisp_msgaction_t action;
+ struct {
+ gfxQueueItem qi;
+ gdisp_msgaction_t action;
+ };
struct gdisp_lld_msg_init {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_INIT
} init;
struct gdisp_lld_msg_clear {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_CLEAR
color_t color;
} clear;
struct gdisp_lld_msg_drawpixel {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWPIXEL
coord_t x, y;
color_t color;
} drawpixel;
struct gdisp_lld_msg_fillarea {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLAREA
coord_t x, y;
coord_t cx, cy;
color_t color;
} fillarea;
struct gdisp_lld_msg_blitarea {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_BLITAREA
coord_t x, y;
coord_t cx, cy;
@@ -87,41 +95,48 @@ typedef union gdisp_lld_msg {
const pixel_t *buffer;
} blitarea;
struct gdisp_lld_msg_setclip {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_SETCLIP
coord_t x, y;
coord_t cx, cy;
} setclip;
struct gdisp_lld_msg_drawline {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWLINE
coord_t x0, y0;
coord_t x1, y1;
color_t color;
} drawline;
struct gdisp_lld_msg_drawcircle {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCIRCLE
coord_t x, y;
coord_t radius;
color_t color;
} drawcircle;
struct gdisp_lld_msg_fillcircle {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCIRCLE
coord_t x, y;
coord_t radius;
color_t color;
} fillcircle;
struct gdisp_lld_msg_drawellipse {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWELLIPSE
coord_t x, y;
coord_t a, b;
color_t color;
} drawellipse;
struct gdisp_lld_msg_fillellipse {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLELLIPSE
coord_t x, y;
coord_t a, b;
color_t color;
} fillellipse;
struct gdisp_lld_msg_drawarc {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWARC
coord_t x, y;
coord_t radius;
@@ -129,6 +144,7 @@ typedef union gdisp_lld_msg {
color_t color;
} drawarc;
struct gdisp_lld_msg_fillarc {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLARC
coord_t x, y;
coord_t radius;
@@ -136,6 +152,7 @@ typedef union gdisp_lld_msg {
color_t color;
} fillarc;
struct gdisp_lld_msg_drawchar {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCHAR
coord_t x, y;
char c;
@@ -143,6 +160,7 @@ typedef union gdisp_lld_msg {
color_t color;
} drawchar;
struct gdisp_lld_msg_fillchar {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCHAR
coord_t x, y;
char c;
@@ -151,11 +169,13 @@ typedef union gdisp_lld_msg {
color_t bgcolor;
} fillchar;
struct gdisp_lld_msg_getpixelcolor {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_GETPIXELCOLOR
coord_t x, y;
color_t result;
} getpixelcolor;
struct gdisp_lld_msg_verticalscroll {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_VERTICALSCROLL
coord_t x, y;
coord_t cx, cy;
@@ -163,11 +183,13 @@ typedef union gdisp_lld_msg {
color_t bgcolor;
} verticalscroll;
struct gdisp_lld_msg_control {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_CONTROL
int what;
void * value;
} control;
struct gdisp_lld_msg_query {
+ gfxQueueItem qi;
gdisp_msgaction_t action; // GDISP_LLD_MSG_QUERY
int what;
void * result;
diff --git a/include/gevent/gevent.h b/include/gevent/gevent.h
index 27d05db6..59557991 100644
--- a/include/gevent/gevent.h
+++ b/include/gevent/gevent.h
@@ -25,11 +25,6 @@
#if GFX_USE_GEVENT || defined(__DOXYGEN__)
-/* Data part of a static GListener initializer */
-#define _GLISTENER_DATA(name) { _SEMAPHORE_DATA(name.waitqueue, 0), _BSEMAPHORE_DATA(name.eventlock, FALSE), 0, 0, {0} }
-/* Static GListener initializer */
-#define GLISTENER_DECL(name) GListener name = _GLISTENER_DATA(name)
-
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
@@ -60,8 +55,8 @@ typedef void (*GEventCallbackFn)(void *param, GEvent *pe);
// The Listener Object
typedef struct GListener {
- Semaphore waitqueue; // Private: Semaphore for the listener to wait on.
- BinarySemaphore eventlock; // Private: Protect against more than one sources trying to use this event lock at the same time
+ gfxSem waitqueue; // Private: Semaphore for the listener to wait on.
+ gfxSem eventlock; // Private: Protect against more than one sources trying to use this event lock at the same time
GEventCallbackFn callback; // Private: Call back Function
void *param; // Private: Parameter for the callback function.
GEvent event; // Public: The event object into which the event information is stored.
@@ -163,7 +158,7 @@ void geventDetachSource(GListener *pl, GSourceHandle gsh);
*
* @return NULL on timeout
*/
-GEvent *geventEventWait(GListener *pl, systime_t timeout);
+GEvent *geventEventWait(GListener *pl, delaytime_t timeout);
/* @brief Register a callback for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should be typecast to the
diff --git a/include/gfx.h b/include/gfx.h
index ba4a9167..84aec39f 100644
--- a/include/gfx.h
+++ b/include/gfx.h
@@ -16,6 +16,25 @@
#ifndef _GFX_H
#define _GFX_H
+/**
+ * These two definitions below are required before anything else so that we can
+ * turn module definitions off and on.
+ */
+
+/**
+ * @brief Generic 'false' boolean constant.
+ */
+#if !defined(FALSE) || defined(__DOXYGEN__)
+ #define FALSE 0
+#endif
+
+/**
+ * @brief Generic 'true' boolean constant.
+ */
+#if !defined(TRUE) || defined(__DOXYGEN__)
+ #define TRUE -1
+#endif
+
/* gfxconf.h is the user's project configuration for the GFX system. */
#include "gfxconf.h"
@@ -122,6 +141,7 @@
* Get all the options for each sub-system.
*
*/
+#include "gos/options.h"
#include "gmisc/options.h"
#include "gevent/options.h"
#include "gtimer/options.h"
@@ -142,6 +162,7 @@
/**
* Include the sub-system header files
*/
+#include "gos/gos.h"
#include "gmisc/gmisc.h"
#include "gevent/gevent.h"
#include "gtimer/gtimer.h"
@@ -153,5 +174,27 @@
#include "gaudin/gaudin.h"
#include "gaudout/gaudout.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * @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.
+ *
+ * @api
+ */
+ void gfxInit(void);
+
+ /* Compatibility for old programs */
+ #define gdispInit() gfxInit()
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _GFX_H */
/** @} */
diff --git a/include/gfx_rules.h b/include/gfx_rules.h
index b93ea8ae..4fff2d21 100644
--- a/include/gfx_rules.h
+++ b/include/gfx_rules.h
@@ -22,28 +22,51 @@
* These are defined in the order of their inter-dependancies.
*/
+#ifndef GFX_DISPLAY_RULE_WARNINGS
+ #define GFX_DISPLAY_RULE_WARNINGS FALSE
+#endif
+
+#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_POSIX
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
+ #endif
+ #undef GFX_USE_OS_CHIBIOS
+ #define GFX_USE_OS_CHIBIOS TRUE
+#endif
+#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_POSIX != 1 * TRUE
+ #error "GOS: More than one operation system has been defined as TRUE."
+#endif
+
#if GFX_USE_GWIN
#if !GFX_USE_GDISP
#error "GWIN: GFX_USE_GDISP must be TRUE when using GWIN"
#endif
#if !GDISP_NEED_CLIP
- #warning "GWIN: Drawing can occur outside the defined windows as GDISP_NEED_CLIP is FALSE"
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GWIN: Drawing can occur outside the defined windows as GDISP_NEED_CLIP is FALSE"
+ #endif
#endif
#if GWIN_NEED_BUTTON
#if !GDISP_NEED_TEXT
#error "GWIN: GDISP_NEED_TEXT is required if GWIN_NEED_BUTTON is TRUE."
#endif
#if !GFX_USE_GEVENT
- #warning "GWIN: GFX_USE_GEVENT is required if GWIN_NEED_BUTTON is TRUE. It has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GWIN: GFX_USE_GEVENT is required if GWIN_NEED_BUTTON is TRUE. It has been turned on for you."
+ #endif
#undef GFX_USE_GEVENT
#define GFX_USE_GEVENT TRUE
#endif
#if !GFX_USE_GINPUT || !(GINPUT_NEED_MOUSE || GINPUT_NEED_TOGGLE)
- #warning "GWIN: You have set GWIN_NEED_BUTTON to TRUE but no supported GINPUT (mouse/toggle) devices have been included"
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GWIN: You have set GWIN_NEED_BUTTON to TRUE but no supported GINPUT (mouse/toggle) devices have been included"
+ #endif
#endif
#if !GDISP_NEED_MULTITHREAD && !GDISP_NEED_ASYNC
- #warning "GWIN: Either GDISP_NEED_MULTITHREAD or GDISP_NEED_ASYNC is required if GWIN_NEED_BUTTON is TRUE."
- #warning "GWIN: GDISP_NEED_MULTITHREAD has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GWIN: Either GDISP_NEED_MULTITHREAD or GDISP_NEED_ASYNC is required if GWIN_NEED_BUTTON is TRUE."
+ #warning "GWIN: GDISP_NEED_MULTITHREAD has been turned on for you."
+ #endif
#undef GDISP_NEED_MULTITHREAD
#define GDISP_NEED_MULTITHREAD TRUE
#endif
@@ -59,12 +82,16 @@
#if GFX_USE_GINPUT
#if !GFX_USE_GEVENT
- #warning "GINPUT: GFX_USE_GEVENT is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GINPUT: GFX_USE_GEVENT is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
+ #endif
#undef GFX_USE_GEVENT
#define GFX_USE_GEVENT TRUE
#endif
#if !GFX_USE_GTIMER
- #warning "GINPUT: GFX_USE_GTIMER is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GINPUT: GFX_USE_GTIMER is required if GFX_USE_GINPUT is TRUE. It has been turned on for you."
+ #endif
#undef GFX_USE_GTIMER
#define GFX_USE_GTIMER TRUE
#endif
@@ -74,13 +101,6 @@
#if GDISP_NEED_MULTITHREAD && GDISP_NEED_ASYNC
#error "GDISP: Only one of GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC should be defined."
#endif
- #if GDISP_NEED_ASYNC
- #if !GDISP_NEED_MSGAPI
- #warning "GDISP: Messaging API is required for Async Multi-Thread. It has been turned on for you."
- #undef GDISP_NEED_MSGAPI
- #define GDISP_NEED_MSGAPI TRUE
- #endif
- #endif
#endif
#if GFX_USE_TDISP
@@ -88,33 +108,33 @@
#if GFX_USE_GAUDIN
#if GFX_USE_GEVENT && !GFX_USE_GTIMER
- #warning "GAUDIN: GFX_USE_GTIMER is required if GFX_USE_GAUDIN and GFX_USE_GEVENT are TRUE. It has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GAUDIN: GFX_USE_GTIMER is required if GFX_USE_GAUDIN and GFX_USE_GEVENT are TRUE. It has been turned on for you."
+ #endif
#undef GFX_USE_GTIMER
#define GFX_USE_GTIMER TRUE
#endif
#endif
#if GFX_USE_GADC
- #if !CH_USE_MUTEXES || !CH_USE_SEMAPHORES
- #error "GADC: CH_USE_MUTEXES and CH_USE_SEMAPHORES must be defined in chconf.h"
- #endif
#if !GFX_USE_GTIMER
- #warning "GADC: GFX_USE_GTIMER is required if GFX_USE_GADC is TRUE. It has been turned on for you."
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GADC: GFX_USE_GTIMER is required if GFX_USE_GADC is TRUE. It has been turned on for you."
+ #endif
#undef GFX_USE_GTIMER
#define GFX_USE_GTIMER TRUE
#endif
#endif
#if GFX_USE_GEVENT
- #if !CH_USE_MUTEXES || !CH_USE_SEMAPHORES
- #error "GEVENT: CH_USE_MUTEXES and CH_USE_SEMAPHORES must be defined in chconf.h"
- #endif
#endif
#if GFX_USE_GTIMER
#if GFX_USE_GDISP && !GDISP_NEED_MULTITHREAD && !GDISP_NEED_ASYNC
- #warning "GTIMER: Neither GDISP_NEED_MULTITHREAD nor GDISP_NEED_ASYNC has been specified."
- #warning "GTIMER: Make sure you are not performing any GDISP/GWIN drawing operations in the timer callback!"
+ #if GFX_DISPLAY_RULE_WARNINGS
+ #warning "GTIMER: Neither GDISP_NEED_MULTITHREAD nor GDISP_NEED_ASYNC has been specified."
+ #warning "GTIMER: Make sure you are not performing any GDISP/GWIN drawing operations in the timer callback!"
+ #endif
#endif
#endif
diff --git a/include/gmisc/gmisc.h b/include/gmisc/gmisc.h
index bf1aa498..21eb2bbe 100644
--- a/include/gmisc/gmisc.h
+++ b/include/gmisc/gmisc.h
@@ -37,6 +37,32 @@ typedef enum ArrayDataFormat_e {
ARRAY_DATA_16BITUNSIGNED = 16, ARRAY_DATA_16BITSIGNED = 17,
} ArrayDataFormat;
+/**
+ * @brief The type for a fixed point type.
+ * @details The top 16 bits are the integer component, the bottom 16 bits are the real component.
+ */
+typedef int32_t fixed;
+
+/**
+ * @brief Macros to convert to and from a fixed point.
+ * @{
+ */
+#define FIXED(x) ((fixed)(x)<<16) /* @< integer to fixed */
+#define NONFIXED(x) ((x)>>16) /* @< fixed to integer */
+#define FP2FIXED(x) ((fixed)((x)*65536.0)) /* @< floating point to fixed */
+#define FIXED2FP(x) ((double)(x)/65536.0) /* @< fixed to floating point */
+/* @} */
+
+/**
+ * @brief The famous number pi
+ */
+#define PI 3.1415926535897932384626433832795028841971693993751
+
+/**
+ * @brief pi as a fixed point
+ */
+#define FIXED_PI FP2FIXED(PI)
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -85,6 +111,76 @@ extern "C" {
#endif
#endif
+#if GMISC_NEED_FASTTRIG || defined(__DOXYGEN__)
+ extern const double sintabledouble[];
+
+ /**
+ * @brief Fast Table Based Trig functions
+ * @return A double in the range -1.0 .. 0.0 .. 1.0
+ *
+ * @param[in] degrees The angle in degrees (not radians)
+ *
+ * @note These functions use degrees rather than radians to describe the angle.
+ *
+ * @api
+ * @{
+ */
+ double fsin(int degrees);
+ double fcos(int degrees);
+ /** @}
+ *
+ * @brief Fast Table Based Trig functions
+ * @return A double in the range -1.0 .. 0.0 .. 1.0
+ *
+ * @param[in] degrees The angle in degrees 0 .. 359
+ *
+ * @note These functions use degrees rather than radians to describe the angle.
+ * @note These functions are super fast but require the parameter to be in range.
+ * Use the lowercase functions if the parameter may not be in range or if a
+ * required trig function is not supported in this form.
+ *
+ * @api
+ * @{
+ */
+ #define FSIN(degrees) sintabledouble[degrees];
+ /** @} */
+#endif
+
+#if GMISC_NEED_FIXEDTRIG || defined(__DOXYGEN__)
+ extern const fixed sintablefixed[];
+
+ /**
+ * @brief Fast Table Based Trig functions
+ * @return A fixed point in the range -1.0 .. 0.0 .. 1.0
+ *
+ * @param[in] degrees The angle in degrees (not radians)
+ *
+ * @note These functions use degrees rather than radians to describe the angle.
+ *
+ * @api
+ * @{
+ */
+ fixed ffsin(int degrees);
+ fixed ffcos(int degrees);
+ /** @}
+ *
+ * @brief Fast Table Based Trig functions
+ * @return A fixed point in the range -1.0 .. 0.0 .. 1.0
+ *
+ * @param[in] degrees The angle in degrees 0 .. 359
+ *
+ * @note These functions use degrees rather than radians to describe the angle.
+ * @note These functions are super fast but require the parameter to be in range.
+ * Use the lowercase functions if the parameter may not be in range or if a
+ * required trig function is not supported in this form.
+ *
+ * @api
+ * @{
+ */
+ #define FFSIN(degrees) sintablefixed[degrees];
+ /** @} */
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/include/gmisc/options.h b/include/gmisc/options.h
index ee58609e..5a2f68ea 100644
--- a/include/gmisc/options.h
+++ b/include/gmisc/options.h
@@ -1,9 +1,9 @@
-/*
- * This file is subject to the terms of the GFX License, v1.0. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://chibios-gfx.com/license.html
- */
+/*
+ * This file is subject to the terms of the GFX License, v1.0. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://chibios-gfx.com/license.html
+ */
/**
* @file include/gmisc/options.h
@@ -27,6 +27,20 @@
#ifndef GMISC_NEED_ARRAYOPS
#define GMISC_NEED_ARRAYOPS FALSE
#endif
+ /**
+ * @brief Include fast array based trig functions (sin, cos)
+ * @details Defaults to FALSE
+ */
+ #ifndef GMISC_NEED_FASTTRIG
+ #define GMISC_NEED_FASTTRIG FALSE
+ #endif
+ /**
+ * @brief Include fast fixed point trig functions (sin, cos)
+ * @details Defaults to FALSE
+ */
+ #ifndef GMISC_NEED_FIXEDTRIG
+ #define GMISC_NEED_FIXEDTRIG FALSE
+ #endif
/**
* @}
*
diff --git a/include/gos/chibios.h b/include/gos/chibios.h
new file mode 100644
index 00000000..37bf93ee
--- /dev/null
+++ b/include/gos/chibios.h
@@ -0,0 +1,124 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gos/chibios.h
+ * @brief GOS - Operating System Support header file for ChibiOS.
+ */
+
+#ifndef _GOS_CHIBIOS_H
+#define _GOS_CHIBIOS_H
+
+#if GFX_USE_OS_CHIBIOS
+
+#include "ch.h"
+#include "hal.h"
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+/**
+ * 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
+ */
+
+typedef systime_t delaytime_t;
+typedef systime_t systemticks_t;
+typedef cnt_t semcount_t;
+typedef msg_t threadreturn_t;
+typedef tprio_t threadpriority_t;
+
+typedef threadreturn_t (*gfxThreadFunction)(void *param);
+
+#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
+#define LOW_PRIORITY LOWPRIO
+#define NORMAL_PRIORITY NORMALPRIO
+#define HIGH_PRIORITY HIGHPRIO
+#define DECLARESTACK(name, sz) WORKING_AREA(name, sz);
+
+
+typedef struct {
+ Semaphore sem;
+ semcount_t limit;
+ } gfxSem;
+
+#define gfxMutex Mutex
+
+typedef struct gfxQueue {
+ struct gfxQueueItem *head;
+ struct gfxQueueItem *tail;
+ Semaphore sem;
+ } gfxQueue;
+
+typedef struct gfxQueueItem {
+ struct gfxQueueItem *next;
+ Semaphore sem;
+ } gfxQueueItem;
+
+/*===========================================================================*/
+/* Function declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define gfxHalt(msg) chDbgPanic(msg)
+#define gfxExit() chSysHalt()
+#define gfxAlloc(sz) chHeapAlloc(NULL, sz)
+#define gfxFree(ptr) chHeapFree(ptr)
+void gfxSleepMilliseconds(delaytime_t ms);
+void gfxSleepMicroseconds(delaytime_t ms);
+void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
+bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
+void gfxSemSignal(gfxSem *psem);
+void gfxSemSignalI(gfxSem *psem);
+#define gfxSemCounterI(psem) ((psem)->sem.s_cnt)
+#define gfxSemCounter(psem) ((psem)->sem.s_cnt)
+#define gfxSystemTicks() chTimeNow()
+#define gfxMillisecondsToTicks(ms) MS2ST(ms)
+#define gfxYield() chThdYield()
+#define gfxSystemLock() chSysLock()
+#define gfxSystemUnlock() chSysUnlock()
+#define gfxMutexInit(pmutex) chMtxInit(pmutex)
+#define gfxMutexEnter(pmutex) chMtxLock(pmutex)
+#define gfxMutexExit(pmutex) chMtxUnlock()
+void gfxQueueInit(gfxQueue *pqueue);
+gfxQueueItem * gfxQueueGet(gfxQueue *pqueue, delaytime_t ms);
+bool_t gfxQueuePut(gfxQueue *pqueue, gfxQueueItem *pitem, delaytime_t ms);
+#define gfxQueuePop(q) gfxQueueGet(q)
+bool_t gfxQueuePush(gfxQueue *pqueue, gfxQueueItem *pitem, delaytime_t ms);
+void gfxQueueRemove(gfxQueue *pqueue, gfxQueueItem *pitem);
+bool_t gfxQueueIsEmpty(gfxQueue *pqueue);
+bool_t gfxQueueIsIn(gfxQueue *pqueue, gfxQueueItem *pitem);
+bool_t gfxCreateThread(void *stackarea, size_t stacksz, threadpriority_t prio, gfxThreadFunction fn, void *param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_OS_CHIBIOS */
+#endif /* _GOS_CHIBIOS_H */
diff --git a/include/gos/gos.h b/include/gos/gos.h
new file mode 100644
index 00000000..04799540
--- /dev/null
+++ b/include/gos/gos.h
@@ -0,0 +1,483 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gos/gos.h
+ * @brief GOS - Operating System Support header file.
+ *
+ * @addtogroup GOS
+ * @brief GOS provides the operating system interface with the GFX library.
+ * @note Some of the routines specified below may be implemented simply as
+ * a macro to the real operating system call.
+ * @{
+ */
+
+#ifndef _GOS_H
+#define _GOS_H
+
+#if defined(__DOXYGEN__)
+ /*===========================================================================*/
+ /* Type definitions */
+ /*===========================================================================*/
+
+ /**
+ * @brief A function for a new thread to execute.
+ */
+ typedef threadreturn_t (*gfxThreadFunction)(void *param);
+
+ /**
+ * @brief Various integer sizes
+ * @note Your platform may use slightly different definitions to these
+ * @{
+ */
+ 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;
+ /**
+ * @}
+ *
+ * @brief Various platform (and operating system) dependent types
+ * @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;
+ typedef int threadreturn_t;
+ typedef int threadpriority_t;
+ /**
+ * @}
+ *
+ * @brief Various platform (and operating system) constants
+ * @note Your platform may use slightly different definitions to these
+ * @{
+ */
+ #define FALSE 0
+ #define TRUE 1
+ #define TIME_IMMEDIATE 0
+ #define TIME_INFINITE ((delaytime_t)-1)
+ #define MAX_SEMAPHORE_COUNT ((semcount_t)-1)
+ #define LOW_PRIORITY 0
+ #define NORMAL_PRIORITY 1
+ #define HIGH_PRIORITY 2
+ #define DECLARESTACK(name, sz) uint8_t name[sz];
+ /* @} */
+
+ /**
+ * @brief A semaphore
+ * @note Your operating system will have a proper definition for this structure
+ */
+ typedef struct {} gfxSem;
+
+ /**
+ * @brief A mutex
+ * @note Your operating system will have a proper definition for this structure
+ */
+ typedef struct {} gfxMutex;
+
+ /**
+ * @brief A queue
+ * @note Your operating system will have a proper definition for this structure
+ */
+ typedef struct {} gfxQueue;
+
+ /**
+ * @brief A queue item
+ * @note Your operating system will have a proper definition for this structure
+ */
+ typedef struct {} gfxQueueItem;
+
+ /*===========================================================================*/
+ /* Function declarations. */
+ /*===========================================================================*/
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+ /**
+ * @brief Halt the GFX application due to an error.
+ *
+ * @param[in] msg An optional debug message to show (Can be NULL)
+ *
+ * @api
+ */
+ void gfxHalt(const char *msg);
+
+ /**
+ * @brief Exit the GFX application.
+ *
+ * @api
+ */
+ void gfxExit(void);
+
+ /**
+ * @brief Allocate memory
+ * @return A pointer to the memory allocated or NULL if there is no more memory available
+ *
+ * @param[in] sz The size in bytes of the area to allocate
+ *
+ * @api
+ */
+ void *gfxAlloc(size_t sz);
+
+ /**
+ * @brief Free memory
+ *
+ * @param[in] ptr The memory to free
+ *
+ * @api
+ */
+ void gfxFree(void *ptr);
+
+ /**
+ * @brief Put the current thread to sleep for the specified period in milliseconds
+ *
+ * @param[in] ms The number milliseconds to sleep
+ *
+ * @note Specifying TIME_IMMEDIATE will yield the current thread but return
+ * on the next time slice.
+ * @note Specifying TIME_INFINITE will sleep forever.
+ *
+ * @api
+ */
+ void gfxSleepMilliseconds(delaytime_t ms);
+
+ /**
+ * @brief Put the current thread to sleep for the specified period in microseconds
+ *
+ * @param[in] ms The number microseconds to sleep
+ *
+ * @note Specifying TIME_IMMEDIATE will return immediately (no sleeping)
+ * @note Specifying TIME_INFINITE will sleep forever.
+ *
+ * @api
+ */
+ void gfxSleepMicroseconds(delaytime_t ms);
+
+ /**
+ * @brief Initialise a Counted Semaphore
+ *
+ * @param[in] psem A pointer to the semaphore
+ * @param[in] val The initial value of the semaphore
+ * @param[in] limit The maxmimum value of the semaphore
+ *
+ * @note Operations defined for counted semaphores:
+ * Signal: The semaphore counter is increased and if the result is non-positive then a waiting thread
+ * is queued for execution. Note that once the thread reaches "limit", further signals are
+ * ignored.
+ * Wait: The semaphore counter is decreased and if the result becomes negative the thread is queued
+ * in the semaphore and suspended.
+ *
+ * @api
+ */
+ void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
+
+ /**
+ * @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
+ *
+ * @param[in] psem A pointer to the semaphore
+ * @param[in] ms The maxmimum time to wait for the semaphore
+ *
+ * @api
+ */
+ bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
+
+ /**
+ * @brief Signal a semaphore
+ * @details The semaphore counter is increased and if the result is non-positive then a waiting thread
+ * is queued for execution. Note that once the thread reaches "limit", further signals are
+ * ignored.
+ *
+ * @param[in] psem A pointer to the semaphore
+ *
+ * @api
+ */
+ void gfxSemSignal(gfxSem *psem);
+
+ /**
+ * @brief Signal a semaphore
+ * @details The semaphore counter is increased and if the result is non-positive then a waiting thread
+ * is queued for execution. Note that once the thread reaches "limit", further signals are
+ * ignored.
+ *
+ * @param[in] psem A pointer to the semaphore
+ *
+ * @iclass
+ * @api
+ */
+ void gfxSemSignalI(gfxSem *psem);
+
+ /**
+ * @brief Get the current semaphore count
+ * @return The current semaphore count
+ *
+ * @param[in] psem A pointer to the semaphore
+ *
+ * @api
+ */
+ semcount_t gfxSemCounter(gfxSem *pSem);
+
+ /**
+ * @brief Get the current semaphore count
+ * @return The current semaphore count
+ *
+ * @param[in] psem A pointer to the semaphore
+ *
+ * @iclass
+ * @api
+ */
+ semcount_t gfxSemCounterI(gfxSem *pSem);
+
+ /**
+ * @brief Get the current operating system tick time
+ * @return The current tick time
+ *
+ * @note A "tick" is an arbitrary period of time that the operating
+ * system uses to mark time.
+ * @note The absolute value of this call is relatively meaningless. Its usefulness
+ * is in calculating periods between two calls to this function.
+ * @note As the value from this function can wrap it is important that any periods are calculated
+ * as t2 - t1 and then compared to the desired period rather than comparing
+ * t1 + period to t2
+ *
+ * @api
+ */
+ systemticks_t gfxSystemTicks(void);
+
+ /**
+ * @brief Convert a given number of millseconds to a number of operating system ticks
+ * @return The period in system ticks.
+ *
+ * @note A "tick" is an arbitrary period of time that the operating
+ * system uses to mark time.
+ *
+ * @param[in] ms The number of millseconds
+ *
+ * @api
+ */
+ systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
+
+ /**
+ * @brief Yield the current thread
+ * @details Give up the rest of the current time slice for this thread in order to give other threads
+ * a chance to run.
+ *
+ * @api
+ */
+ void gfxYield(void);
+
+ /**
+ * @brief Lock the operating system to protect a sequence of code
+ *
+ * @note Calling this will lock out all other threads from executing even at interrupt level
+ * within the GFX system. On hardware this may be implemented as a disabling of interrupts,
+ * however in an operating system which hides real interrupt level code it may simply use a
+ * mutex lock.
+ * @note The thread MUST NOT block whilst the system is locked. It must execute in this state for
+ * as short a period as possible as this can seriously affect interrupt latency on some
+ * platforms.
+ * @note While locked only interrupt level (iclass) GFX routines may be called.
+ *
+ * @api
+ */
+ void gfxSystemLock(void);
+
+ /**
+ * @brief Unlock the operating system previous locked by gfxSystemLock()
+ *
+ * @api
+ */
+ void gfxSystemUnlock(void);
+
+ /**
+ * @brief Initialise a mutex to protect a region of code from other threads.
+ *
+ * @param[in] pmutex A pointer to the mutex
+ *
+ * @note Whilst a counting semaphore with a limit of 1 can be used for similiar purposes
+ * on many operating systems using a seperate mutex structure is more efficient.
+ *
+ * @api
+ */
+ void gfxMutexInit(gfxMutex *pmutex);
+
+ /**
+ * @brief Enter the critical code region protected by the mutex.
+ * @details Blocks until there is no other thread in the critical region.
+ *
+ * @param[in] pmutex A pointer to the mutex
+ *
+ * @api
+ */
+ void gfxMutexEnter(gfxMutex *pmutex);
+
+ /**
+ * @brief Exit the critical code region protected by the mutex.
+ * @details May cause another thread waiting on the mutex to now be placed into the run queue.
+ *
+ * @param[in] pmutex A pointer to the mutex
+ *
+ * @api
+ */
+ void gfxMutexExit(gfxMutex *pmutex);
+
+ /**
+ * @brief Initialise a queue.
+ *
+ * @param[in] pqueue A pointer to the queue
+ *
+ * @note Whilst queues are normally FIFO, a GFX queue also supports push and pop operations.
+ * A pop operation is the same as normal get from the queue but a push places the item
+ * at the head of the queue instead of the tail (as a put would).
+ *
+ * @api
+ */
+ void gfxQueueInit(gfxQueue *pqueue);
+
+ /**
+ * @brief Get an item from the head of the queue.
+ * @return NULL if the timeout expires before an item is available
+ *
+ * @param[in] pqueue A pointer to the queue
+ * @param[in] ms The maxmimum time to wait for an item
+ *
+ * @api
+ */
+ gfxQueueItem * gfxQueueGet(gfxQueue *pqueue, delaytime_t ms);
+
+ /**
+ * @brief Put an item on the end of the queue.
+ * @return FALSE on timeout, otherwise TRUE
+ *
+ * @param[in] pqueue A pointer to the queue
+ * @param[in] pitem A pointer to the queue item
+ * @param[in] ms The maxmimum time to wait for an item to be removed from the queue
+ *
+ * @note Use a delay time of TIME_IMMEDIATE if you don't want to wait until the
+ * item is removed from the queue
+ *
+ * @api
+ */
+ bool_t gfxQueuePut(gfxQueue *pqueue, gfxQueueItem *pitem, delaytime_t ms);
+
+ /**
+ * @brief Pop an item from the head of the queue.
+ * @return NULL if there are no more items on the queue
+ *
+ * @param[in] pqueue A pointer to the queue
+ *
+ * @api
+ */
+ #define gfxQueuePop(pqueue, ms) gfxQueueGet(pqueue, ms)
+
+ /**
+ * @brief Push an item into the start of the queue.
+ * @return FALSE on timeout, otherwise TRUE
+ *
+ * @param[in] pqueue A pointer to the queue
+ * @param[in] pitem A pointer to the queue item
+ * @param[in] ms The maxmimum time to wait for an item to be popped
+ *
+ * @note Use a delay time of TIME_IMMEDIATE if you don't want to wait until the
+ * item is removed from the queue
+ *
+ * @api
+ */
+ bool_t gfxQueuePush(gfxQueue *pqueue, gfxQueueItem *pitem, delaytime_t ms);
+
+ /**
+ * @brief Remove an item from the queue.
+ * @note Removes the specified item from the queue whereever it is in the queue
+ *
+ * @param[in] pqueue A pointer to the queue
+ * @param[in] pitem A pointer to the queue item
+ *
+ * @note If the item isn't in the queue the routine just returns.
+ *
+ * @api
+ */
+ void gfxQueueRemove(gfxQueue *pqueue, gfxQueueItem *pitem);
+
+ /**
+ * @brief Is the queue empty?
+ * @return TRUE if the queue is empty
+ *
+ * @param[in] pqueue A pointer to the queue
+ *
+ * @api
+ */
+ bool_t gfxQueueIsEmpty(gfxQueue *pqueue);
+
+ /**
+ * @brief Is an item in the queue?
+ * @return TRUE if the item is in the queue?
+ *
+ * @param[in] pqueue A pointer to the queue
+ * @param[in] pitem A pointer to the queue item
+ *
+ * @note This operation may be expensive.
+ *
+ * @api
+ */
+ bool_t gfxQueueIsIn(gfxQueue *pqueue, gfxQueueItem *pitem);
+
+ /**
+ * @brief Start a new thread.
+ * @return Return TRUE if the thread was started, FALSE on an error
+ *
+ * @param[in] stackarea A pointer to the area for the new threads stack or NULL to dynamically allocate it
+ * @param[in] stacksz The size of the thread stack. 0 means the default operating system size although this
+ * is only valid when stackarea is dynamically allocated.
+ * @param[in] prio The priority of the new thread
+ * @param[in] fn The function the new thread will run
+ * @param[in] param A parameter to pass the thread function.
+ *
+ * @api
+ */
+ bool_t gfxCreateThread(void *stackarea, size_t stacksz, threadpriority_t prio, gfxThreadFunction fn, void *param);
+
+ #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.
+ */
+#elif GFX_USE_OS_CHIBIOS
+ #include "gos/chibios.h"
+#elif GFX_USE_OS_WIN32
+ #include "gos/win32.h"
+#elif GFX_USE_OS_POSIX
+ #include "gos/posix.h"
+#else
+ #error "Your operating system is not supported yet"
+#endif
+
+#endif /* _GOS_H */
+/** @} */
diff --git a/include/gos/options.h b/include/gos/options.h
new file mode 100644
index 00000000..f9d41bb5
--- /dev/null
+++ b/include/gos/options.h
@@ -0,0 +1,66 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file include/gos/options.h
+ * @brief GOS - Operating System options header file.
+ *
+ * @addtogroup GOS
+ * @{
+ */
+
+#ifndef _GOS_OPTIONS_H
+#define _GOS_OPTIONS_H
+
+/**
+ * @name GOS The operating system to use. One (and only one) of these must be defined.
+ * @{
+ */
+ /**
+ * @brief Use ChibiOS
+ * @details Defaults to FALSE
+ */
+ #ifndef GFX_USE_OS_CHIBIOS
+ #define GFX_USE_OS_CHIBIOS FALSE
+ #endif
+ /**
+ * @brief Use Win32
+ * @details Defaults to FALSE
+ */
+ #ifndef GFX_USE_OS_WIN32
+ #define GFX_USE_OS_WIN32 FALSE
+ #endif
+ /**
+ * @brief Use a unix variant with posix threads
+ * @details Defaults to FALSE
+ */
+ #ifndef GFX_USE_OS_POSIX
+ #define GFX_USE_OS_POSIX FALSE
+ #endif
+/**
+ * @}
+ *
+ * @name GOS Optional Sizing Parameters
+ * @{
+ */
+/** @} */
+
+#endif /* _GOS_OPTIONS_H */
+/** @} */
diff --git a/include/gos/posix.h b/include/gos/posix.h
new file mode 100644
index 00000000..f61b13db
--- /dev/null
+++ b/include/gos/posix.h
@@ -0,0 +1,31 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gos/posix.h
+ * @brief GOS - Operating System Support header file for POSIX.
+ */
+
+#ifndef _GOS_POSIX_H
+#define _GOS_POSIX_H
+
+#if GFX_USE_OS_POSIX
+#endif /* GFX_USE_OS_POSIX */
+
+#endif /* _GOS_POSIX_H */
diff --git a/include/gos/win32.h b/include/gos/win32.h
new file mode 100644
index 00000000..a6f28865
--- /dev/null
+++ b/include/gos/win32.h
@@ -0,0 +1,31 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/gos/win32.h
+ * @brief GOS - Operating System Support header file for WIN32.
+ */
+
+#ifndef _GOS_WIN32_H
+#define _GOS_WIN32_H
+
+#if GFX_USE_OS_WIN32
+#endif /* GFX_USE_OS_WIN32 */
+
+#endif /* _GOS_WIN32_H */
diff --git a/include/gtimer/gtimer.h b/include/gtimer/gtimer.h
index 7d7747d4..5ad8c7c0 100644
--- a/include/gtimer/gtimer.h
+++ b/include/gtimer/gtimer.h
@@ -51,8 +51,8 @@ typedef void (*GTimerFunction)(void *param);
typedef struct GTimer_t {
GTimerFunction fn;
void *param;
- systime_t when;
- systime_t period;
+ systemticks_t when;
+ systemticks_t period;
uint16_t flags;
struct GTimer_t *next;
struct GTimer_t *prev;
@@ -104,7 +104,7 @@ void gtimerInit(GTimer *pt);
*
* @api
*/
-void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, systime_t millisec);
+void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec);
/**
* @brief Stop a timer (periodic or otherwise)
diff --git a/include/gwin/console.h b/include/gwin/console.h
index 55bad841..1fc19e42 100644
--- a/include/gwin/console.h
+++ b/include/gwin/console.h
@@ -40,10 +40,12 @@
typedef struct GConsoleObject_t {
GWindowObject gwin;
- struct GConsoleWindowStream_t {
- const struct GConsoleWindowVMT_t *vmt;
- _base_asynchronous_channel_data
- } stream;
+ #if GFX_USE_OS_CHIBIOS
+ struct GConsoleWindowStream_t {
+ const struct GConsoleWindowVMT_t *vmt;
+ _base_asynchronous_channel_data
+ } stream;
+ #endif
coord_t cx,cy; // Cursor position
uint8_t fy; // Current font height
@@ -78,15 +80,19 @@ extern "C" {
*/
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
-/**
- * @brief Get a stream from a console window suitable for use with chprintf().
- * @return The stream handle or NULL if this is not a console window.
- *
- * @param[in] gh The window handle (must be a console window)
- *
- * @api
- */
-BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
+#if GFX_USE_OS_CHIBIOS
+ /**
+ * @brief Get a stream from a console window suitable for use with chprintf().
+ * @return The stream handle or NULL if this is not a console window.
+ *
+ * @param[in] gh The window handle (must be a console window)
+ *
+ * @note Only useful in ChibiOS
+ *
+ * @api
+ */
+ BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
+#endif
/**
* @brief Put a character at the cursor position in the window.