aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2013-05-25 01:26:52 +1000
committerinmarket <andrewh@inmarket.com.au>2013-05-25 01:26:52 +1000
commit7fbfde42aabbcd30cffba2fba35158236c0a6c6c (patch)
treee85c90a4f21974b706315d64209021e0b2bde764 /src/gwin
parent42006a67b5ccfd86f30d8a91cc474681c437eaf6 (diff)
downloaduGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.tar.gz
uGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.tar.bz2
uGFX-7fbfde42aabbcd30cffba2fba35158236c0a6c6c.zip
GOS module, for operating system independance
GMISC fast floating point trig GMISC fast fixed point trig
Diffstat (limited to 'src/gwin')
-rw-r--r--src/gwin/button.c6
-rw-r--r--src/gwin/console.c70
-rw-r--r--src/gwin/graph.c2
-rw-r--r--src/gwin/gwin.c11
-rw-r--r--src/gwin/slider.c2
5 files changed, 44 insertions, 47 deletions
diff --git a/src/gwin/button.c b/src/gwin/button.c
index 8d77b8ba..19301698 100644
--- a/src/gwin/button.c
+++ b/src/gwin/button.c
@@ -15,8 +15,6 @@
* @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_BUTTON) || defined(__DOXYGEN__)
@@ -204,7 +202,7 @@ void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc) {
if ((gh->flags & GBTN_FLG_ALLOCTXT)) {
gh->flags &= ~GBTN_FLG_ALLOCTXT;
if (gbw->txt) {
- chHeapFree((void *)gbw->txt);
+ gfxFree((void *)gbw->txt);
gbw->txt = "";
}
}
@@ -212,7 +210,7 @@ void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc) {
if (txt && useAlloc) {
char *str;
- if ((str = (char *)chHeapAlloc(NULL, strlen(txt)+1))) {
+ if ((str = (char *)gfxAlloc(strlen(txt)+1))) {
gh->flags |= GBTN_FLG_ALLOCTXT;
strcpy(str, txt);
}
diff --git a/src/gwin/console.c b/src/gwin/console.c
index 6abb18dc..a01ed79d 100644
--- a/src/gwin/console.c
+++ b/src/gwin/console.c
@@ -15,8 +15,6 @@
* @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__)
@@ -32,48 +30,54 @@
* Stream interface implementation. The interface is write only
*/
-#define Stream2GWindow(ip) ((GHandle)(((char *)(ip)) - (size_t)(&(((GConsoleObject *)0)->stream))))
-
-static size_t GWinStreamWrite(void *ip, const uint8_t *bp, size_t n) { gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
-static size_t GWinStreamRead(void *ip, uint8_t *bp, size_t n) { (void)ip; (void)bp; (void)n; return 0; }
-static msg_t GWinStreamPut(void *ip, uint8_t b) { gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
-static msg_t GWinStreamGet(void *ip) {(void)ip; return RDY_OK; }
-static msg_t GWinStreamPutTimed(void *ip, uint8_t b, systime_t time) { (void)time; gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
-static msg_t GWinStreamGetTimed(void *ip, systime_t timeout) { (void)ip; (void)timeout; return RDY_OK; }
-static size_t GWinStreamWriteTimed(void *ip, const uint8_t *bp, size_t n, systime_t time) { (void)time; gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
-static size_t GWinStreamReadTimed(void *ip, uint8_t *bp, size_t n, systime_t time) { (void)ip; (void)bp; (void)n; (void)time; return 0; }
-
-struct GConsoleWindowVMT_t {
- _base_asynchronous_channel_methods
-};
-
-static const struct GConsoleWindowVMT_t GWindowConsoleVMT = {
- GWinStreamWrite,
- GWinStreamRead,
- GWinStreamPut,
- GWinStreamGet,
- GWinStreamPutTimed,
- GWinStreamGetTimed,
- GWinStreamWriteTimed,
- GWinStreamReadTimed
-};
+#if GFX_USE_OS_CHIBIOS
+ #define Stream2GWindow(ip) ((GHandle)(((char *)(ip)) - (size_t)(&(((GConsoleObject *)0)->stream))))
+
+ static size_t GWinStreamWrite(void *ip, const uint8_t *bp, size_t n) { gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
+ static size_t GWinStreamRead(void *ip, uint8_t *bp, size_t n) { (void)ip; (void)bp; (void)n; return 0; }
+ static msg_t GWinStreamPut(void *ip, uint8_t b) { gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
+ static msg_t GWinStreamGet(void *ip) {(void)ip; return RDY_OK; }
+ static msg_t GWinStreamPutTimed(void *ip, uint8_t b, systime_t time) { (void)time; gwinPutChar(Stream2GWindow(ip), (char)b); return RDY_OK; }
+ static msg_t GWinStreamGetTimed(void *ip, systime_t timeout) { (void)ip; (void)timeout; return RDY_OK; }
+ static size_t GWinStreamWriteTimed(void *ip, const uint8_t *bp, size_t n, systime_t time) { (void)time; gwinPutCharArray(Stream2GWindow(ip), (const char *)bp, n); return RDY_OK; }
+ static size_t GWinStreamReadTimed(void *ip, uint8_t *bp, size_t n, systime_t time) { (void)ip; (void)bp; (void)n; (void)time; return 0; }
+
+ struct GConsoleWindowVMT_t {
+ _base_asynchronous_channel_methods
+ };
+
+ static const struct GConsoleWindowVMT_t GWindowConsoleVMT = {
+ GWinStreamWrite,
+ GWinStreamRead,
+ GWinStreamPut,
+ GWinStreamGet,
+ GWinStreamPutTimed,
+ GWinStreamGetTimed,
+ GWinStreamWriteTimed,
+ GWinStreamReadTimed
+ };
+#endif
GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font) {
if (!(gc = (GConsoleObject *)_gwinInit((GWindowObject *)gc, x, y, width, height, sizeof(GConsoleObject))))
return 0;
gc->gwin.type = GW_CONSOLE;
gwinSetFont(&gc->gwin, font);
- gc->stream.vmt = &GWindowConsoleVMT;
+ #if GFX_USE_OS_CHIBIOS
+ gc->stream.vmt = &GWindowConsoleVMT;
+ #endif
gc->cx = 0;
gc->cy = 0;
return (GHandle)gc;
}
-BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
- if (gh->type != GW_CONSOLE)
- return 0;
- return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
-}
+#if GFX_USE_OS_CHIBIOS
+ BaseSequentialStream *gwinGetConsoleStream(GHandle gh) {
+ if (gh->type != GW_CONSOLE)
+ return 0;
+ return (BaseSequentialStream *)&(((GConsoleObject *)(gh))->stream);
+ }
+#endif
void gwinPutChar(GHandle gh, char c) {
uint8_t width;
diff --git a/src/gwin/graph.c b/src/gwin/graph.c
index dd4506a3..287deba9 100644
--- a/src/gwin/graph.c
+++ b/src/gwin/graph.c
@@ -15,8 +15,6 @@
* @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_GRAPH) || defined(__DOXYGEN__)
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index b6340c2d..c01c8a90 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -5,8 +5,6 @@
* http://chibios-gfx.com/license.html
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if GFX_USE_GWIN
@@ -29,7 +27,7 @@ GHandle _gwinInit(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_
// Allocate the structure if necessary
if (!gw) {
- if (!(gw = (GWindowObject *)chHeapAlloc(NULL, size)))
+ if (!(gw = (GWindowObject *)gfxAlloc(size)))
return 0;
gw->flags = GWIN_FLG_DYNAMIC;
} else
@@ -56,7 +54,8 @@ GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width,
}
void gwinSetEnabled(GHandle gh, bool_t enabled) {
-
+ (void)gh;
+ (void)enabled;
}
void gwinDestroyWindow(GHandle gh) {
@@ -66,7 +65,7 @@ void gwinDestroyWindow(GHandle gh) {
case GW_BUTTON:
if ((gh->flags & GBTN_FLG_ALLOCTXT)) {
gh->flags &= ~GBTN_FLG_ALLOCTXT; // To be sure, to be sure
- chHeapFree((void *)((GButtonObject *)gh)->txt);
+ gfxFree((void *)((GButtonObject *)gh)->txt);
}
geventDetachSource(&((GButtonObject *)gh)->listener, 0);
geventDetachSourceListeners((GSourceHandle)gh);
@@ -85,7 +84,7 @@ void gwinDestroyWindow(GHandle gh) {
// Clean up the structure
if (gh->flags & GWIN_FLG_DYNAMIC) {
gh->flags = 0; // To be sure, to be sure
- chHeapFree((void *)gh);
+ gfxFree((void *)gh);
}
}
diff --git a/src/gwin/slider.c b/src/gwin/slider.c
index 26555f33..7f1e36bc 100644
--- a/src/gwin/slider.c
+++ b/src/gwin/slider.c
@@ -15,8 +15,6 @@
* @{
*/
-#include "ch.h"
-#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GWIN && GWIN_NEED_SLIDER) || defined(__DOXYGEN__)