diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2013-05-06 14:44:47 +1000 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2013-05-06 14:44:47 +1000 |
commit | 3374aa25c6e4e118df670c18eaeefa0f6f29377f (patch) | |
tree | 99bdea0be61386bd3ae70c8516198dd857e4db13 /src/gwin | |
parent | bbfeec2dd7b312745856236214c91fce6b9ec22c (diff) | |
download | uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.tar.gz uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.tar.bz2 uGFX-3374aa25c6e4e118df670c18eaeefa0f6f29377f.zip |
Reinsertion of doxygen headers
Reinsertion of doxygen headers that got lost in license change
Diffstat (limited to 'src/gwin')
-rw-r--r-- | src/gwin/button.c | 10 | ||||
-rw-r--r-- | src/gwin/console.c | 270 | ||||
-rw-r--r-- | src/gwin/graph.c | 10 | ||||
-rw-r--r-- | src/gwin/slider.c | 10 |
4 files changed, 170 insertions, 130 deletions
diff --git a/src/gwin/button.c b/src/gwin/button.c index 47c060e1..96478390 100644 --- a/src/gwin/button.c +++ b/src/gwin/button.c @@ -5,6 +5,16 @@ * http://chibios-gfx.com/license.html */ +/** + * @file src/gwin/button.c + * @brief GWIN sub-system button code. + * + * @defgroup Button Button + * @ingroup GWIN + * + * @{ + */ + #include "ch.h" #include "hal.h" #include "gfx.h" diff --git a/src/gwin/console.c b/src/gwin/console.c index 13482d25..6abb18dc 100644 --- a/src/gwin/console.c +++ b/src/gwin/console.c @@ -4,133 +4,143 @@ * * http://chibios-gfx.com/license.html */ -
-#include "ch.h"
-#include "hal.h"
-#include "gfx.h"
-
-#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__)
-
-#include <string.h>
-
-#include "gwin/internal.h"
-
-#define GWIN_CONSOLE_USE_CLEAR_LINES TRUE
-#define GWIN_CONSOLE_USE_FILLED_CHARS FALSE
-
-/*
- * 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
-};
-
-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;
- 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);
-}
-
-void gwinPutChar(GHandle gh, char c) {
- uint8_t width;
- #define gcw ((GConsoleObject *)gh)
-
- if (gh->type != GW_CONSOLE || !gh->font) return;
-
- #if GDISP_NEED_CLIP
- gdispSetClip(gh->x, gh->y, gh->width, gh->height);
- #endif
-
- if (c == '\n') {
- gcw->cx = 0;
- gcw->cy += gcw->fy;
- // We use lazy scrolling here and only scroll when the next char arrives
- } else if (c == '\r') {
- // gcw->cx = 0;
- } else {
- width = gdispGetCharWidth(c, gh->font) + gcw->fp;
- if (gcw->cx + width >= gh->width) {
- gcw->cx = 0;
- gcw->cy += gcw->fy;
- }
-
- if (gcw->cy + gcw->fy > gh->height) {
-#if GDISP_NEED_SCROLL
- /* scroll the console */
- gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, gcw->fy, gh->bgcolor);
- /* reset the cursor to the start of the last line */
- gcw->cx = 0;
- gcw->cy = (((coord_t)(gh->height/gcw->fy))-1)*gcw->fy;
-#else
- /* clear the console */
- gdispFillArea(gh->x, gh->y, gh->width, gh->height, gh->bgcolor);
- /* reset the cursor to the top of the window */
- gcw->cx = 0;
- gcw->cy = 0;
-#endif
- }
-
-#if GWIN_CONSOLE_USE_CLEAR_LINES
- /* clear to the end of the line */
- if (gcw->cx == 0)
- gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor);
-#endif
-#if GWIN_CONSOLE_USE_FILLED_CHARS
- gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor);
-#else
- gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color);
-#endif
-
- /* update cursor */
- gcw->cx += width;
- }
- #undef gcw
-}
-
-void gwinPutString(GHandle gh, const char *str) {
- while(*str)
- gwinPutChar(gh, *str++);
-}
-
-void gwinPutCharArray(GHandle gh, const char *str, size_t n) {
- while(n--)
- gwinPutChar(gh, *str++);
-}
-
-#endif /* GFX_USE_GWIN && GWIN_NEED_CONSOLE */
-/** @} */
-
+ +/** + * @file src/gwin/console.c + * @brief GWIN sub-system console code. + * + * @defgroup Console Console + * @ingroup GWIN + * + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gfx.h" + +#if (GFX_USE_GWIN && GWIN_NEED_CONSOLE) || defined(__DOXYGEN__) + +#include <string.h> + +#include "gwin/internal.h" + +#define GWIN_CONSOLE_USE_CLEAR_LINES TRUE +#define GWIN_CONSOLE_USE_FILLED_CHARS FALSE + +/* + * 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 +}; + +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; + 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); +} + +void gwinPutChar(GHandle gh, char c) { + uint8_t width; + #define gcw ((GConsoleObject *)gh) + + if (gh->type != GW_CONSOLE || !gh->font) return; + + #if GDISP_NEED_CLIP + gdispSetClip(gh->x, gh->y, gh->width, gh->height); + #endif + + if (c == '\n') { + gcw->cx = 0; + gcw->cy += gcw->fy; + // We use lazy scrolling here and only scroll when the next char arrives + } else if (c == '\r') { + // gcw->cx = 0; + } else { + width = gdispGetCharWidth(c, gh->font) + gcw->fp; + if (gcw->cx + width >= gh->width) { + gcw->cx = 0; + gcw->cy += gcw->fy; + } + + if (gcw->cy + gcw->fy > gh->height) { +#if GDISP_NEED_SCROLL + /* scroll the console */ + gdispVerticalScroll(gh->x, gh->y, gh->width, gh->height, gcw->fy, gh->bgcolor); + /* reset the cursor to the start of the last line */ + gcw->cx = 0; + gcw->cy = (((coord_t)(gh->height/gcw->fy))-1)*gcw->fy; +#else + /* clear the console */ + gdispFillArea(gh->x, gh->y, gh->width, gh->height, gh->bgcolor); + /* reset the cursor to the top of the window */ + gcw->cx = 0; + gcw->cy = 0; +#endif + } + +#if GWIN_CONSOLE_USE_CLEAR_LINES + /* clear to the end of the line */ + if (gcw->cx == 0) + gdispFillArea(gh->x, gh->y + gcw->cy, gh->width, gcw->fy, gh->bgcolor); +#endif +#if GWIN_CONSOLE_USE_FILLED_CHARS + gdispFillChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color, gh->bgcolor); +#else + gdispDrawChar(gh->x + gcw->cx, gh->y + gcw->cy, c, gh->font, gh->color); +#endif + + /* update cursor */ + gcw->cx += width; + } + #undef gcw +} + +void gwinPutString(GHandle gh, const char *str) { + while(*str) + gwinPutChar(gh, *str++); +} + +void gwinPutCharArray(GHandle gh, const char *str, size_t n) { + while(n--) + gwinPutChar(gh, *str++); +} + +#endif /* GFX_USE_GWIN && GWIN_NEED_CONSOLE */ +/** @} */ + diff --git a/src/gwin/graph.c b/src/gwin/graph.c index 05480862..dd4506a3 100644 --- a/src/gwin/graph.c +++ b/src/gwin/graph.c @@ -5,6 +5,16 @@ * http://chibios-gfx.com/license.html */ +/** + * @file src/gwin/graph.c + * @brief GWIN sub-system button code. + * + * @defgroup Graph Graph + * @ingroup GWIN + * + * @{ + */ + #include "ch.h" #include "hal.h" #include "gfx.h" diff --git a/src/gwin/slider.c b/src/gwin/slider.c index 72421367..26555f33 100644 --- a/src/gwin/slider.c +++ b/src/gwin/slider.c @@ -5,6 +5,16 @@ * http://chibios-gfx.com/license.html */ +/** + * @file src/gwin/slider.c + * @brief GWIN sub-system slider code. + * + * @defgroup Slider Slider + * @ingroup GWIN + * + * @{ + */ + #include "ch.h" #include "hal.h" #include "gfx.h" |