new graphics and user input
Dependencies: BSP_DISCO_F769NI
main.cpp@0:cc2802bc7c1b, 2017-04-11 (annotated)
- Committer:
- jeromecoutant
- Date:
- Tue Apr 11 12:31:47 2017 +0000
- Revision:
- 0:cc2802bc7c1b
- Child:
- 2:2becc6f12303
Touchscreen basic example for DISCO_F769NI
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jeromecoutant | 0:cc2802bc7c1b | 1 | #include "mbed.h" |
jeromecoutant | 0:cc2802bc7c1b | 2 | #include "stm32f769i_discovery.h" |
jeromecoutant | 0:cc2802bc7c1b | 3 | #include "stm32f769i_discovery_ts.h" |
jeromecoutant | 0:cc2802bc7c1b | 4 | #include "stm32f769i_discovery_lcd.h" |
jeromecoutant | 0:cc2802bc7c1b | 5 | |
jeromecoutant | 0:cc2802bc7c1b | 6 | TS_StateTypeDef TS_State = {0}; |
jeromecoutant | 0:cc2802bc7c1b | 7 | |
jeromecoutant | 0:cc2802bc7c1b | 8 | int main() |
jeromecoutant | 0:cc2802bc7c1b | 9 | { |
jeromecoutant | 0:cc2802bc7c1b | 10 | uint16_t x1, y1; |
jeromecoutant | 0:cc2802bc7c1b | 11 | |
jeromecoutant | 0:cc2802bc7c1b | 12 | printf("\n\n TOUCHSCREEN EXAMPLE FOR DISCO-F769NI START:\n"); |
jeromecoutant | 0:cc2802bc7c1b | 13 | |
jeromecoutant | 0:cc2802bc7c1b | 14 | BSP_LCD_Init(); |
jeromecoutant | 0:cc2802bc7c1b | 15 | BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); |
jeromecoutant | 0:cc2802bc7c1b | 16 | |
jeromecoutant | 0:cc2802bc7c1b | 17 | /* Touchscreen initialization */ |
jeromecoutant | 0:cc2802bc7c1b | 18 | if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) { |
jeromecoutant | 0:cc2802bc7c1b | 19 | printf("BSP_TS_Init error\n"); |
jeromecoutant | 0:cc2802bc7c1b | 20 | } |
jeromecoutant | 0:cc2802bc7c1b | 21 | |
jeromecoutant | 0:cc2802bc7c1b | 22 | /* Clear the LCD */ |
jeromecoutant | 0:cc2802bc7c1b | 23 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
jeromecoutant | 0:cc2802bc7c1b | 24 | |
jeromecoutant | 0:cc2802bc7c1b | 25 | /* Set Touchscreen Demo1 description */ |
jeromecoutant | 0:cc2802bc7c1b | 26 | BSP_LCD_SetTextColor(LCD_COLOR_BLUE); |
jeromecoutant | 0:cc2802bc7c1b | 27 | BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40); |
jeromecoutant | 0:cc2802bc7c1b | 28 | BSP_LCD_SetTextColor(LCD_COLOR_WHITE); |
jeromecoutant | 0:cc2802bc7c1b | 29 | BSP_LCD_SetBackColor(LCD_COLOR_BLUE); |
jeromecoutant | 0:cc2802bc7c1b | 30 | BSP_LCD_SetFont(&Font24); |
jeromecoutant | 0:cc2802bc7c1b | 31 | BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen basic example", CENTER_MODE); |
jeromecoutant | 0:cc2802bc7c1b | 32 | |
jeromecoutant | 0:cc2802bc7c1b | 33 | while (1) { |
jeromecoutant | 0:cc2802bc7c1b | 34 | BSP_TS_GetState(&TS_State); |
jeromecoutant | 0:cc2802bc7c1b | 35 | if(TS_State.touchDetected) { |
jeromecoutant | 0:cc2802bc7c1b | 36 | /* One or dual touch have been detected */ |
jeromecoutant | 0:cc2802bc7c1b | 37 | |
jeromecoutant | 0:cc2802bc7c1b | 38 | /* Get X and Y position of the first touch post calibrated */ |
jeromecoutant | 0:cc2802bc7c1b | 39 | x1 = TS_State.touchX[0]; |
jeromecoutant | 0:cc2802bc7c1b | 40 | y1 = TS_State.touchY[0]; |
jeromecoutant | 0:cc2802bc7c1b | 41 | printf("Touch Detected x=%d y=%d\n", x1, y1); |
jeromecoutant | 0:cc2802bc7c1b | 42 | |
jeromecoutant | 0:cc2802bc7c1b | 43 | BSP_LCD_SetTextColor(LCD_COLOR_BLUE); |
jeromecoutant | 0:cc2802bc7c1b | 44 | BSP_LCD_FillCircle(x1, y1, 20); |
jeromecoutant | 0:cc2802bc7c1b | 45 | |
jeromecoutant | 0:cc2802bc7c1b | 46 | wait_ms(10); |
jeromecoutant | 0:cc2802bc7c1b | 47 | } |
jeromecoutant | 0:cc2802bc7c1b | 48 | } |
jeromecoutant | 0:cc2802bc7c1b | 49 | } |