aboutsummaryrefslogtreecommitdiffstats
path: root/include/gwin
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-12-06 18:45:54 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-12-06 18:45:54 +1000
commit07f34835358ef65de310934ae726b66c7ca46f68 (patch)
tree6b6875cc38f19bc1dd41b3b7edc8ea10ab7dbc84 /include/gwin
parente236a0a6b79ccd4446df72256740913392cf12f7 (diff)
downloaduGFX-07f34835358ef65de310934ae726b66c7ca46f68.tar.gz
uGFX-07f34835358ef65de310934ae726b66c7ca46f68.tar.bz2
uGFX-07f34835358ef65de310934ae726b66c7ca46f68.zip
Restructure
Create global include file called gfx.h which knows about sub-system dependancies. Deprecate Touchscreen (GINPUT touch is now working properly) Merge Graph into GWIN Change directory structure to reflect sub-system structure Many small bugs fixed Split Nokia6610 gdisp driver into GE8 and GE12 controller versions Fixed broken demos. GFX sub-systems are now clearly defined and new ones should be much easier to add.
Diffstat (limited to 'include/gwin')
-rw-r--r--include/gwin/button.h (renamed from include/gwin/gwin_button.h)34
-rw-r--r--include/gwin/console.h (renamed from include/gwin/gwin_console.h)27
-rw-r--r--include/gwin/graph.h156
-rw-r--r--include/gwin/gwin.h175
-rw-r--r--include/gwin/internal.h53
-rw-r--r--include/gwin/options.h71
6 files changed, 457 insertions, 59 deletions
diff --git a/include/gwin/gwin_button.h b/include/gwin/button.h
index e95628e4..6fc564c7 100644
--- a/include/gwin/gwin_button.h
+++ b/include/gwin/button.h
@@ -18,7 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * @file gwin/gwin_button.h
+ * @file include/gwin/button.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
@@ -27,20 +27,6 @@
#ifndef _GWIN_BUTTON_H
#define _GWIN_BUTTON_H
-/**
- * @name GWIN more complex functionality to be compiled
- * @{
- */
- /**
- * @brief Should button functions be included.
- * @details Defaults to FALSE
- */
- #ifndef GWIN_NEED_BUTTON
- #define GWIN_NEED_BUTTON FALSE
- #endif
-
-/** @} */
-
#if GWIN_NEED_BUTTON || defined(__DOXYGEN__)
/*===========================================================================*/
@@ -51,24 +37,6 @@
#define GEVENT_GWIN_BUTTON (GEVENT_GWIN_FIRST+0)
/*===========================================================================*/
-/* Driver pre-compile time settings. */
-/*===========================================================================*/
-
-
-/*===========================================================================*/
-/* Low Level Driver details and error checks. */
-/*===========================================================================*/
-
-#if !GDISP_NEED_TEXT
- #error "GWIN: Text support (GDISP_NEED_TEXT) is required if GWIN_NEED_BUTTON is defined."
-#endif
-
-#if !defined(GFX_USE_GEVENT) || !GFX_USE_GEVENT
- #error "GWIN Buttons require GFX_USE_GEVENT"
-#endif
-#include "gevent.h"
-
-/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
diff --git a/include/gwin/gwin_console.h b/include/gwin/console.h
index 5462ec2b..4e78d747 100644
--- a/include/gwin/gwin_console.h
+++ b/include/gwin/console.h
@@ -18,7 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
- * @file gwin/gwin_console.h
+ * @file include/gwin/console.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
@@ -27,19 +27,6 @@
#ifndef _GWIN_CONSOLE_H
#define _GWIN_CONSOLE_H
-/**
- * @name GWIN more complex functionality to be compiled
- * @{
- */
- /**
- * @brief Should console functions be included.
- * @details Defaults to FALSE
- */
- #ifndef GWIN_NEED_CONSOLE
- #define GWIN_NEED_CONSOLE FALSE
- #endif
-/** @} */
-
#if GWIN_NEED_CONSOLE || defined(__DOXYGEN__)
/*===========================================================================*/
@@ -49,18 +36,6 @@
#define GW_CONSOLE 0x0001
/*===========================================================================*/
-/* Driver pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Low Level Driver details and error checks. */
-/*===========================================================================*/
-
-#if GWIN_NEED_CONSOLE && !GDISP_NEED_TEXT
- #error "GWIN: Text support (GDISP_NEED_TEXT) is required if GWIN_NEED_CONSOLE is defined."
-#endif
-
-/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
diff --git a/include/gwin/graph.h b/include/gwin/graph.h
new file mode 100644
index 00000000..752460cb
--- /dev/null
+++ b/include/gwin/graph.h
@@ -0,0 +1,156 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ 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/gwin/graph.h
+ * @brief GWIN GRAPH module header file.
+ *
+ * @addtogroup GWIN_GRAPH
+ * @{
+ */
+
+#ifndef _GWIN_GRAPH_H
+#define _GWIN_GRAPH_H
+
+#if GWIN_NEED_GRAPH || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+#define GW_GRAPH 0x0003
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+typedef struct GGraphPoint_t {
+ coord_t x, y;
+ } GGraphPoint;
+
+typedef enum GGraphPointType_e {
+ GGRAPH_POINT_NONE, GGRAPH_POINT_DOT, GGRAPH_POINT_SQUARE, GGRAPH_POINT_CIRCLE
+ } GGraphPointType;
+
+typedef struct GGraphPointStyle_t {
+ GGraphPointType type;
+ coord_t size;
+ color_t color;
+ } GGraphPointStyle;
+
+typedef enum GGraphLineType_e {
+ GGRAPH_LINE_NONE, GGRAPH_LINE_SOLID, GGRAPH_LINE_DOT, GGRAPH_LINE_DASH
+ } GGraphLineType;
+
+typedef struct GGraphLineStyle_t {
+ GGraphLineType type;
+ coord_t size;
+ color_t color;
+ } GGraphLineStyle;
+
+typedef struct GGraphGridStyle_t {
+ GGraphLineType type;
+ coord_t size;
+ color_t color;
+ coord_t spacing;
+ } GGraphGridStyle;
+
+typedef struct GGraphStyle_t {
+ GGraphPointStyle point;
+ GGraphLineStyle line;
+ GGraphLineStyle xaxis;
+ GGraphLineStyle yaxis;
+ GGraphGridStyle xgrid;
+ GGraphGridStyle ygrid;
+ uint16_t flags;
+ #define GWIN_GRAPH_STYLE_XAXIS_ARROWS 0x0001
+ #define GWIN_GRAPH_STYLE_YAXIS_ARROWS 0x0002
+} GGraphStyle;
+
+// A graph window
+typedef struct GGraphObject_t {
+ GWindowObject gwin;
+ GGraphStyle style;
+ coord_t xorigin, yorigin;
+ coord_t lastx, lasty;
+ } GGraphObject;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+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;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GWIN_NEED_GRAPH */
+
+#endif /* _GWIN_GRAPH_H */
+/** @} */
+
diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h
new file mode 100644
index 00000000..cca02d7e
--- /dev/null
+++ b/include/gwin/gwin.h
@@ -0,0 +1,175 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ 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/gwin/gwin.h
+ * @brief GWIN Graphic window subsystem header file.
+ *
+ * @addtogroup GWIN
+ * @{
+ */
+#ifndef _GWIN_H
+#define _GWIN_H
+
+#include "gfx.h"
+
+#if GFX_USE_GWIN || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+typedef uint16_t GWindowType;
+#define GW_WINDOW 0x0000
+#define GW_FIRST_USER_WINDOW 0x8000
+
+// A basic window
+typedef struct GWindowObject_t {
+ GWindowType type; // What type of window is this
+ uint16_t flags; // Internal flags
+ coord_t x, y; // Screen relative position
+ coord_t width, height; // Dimensions of this window
+ color_t color, bgcolor; // Current drawing colors
+#if GDISP_NEED_TEXT
+ font_t font; // Current font
+#endif
+} GWindowObject, * GHandle;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Base Functions */
+GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height);
+void gwinDestroyWindow(GHandle gh);
+
+/**
+ * @brief Get the X coordinate of the window
+ * @details Returns the X coordinate of the origin of the window.
+ * The coordinate is relative to the physical screen zero point.
+ *
+ * @param[in] gh The window
+ */
+#define gwinGetScreenX(gh) ((gh)->x)
+
+/**
+ * @brief Get the Y coordinate of the window
+ * @details Returns the Y coordinate of the origin of the window.
+ * The coordinate is relative to the physical screen zero point.
+ *
+ * @param[in] gh The window
+ */
+#define gwinGetScreenY(gh) ((gh)->y)
+
+/**
+ * @brief Get the width of the window
+ *
+ * @param[in] gh The window
+ */
+#define gwinGetWidth(gh) ((gh)->width)
+
+/**
+ * @brief Get the height of the window
+ *
+ * @param[in] gh The window
+ */
+#define gwinGetHeight(gh) ((gh)->height)
+
+/**
+ * @brief Set foreground color
+ * @details Set the color which will be used to draw
+ *
+ * @param[in] gh The window
+ * @param[in] clr The color to be set
+ */
+#define gwinSetColor(gh, clr) (gh)->color = (clr)
+
+/**
+ * @brief Set background color
+ * @details Set the color which will be used as background
+ * @note gwinClear() must be called to set the background color
+ *
+ * @param[in] gh The window
+ * @param[in] bgclr The background color
+ */
+#define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr)
+
+/* Set up for text */
+#if GDISP_NEED_TEXT
+ void gwinSetFont(GHandle gh, font_t font);
+#endif
+
+/* Drawing Functions */
+void gwinClear(GHandle gh);
+void gwinDrawPixel(GHandle gh, coord_t x, coord_t y);
+void gwinDrawLine(GHandle gh, coord_t x0, coord_t y0, coord_t x1, coord_t y1);
+void gwinDrawBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
+void gwinFillArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy);
+void gwinBlitArea(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, coord_t srcx, coord_t srcy, coord_t srccx, const pixel_t *buffer);
+
+/* Circle Functions */
+#if GDISP_NEED_CIRCLE
+ void gwinDrawCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
+ void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius);
+#endif
+
+/* Ellipse Functions */
+#if GDISP_NEED_ELLIPSE
+ void gwinDrawEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
+ void gwinFillEllipse(GHandle gh, coord_t x, coord_t y, coord_t a, coord_t b);
+#endif
+
+/* Arc Functions */
+#if GDISP_NEED_ARC
+ void gwinDrawArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
+ void gwinFillArc(GHandle gh, coord_t x, coord_t y, coord_t radius, coord_t startangle, coord_t endangle);
+#endif
+
+/* Read a pixel Function */
+#if GDISP_NEED_PIXELREAD
+ color_t gwinGetPixelColor(GHandle gh, coord_t x, coord_t y);
+#endif
+
+/* Extra Text Functions */
+#if GDISP_NEED_TEXT
+ void gwinDrawChar(GHandle gh, coord_t x, coord_t y, char c);
+ void gwinFillChar(GHandle gh, coord_t x, coord_t y, char c);
+ void gwinDrawString(GHandle gh, coord_t x, coord_t y, const char *str);
+ void gwinFillString(GHandle gh, coord_t x, coord_t y, const char *str);
+ void gwinDrawStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
+ void gwinFillStringBox(GHandle gh, coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, justify_t justify);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Include extra window types */
+#include "gwin/console.h"
+#include "gwin/button.h"
+#include "gwin/graph.h"
+
+#endif /* GFX_USE_GWIN */
+
+#endif /* _GWIN_H */
+/** @} */
diff --git a/include/gwin/internal.h b/include/gwin/internal.h
new file mode 100644
index 00000000..b47a2229
--- /dev/null
+++ b/include/gwin/internal.h
@@ -0,0 +1,53 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ 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/gwin/internal.h
+ * @brief GWIN Graphic window subsystem header file.
+ *
+ * @addtogroup GWIN
+ * @{
+ */
+#ifndef _GWIN_INTERNAL_H
+#define _GWIN_INTERNAL_H
+
+#if GFX_USE_GWIN || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Sub-system constants. */
+/*===========================================================================*/
+
+#define GWIN_FLG_DYNAMIC 0x0001
+#define GBTN_FLG_ALLOCTXT 0x0002
+#define GWIN_FIRST_CONTROL_FLAG 0x0004
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GHandle _gwinInit(GWindowObject *gw, coord_t x, coord_t y, coord_t width, coord_t height, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_GWIN */
+
+#endif /* _GWIN_INTERNAL_H */
+/** @} */
diff --git a/include/gwin/options.h b/include/gwin/options.h
new file mode 100644
index 00000000..899da5a4
--- /dev/null
+++ b/include/gwin/options.h
@@ -0,0 +1,71 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012
+ 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/gwin_options.h
+ * @brief GWIN sub-system options header file.
+ *
+ * @addtogroup GWIN
+ * @{
+ */
+
+#ifndef _GWIN_OPTIONS_H
+#define _GWIN_OPTIONS_H
+
+/**
+ * @name GWIN Functionality to be included
+ * @{
+ */
+ /**
+ * @brief Should button functions be included.
+ * @details Defaults to FALSE
+ */
+ #ifndef GWIN_NEED_BUTTON
+ #define GWIN_NEED_BUTTON FALSE
+ #endif
+ /**
+ * @brief Should console functions be included.
+ * @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"
+ * Also in your makefile, as part of your list of C source files, include
+ * ${CHIBIOS}/os/various/chprintf.c
+ */
+ #ifndef GWIN_NEED_CONSOLE
+ #define GWIN_NEED_CONSOLE FALSE
+ #endif
+ /**
+ * @brief Should graph functions be included.
+ * @details Defaults to FALSE
+ */
+ #ifndef GWIN_NEED_GRAPH
+ #define GWIN_NEED_GRAPH FALSE
+ #endif
+/**
+ * @}
+ *
+ * @name GWIN Optional Sizing Parameters
+ * @{
+ */
+/** @} */
+
+#endif /* _GWIN_OPTIONS_H */
+/** @} */