1 /**************************************************************************/
4 @author K. Townsend (microBuilder.eu)
8 Software License Agreement (BSD License)
10 Copyright (c) 2011, microBuilder SARL
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /**************************************************************************/
38 #include "projectconfig.h"
41 #include "core/gpio/gpio.h"
42 #include "core/adc/adc.h"
43 #include "core/systick/systick.h"
45 #include "drivers/displays/tft/lcd.h"
46 #include "drivers/displays/tft/bmp.h"
47 #include "drivers/displays/tft/drawing.h"
48 #include "drivers/displays/tft/touchscreen.h"
49 #include "drivers/displays/tft/fonts/dejavusans9.h"
50 #include "drivers/displays/tft/fonts/dejavusansbold9.h"
51 #include "drivers/displays/tft/fonts/dejavusansmono8.h"
53 #include "drivers/displays/icons16.h"
56 #define FONT_REGULAR &dejaVuSans9ptFontInfo
57 #define FONT_BOLD &dejaVuSansBold9ptFontInfo
58 #define COL_BACKGROUND COLOR_GRAY_80
59 #define COL_TEXT COLOR_WHITE
61 #define COL_BUTTON COLOR_GRAY_50
62 #define COL_BUTTONBORDER COLOR_GRAY_50
63 #define COL_BUTTONTEXT COLOR_WHITE
64 #define COL_BUTTONACTIVE COLOR_THEME_DEFAULT_BASE
65 #define COL_BUTTONACTIVEBORDER COLOR_THEME_DEFAULT_DARKER
66 #define COL_BUTTONACTIVETEXT COLOR_BLACK
68 #define COL_MENU COLOR_GRAY_30
69 #define COL_MENULIGHTER COLOR_GRAY_50
70 #define COL_MENUTEXT COLOR_WHITE
71 #define COL_MENUACTIVE COLOR_THEME_DEFAULT_DARKER
72 #define COL_MENUACTIVELIGHTER COLOR_THEME_DEFAULT_BASE
73 #define COL_MENUACTIVETEXT COLOR_BLACK
75 /**************************************************************************/
77 Draws a single entry in the menu (adjusting the display depending
78 on whether the item is currently active or not)
80 /**************************************************************************/
81 void renderMenuItem(uint16_t x
, uint16_t y
, uint16_t width
, uint16_t height
, uint16_t headerWidth
, bool active
, char* headerText
, char* bodyText
)
83 drawRectangleRounded(x
, y
, x
+headerWidth
, y
+height
, active
? COL_MENUACTIVE
: COL_MENU
, 10, DRAW_ROUNDEDCORNERS_NONE
);
84 drawRectangleRounded(x
+headerWidth
, y
, x
+width
, y
+height
, active
? COL_MENUACTIVELIGHTER
: COL_MENULIGHTER
, 10, DRAW_ROUNDEDCORNERS_NONE
);
85 fontsDrawString(x
+10, y
+height
/2, active
? COL_MENUACTIVETEXT
: COL_MENUTEXT
, FONT_BOLD
, headerText
);
86 fontsDrawString(x
+headerWidth
+25, y
+height
/2, active
? COL_MENUACTIVETEXT
: COL_MENUTEXT
, FONT_REGULAR
, bodyText
);
90 drawArrow(x
+headerWidth
+5, y
+height
/2, 7, DRAW_DIRECTION_LEFT
, COL_MENUACTIVETEXT
);
91 drawArrow(x
+width
-5, y
+height
/2, 7, DRAW_DIRECTION_RIGHT
, COL_MENUACTIVETEXT
);
95 /**************************************************************************/
97 Renders the 16x16 icons found in "/drivers/displays/icons16.h"
99 /**************************************************************************/
100 void renderIcons(void)
103 drawRectangleRounded(10, 190, 30, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
104 drawIcon16(12, 192, COLOR_RED
, icons16_failed
);
105 drawRectangleRounded(10, 220, 30, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
106 drawIcon16(12, 222, COLOR_RED
, icons16_failed
);
107 drawIcon16(12, 222, COLOR_WHITE
, icons16_failed_interior
);
108 drawRectangleRounded(10, 250, 30, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
109 drawIcon16(12, 252, COLOR_WHITE
, icons16_failed_interior
);
112 drawRectangleRounded(40, 190, 60, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
113 drawIcon16(42, 192, COLOR_YELLOW
, icons16_alert
);
114 drawRectangleRounded(40, 220, 60, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
115 drawIcon16(42, 222, COLOR_YELLOW
, icons16_alert
);
116 drawIcon16(42, 222, COLOR_WHITE
, icons16_alert_interior
);
117 drawRectangleRounded(40, 250, 60, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
118 drawIcon16(42, 252, COLOR_WHITE
, icons16_alert_interior
);
121 drawRectangleRounded(70, 190, 90, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
122 drawIcon16(72, 192, COLOR_GREEN
, icons16_passed
);
123 drawRectangleRounded(70, 220, 90, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
124 drawIcon16(72, 222, COLOR_GREEN
, icons16_passed
);
125 drawIcon16(72, 222, COLOR_WHITE
, icons16_passed_interior
);
126 drawRectangleRounded(70, 250, 90, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
127 drawIcon16(72, 252, COLOR_WHITE
, icons16_passed_interior
);
130 drawRectangleRounded(100, 190, 120, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
131 drawIcon16(102, 192, COLOR_BLUE
, icons16_info
);
132 drawRectangleRounded(100, 220, 120, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
133 drawIcon16(102, 222, COLOR_BLUE
, icons16_info
);
134 drawIcon16(102, 222, COLOR_WHITE
, icons16_info_interior
);
135 drawRectangleRounded(100, 250, 120, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
136 drawIcon16(102, 252, COLOR_WHITE
, icons16_info_interior
);
139 drawRectangleRounded(130, 190, 150, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
140 drawIcon16(132, 192, COLOR_GREEN
, icons16_tools
);
143 drawRectangleRounded(160, 190, 180, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
144 drawIcon16(162, 192, COLOR_MAGENTA
, icons16_pointer
);
145 drawRectangleRounded(160, 220, 180, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
146 drawIcon16(162, 222, COLOR_MAGENTA
, icons16_pointer
);
147 drawIcon16(162, 222, COLOR_WHITE
, icons16_pointer_dot
);
148 drawRectangleRounded(160, 250, 180, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
149 drawIcon16(162, 252, COLOR_WHITE
, icons16_pointer_dot
);
152 drawRectangleRounded(190, 190, 210, 210, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
153 drawIcon16(192, 192, COLOR_CYAN
, icons16_tag
);
154 drawRectangleRounded(190, 220, 210, 240, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
155 drawIcon16(192, 222, COLOR_CYAN
, icons16_tag
);
156 drawIcon16(192, 222, COLOR_WHITE
, icons16_tag_dot
);
157 drawRectangleRounded(190, 250, 210, 270, COL_BUTTON
, 5, DRAW_ROUNDEDCORNERS_ALL
);
158 drawIcon16(192, 252, COLOR_WHITE
, icons16_tag_dot
);
161 /**************************************************************************/
163 Main program entry point. After reset, normal code execution will
166 /**************************************************************************/
169 #if !defined CFG_TFTLCD
170 #error "CFG_TFTLCD must be enabled in projectconfig.h for this test"
173 // Configure cpu and mandatory peripherals
177 drawFill(COL_BACKGROUND
);
179 // Top/bottom action bars
180 drawRectangleFilled(0, 0, 239, 19, COL_MENU
);
181 drawRectangleFilled(0, 280, 239, 319, COL_MENU
);
184 drawRectangleRounded(6, 30, 232, 160, COL_MENU
, 10, DRAW_ROUNDEDCORNERS_ALL
);
185 fontsDrawString(20, 45, COL_MENUTEXT
, FONT_BOLD
, "SYSTEM SETTINGS");
186 renderMenuItem(8, 65, 222, 23, 90, false, "LANGUAGE", "English");
187 renderMenuItem(8, 90, 222, 23, 90, false, "TIMEZONE", "GMT+1");
188 renderMenuItem(8, 115, 222, 23, 90, true, "SLEEP", "5 Minutes");
191 drawProgressBar (70, 165, 160, 15, DRAW_ROUNDEDCORNERS_ALL
, DRAW_ROUNDEDCORNERS_ALL
, COL_MENU
, COL_MENULIGHTER
, COL_MENUACTIVE
, COL_MENUACTIVELIGHTER
, 72 );
196 // Action bar buttons
197 drawButton(5, 285, 75, 29, FONT_BOLD
, COL_BUTTONBORDER
, COL_BUTTON
, COL_BUTTONTEXT
, "CANCEL");
198 drawButton(160, 285, 75, 29, FONT_BOLD
, COL_BUTTONBORDER
, COL_BUTTON
, COL_BUTTONTEXT
, "SAVE");
201 tsTouchError_t error
;
203 // Draw pixels whenever a touch screen event is detected
206 // Wait for a valid touch event
207 error
= tsWaitForEvent(&touch
, 0);
210 drawPixel(touch
.xlcd
, touch
.ylcd
, COLOR_WHITE
);
This page took 0.068036 seconds and 5 git commands to generate.