![](/media/cache/profiles/20200518_163046.jpg.50x50_q85.jpg)
PSoC 6 pioneer kit multi library code for emwin driven tft display, capsense and mechanical button input.
main.cpp@0:4ad2c16b6e43, 2019-08-09 (annotated)
- Committer:
- reedas
- Date:
- Fri Aug 09 23:18:24 2019 +0000
- Revision:
- 0:4ad2c16b6e43
- Child:
- 1:f8f4e789361f
First Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
reedas | 0:4ad2c16b6e43 | 1 | #include "mbed.h" |
reedas | 0:4ad2c16b6e43 | 2 | #include "GUI.h" |
reedas | 0:4ad2c16b6e43 | 3 | #include "cy8ckit_028_tft.h" |
reedas | 0:4ad2c16b6e43 | 4 | #define Cy_SysLib_Delay wait_ms |
reedas | 0:4ad2c16b6e43 | 5 | |
reedas | 0:4ad2c16b6e43 | 6 | DigitalOut ledGreen(LED_GREEN); |
reedas | 0:4ad2c16b6e43 | 7 | DigitalIn sw2(SWITCH2, PullUp); |
reedas | 0:4ad2c16b6e43 | 8 | DigitalOut ledRed(LED_RED); |
reedas | 0:4ad2c16b6e43 | 9 | DigitalOut ledBlue(LED_BLUE); |
reedas | 0:4ad2c16b6e43 | 10 | |
reedas | 0:4ad2c16b6e43 | 11 | DigitalInOut LCD_REG0(P9_0); |
reedas | 0:4ad2c16b6e43 | 12 | DigitalInOut LCD_REG1(P9_1); |
reedas | 0:4ad2c16b6e43 | 13 | DigitalInOut LCD_REG2(P9_2); |
reedas | 0:4ad2c16b6e43 | 14 | DigitalInOut LCD_REG3(P9_4); |
reedas | 0:4ad2c16b6e43 | 15 | DigitalInOut LCD_REG4(P9_5); |
reedas | 0:4ad2c16b6e43 | 16 | DigitalInOut LCD_REG5(P0_2); |
reedas | 0:4ad2c16b6e43 | 17 | DigitalInOut LCD_REG6(P13_0); |
reedas | 0:4ad2c16b6e43 | 18 | DigitalInOut LCD_REG7(P13_1); |
reedas | 0:4ad2c16b6e43 | 19 | |
reedas | 0:4ad2c16b6e43 | 20 | DigitalOut LCD_NWR(P12_0); |
reedas | 0:4ad2c16b6e43 | 21 | DigitalOut LCD_DC(P12_1); |
reedas | 0:4ad2c16b6e43 | 22 | DigitalOut LCD_RESET(P12_2); |
reedas | 0:4ad2c16b6e43 | 23 | DigitalOut LCD_NRD(P12_3); |
reedas | 0:4ad2c16b6e43 | 24 | |
reedas | 0:4ad2c16b6e43 | 25 | #define NUMBER_OF_DEMO_PAGES (10u) |
reedas | 0:4ad2c16b6e43 | 26 | |
reedas | 0:4ad2c16b6e43 | 27 | |
reedas | 0:4ad2c16b6e43 | 28 | /* Macros for switch press status */ |
reedas | 0:4ad2c16b6e43 | 29 | #define BTN_PRESSED (0u) |
reedas | 0:4ad2c16b6e43 | 30 | #define BTN_RELEASED (1u) |
reedas | 0:4ad2c16b6e43 | 31 | |
reedas | 0:4ad2c16b6e43 | 32 | /* Macros to control LEDs */ |
reedas | 0:4ad2c16b6e43 | 33 | #define LED_ON (0) |
reedas | 0:4ad2c16b6e43 | 34 | #define LED_OFF (1) |
reedas | 0:4ad2c16b6e43 | 35 | |
reedas | 0:4ad2c16b6e43 | 36 | |
reedas | 0:4ad2c16b6e43 | 37 | |
reedas | 0:4ad2c16b6e43 | 38 | /* External global references */ |
reedas | 0:4ad2c16b6e43 | 39 | //extern GUI_CONST_STORAGE GUI_BITMAP bmCypressLogo_1bpp; |
reedas | 0:4ad2c16b6e43 | 40 | |
reedas | 0:4ad2c16b6e43 | 41 | extern GUI_CONST_STORAGE GUI_BITMAP bmExampleImage; |
reedas | 0:4ad2c16b6e43 | 42 | extern GUI_CONST_STORAGE GUI_BITMAP bmCypressLogo; |
reedas | 0:4ad2c16b6e43 | 43 | |
reedas | 0:4ad2c16b6e43 | 44 | /* Function prototypes */ |
reedas | 0:4ad2c16b6e43 | 45 | void ShowTextModes(void); |
reedas | 0:4ad2c16b6e43 | 46 | void ShowTextColors(void); |
reedas | 0:4ad2c16b6e43 | 47 | void ShowFontSizesNormal(void); |
reedas | 0:4ad2c16b6e43 | 48 | void ShowFontSizesBold(void); |
reedas | 0:4ad2c16b6e43 | 49 | void ShowColorBar(void); |
reedas | 0:4ad2c16b6e43 | 50 | void Show2DGraphics1(void); |
reedas | 0:4ad2c16b6e43 | 51 | void Show2DGraphics2(void); |
reedas | 0:4ad2c16b6e43 | 52 | void ShowConcentricCircles(void); |
reedas | 0:4ad2c16b6e43 | 53 | void ShowTextWrapAndOrientation(void); |
reedas | 0:4ad2c16b6e43 | 54 | void ShowBitmap(void); |
reedas | 0:4ad2c16b6e43 | 55 | |
reedas | 0:4ad2c16b6e43 | 56 | /* Array of demo pages functions */ |
reedas | 0:4ad2c16b6e43 | 57 | void (*demoPageArray[NUMBER_OF_DEMO_PAGES])(void) = { |
reedas | 0:4ad2c16b6e43 | 58 | ShowTextModes, |
reedas | 0:4ad2c16b6e43 | 59 | ShowTextColors, |
reedas | 0:4ad2c16b6e43 | 60 | ShowFontSizesNormal, |
reedas | 0:4ad2c16b6e43 | 61 | ShowFontSizesBold, |
reedas | 0:4ad2c16b6e43 | 62 | ShowTextWrapAndOrientation, |
reedas | 0:4ad2c16b6e43 | 63 | ShowColorBar, |
reedas | 0:4ad2c16b6e43 | 64 | Show2DGraphics1, |
reedas | 0:4ad2c16b6e43 | 65 | Show2DGraphics2, |
reedas | 0:4ad2c16b6e43 | 66 | ShowConcentricCircles, |
reedas | 0:4ad2c16b6e43 | 67 | ShowBitmap |
reedas | 0:4ad2c16b6e43 | 68 | }; |
reedas | 0:4ad2c16b6e43 | 69 | |
reedas | 0:4ad2c16b6e43 | 70 | |
reedas | 0:4ad2c16b6e43 | 71 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 72 | * Function Name: void ShowStartupScreen(void) |
reedas | 0:4ad2c16b6e43 | 73 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 74 | * |
reedas | 0:4ad2c16b6e43 | 75 | * Summary: This function displays the startup screen. |
reedas | 0:4ad2c16b6e43 | 76 | * |
reedas | 0:4ad2c16b6e43 | 77 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 78 | * None |
reedas | 0:4ad2c16b6e43 | 79 | * |
reedas | 0:4ad2c16b6e43 | 80 | * Return: |
reedas | 0:4ad2c16b6e43 | 81 | * None |
reedas | 0:4ad2c16b6e43 | 82 | * |
reedas | 0:4ad2c16b6e43 | 83 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 84 | void ShowStartupScreen(void) |
reedas | 0:4ad2c16b6e43 | 85 | { |
reedas | 0:4ad2c16b6e43 | 86 | /* Set font size, foreground and background Colours */ |
reedas | 0:4ad2c16b6e43 | 87 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 88 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 89 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 90 | |
reedas | 0:4ad2c16b6e43 | 91 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 92 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 93 | |
reedas | 0:4ad2c16b6e43 | 94 | /* Draw the Cypress Logo */ |
reedas | 0:4ad2c16b6e43 | 95 | GUI_DrawBitmap(&bmCypressLogo, 4, 4); |
reedas | 0:4ad2c16b6e43 | 96 | |
reedas | 0:4ad2c16b6e43 | 97 | /* Print the text CYPRESS EMWIN GRAPHICS DEMO TFT DISPLAY */ |
reedas | 0:4ad2c16b6e43 | 98 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 99 | GUI_DispStringAt("CYPRESS", 160, 120); |
reedas | 0:4ad2c16b6e43 | 100 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 101 | GUI_DispStringAt("EMWIN GRAPHICS DEMO", 160, 140); |
reedas | 0:4ad2c16b6e43 | 102 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 103 | GUI_DispStringAt("TFT DISPLAY", 160, 160); |
reedas | 0:4ad2c16b6e43 | 104 | } |
reedas | 0:4ad2c16b6e43 | 105 | |
reedas | 0:4ad2c16b6e43 | 106 | |
reedas | 0:4ad2c16b6e43 | 107 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 108 | * Function Name: void ShowInstructionsScreen(void) |
reedas | 0:4ad2c16b6e43 | 109 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 110 | * |
reedas | 0:4ad2c16b6e43 | 111 | * Summary: This function shows screen with instructions to press SW2 to |
reedas | 0:4ad2c16b6e43 | 112 | * scroll through various display pages |
reedas | 0:4ad2c16b6e43 | 113 | * |
reedas | 0:4ad2c16b6e43 | 114 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 115 | * None |
reedas | 0:4ad2c16b6e43 | 116 | * |
reedas | 0:4ad2c16b6e43 | 117 | * Return: |
reedas | 0:4ad2c16b6e43 | 118 | * None |
reedas | 0:4ad2c16b6e43 | 119 | * |
reedas | 0:4ad2c16b6e43 | 120 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 121 | void ShowInstructionsScreen(void) |
reedas | 0:4ad2c16b6e43 | 122 | { |
reedas | 0:4ad2c16b6e43 | 123 | /* Set font size, background Colour and text mode */ |
reedas | 0:4ad2c16b6e43 | 124 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 125 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 126 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 127 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 128 | |
reedas | 0:4ad2c16b6e43 | 129 | /* Clear the display */ |
reedas | 0:4ad2c16b6e43 | 130 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 131 | |
reedas | 0:4ad2c16b6e43 | 132 | /* Display instructions text */ |
reedas | 0:4ad2c16b6e43 | 133 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 134 | GUI_DispStringAt("PRESS SW2 ON THE KIT", 160, 90); |
reedas | 0:4ad2c16b6e43 | 135 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 136 | GUI_DispStringAt("TO SCROLL THROUGH ", 160, 110); |
reedas | 0:4ad2c16b6e43 | 137 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 138 | GUI_DispStringAt("DEMO PAGES!", 160, 130); |
reedas | 0:4ad2c16b6e43 | 139 | } |
reedas | 0:4ad2c16b6e43 | 140 | |
reedas | 0:4ad2c16b6e43 | 141 | |
reedas | 0:4ad2c16b6e43 | 142 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 143 | * Function Name: void ShowTextModes(void) |
reedas | 0:4ad2c16b6e43 | 144 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 145 | * |
reedas | 0:4ad2c16b6e43 | 146 | * Summary: This function displays the following |
reedas | 0:4ad2c16b6e43 | 147 | * 1. Left, Center and Right aligned text |
reedas | 0:4ad2c16b6e43 | 148 | * 2. Underline, overline and strikethrough style text |
reedas | 0:4ad2c16b6e43 | 149 | * 3. Normal, reverse, transparent and XOR text modes |
reedas | 0:4ad2c16b6e43 | 150 | * |
reedas | 0:4ad2c16b6e43 | 151 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 152 | * None |
reedas | 0:4ad2c16b6e43 | 153 | * |
reedas | 0:4ad2c16b6e43 | 154 | * Return: |
reedas | 0:4ad2c16b6e43 | 155 | * None |
reedas | 0:4ad2c16b6e43 | 156 | * |
reedas | 0:4ad2c16b6e43 | 157 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 158 | void ShowTextModes(void) |
reedas | 0:4ad2c16b6e43 | 159 | { |
reedas | 0:4ad2c16b6e43 | 160 | /* Set font size, foreground and background Colours */ |
reedas | 0:4ad2c16b6e43 | 161 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 162 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 163 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 164 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 165 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 166 | |
reedas | 0:4ad2c16b6e43 | 167 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 168 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 169 | |
reedas | 0:4ad2c16b6e43 | 170 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 171 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 172 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 173 | GUI_DispStringAt("1 OF 10: TEXT ALIGNMENTS, STYLES AND MODES", 160, 10); |
reedas | 0:4ad2c16b6e43 | 174 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 175 | |
reedas | 0:4ad2c16b6e43 | 176 | /* Display left aligned text */ |
reedas | 0:4ad2c16b6e43 | 177 | GUI_SetTextAlign(GUI_TA_LEFT); |
reedas | 0:4ad2c16b6e43 | 178 | GUI_DispStringAt("TEXT ALIGNMENT LEFT", 0, 40); |
reedas | 0:4ad2c16b6e43 | 179 | |
reedas | 0:4ad2c16b6e43 | 180 | /* Display center aligned text */ |
reedas | 0:4ad2c16b6e43 | 181 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 182 | GUI_DispStringAt("TEXT ALIGNMENT CENTER", 160, 60); |
reedas | 0:4ad2c16b6e43 | 183 | |
reedas | 0:4ad2c16b6e43 | 184 | /* Display right aligned text */ |
reedas | 0:4ad2c16b6e43 | 185 | GUI_SetTextAlign(GUI_TA_RIGHT); |
reedas | 0:4ad2c16b6e43 | 186 | GUI_DispStringAt("TEXT ALIGNMENT RIGHT", 319, 80); |
reedas | 0:4ad2c16b6e43 | 187 | |
reedas | 0:4ad2c16b6e43 | 188 | /* Display underlined text */ |
reedas | 0:4ad2c16b6e43 | 189 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 190 | GUI_SetTextAlign(GUI_TA_LEFT); |
reedas | 0:4ad2c16b6e43 | 191 | GUI_DispStringAt("TEXT STYLE UNDERLINE", 0, 100); |
reedas | 0:4ad2c16b6e43 | 192 | |
reedas | 0:4ad2c16b6e43 | 193 | /* Display overlined text */ |
reedas | 0:4ad2c16b6e43 | 194 | GUI_SetTextStyle(GUI_TS_OVERLINE); |
reedas | 0:4ad2c16b6e43 | 195 | GUI_SetTextAlign(GUI_TA_LEFT); |
reedas | 0:4ad2c16b6e43 | 196 | GUI_DispStringAt("TEXT STYLE OVERLINE", 0, 120); |
reedas | 0:4ad2c16b6e43 | 197 | |
reedas | 0:4ad2c16b6e43 | 198 | /* Display strikethrough text */ |
reedas | 0:4ad2c16b6e43 | 199 | GUI_SetTextStyle(GUI_TS_STRIKETHRU); |
reedas | 0:4ad2c16b6e43 | 200 | GUI_SetTextAlign(GUI_TA_LEFT); |
reedas | 0:4ad2c16b6e43 | 201 | GUI_DispStringAt("TEXT STYLE STRIKETHROUGH", 0, 140); |
reedas | 0:4ad2c16b6e43 | 202 | |
reedas | 0:4ad2c16b6e43 | 203 | /* Create a rectangle filled with blue Colour */ |
reedas | 0:4ad2c16b6e43 | 204 | GUI_SetColor(GUI_BROWN); |
reedas | 0:4ad2c16b6e43 | 205 | GUI_FillRect(0, 160, 319, 239); |
reedas | 0:4ad2c16b6e43 | 206 | |
reedas | 0:4ad2c16b6e43 | 207 | /* Draw two diagonal lines */ |
reedas | 0:4ad2c16b6e43 | 208 | GUI_SetColor(GUI_BLUE); |
reedas | 0:4ad2c16b6e43 | 209 | GUI_SetPenSize(3); |
reedas | 0:4ad2c16b6e43 | 210 | GUI_DrawLine(0, 160, 319, 239); |
reedas | 0:4ad2c16b6e43 | 211 | GUI_DrawLine(0, 239, 319, 160); |
reedas | 0:4ad2c16b6e43 | 212 | |
reedas | 0:4ad2c16b6e43 | 213 | /* Set text Colour to white with black background */ |
reedas | 0:4ad2c16b6e43 | 214 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 215 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 216 | |
reedas | 0:4ad2c16b6e43 | 217 | /* Set text style to normal */ |
reedas | 0:4ad2c16b6e43 | 218 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 219 | |
reedas | 0:4ad2c16b6e43 | 220 | /* Display text in normal mode. This will print white text in |
reedas | 0:4ad2c16b6e43 | 221 | a black box */ |
reedas | 0:4ad2c16b6e43 | 222 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 223 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 224 | GUI_DispStringAt("TEXT MODE NORMAL", 160, 165); |
reedas | 0:4ad2c16b6e43 | 225 | |
reedas | 0:4ad2c16b6e43 | 226 | /* Display text in reverse mode. This will print black text n |
reedas | 0:4ad2c16b6e43 | 227 | a white box */ |
reedas | 0:4ad2c16b6e43 | 228 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 229 | GUI_SetTextMode(GUI_TM_REV); |
reedas | 0:4ad2c16b6e43 | 230 | GUI_DispStringAt("TEXT MODE REVERSE", 160, 185); |
reedas | 0:4ad2c16b6e43 | 231 | |
reedas | 0:4ad2c16b6e43 | 232 | /* Display transparent text. This will display white text |
reedas | 0:4ad2c16b6e43 | 233 | on the blue background already present in the rectangle */ |
reedas | 0:4ad2c16b6e43 | 234 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 235 | GUI_SetTextMode(GUI_TM_TRANS); |
reedas | 0:4ad2c16b6e43 | 236 | GUI_DispStringAt("TEXT MODE TRANSPARENT", 160, 205); |
reedas | 0:4ad2c16b6e43 | 237 | |
reedas | 0:4ad2c16b6e43 | 238 | /* Display XOR text. This will XOR the blue background with |
reedas | 0:4ad2c16b6e43 | 239 | the white text */ |
reedas | 0:4ad2c16b6e43 | 240 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 241 | GUI_SetTextMode(GUI_TM_XOR); |
reedas | 0:4ad2c16b6e43 | 242 | GUI_DispStringAt("TEXT MODE XOR", 160, 225); |
reedas | 0:4ad2c16b6e43 | 243 | } |
reedas | 0:4ad2c16b6e43 | 244 | |
reedas | 0:4ad2c16b6e43 | 245 | |
reedas | 0:4ad2c16b6e43 | 246 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 247 | * Function Name: void ShowTextColors(void) |
reedas | 0:4ad2c16b6e43 | 248 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 249 | * |
reedas | 0:4ad2c16b6e43 | 250 | * Summary: This function displays text in various Colours |
reedas | 0:4ad2c16b6e43 | 251 | * |
reedas | 0:4ad2c16b6e43 | 252 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 253 | * None |
reedas | 0:4ad2c16b6e43 | 254 | * |
reedas | 0:4ad2c16b6e43 | 255 | * Return: |
reedas | 0:4ad2c16b6e43 | 256 | * None |
reedas | 0:4ad2c16b6e43 | 257 | * |
reedas | 0:4ad2c16b6e43 | 258 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 259 | void ShowTextColors(void) |
reedas | 0:4ad2c16b6e43 | 260 | { |
reedas | 0:4ad2c16b6e43 | 261 | /* Set font size, background Colour and text mode */ |
reedas | 0:4ad2c16b6e43 | 262 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 263 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 264 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 265 | |
reedas | 0:4ad2c16b6e43 | 266 | /* Clear the display */ |
reedas | 0:4ad2c16b6e43 | 267 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 268 | |
reedas | 0:4ad2c16b6e43 | 269 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 270 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 271 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 272 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 273 | GUI_DispStringAt("2 OF 10: TEXT COLOURS", 160, 10); |
reedas | 0:4ad2c16b6e43 | 274 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 275 | |
reedas | 0:4ad2c16b6e43 | 276 | /* White */ |
reedas | 0:4ad2c16b6e43 | 277 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 278 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 279 | GUI_DispStringAt("TEXT COLOUR WHITE", 160, 40); |
reedas | 0:4ad2c16b6e43 | 280 | |
reedas | 0:4ad2c16b6e43 | 281 | /* Gray */ |
reedas | 0:4ad2c16b6e43 | 282 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 283 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 284 | GUI_DispStringAt("TEXT COLOUR GRAY", 160, 60); |
reedas | 0:4ad2c16b6e43 | 285 | |
reedas | 0:4ad2c16b6e43 | 286 | /* Red */ |
reedas | 0:4ad2c16b6e43 | 287 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 288 | GUI_SetColor(GUI_RED); |
reedas | 0:4ad2c16b6e43 | 289 | GUI_DispStringAt("TEXT COLOUR RED", 160, 80); |
reedas | 0:4ad2c16b6e43 | 290 | |
reedas | 0:4ad2c16b6e43 | 291 | /* Green */ |
reedas | 0:4ad2c16b6e43 | 292 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 293 | GUI_SetColor(GUI_GREEN); |
reedas | 0:4ad2c16b6e43 | 294 | GUI_DispStringAt("TEXT COLOUR GREEN", 160, 100); |
reedas | 0:4ad2c16b6e43 | 295 | |
reedas | 0:4ad2c16b6e43 | 296 | /* Blue */ |
reedas | 0:4ad2c16b6e43 | 297 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 298 | GUI_SetColor(GUI_BLUE); |
reedas | 0:4ad2c16b6e43 | 299 | GUI_DispStringAt("TEXT COLOUR BLUE", 160, 120); |
reedas | 0:4ad2c16b6e43 | 300 | |
reedas | 0:4ad2c16b6e43 | 301 | /* Yellow */ |
reedas | 0:4ad2c16b6e43 | 302 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 303 | GUI_SetColor(GUI_YELLOW); |
reedas | 0:4ad2c16b6e43 | 304 | GUI_DispStringAt("TEXT COLOUR YELLOW", 160, 140); |
reedas | 0:4ad2c16b6e43 | 305 | |
reedas | 0:4ad2c16b6e43 | 306 | /* Brown */ |
reedas | 0:4ad2c16b6e43 | 307 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 308 | GUI_SetColor(GUI_BROWN); |
reedas | 0:4ad2c16b6e43 | 309 | GUI_DispStringAt("TEXT COLOUR BROWN", 160, 160); |
reedas | 0:4ad2c16b6e43 | 310 | |
reedas | 0:4ad2c16b6e43 | 311 | /* Magenta */ |
reedas | 0:4ad2c16b6e43 | 312 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 313 | GUI_SetColor(GUI_MAGENTA); |
reedas | 0:4ad2c16b6e43 | 314 | GUI_DispStringAt("TEXT COLOUR MAGENTA", 160, 180); |
reedas | 0:4ad2c16b6e43 | 315 | |
reedas | 0:4ad2c16b6e43 | 316 | /* Cyan */ |
reedas | 0:4ad2c16b6e43 | 317 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 318 | GUI_SetColor(GUI_CYAN); |
reedas | 0:4ad2c16b6e43 | 319 | GUI_DispStringAt("TEXT COLOUR CYAN", 160, 200); |
reedas | 0:4ad2c16b6e43 | 320 | |
reedas | 0:4ad2c16b6e43 | 321 | /* Orange */ |
reedas | 0:4ad2c16b6e43 | 322 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 323 | GUI_SetColor(GUI_ORANGE); |
reedas | 0:4ad2c16b6e43 | 324 | GUI_DispStringAt("TEXT COLOUR ORANGE", 160, 220); |
reedas | 0:4ad2c16b6e43 | 325 | } |
reedas | 0:4ad2c16b6e43 | 326 | |
reedas | 0:4ad2c16b6e43 | 327 | |
reedas | 0:4ad2c16b6e43 | 328 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 329 | * Function Name: void ShowFontSizesNormal(void) |
reedas | 0:4ad2c16b6e43 | 330 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 331 | * |
reedas | 0:4ad2c16b6e43 | 332 | * Summary: This function shows various font sizes |
reedas | 0:4ad2c16b6e43 | 333 | * |
reedas | 0:4ad2c16b6e43 | 334 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 335 | * None |
reedas | 0:4ad2c16b6e43 | 336 | * |
reedas | 0:4ad2c16b6e43 | 337 | * Return: |
reedas | 0:4ad2c16b6e43 | 338 | * None |
reedas | 0:4ad2c16b6e43 | 339 | * |
reedas | 0:4ad2c16b6e43 | 340 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 341 | void ShowFontSizesNormal(void) |
reedas | 0:4ad2c16b6e43 | 342 | { |
reedas | 0:4ad2c16b6e43 | 343 | /* Set font size, background colour and text mode */ |
reedas | 0:4ad2c16b6e43 | 344 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 345 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 346 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 347 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 348 | |
reedas | 0:4ad2c16b6e43 | 349 | /* Clear the display */ |
reedas | 0:4ad2c16b6e43 | 350 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 351 | |
reedas | 0:4ad2c16b6e43 | 352 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 353 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 354 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 355 | GUI_DispStringAt("3 OF 10: NORMAL FONTS", 160, 10); |
reedas | 0:4ad2c16b6e43 | 356 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 357 | |
reedas | 0:4ad2c16b6e43 | 358 | /* Font8_1*/ |
reedas | 0:4ad2c16b6e43 | 359 | GUI_SetFont(GUI_FONT_8_1); |
reedas | 0:4ad2c16b6e43 | 360 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 361 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 362 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 363 | GUI_DispStringAt("GUI_Font8_1", 10, 40); |
reedas | 0:4ad2c16b6e43 | 364 | |
reedas | 0:4ad2c16b6e43 | 365 | /* Font10_1*/ |
reedas | 0:4ad2c16b6e43 | 366 | GUI_SetFont(GUI_FONT_10_1); |
reedas | 0:4ad2c16b6e43 | 367 | GUI_DispStringAt("GUI_Font10_1", 10, 50); |
reedas | 0:4ad2c16b6e43 | 368 | |
reedas | 0:4ad2c16b6e43 | 369 | /* Font13_1*/ |
reedas | 0:4ad2c16b6e43 | 370 | GUI_SetFont(GUI_FONT_13_1); |
reedas | 0:4ad2c16b6e43 | 371 | GUI_DispStringAt("GUI_Font13_1", 10, 62); |
reedas | 0:4ad2c16b6e43 | 372 | |
reedas | 0:4ad2c16b6e43 | 373 | /* Font16_1*/ |
reedas | 0:4ad2c16b6e43 | 374 | GUI_SetFont(GUI_FONT_16_1); |
reedas | 0:4ad2c16b6e43 | 375 | GUI_DispStringAt("GUI_Font16_1", 10, 77); |
reedas | 0:4ad2c16b6e43 | 376 | |
reedas | 0:4ad2c16b6e43 | 377 | /* Font20_1*/ |
reedas | 0:4ad2c16b6e43 | 378 | GUI_SetFont(GUI_FONT_20_1); |
reedas | 0:4ad2c16b6e43 | 379 | GUI_DispStringAt("GUI_Font20_1", 10, 95); |
reedas | 0:4ad2c16b6e43 | 380 | |
reedas | 0:4ad2c16b6e43 | 381 | /* Font24_1*/ |
reedas | 0:4ad2c16b6e43 | 382 | GUI_SetFont(GUI_FONT_24_1); |
reedas | 0:4ad2c16b6e43 | 383 | GUI_DispStringAt("GUI_Font24_1", 10, 117); |
reedas | 0:4ad2c16b6e43 | 384 | |
reedas | 0:4ad2c16b6e43 | 385 | /* Font32_1*/ |
reedas | 0:4ad2c16b6e43 | 386 | GUI_SetFont(GUI_FONT_32_1); |
reedas | 0:4ad2c16b6e43 | 387 | GUI_DispStringAt("GUI_Font32_1", 10, 143); |
reedas | 0:4ad2c16b6e43 | 388 | |
reedas | 0:4ad2c16b6e43 | 389 | /* Font48_1*/ |
reedas | 0:4ad2c16b6e43 | 390 | GUI_SetFont(GUI_FONT_8X16X2X2); |
reedas | 0:4ad2c16b6e43 | 391 | GUI_DispStringAt("GUI_Font8x16x2x2", 10, 180); |
reedas | 0:4ad2c16b6e43 | 392 | } |
reedas | 0:4ad2c16b6e43 | 393 | |
reedas | 0:4ad2c16b6e43 | 394 | |
reedas | 0:4ad2c16b6e43 | 395 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 396 | * Function Name: void ShowFontSizesBold(void) |
reedas | 0:4ad2c16b6e43 | 397 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 398 | * |
reedas | 0:4ad2c16b6e43 | 399 | * Summary: This function shows various font sizes |
reedas | 0:4ad2c16b6e43 | 400 | * |
reedas | 0:4ad2c16b6e43 | 401 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 402 | * None |
reedas | 0:4ad2c16b6e43 | 403 | * |
reedas | 0:4ad2c16b6e43 | 404 | * Return: |
reedas | 0:4ad2c16b6e43 | 405 | * None |
reedas | 0:4ad2c16b6e43 | 406 | * |
reedas | 0:4ad2c16b6e43 | 407 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 408 | void ShowFontSizesBold(void) |
reedas | 0:4ad2c16b6e43 | 409 | { |
reedas | 0:4ad2c16b6e43 | 410 | /* Set font size, background colour and text mode */ |
reedas | 0:4ad2c16b6e43 | 411 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 412 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 413 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 414 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 415 | |
reedas | 0:4ad2c16b6e43 | 416 | /* Clear the display */ |
reedas | 0:4ad2c16b6e43 | 417 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 418 | |
reedas | 0:4ad2c16b6e43 | 419 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 420 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 421 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 422 | GUI_DispStringAt("4 OF 10: BOLD FONTS", 160, 10); |
reedas | 0:4ad2c16b6e43 | 423 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 424 | |
reedas | 0:4ad2c16b6e43 | 425 | /* Font13B_1*/ |
reedas | 0:4ad2c16b6e43 | 426 | GUI_SetFont(GUI_FONT_13B_1); |
reedas | 0:4ad2c16b6e43 | 427 | GUI_DispStringAt("GUI_Font13B_1", 10, 40); |
reedas | 0:4ad2c16b6e43 | 428 | |
reedas | 0:4ad2c16b6e43 | 429 | /* Font13HB_1*/ |
reedas | 0:4ad2c16b6e43 | 430 | GUI_SetFont(GUI_FONT_13HB_1); |
reedas | 0:4ad2c16b6e43 | 431 | GUI_DispStringAt("GUI_Font13HB_1", 10, 55); |
reedas | 0:4ad2c16b6e43 | 432 | |
reedas | 0:4ad2c16b6e43 | 433 | /* Font16B_1*/ |
reedas | 0:4ad2c16b6e43 | 434 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 435 | GUI_DispStringAt("GUI_Font6B_1", 10, 70); |
reedas | 0:4ad2c16b6e43 | 436 | |
reedas | 0:4ad2c16b6e43 | 437 | /* FontComic18B_1*/ |
reedas | 0:4ad2c16b6e43 | 438 | GUI_SetFont(GUI_FONT_COMIC18B_1); |
reedas | 0:4ad2c16b6e43 | 439 | GUI_DispStringAt("GUI_FontComic18B_1", 10, 88); |
reedas | 0:4ad2c16b6e43 | 440 | |
reedas | 0:4ad2c16b6e43 | 441 | /* Font20B_1*/ |
reedas | 0:4ad2c16b6e43 | 442 | GUI_SetFont(GUI_FONT_20B_1); |
reedas | 0:4ad2c16b6e43 | 443 | GUI_DispStringAt("GUI_Font20B_1", 10, 108); |
reedas | 0:4ad2c16b6e43 | 444 | |
reedas | 0:4ad2c16b6e43 | 445 | /* Font24B_1*/ |
reedas | 0:4ad2c16b6e43 | 446 | GUI_SetFont(GUI_FONT_24B_1); |
reedas | 0:4ad2c16b6e43 | 447 | GUI_DispStringAt("GUI_Font24B_1", 10, 130); |
reedas | 0:4ad2c16b6e43 | 448 | |
reedas | 0:4ad2c16b6e43 | 449 | /* Font32B_1*/ |
reedas | 0:4ad2c16b6e43 | 450 | GUI_SetFont(GUI_FONT_32B_1); |
reedas | 0:4ad2c16b6e43 | 451 | GUI_DispStringAt("GUI_Font32B_1", 10, 156); |
reedas | 0:4ad2c16b6e43 | 452 | |
reedas | 0:4ad2c16b6e43 | 453 | /* Font48B_1*/ |
reedas | 0:4ad2c16b6e43 | 454 | GUI_SetFont(GUI_FONT_8X16X3X3); |
reedas | 0:4ad2c16b6e43 | 455 | GUI_DispStringAt("GUI_Font8x16x3x3", 10, 190); |
reedas | 0:4ad2c16b6e43 | 456 | } |
reedas | 0:4ad2c16b6e43 | 457 | |
reedas | 0:4ad2c16b6e43 | 458 | |
reedas | 0:4ad2c16b6e43 | 459 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 460 | * Function Name: void ShowColorBar(void) |
reedas | 0:4ad2c16b6e43 | 461 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 462 | * |
reedas | 0:4ad2c16b6e43 | 463 | * Summary: This function displays displays horizontal colour bars. For each |
reedas | 0:4ad2c16b6e43 | 464 | * colour, two bars are printed, one bar that has a gradient from |
reedas | 0:4ad2c16b6e43 | 465 | * black to the colour and another bar that has a gradient from white |
reedas | 0:4ad2c16b6e43 | 466 | * to the colour. |
reedas | 0:4ad2c16b6e43 | 467 | * |
reedas | 0:4ad2c16b6e43 | 468 | * Note: This function is provided by EmWin as a demo code. |
reedas | 0:4ad2c16b6e43 | 469 | * |
reedas | 0:4ad2c16b6e43 | 470 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 471 | * None |
reedas | 0:4ad2c16b6e43 | 472 | * |
reedas | 0:4ad2c16b6e43 | 473 | * Return: |
reedas | 0:4ad2c16b6e43 | 474 | * None |
reedas | 0:4ad2c16b6e43 | 475 | * |
reedas | 0:4ad2c16b6e43 | 476 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 477 | void ShowColorBar(void) |
reedas | 0:4ad2c16b6e43 | 478 | { |
reedas | 0:4ad2c16b6e43 | 479 | /* Local variables */ |
reedas | 0:4ad2c16b6e43 | 480 | int x0; |
reedas | 0:4ad2c16b6e43 | 481 | int y0; |
reedas | 0:4ad2c16b6e43 | 482 | int yStep; |
reedas | 0:4ad2c16b6e43 | 483 | int i; |
reedas | 0:4ad2c16b6e43 | 484 | int xsize; |
reedas | 0:4ad2c16b6e43 | 485 | U16 cs; |
reedas | 0:4ad2c16b6e43 | 486 | U16 x; |
reedas | 0:4ad2c16b6e43 | 487 | |
reedas | 0:4ad2c16b6e43 | 488 | /* Initialize parameters */ |
reedas | 0:4ad2c16b6e43 | 489 | x0 = 60; |
reedas | 0:4ad2c16b6e43 | 490 | y0 = 40; |
reedas | 0:4ad2c16b6e43 | 491 | yStep = 15; |
reedas | 0:4ad2c16b6e43 | 492 | xsize = LCD_GetDevCap(LCD_DEVCAP_XSIZE) - x0; |
reedas | 0:4ad2c16b6e43 | 493 | |
reedas | 0:4ad2c16b6e43 | 494 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 495 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 496 | |
reedas | 0:4ad2c16b6e43 | 497 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 498 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 499 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 500 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 501 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 502 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 503 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 504 | GUI_DispStringAt("6 OF 10: COLOUR BARS", 160, 5); |
reedas | 0:4ad2c16b6e43 | 505 | |
reedas | 0:4ad2c16b6e43 | 506 | /* Set text mode to normal and left alignment */ |
reedas | 0:4ad2c16b6e43 | 507 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 508 | GUI_SetTextAlign(GUI_TA_LEFT); |
reedas | 0:4ad2c16b6e43 | 509 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 510 | |
reedas | 0:4ad2c16b6e43 | 511 | /* Display labels for the bars */ |
reedas | 0:4ad2c16b6e43 | 512 | GUI_SetFont(&GUI_Font8x16); |
reedas | 0:4ad2c16b6e43 | 513 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 514 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 515 | GUI_DispStringAt("Red", 0, y0 + yStep); |
reedas | 0:4ad2c16b6e43 | 516 | GUI_DispStringAt("Green", 0, y0 + 3 * yStep); |
reedas | 0:4ad2c16b6e43 | 517 | GUI_DispStringAt("Blue", 0, y0 + 5 * yStep); |
reedas | 0:4ad2c16b6e43 | 518 | GUI_DispStringAt("Yellow", 0, y0 + 7 * yStep); |
reedas | 0:4ad2c16b6e43 | 519 | GUI_DispStringAt("Cyan", 0, y0 + 9 * yStep); |
reedas | 0:4ad2c16b6e43 | 520 | GUI_DispStringAt("Magenta", 0, y0 + 11 * yStep); |
reedas | 0:4ad2c16b6e43 | 521 | |
reedas | 0:4ad2c16b6e43 | 522 | /* Draw the colour bars */ |
reedas | 0:4ad2c16b6e43 | 523 | for (i = 0; i < xsize; i++) |
reedas | 0:4ad2c16b6e43 | 524 | { |
reedas | 0:4ad2c16b6e43 | 525 | cs = (0xFF * (U32)i) / xsize; |
reedas | 0:4ad2c16b6e43 | 526 | x = x0 + i;; |
reedas | 0:4ad2c16b6e43 | 527 | |
reedas | 0:4ad2c16b6e43 | 528 | /* Red */ |
reedas | 0:4ad2c16b6e43 | 529 | GUI_SetColor(cs); |
reedas | 0:4ad2c16b6e43 | 530 | GUI_DrawVLine(x, y0 , y0 + yStep - 1); |
reedas | 0:4ad2c16b6e43 | 531 | GUI_SetColor(0xff + (255 - cs) * 0x10100uL); |
reedas | 0:4ad2c16b6e43 | 532 | GUI_DrawVLine(x, y0 + yStep, y0 + 2 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 533 | |
reedas | 0:4ad2c16b6e43 | 534 | /* Green */ |
reedas | 0:4ad2c16b6e43 | 535 | GUI_SetColor(cs<<8); |
reedas | 0:4ad2c16b6e43 | 536 | GUI_DrawVLine(x, y0 + 2 * yStep, y0 + 3 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 537 | GUI_SetColor(0xff00 + (255 - cs) * 0x10001uL); |
reedas | 0:4ad2c16b6e43 | 538 | GUI_DrawVLine(x, y0 + 3 * yStep, y0 + 4 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 539 | |
reedas | 0:4ad2c16b6e43 | 540 | /* Blue */ |
reedas | 0:4ad2c16b6e43 | 541 | GUI_SetColor(cs * 0x10000uL); |
reedas | 0:4ad2c16b6e43 | 542 | GUI_DrawVLine(x, y0 + 4 * yStep, y0 + 5 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 543 | GUI_SetColor(0xff0000 + (255 - cs) * 0x101uL); |
reedas | 0:4ad2c16b6e43 | 544 | GUI_DrawVLine(x, y0 + 5 * yStep, y0 + 6 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 545 | |
reedas | 0:4ad2c16b6e43 | 546 | /* Yellow */ |
reedas | 0:4ad2c16b6e43 | 547 | GUI_SetColor(cs * 0x101uL); |
reedas | 0:4ad2c16b6e43 | 548 | GUI_DrawVLine(x, y0 + 6 * yStep, y0 + 7 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 549 | GUI_SetColor(0xffff + (255 - cs) * 0x10000uL); |
reedas | 0:4ad2c16b6e43 | 550 | GUI_DrawVLine(x, y0 + 7 * yStep, y0 + 8 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 551 | |
reedas | 0:4ad2c16b6e43 | 552 | /* Cyan */ |
reedas | 0:4ad2c16b6e43 | 553 | GUI_SetColor(cs * 0x10100uL); |
reedas | 0:4ad2c16b6e43 | 554 | GUI_DrawVLine(x, y0 + 8 * yStep, y0 + 9 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 555 | GUI_SetColor(0xffff00 + (255 - cs) * 0x1L); |
reedas | 0:4ad2c16b6e43 | 556 | GUI_DrawVLine(x, y0 + 9 * yStep, y0 + 10 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 557 | |
reedas | 0:4ad2c16b6e43 | 558 | /* Magenta */ |
reedas | 0:4ad2c16b6e43 | 559 | GUI_SetColor(cs * 0x10001uL); |
reedas | 0:4ad2c16b6e43 | 560 | GUI_DrawVLine(x, y0 + 10 * yStep, y0 + 11 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 561 | GUI_SetColor(0xff00ff + (255 - cs) * 0x100uL); |
reedas | 0:4ad2c16b6e43 | 562 | GUI_DrawVLine(x, y0 + 11 * yStep, y0 + 12 * yStep - 1); |
reedas | 0:4ad2c16b6e43 | 563 | } |
reedas | 0:4ad2c16b6e43 | 564 | } |
reedas | 0:4ad2c16b6e43 | 565 | |
reedas | 0:4ad2c16b6e43 | 566 | |
reedas | 0:4ad2c16b6e43 | 567 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 568 | * Function Name: void Show2DGraphics1(void) |
reedas | 0:4ad2c16b6e43 | 569 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 570 | * |
reedas | 0:4ad2c16b6e43 | 571 | * Summary: This function displays the following 2D graphics |
reedas | 0:4ad2c16b6e43 | 572 | * 1. Horizontal lines with various pen widths |
reedas | 0:4ad2c16b6e43 | 573 | * 2. Vertical lines with various pen widths |
reedas | 0:4ad2c16b6e43 | 574 | * 3. Arcs |
reedas | 0:4ad2c16b6e43 | 575 | * 4. Filled rounded rectangle |
reedas | 0:4ad2c16b6e43 | 576 | * |
reedas | 0:4ad2c16b6e43 | 577 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 578 | * None |
reedas | 0:4ad2c16b6e43 | 579 | * |
reedas | 0:4ad2c16b6e43 | 580 | * Return: |
reedas | 0:4ad2c16b6e43 | 581 | * None |
reedas | 0:4ad2c16b6e43 | 582 | * |
reedas | 0:4ad2c16b6e43 | 583 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 584 | void Show2DGraphics1(void) |
reedas | 0:4ad2c16b6e43 | 585 | { |
reedas | 0:4ad2c16b6e43 | 586 | /* Set font size, foreground and background colours */ |
reedas | 0:4ad2c16b6e43 | 587 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 588 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 589 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 590 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 591 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 592 | |
reedas | 0:4ad2c16b6e43 | 593 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 594 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 595 | |
reedas | 0:4ad2c16b6e43 | 596 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 597 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 598 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 599 | GUI_DispStringAt("7 OF 10: 2D GRAPHICS - 1", 160, 10); |
reedas | 0:4ad2c16b6e43 | 600 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 601 | |
reedas | 0:4ad2c16b6e43 | 602 | /* Set drawing colour to gray */ |
reedas | 0:4ad2c16b6e43 | 603 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 604 | |
reedas | 0:4ad2c16b6e43 | 605 | /* Display labels */ |
reedas | 0:4ad2c16b6e43 | 606 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 607 | GUI_DispStringAt("H-LINES", 80, 110); |
reedas | 0:4ad2c16b6e43 | 608 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 609 | GUI_DispStringAt("V-LINES", 240, 110); |
reedas | 0:4ad2c16b6e43 | 610 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 611 | GUI_DispStringAt("ARCS", 80, 220); |
reedas | 0:4ad2c16b6e43 | 612 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 613 | GUI_DispStringAt("ROUNDED RECT", 240, 220); |
reedas | 0:4ad2c16b6e43 | 614 | |
reedas | 0:4ad2c16b6e43 | 615 | /* Horizontal lines */ |
reedas | 0:4ad2c16b6e43 | 616 | GUI_SetPenSize(1); |
reedas | 0:4ad2c16b6e43 | 617 | GUI_DrawLine(10, 35, 150, 35); |
reedas | 0:4ad2c16b6e43 | 618 | GUI_SetPenSize(2); |
reedas | 0:4ad2c16b6e43 | 619 | GUI_DrawLine(10, 50, 150, 50); |
reedas | 0:4ad2c16b6e43 | 620 | GUI_SetPenSize(3); |
reedas | 0:4ad2c16b6e43 | 621 | GUI_DrawLine(10, 65, 150, 65); |
reedas | 0:4ad2c16b6e43 | 622 | GUI_SetPenSize(4); |
reedas | 0:4ad2c16b6e43 | 623 | GUI_DrawLine(10, 80, 150, 80); |
reedas | 0:4ad2c16b6e43 | 624 | GUI_SetPenSize(5); |
reedas | 0:4ad2c16b6e43 | 625 | GUI_DrawLine(10, 95, 150, 95); |
reedas | 0:4ad2c16b6e43 | 626 | |
reedas | 0:4ad2c16b6e43 | 627 | /* Vertical lines */ |
reedas | 0:4ad2c16b6e43 | 628 | GUI_SetPenSize(1); |
reedas | 0:4ad2c16b6e43 | 629 | GUI_DrawLine(210, 30, 210, 100); |
reedas | 0:4ad2c16b6e43 | 630 | GUI_SetPenSize(2); |
reedas | 0:4ad2c16b6e43 | 631 | GUI_DrawLine(225, 30, 225, 100); |
reedas | 0:4ad2c16b6e43 | 632 | GUI_SetPenSize(3); |
reedas | 0:4ad2c16b6e43 | 633 | GUI_DrawLine(240, 30, 240, 100); |
reedas | 0:4ad2c16b6e43 | 634 | GUI_SetPenSize(4); |
reedas | 0:4ad2c16b6e43 | 635 | GUI_DrawLine(255, 30, 255, 100); |
reedas | 0:4ad2c16b6e43 | 636 | GUI_SetPenSize(5); |
reedas | 0:4ad2c16b6e43 | 637 | GUI_DrawLine(270, 30, 270, 100); |
reedas | 0:4ad2c16b6e43 | 638 | |
reedas | 0:4ad2c16b6e43 | 639 | /* Arcs */ |
reedas | 0:4ad2c16b6e43 | 640 | GUI_SetPenSize(2); |
reedas | 0:4ad2c16b6e43 | 641 | GUI_DrawArc(80, 210, 10, 10, 0, 180); |
reedas | 0:4ad2c16b6e43 | 642 | GUI_DrawArc(80, 210, 20, 20, 0, 180); |
reedas | 0:4ad2c16b6e43 | 643 | GUI_DrawArc(80, 210, 30, 30, 0, 180); |
reedas | 0:4ad2c16b6e43 | 644 | GUI_DrawArc(80, 210, 40, 40, 0, 180); |
reedas | 0:4ad2c16b6e43 | 645 | GUI_DrawArc(80, 210, 50, 50, 0, 180); |
reedas | 0:4ad2c16b6e43 | 646 | GUI_DrawArc(80, 210, 60, 60, 0, 180); |
reedas | 0:4ad2c16b6e43 | 647 | |
reedas | 0:4ad2c16b6e43 | 648 | /* Rounded rectangle */ |
reedas | 0:4ad2c16b6e43 | 649 | GUI_FillRoundedRect(180, 150, 300, 210, 5); |
reedas | 0:4ad2c16b6e43 | 650 | } |
reedas | 0:4ad2c16b6e43 | 651 | |
reedas | 0:4ad2c16b6e43 | 652 | |
reedas | 0:4ad2c16b6e43 | 653 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 654 | * Function Name: void Show2DGraphics2(void) |
reedas | 0:4ad2c16b6e43 | 655 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 656 | * |
reedas | 0:4ad2c16b6e43 | 657 | * Summary: This function displays the following 2D graphics |
reedas | 0:4ad2c16b6e43 | 658 | * 1. Concentric circles |
reedas | 0:4ad2c16b6e43 | 659 | * 2. Concentric ellipses |
reedas | 0:4ad2c16b6e43 | 660 | * 3. Filled rectangle with horizontal colour gradient |
reedas | 0:4ad2c16b6e43 | 661 | * 4. Filled rectangle with vertical colour gradient |
reedas | 0:4ad2c16b6e43 | 662 | * |
reedas | 0:4ad2c16b6e43 | 663 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 664 | * None |
reedas | 0:4ad2c16b6e43 | 665 | * |
reedas | 0:4ad2c16b6e43 | 666 | * Return: |
reedas | 0:4ad2c16b6e43 | 667 | * None |
reedas | 0:4ad2c16b6e43 | 668 | * |
reedas | 0:4ad2c16b6e43 | 669 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 670 | void Show2DGraphics2(void) |
reedas | 0:4ad2c16b6e43 | 671 | { |
reedas | 0:4ad2c16b6e43 | 672 | /* Set font size, foreground and background colours */ |
reedas | 0:4ad2c16b6e43 | 673 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 674 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 675 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 676 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 677 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 678 | |
reedas | 0:4ad2c16b6e43 | 679 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 680 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 681 | |
reedas | 0:4ad2c16b6e43 | 682 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 683 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 684 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 685 | GUI_DispStringAt("8 OF 10: 2D GRAPHICS - 2", 160, 10); |
reedas | 0:4ad2c16b6e43 | 686 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 687 | |
reedas | 0:4ad2c16b6e43 | 688 | /* Set drawing colour to gray */ |
reedas | 0:4ad2c16b6e43 | 689 | GUI_SetColor(GUI_GRAY); |
reedas | 0:4ad2c16b6e43 | 690 | |
reedas | 0:4ad2c16b6e43 | 691 | /* Display labels */ |
reedas | 0:4ad2c16b6e43 | 692 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 693 | GUI_DispStringAt("CIRCLE", 80, 110); |
reedas | 0:4ad2c16b6e43 | 694 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 695 | GUI_DispStringAt("ELLIPSE", 240, 110); |
reedas | 0:4ad2c16b6e43 | 696 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 697 | GUI_DispStringAt("RECT-HGRAD", 80, 220); |
reedas | 0:4ad2c16b6e43 | 698 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 699 | GUI_DispStringAt("RECT-VGRAD", 240, 220); |
reedas | 0:4ad2c16b6e43 | 700 | |
reedas | 0:4ad2c16b6e43 | 701 | /* Concentric Circles */ |
reedas | 0:4ad2c16b6e43 | 702 | GUI_DrawCircle(80, 65, 35); |
reedas | 0:4ad2c16b6e43 | 703 | GUI_DrawCircle(80, 65, 25); |
reedas | 0:4ad2c16b6e43 | 704 | GUI_DrawCircle(80, 65, 15); |
reedas | 0:4ad2c16b6e43 | 705 | GUI_DrawCircle(80, 65, 5); |
reedas | 0:4ad2c16b6e43 | 706 | |
reedas | 0:4ad2c16b6e43 | 707 | /* Concentric Ellipses */ |
reedas | 0:4ad2c16b6e43 | 708 | GUI_DrawEllipse(240, 65, 60, 35); |
reedas | 0:4ad2c16b6e43 | 709 | GUI_DrawEllipse(240, 65, 50, 25); |
reedas | 0:4ad2c16b6e43 | 710 | GUI_DrawEllipse(240, 65, 40, 15); |
reedas | 0:4ad2c16b6e43 | 711 | GUI_DrawEllipse(240, 65, 30, 5); |
reedas | 0:4ad2c16b6e43 | 712 | |
reedas | 0:4ad2c16b6e43 | 713 | /* Rectangle horizontal gradient */ |
reedas | 0:4ad2c16b6e43 | 714 | GUI_DrawGradientH(20, 150, 140, 210, GUI_BLACK, GUI_GREEN); |
reedas | 0:4ad2c16b6e43 | 715 | |
reedas | 0:4ad2c16b6e43 | 716 | /* Rectangle vertical gradient */ |
reedas | 0:4ad2c16b6e43 | 717 | GUI_DrawGradientV(180, 150, 300, 210, GUI_RED, GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 718 | } |
reedas | 0:4ad2c16b6e43 | 719 | |
reedas | 0:4ad2c16b6e43 | 720 | |
reedas | 0:4ad2c16b6e43 | 721 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 722 | * Function Name: void ShowConcentricCircles(void) |
reedas | 0:4ad2c16b6e43 | 723 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 724 | * |
reedas | 0:4ad2c16b6e43 | 725 | * Summary: This function displays a short animation by drawing concentric circles |
reedas | 0:4ad2c16b6e43 | 726 | * with colour gradients |
reedas | 0:4ad2c16b6e43 | 727 | * |
reedas | 0:4ad2c16b6e43 | 728 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 729 | * None |
reedas | 0:4ad2c16b6e43 | 730 | * |
reedas | 0:4ad2c16b6e43 | 731 | * Return: |
reedas | 0:4ad2c16b6e43 | 732 | * None |
reedas | 0:4ad2c16b6e43 | 733 | * |
reedas | 0:4ad2c16b6e43 | 734 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 735 | void ShowConcentricCircles(void) |
reedas | 0:4ad2c16b6e43 | 736 | { |
reedas | 0:4ad2c16b6e43 | 737 | #define NUMBER_OF_COLOURS (3u) |
reedas | 0:4ad2c16b6e43 | 738 | #define MAX_RADIUS (100u) |
reedas | 0:4ad2c16b6e43 | 739 | |
reedas | 0:4ad2c16b6e43 | 740 | uint16 radius = 0; |
reedas | 0:4ad2c16b6e43 | 741 | uint16 colourIndex = 0; |
reedas | 0:4ad2c16b6e43 | 742 | |
reedas | 0:4ad2c16b6e43 | 743 | const uint32 colourArray[NUMBER_OF_COLOURS] = |
reedas | 0:4ad2c16b6e43 | 744 | { |
reedas | 0:4ad2c16b6e43 | 745 | GUI_RED, |
reedas | 0:4ad2c16b6e43 | 746 | GUI_BLUE, |
reedas | 0:4ad2c16b6e43 | 747 | GUI_GREEN, |
reedas | 0:4ad2c16b6e43 | 748 | }; |
reedas | 0:4ad2c16b6e43 | 749 | |
reedas | 0:4ad2c16b6e43 | 750 | /* Set font size, background colour and text mode */ |
reedas | 0:4ad2c16b6e43 | 751 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 752 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 753 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 754 | |
reedas | 0:4ad2c16b6e43 | 755 | /* Clear the display */ |
reedas | 0:4ad2c16b6e43 | 756 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 757 | |
reedas | 0:4ad2c16b6e43 | 758 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 759 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 760 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 761 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 762 | GUI_DispStringAt("9 OF 10: CONCENTRIC CIRCLES", 160, 10); |
reedas | 0:4ad2c16b6e43 | 763 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 764 | |
reedas | 0:4ad2c16b6e43 | 765 | /* Draw concentric circles with colour gradient */ |
reedas | 0:4ad2c16b6e43 | 766 | /* Cycle through number of colours */ |
reedas | 0:4ad2c16b6e43 | 767 | for(colourIndex = 0; colourIndex < NUMBER_OF_COLOURS; colourIndex++) |
reedas | 0:4ad2c16b6e43 | 768 | { |
reedas | 0:4ad2c16b6e43 | 769 | /* Draw circles with increasing radius */ |
reedas | 0:4ad2c16b6e43 | 770 | for(radius = 0; radius < MAX_RADIUS; radius++) |
reedas | 0:4ad2c16b6e43 | 771 | { |
reedas | 0:4ad2c16b6e43 | 772 | GUI_SetColor(radius*colourArray[colourIndex]); |
reedas | 0:4ad2c16b6e43 | 773 | GUI_DrawCircle(160, 130, radius); |
reedas | 0:4ad2c16b6e43 | 774 | CyDelay(2); |
reedas | 0:4ad2c16b6e43 | 775 | } |
reedas | 0:4ad2c16b6e43 | 776 | } |
reedas | 0:4ad2c16b6e43 | 777 | } |
reedas | 0:4ad2c16b6e43 | 778 | |
reedas | 0:4ad2c16b6e43 | 779 | |
reedas | 0:4ad2c16b6e43 | 780 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 781 | * Function Name: void ShowBitmap(void) |
reedas | 0:4ad2c16b6e43 | 782 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 783 | * |
reedas | 0:4ad2c16b6e43 | 784 | * Summary: This function displays a bitmap image with an overlay text |
reedas | 0:4ad2c16b6e43 | 785 | * |
reedas | 0:4ad2c16b6e43 | 786 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 787 | * None |
reedas | 0:4ad2c16b6e43 | 788 | * |
reedas | 0:4ad2c16b6e43 | 789 | * Return: |
reedas | 0:4ad2c16b6e43 | 790 | * None |
reedas | 0:4ad2c16b6e43 | 791 | * |
reedas | 0:4ad2c16b6e43 | 792 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 793 | void ShowTextWrapAndOrientation(void) |
reedas | 0:4ad2c16b6e43 | 794 | { |
reedas | 0:4ad2c16b6e43 | 795 | GUI_RECT leftRect = {4, 19, 24, 166}; |
reedas | 0:4ad2c16b6e43 | 796 | GUI_RECT rightRect = {238, 19, 258, 166}; |
reedas | 0:4ad2c16b6e43 | 797 | GUI_RECT middleRect = {29, 19, 233, 166}; |
reedas | 0:4ad2c16b6e43 | 798 | GUI_RECT middleRectMargins = {31, 20, 232, 165}; |
reedas | 0:4ad2c16b6e43 | 799 | GUI_RECT bottomRect = {31, 170, 232, 220}; |
reedas | 0:4ad2c16b6e43 | 800 | |
reedas | 0:4ad2c16b6e43 | 801 | const char leftText[] = "ROTATED TEXT CCW"; |
reedas | 0:4ad2c16b6e43 | 802 | const char rightText[] = "ROTATED TEXT CW"; |
reedas | 0:4ad2c16b6e43 | 803 | const char bottomText[] = "INVERTED TEXT 180"; |
reedas | 0:4ad2c16b6e43 | 804 | |
reedas | 0:4ad2c16b6e43 | 805 | const char middleText[] = "This project demonstrates displaying 2D graphics in a TFT display using Segger EmWin Graphics Library. \n\nThis page shows the text wrap and text rotation features. In the left rectangle, the text is rotated counter clockwise and in the right rectangle, the text is rotated clockwise."; |
reedas | 0:4ad2c16b6e43 | 806 | |
reedas | 0:4ad2c16b6e43 | 807 | |
reedas | 0:4ad2c16b6e43 | 808 | /* Set font size, foreground and background colours */ |
reedas | 0:4ad2c16b6e43 | 809 | GUI_SetFont(GUI_FONT_13B_1); |
reedas | 0:4ad2c16b6e43 | 810 | GUI_SetColor(GUI_WHITE); |
reedas | 0:4ad2c16b6e43 | 811 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 812 | GUI_SetTextMode(GUI_TM_NORMAL); |
reedas | 0:4ad2c16b6e43 | 813 | GUI_SetTextStyle(GUI_TS_NORMAL); |
reedas | 0:4ad2c16b6e43 | 814 | |
reedas | 0:4ad2c16b6e43 | 815 | /* Clear the screen */ |
reedas | 0:4ad2c16b6e43 | 816 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 817 | |
reedas | 0:4ad2c16b6e43 | 818 | /* Display page title */ |
reedas | 0:4ad2c16b6e43 | 819 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 820 | GUI_DispStringAt("5 OF 10: TEXT WRAP AND ROTATION", 132, 5); |
reedas | 0:4ad2c16b6e43 | 821 | |
reedas | 0:4ad2c16b6e43 | 822 | /* Draw rectangles to hold text */ |
reedas | 0:4ad2c16b6e43 | 823 | GUI_DrawRectEx(&leftRect); |
reedas | 0:4ad2c16b6e43 | 824 | GUI_DrawRectEx(&rightRect); |
reedas | 0:4ad2c16b6e43 | 825 | GUI_DrawRectEx(&middleRect); |
reedas | 0:4ad2c16b6e43 | 826 | GUI_DrawRectEx(&bottomRect); |
reedas | 0:4ad2c16b6e43 | 827 | |
reedas | 0:4ad2c16b6e43 | 828 | /* Display string in left rectangle rotated counter clockwise */ |
reedas | 0:4ad2c16b6e43 | 829 | GUI_DispStringInRectEx(leftText, &leftRect, GUI_TA_HCENTER | GUI_TA_VCENTER, strlen(leftText), GUI_ROTATE_CCW); |
reedas | 0:4ad2c16b6e43 | 830 | |
reedas | 0:4ad2c16b6e43 | 831 | /* Display string in right rectangle rotated clockwise */ |
reedas | 0:4ad2c16b6e43 | 832 | GUI_DispStringInRectEx(rightText, &rightRect, GUI_TA_HCENTER | GUI_TA_VCENTER, strlen(rightText), GUI_ROTATE_CW); |
reedas | 0:4ad2c16b6e43 | 833 | |
reedas | 0:4ad2c16b6e43 | 834 | /* Display string in right rectangle rotated clockwise */ |
reedas | 0:4ad2c16b6e43 | 835 | GUI_DispStringInRectEx(bottomText, &bottomRect, GUI_TA_HCENTER | GUI_TA_VCENTER, strlen(bottomText), GUI_ROTATE_180); |
reedas | 0:4ad2c16b6e43 | 836 | |
reedas | 0:4ad2c16b6e43 | 837 | /* Display string in middle rectangle with word wrap */ |
reedas | 0:4ad2c16b6e43 | 838 | GUI_DispStringInRectWrap(middleText, &middleRectMargins, GUI_TA_LEFT, GUI_WRAPMODE_WORD); |
reedas | 0:4ad2c16b6e43 | 839 | |
reedas | 0:4ad2c16b6e43 | 840 | } |
reedas | 0:4ad2c16b6e43 | 841 | void ShowBitmap(void) |
reedas | 0:4ad2c16b6e43 | 842 | { |
reedas | 0:4ad2c16b6e43 | 843 | /* Set background colour to black and clear screen */ |
reedas | 0:4ad2c16b6e43 | 844 | GUI_SetBkColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 845 | GUI_Clear(); |
reedas | 0:4ad2c16b6e43 | 846 | |
reedas | 0:4ad2c16b6e43 | 847 | /* Display the bitmap image on the screen */ |
reedas | 0:4ad2c16b6e43 | 848 | GUI_DrawBitmap(&bmExampleImage, 0, 4); |
reedas | 0:4ad2c16b6e43 | 849 | |
reedas | 0:4ad2c16b6e43 | 850 | /* Set font size, font colour to black */ |
reedas | 0:4ad2c16b6e43 | 851 | GUI_SetFont(GUI_FONT_16B_1); |
reedas | 0:4ad2c16b6e43 | 852 | GUI_SetColor(GUI_BLACK); |
reedas | 0:4ad2c16b6e43 | 853 | |
reedas | 0:4ad2c16b6e43 | 854 | /* Set text mode to transparent, underlined and center aligned */ |
reedas | 0:4ad2c16b6e43 | 855 | GUI_SetTextMode(GUI_TM_TRANS); |
reedas | 0:4ad2c16b6e43 | 856 | GUI_SetTextAlign(GUI_TA_HCENTER); |
reedas | 0:4ad2c16b6e43 | 857 | GUI_SetTextStyle(GUI_TS_UNDERLINE); |
reedas | 0:4ad2c16b6e43 | 858 | |
reedas | 0:4ad2c16b6e43 | 859 | /* Print the page title text */ |
reedas | 0:4ad2c16b6e43 | 860 | GUI_DispStringAt("10 OF 10: BITMAP IMAGE", 160, 10); |
reedas | 0:4ad2c16b6e43 | 861 | } |
reedas | 0:4ad2c16b6e43 | 862 | |
reedas | 0:4ad2c16b6e43 | 863 | |
reedas | 0:4ad2c16b6e43 | 864 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 865 | * Function Name: bool IsBtnClicked |
reedas | 0:4ad2c16b6e43 | 866 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 867 | * |
reedas | 0:4ad2c16b6e43 | 868 | * Summary: This non-blocking function implements SW2 button click check. |
reedas | 0:4ad2c16b6e43 | 869 | * |
reedas | 0:4ad2c16b6e43 | 870 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 871 | * None |
reedas | 0:4ad2c16b6e43 | 872 | * |
reedas | 0:4ad2c16b6e43 | 873 | * Return: |
reedas | 0:4ad2c16b6e43 | 874 | * Status of the SW2 button: |
reedas | 0:4ad2c16b6e43 | 875 | * true when button was pressed and then released and |
reedas | 0:4ad2c16b6e43 | 876 | * false in other cases |
reedas | 0:4ad2c16b6e43 | 877 | * |
reedas | 0:4ad2c16b6e43 | 878 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 879 | bool IsBtnClicked(void) |
reedas | 0:4ad2c16b6e43 | 880 | { |
reedas | 0:4ad2c16b6e43 | 881 | int currBtnState; |
reedas | 0:4ad2c16b6e43 | 882 | static int prevBtnState = BTN_RELEASED; |
reedas | 0:4ad2c16b6e43 | 883 | |
reedas | 0:4ad2c16b6e43 | 884 | bool result = false; |
reedas | 0:4ad2c16b6e43 | 885 | |
reedas | 0:4ad2c16b6e43 | 886 | currBtnState = sw2; |
reedas | 0:4ad2c16b6e43 | 887 | |
reedas | 0:4ad2c16b6e43 | 888 | if((prevBtnState == BTN_RELEASED) && (currBtnState == BTN_PRESSED)) |
reedas | 0:4ad2c16b6e43 | 889 | { |
reedas | 0:4ad2c16b6e43 | 890 | result = true; |
reedas | 0:4ad2c16b6e43 | 891 | } |
reedas | 0:4ad2c16b6e43 | 892 | |
reedas | 0:4ad2c16b6e43 | 893 | prevBtnState = currBtnState; |
reedas | 0:4ad2c16b6e43 | 894 | |
reedas | 0:4ad2c16b6e43 | 895 | wait_ms(5); |
reedas | 0:4ad2c16b6e43 | 896 | |
reedas | 0:4ad2c16b6e43 | 897 | return result; |
reedas | 0:4ad2c16b6e43 | 898 | } |
reedas | 0:4ad2c16b6e43 | 899 | |
reedas | 0:4ad2c16b6e43 | 900 | |
reedas | 0:4ad2c16b6e43 | 901 | /******************************************************************************* |
reedas | 0:4ad2c16b6e43 | 902 | * Function Name: int main(void) |
reedas | 0:4ad2c16b6e43 | 903 | ******************************************************************************** |
reedas | 0:4ad2c16b6e43 | 904 | * |
reedas | 0:4ad2c16b6e43 | 905 | * Summary: This is the main for this code example. This function does the following |
reedas | 0:4ad2c16b6e43 | 906 | * 1. Initializes the EmWin display engine |
reedas | 0:4ad2c16b6e43 | 907 | * 2. Displays startup screen for 3 seconds |
reedas | 0:4ad2c16b6e43 | 908 | * 3. In an infinite loop, displays the following screens on |
reedas | 0:4ad2c16b6e43 | 909 | * key press and release |
reedas | 0:4ad2c16b6e43 | 910 | * a. Text alignment, styles and modes |
reedas | 0:4ad2c16b6e43 | 911 | * b. Text colour |
reedas | 0:4ad2c16b6e43 | 912 | * c. Normal fonts |
reedas | 0:4ad2c16b6e43 | 913 | * d. Bold fonts |
reedas | 0:4ad2c16b6e43 | 914 | * e. colour bars |
reedas | 0:4ad2c16b6e43 | 915 | * f. 2D graphics #1 |
reedas | 0:4ad2c16b6e43 | 916 | * g. 2D graphics #2 |
reedas | 0:4ad2c16b6e43 | 917 | * h. Concentric circles |
reedas | 0:4ad2c16b6e43 | 918 | * i. Bitmap image |
reedas | 0:4ad2c16b6e43 | 919 | * |
reedas | 0:4ad2c16b6e43 | 920 | * Parameters: |
reedas | 0:4ad2c16b6e43 | 921 | * None |
reedas | 0:4ad2c16b6e43 | 922 | * |
reedas | 0:4ad2c16b6e43 | 923 | * Return: |
reedas | 0:4ad2c16b6e43 | 924 | * None |
reedas | 0:4ad2c16b6e43 | 925 | * |
reedas | 0:4ad2c16b6e43 | 926 | *******************************************************************************/ |
reedas | 0:4ad2c16b6e43 | 927 | int main(void) |
reedas | 0:4ad2c16b6e43 | 928 | { |
reedas | 0:4ad2c16b6e43 | 929 | uint8_t pageNumber = 0; |
reedas | 0:4ad2c16b6e43 | 930 | |
reedas | 0:4ad2c16b6e43 | 931 | /* Turn off both red and green LEDs */ |
reedas | 0:4ad2c16b6e43 | 932 | ledGreen = LED_OFF; |
reedas | 0:4ad2c16b6e43 | 933 | ledRed = LED_OFF; |
reedas | 0:4ad2c16b6e43 | 934 | ledBlue = LED_ON; |
reedas | 0:4ad2c16b6e43 | 935 | |
reedas | 0:4ad2c16b6e43 | 936 | /* Initialize EmWin driver*/ |
reedas | 0:4ad2c16b6e43 | 937 | GUI_Init(); |
reedas | 0:4ad2c16b6e43 | 938 | |
reedas | 0:4ad2c16b6e43 | 939 | /* Display the startup screen for 2 seconds */ |
reedas | 0:4ad2c16b6e43 | 940 | ShowStartupScreen(); |
reedas | 0:4ad2c16b6e43 | 941 | Cy_SysLib_Delay(2000); |
reedas | 0:4ad2c16b6e43 | 942 | |
reedas | 0:4ad2c16b6e43 | 943 | /* Show Instructions Screen */ |
reedas | 0:4ad2c16b6e43 | 944 | ShowInstructionsScreen(); |
reedas | 0:4ad2c16b6e43 | 945 | |
reedas | 0:4ad2c16b6e43 | 946 | /* Display various demo pages in a loop */ |
reedas | 0:4ad2c16b6e43 | 947 | for(;;) |
reedas | 0:4ad2c16b6e43 | 948 | { |
reedas | 0:4ad2c16b6e43 | 949 | if(IsBtnClicked()) |
reedas | 0:4ad2c16b6e43 | 950 | { |
reedas | 0:4ad2c16b6e43 | 951 | /* Using pageNumber as index, update the display with a demo screen |
reedas | 0:4ad2c16b6e43 | 952 | Following are the functions that are called in sequence |
reedas | 0:4ad2c16b6e43 | 953 | ShowTextModes() |
reedas | 0:4ad2c16b6e43 | 954 | ShowTextColors() |
reedas | 0:4ad2c16b6e43 | 955 | ShowFontSizesNormal() |
reedas | 0:4ad2c16b6e43 | 956 | ShowFontSizesBold() |
reedas | 0:4ad2c16b6e43 | 957 | ShowTextWrapAndOrientation() |
reedas | 0:4ad2c16b6e43 | 958 | ShowColorBar() |
reedas | 0:4ad2c16b6e43 | 959 | Show2DGraphics1() |
reedas | 0:4ad2c16b6e43 | 960 | Show2DGraphics2() |
reedas | 0:4ad2c16b6e43 | 961 | ShowConcentricCircles() |
reedas | 0:4ad2c16b6e43 | 962 | ShowBitmap() |
reedas | 0:4ad2c16b6e43 | 963 | */ |
reedas | 0:4ad2c16b6e43 | 964 | (*demoPageArray[pageNumber])(); |
reedas | 0:4ad2c16b6e43 | 965 | |
reedas | 0:4ad2c16b6e43 | 966 | ledBlue = !ledBlue; |
reedas | 0:4ad2c16b6e43 | 967 | |
reedas | 0:4ad2c16b6e43 | 968 | /* Increment page number */ |
reedas | 0:4ad2c16b6e43 | 969 | pageNumber++; |
reedas | 0:4ad2c16b6e43 | 970 | |
reedas | 0:4ad2c16b6e43 | 971 | /* If page number exceeds maximum pages, reset */ |
reedas | 0:4ad2c16b6e43 | 972 | if(pageNumber >= NUMBER_OF_DEMO_PAGES) |
reedas | 0:4ad2c16b6e43 | 973 | { |
reedas | 0:4ad2c16b6e43 | 974 | pageNumber = 0; |
reedas | 0:4ad2c16b6e43 | 975 | } |
reedas | 0:4ad2c16b6e43 | 976 | } |
reedas | 0:4ad2c16b6e43 | 977 | } |
reedas | 0:4ad2c16b6e43 | 978 | } |
reedas | 0:4ad2c16b6e43 | 979 | |
reedas | 0:4ad2c16b6e43 | 980 | |
reedas | 0:4ad2c16b6e43 | 981 | /* [] END OF FILE */ |