diff options
author | Andrew Hannam <andrewh@inmarket.com.au> | 2013-01-08 18:15:20 -0800 |
---|---|---|
committer | Andrew Hannam <andrewh@inmarket.com.au> | 2013-01-08 18:15:20 -0800 |
commit | 8b5c073ea6f8491ce4176fb2996f74b3222f8188 (patch) | |
tree | eab4bb57fd18e53b85e0d2a8736e0ce5ce5abe86 /include | |
parent | 2c5d5c51183fbdb01f24afdbb5d29dbf00f4f836 (diff) | |
parent | 7a66e63849f43aae17fb256afadc475ffc578945 (diff) | |
download | uGFX-8b5c073ea6f8491ce4176fb2996f74b3222f8188.tar.gz uGFX-8b5c073ea6f8491ce4176fb2996f74b3222f8188.tar.bz2 uGFX-8b5c073ea6f8491ce4176fb2996f74b3222f8188.zip |
Merge pull request #13 from Tectu/master
Merge Tectu Changes
Diffstat (limited to 'include')
-rw-r--r-- | include/gdisp/fonts.h | 3 | ||||
-rw-r--r-- | include/gdisp/gdisp.h | 7 | ||||
-rw-r--r-- | include/gdisp/options.h | 2 | ||||
-rw-r--r-- | include/gwin/button.h | 104 | ||||
-rw-r--r-- | include/gwin/console.h | 68 | ||||
-rw-r--r-- | include/gwin/graph.h | 117 | ||||
-rw-r--r-- | include/gwin/options.h | 2 |
7 files changed, 232 insertions, 71 deletions
diff --git a/include/gdisp/fonts.h b/include/gdisp/fonts.h index 34a5b89d..f92f1b81 100644 --- a/include/gdisp/fonts.h +++ b/include/gdisp/fonts.h @@ -71,9 +71,6 @@ struct font { const fontcolumn_t *dataTable;
};
-/**
- * @brief Macros to get to the complex parts of the font structure.
- */
#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar])
#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar])
#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)])
diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h index f8d5745f..da6d859f 100644 --- a/include/gdisp/gdisp.h +++ b/include/gdisp/gdisp.h @@ -52,7 +52,8 @@ typedef int16_t coord_t; /*===========================================================================*/
/**
- * @brief Some basic colors
+ * @name Some basic colors
+ * @{
*/
#define White HTML2COLOR(0xFFFFFF)
#define Black HTML2COLOR(0x000000)
@@ -76,6 +77,7 @@ typedef int16_t coord_t; #define Orange HTML2COLOR(0xFFA500)
#define Pink HTML2COLOR(0xFFC0CB)
#define SkyBlue HTML2COLOR(0x87CEEB)
+/** @} */
/*===========================================================================*/
/* Low Level Driver details and error checks. */
@@ -102,9 +104,6 @@ typedef enum fontmetric {fontHeight, fontDescendersHeight, fontLineSpacing, font /*===========================================================================*/
#if (GDISP_NEED_TEXT && GDISP_OLD_FONT_DEFINITIONS) || defined(__DOXYGEN__)
- /**
- * @brief Predefined fonts.
- */
#if GDISP_INCLUDE_FONT_SMALL
extern const struct font fontSmall;
extern const struct font fontSmallDouble;
diff --git a/include/gdisp/options.h b/include/gdisp/options.h index b53138ca..2fedd34d 100644 --- a/include/gdisp/options.h +++ b/include/gdisp/options.h @@ -163,7 +163,7 @@ #define GDISP_OLD_FONT_DEFINITIONS FALSE
#endif
/**
- * @brief Predefined built in fonts.
+ * @brief Predefined built in fonts
* @note Turning off the ones you are not using can save program size.
*/
#ifndef GDISP_INCLUDE_FONT_SMALL
diff --git a/include/gwin/button.h b/include/gwin/button.h index 698c840a..ffec858b 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -97,24 +97,92 @@ typedef struct GButtonObject_t { extern "C" {
#endif
- GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width, coord_t height, font_t font, GButtonType type);
- void gwinSetButtonStyle(GHandle gh, const GButtonStyle *style);
- void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc);
- void gwinButtonDraw(GHandle gh);
- #define gwinGetButtonState(gh) (((GButtonObject *)(gh))->state)
-
- // Get the source handle so the application can listen for events
- #define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
-
- #if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
- // Attach a mouse source to this button.
- bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh);
- #endif
-
- #if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE
- // Attach a toggle source to this button.
- bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh);
- #endif
+/**
+ * @brief Create a button window.
+ * @return NULL if there is no resultant drawing area, otherwise a window handle.
+ *
+ * @param[in] gb The GButtonObject structure to initialise. If this is NULL the structure is dynamically allocated.
+ * @param[in] x,y The screen co-ordinates for the bottom left corner of the window
+ * @param[in] width The width of the window
+ * @param[in] height The height of the window
+ * @param[in] font The font to use
+ * @param[in] type The type of button
+ * @note The drawing color gets set to White and the background drawing color to Black.
+ * @note The dimensions and position may be changed to fit on the real screen.
+ * @note The button is not automatically drawn. Call gwinButtonDraw() after changing the button style or setting the text.
+ *
+ * @api
+ */
+GHandle gwinCreateButton(GButtonObject *gb, coord_t x, coord_t y, coord_t width, coord_t height, font_t font, GButtonType type);
+
+/**
+ * @brief Set the style of a button.
+ * @details The button style is defined by its shape and colours.
+ *
+ * @param[in] gh The window handle (must be a button window)
+ * @param[in] style The button style to set.
+ * @note The button is not automatically redrawn. Call gwinButtonDraw() after changing the button style
+ *
+ * @api
+ */
+void gwinSetButtonStyle(GHandle gh, const GButtonStyle *style);
+
+/**
+ * @brief Set the text of a button.
+ *
+ * @param[in] gh The window handle (must be a button window)
+ * @param[in] txt The button 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.
+ * @note The button is not automatically redrawn. Call gwinButtonDraw() after changing the button text.
+ *
+ * @api
+ */
+void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc);
+
+/**
+ * @brief Redraw the button.
+ *
+ * @param[in] gh The window handle (must be a button window)
+ *
+ * @api
+ */
+void gwinButtonDraw(GHandle gh);
+
+#define gwinGetButtonState(gh) (((GButtonObject *)(gh))->state)
+
+/**
+ * @brief Get the source handle of a button
+ * @details Get the source handle of a button so the application can listen for events
+ *
+ * @param[in] gh The Hanlde
+ */
+#define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
+
+#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
+ /**
+ * @brief Attach a mouse source
+ * @details Attach a mouse source to a given button
+ *
+ * @param[in] gh The button handle
+ * @param[in] gsh The source handle
+ *
+ * @return
+ */
+ bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh);
+#endif
+
+#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE
+ /**
+ * @brief Attach a toggle source
+ * @details Attach a toggle source to this button
+ *
+ * @gh The button handle
+ * @gsh The source handle
+ *
+ * @return
+ */
+ bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh);
+#endif
#ifdef __cplusplus
}
diff --git a/include/gwin/console.h b/include/gwin/console.h index 9fa867c8..30058b2b 100644 --- a/include/gwin/console.h +++ b/include/gwin/console.h @@ -70,11 +70,69 @@ typedef struct GConsoleObject_t { extern "C" {
#endif
- GHandle gwinCreateConsole(GConsoleObject *gc, coord_t x, coord_t y, coord_t width, coord_t height, font_t font);
- BaseSequentialStream *gwinGetConsoleStream(GHandle gh);
- void gwinPutChar(GHandle gh, char c);
- void gwinPutString(GHandle gh, const char *str);
- void gwinPutCharArray(GHandle gh, const char *str, size_t n);
+/**
+ * @brief Create a console window.
+ * @details A console window allows text to be written using chprintf() (and the console functions defined here).
+ * @brief Text in a console window supports newlines and will wrap text as required.
+ * @return NULL if there is no resultant drawing area, otherwise a window handle.
+ *
+ * @param[in] gc The GConsoleObject structure to initialise. If this is NULL the structure is dynamically allocated.
+ * @param[in] x,y The screen co-ordinates for the bottom left corner of the window
+ * @param[in] width The width of the window
+ * @param[in] height The height of the window
+ * @param[in] font The font to use
+ * @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
+ * @note If the dispay does not support scrolling, the window will be cleared when the bottom line is reached.
+ * @note The default drawing color gets set to White and the background drawing color to Black.
+ * @note The dimensions and position may be changed to fit on the real screen.
+ *
+ * @api
+ */
+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);
+
+/**
+ * @brief Put a character at the cursor position in the window.
+ * @note Uses the current foreground color to draw the character and fills the background using the background drawing color
+ *
+ * @param[in] gh The window handle (must be a console window)
+ * @param[in] c The character to draw
+ *
+ * @api
+ */
+void gwinPutChar(GHandle gh, char c);
+
+/**
+ * @brief Put a string at the cursor position in the window. It will wrap lines as required.
+ * @note Uses the current foreground color to draw the string and fills the background using the background drawing color
+ *
+ * @param[in] gh The window handle (must be a console window)
+ * @param[in] str The string to draw
+ *
+ * @api
+ */
+void gwinPutString(GHandle gh, const char *str);
+
+/**
+ * @brief Put the character array at the cursor position in the window. It will wrap lines as required.
+ * @note Uses the current foreground color to draw the string and fills the background using the background drawing color
+ *
+ * @param[in] gh The window handle (must be a console window)
+ * @param[in] str The string to draw
+ * @param[in] n The number of characters to draw
+ *
+ * @api
+ */
+void gwinPutCharArray(GHandle gh, const char *str, size_t n);
#ifdef __cplusplus
}
diff --git a/include/gwin/graph.h b/include/gwin/graph.h index 155fd9a9..9267813b 100644 --- a/include/gwin/graph.h +++ b/include/gwin/graph.h @@ -113,50 +113,89 @@ typedef struct GGraphObject_t { extern "C" {
#endif
- GHandle gwinCreateGraph(GGraphObject *gg, coord_t x, coord_t y, coord_t width, coord_t height);
- void gwinGraphSetStyle(GHandle gh, const GGraphStyle *pstyle);
- void gwinGraphSetOrigin(GHandle gh, coord_t x, coord_t y);
- void gwinGraphDrawAxis(GHandle gh);
- void gwinGraphStartSet(GHandle gh);
- void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y);
- void gwinGraphDrawPoints(GHandle gh, const GGraphPoint *points, unsigned count);
+/**
+ * @brief Create a graph window.
+ * @return NULL if there is no resultant drawing area, otherwise a window handle.
+ *
+ * @param[in] gg The GGraphObject structure to initialise. If this is NULL the structure is dynamically allocated.
+ * @param[in] x,y The screen co-ordinates for the bottom left corner of the window
+ * @param[in] width The width of the window
+ * @param[in] height The height of the window
+ * @note The console is not automatically cleared on creation. You must do that by calling gwinClear() (possibly after changing your background color)
+ * @note The coordinate system within the window for graphing operations (but not for any other drawing
+ * operation) is relative to the bottom left corner and then shifted right and up by the specified
+ * graphing x and y origin. Note that this system is inverted in the y direction relative to the display.
+ * This gives the best graphing arrangement ie. increasing y values are closer to the top of the display.
+ *
+ * @api
+ */
+GHandle gwinCreateGraph(GGraphObject *gg, coord_t x, coord_t y, coord_t width, coord_t height);
-#ifdef __cplusplus
-}
-#endif
+/**
+ * @brief Set the style of the graphing operations.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ * @param[in] pstyle The graph style to set.
+ * @note The graph is not automatically redrawn. The new style will apply to any new drawing operations.
+ *
+ * @api
+ */
+void gwinGraphSetStyle(GHandle gh, const GGraphStyle *pstyle);
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
+/**
+ * @brief Set the origin for graphing operations.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ * @param[in] x, y The new origin for the graph (in graph coordinates relative to the bottom left corner).
+ * @note The graph is not automatically redrawn. The new origin will apply to any new drawing operations.
+ *
+ * @api
+ */
+void gwinGraphSetOrigin(GHandle gh, coord_t x, coord_t y);
-typedef struct _Graph {
- coord_t origin_x;
- coord_t origin_y;
- coord_t xmin;
- coord_t xmax;
- coord_t ymin;
- coord_t ymax;
- uint16_t grid_size;
- uint16_t dot_space;
- bool_t full_grid;
- bool_t arrows;
- color_t axis_color;
- color_t grid_color;
-
- /* do never modify values below this line manually */
- coord_t x0;
- coord_t x1;
- coord_t y0;
- coord_t y1;
-} Graph;
+/**
+ * @brief Draw the axis and the background grid.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ * @note The graph is not automatically cleared. You must do that first by calling gwinClear().
+ *
+ * @api
+ */
+void gwinGraphDrawAxis(GHandle gh);
-#ifdef __cplusplus
-extern "C" {
-#endif
+/**
+ * @brief Start a new set of graphing data.
+ * @details This prevents a line being drawn from the last data point to the next point to be drawn.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ *
+ * @api
+ */
+void gwinGraphStartSet(GHandle gh);
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
+/**
+ * @brief Draw a graph point.
+ * @details A graph point and a line connecting to the previous point will be drawn.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ * @param[in] x, y The new point for the graph.
+ *
+ * @api
+ */
+void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y);
+
+/**
+ * @brief Draw multiple graph points.
+ * @details A graph point and a line connecting to each previous point will be drawn.
+ *
+ * @param[in] gh The window handle (must be a graph window)
+ * @param[in] points The array of points for the graph.
+ * @param[in] count The number of points in the array.
+ * @note This is slightly more efficient than calling gwinGraphDrawPoint() repeatedly.
+ *
+ * @api
+ */
+void gwinGraphDrawPoints(GHandle gh, const GGraphPoint *points, unsigned count);
#ifdef __cplusplus
}
diff --git a/include/gwin/options.h b/include/gwin/options.h index e5e335bb..6e17e61f 100644 --- a/include/gwin/options.h +++ b/include/gwin/options.h @@ -45,7 +45,7 @@ * @details Defaults to FALSE
* @note To use chprintf() for printing in a console window you need to
* include in your application source file...
- * #include "chprintf.h"
+ * \#include "chprintf.h"
* Also in your makefile, as part of your list of C source files, include
* ${CHIBIOS}/os/various/chprintf.c
*/
|