Browse Source

Adding gdispGDrawThickArc() demo

Joel Bodenmann 3 years ago
parent
commit
dba9b327ec

+ 3 - 0
demos/modules/gdisp/thickarcs/demo.mk

@@ -0,0 +1,3 @@
1
+DEMODIR  = $(GFXLIB)/demos/modules/gdisp/thickarcs
2
+GFXINC  += $(DEMODIR)
3
+GFXSRC  += $(DEMODIR)/main.c

+ 48 - 0
demos/modules/gdisp/thickarcs/gfxconf.h

@@ -0,0 +1,48 @@
1
+/*
2
+ * Copyright (c) 2012, 2013, Joel Bodenmann aka Tectu <joel@unormal.org>
3
+ * Copyright (c) 2012, 2013, Andrew Hannam aka inmarket
4
+ *
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *    * Redistributions of source code must retain the above copyright
10
+ *      notice, this list of conditions and the following disclaimer.
11
+ *    * Redistributions in binary form must reproduce the above copyright
12
+ *      notice, this list of conditions and the following disclaimer in the
13
+ *      documentation and/or other materials provided with the distribution.
14
+ *    * Neither the name of the <organization> nor the
15
+ *      names of its contributors may be used to endorse or promote products
16
+ *      derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+
30
+#ifndef _GFXCONF_H
31
+#define _GFXCONF_H
32
+
33
+/* The operating system to use. One of these must be defined - preferably in your Makefile */
34
+//#define GFX_USE_OS_CHIBIOS	FALSE
35
+//#define GFX_USE_OS_WIN32		FALSE
36
+//#define GFX_USE_OS_LINUX		FALSE
37
+//#define GFX_USE_OS_OSX		FALSE
38
+
39
+/* GFX sub-systems to turn on */
40
+#define GFX_USE_GDISP			TRUE
41
+
42
+/* Features for the GDISP subsystem. */
43
+#define GDISP_NEED_VALIDATION	TRUE
44
+#define GDISP_NEED_ARC			TRUE
45
+
46
+
47
+#endif /* _GFXCONF_H */
48
+

+ 62 - 0
demos/modules/gdisp/thickarcs/main.c

@@ -0,0 +1,62 @@
1
+/*
2
+ * Copyright (c) 2012, 2013, Joel Bodenmann aka Tectu <joel@unormal.org>
3
+ * Copyright (c) 2012, 2013, Andrew Hannam aka inmarket
4
+ *
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *    * Redistributions of source code must retain the above copyright
10
+ *      notice, this list of conditions and the following disclaimer.
11
+ *    * Redistributions in binary form must reproduce the above copyright
12
+ *      notice, this list of conditions and the following disclaimer in the
13
+ *      documentation and/or other materials provided with the distribution.
14
+ *    * Neither the name of the <organization> nor the
15
+ *      names of its contributors may be used to endorse or promote products
16
+ *      derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+
30
+#include "gfx.h"
31
+
32
+// This function draws a thick arc and a non-thick arc together
33
+static void _drawCombinedArc(int x, int y, int angle1, int angle2)
34
+{
35
+	gdispDrawThickArc(x, y, 40, 60, angle1, angle2, Red);
36
+	gdispDrawArc(x, y, 50, angle1, angle2, White);
37
+}
38
+
39
+int main(void)
40
+{
41
+	int i = 35;
42
+
43
+    // Initialize the uGFX library
44
+    gfxInit();
45
+
46
+	while(TRUE) {
47
+		// Clear the entire screen
48
+		gdispClear(Black);
49
+
50
+		// Draw some thick arcs with an outline
51
+		_drawCombinedArc(150, 150, (i / 360) * 15 + 55, 55+i);
52
+		_drawCombinedArc(300, 150, 100+i, (i / 360) * 15 + 100);
53
+		_drawCombinedArc(300, 300, (i / 360) * 15 + 145, 145+i);
54
+		_drawCombinedArc(150, 300, (i / 360) * 15 + 195, 195-i);
55
+		
56
+		// Draw different arcs the next time
57
+		i++;
58
+
59
+		// Wait a bit
60
+		gfxSleepMilliseconds(20);
61
+	}
62
+}