From 166d78c97aa237a076b2f003dc51b535722d58c3 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sat, 13 Oct 2012 02:04:20 +0200 Subject: [PATCH] console updates --- demos/console/main.c | 18 +++++++++++++++--- docs/configure.txt | 3 ++- include/console.h | 33 ++++++++++++++++++++++++++++----- src/console.c | 37 ++----------------------------------- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/demos/console/main.c b/demos/console/main.c index 7dc90f79..ea27c727 100644 --- a/demos/console/main.c +++ b/demos/console/main.c @@ -18,13 +18,27 @@ along with this program. If not, see . */ +/* + * !!! IMPORTANT !!! + * + * This example dosen't compile yet, there's a problem in the console source. + * This issue will be fixed soon. + */ + +/* + * Please add the following to your halconf.h + * + * #define GDISP_NEED_CONSOLE TRUE + * #define GDISP_NEED_SCROLL TRUE + */ + #include "ch.h" #include "hal.h" #include "gdisp.h" #include "chprintf.h" #include "console.h" -static GLCDConsole CON1; +static GConsole CON1; int main(void) { halInit(); @@ -34,8 +48,6 @@ int main(void) { gdispClear(Lime); lcdConsoleInit(&CON1, 0, 0, gdispGetWidth(), gdispGetHeight(), &fontLarger, Black, White); - - chprintf((BaseSequentialStream *)&CON1, "Hello the time is %d\nGoodbye.", chTimeNow()); diff --git a/docs/configure.txt b/docs/configure.txt index f108afcb..15380e16 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -25,8 +25,9 @@ GDISP macors: #define GDISP_NEED_TEXT // for font rendering support #define GDISP_NEED_PIXELREAD // to read a pixels color value back #define GDISP_NEED_SCROLL // is scrolling is needed (pixel shift) - #define GDISPI_NEED_QUERY // to make certain queries to the LCD controller + #define GDISP_NEED_QUERY // to make certain queries to the LCD controller + #define GDISP_NEED_CONSOLE // for the console abstraction TouchPad macros: diff --git a/include/console.h b/include/console.h index 7b543013..d154d9d0 100644 --- a/include/console.h +++ b/include/console.h @@ -21,10 +21,8 @@ #ifndef CONSOLE_H #define CONSOLE_H -#ifdef HAL_USE_GDISP - #ifndef GDISP_NEED_CONSOLE - #define GDISP_NEED_CONSOLE FALSE + #define GDISP_NEED_CONSOLE FALSE #endif #if GDISP_NEED_CONSOLE @@ -32,8 +30,32 @@ #include "gdisp.h" /** - * @brief Structure representing a GConsole driver. + * @extends BaseAsynchronousChannel + * + * @brief GConsole class. + * @details This class extends @p BaseAsynchronousChannel by adding physical + * I/O queues. */ +typedef struct _GConsole { + /** @brief Virtual Methods Table.*/ + const struct GConsoleVMT *vmt; + _base_asynchronous_channel_data + /* WARNING: Do not add any data to this struct above this comment, only below */ + /* font */ + font_t font; + /* lcd area to use */ + coord_t x0,y0; + /* current cursor position, in pixels */ + coord_t cx,cy; + /* console size in pixels */ + coord_t sx,sy; + /* foreground and background colour */ + color_t bkcolor, color; + /* font size in pixels */ + uint8_t fy; + /* font inter-character padding in pixels */ + uint8_t fp; +} GConsole; #ifdef __cplusplus extern "C" { @@ -48,5 +70,6 @@ msg_t lcdConsoleWrite(GConsole *console, const uint8_t *bp, size_t n); #endif #endif /* GDISP_NEED_CONSOLE */ -#endif /* HAL_USE_GDISP */ + #endif /* CONSOLE_H */ + diff --git a/src/console.c b/src/console.c index 4739c53c..b13f27f6 100644 --- a/src/console.c +++ b/src/console.c @@ -18,11 +18,8 @@ along with this program. If not, see . */ -#if GDISP_NEED_CONSOLE - #include "ch.h" #include "hal.h" - #include "console.h" /** @@ -34,34 +31,6 @@ struct GConsoleVMT { _base_asynchronous_channel_methods }; -/** - * @extends BaseAsynchronousChannel - * - * @brief GConsole class. - * @details This class extends @p BaseAsynchronousChannel by adding physical - * I/O queues. - */ -typedef struct _GConsole { - /** @brief Virtual Methods Table.*/ - const struct GConsoleVMT *vmt; - _base_asynchronous_channel_data - /* WARNING: Do not add any data to this struct above this comment, only below */ - /* font */ - font_t font; - /* lcd area to use */ - coord_t x0,y0; - /* current cursor position, in pixels */ - coord_t cx,cy; - /* console size in pixels */ - coord_t sx,sy; - /* foreground and background colour */ - color_t bkcolor, color; - /* font size in pixels */ - uint8_t fy; - /* font inter-character padding in pixels */ - uint8_t fp; -} GConsole; - /* * Interface implementation. The interface is write only */ @@ -154,7 +123,7 @@ msg_t lcdConsoleInit(GConsole *console, coord_t x0, coord_t y0, coord_t width, c return RDY_OK; } -msg_t lcdConsolePut(GLCDConsole *console, char c) { +msg_t lcdConsolePut(GConsole *console, char c) { uint8_t width; if(c == '\n') { @@ -208,7 +177,7 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) { return RDY_OK; } -msg_t lcdConsoleWrite(GLCDConsole *console, const uint8_t *bp, size_t n) { +msg_t lcdConsoleWrite(GConsole *console, const uint8_t *bp, size_t n) { size_t i; for(i = 0; i < n; i++) lcdConsolePut(console, bp[i]); @@ -216,5 +185,3 @@ msg_t lcdConsoleWrite(GLCDConsole *console, const uint8_t *bp, size_t n) { return RDY_OK; } -#endif /* GDISP_NEED_CONSOLE */ -