![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test
Dependencies: BSP_DISCO_F769NI mbed
main.cpp@0:ca4e25e1c231, 2017-05-28 (annotated)
- Committer:
- joschaihl
- Date:
- Sun May 28 05:09:18 2017 +0000
- Revision:
- 0:ca4e25e1c231
- Child:
- 1:79e5972c0704
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joschaihl | 0:ca4e25e1c231 | 1 | #include "mbed.h" |
joschaihl | 0:ca4e25e1c231 | 2 | #include "stm32f769i_discovery.h" |
joschaihl | 0:ca4e25e1c231 | 3 | #include "stm32f769i_discovery_ts.h" |
joschaihl | 0:ca4e25e1c231 | 4 | #include "stm32f769i_discovery_lcd.h" |
joschaihl | 0:ca4e25e1c231 | 5 | |
joschaihl | 0:ca4e25e1c231 | 6 | TS_StateTypeDef TS_State = {0}; |
joschaihl | 0:ca4e25e1c231 | 7 | |
joschaihl | 0:ca4e25e1c231 | 8 | |
joschaihl | 0:ca4e25e1c231 | 9 | Serial pc(USBTX, USBRX); |
joschaihl | 0:ca4e25e1c231 | 10 | |
joschaihl | 0:ca4e25e1c231 | 11 | DigitalOut led1(LED1); |
joschaihl | 0:ca4e25e1c231 | 12 | |
joschaihl | 0:ca4e25e1c231 | 13 | void print_thread() |
joschaihl | 0:ca4e25e1c231 | 14 | { |
joschaihl | 0:ca4e25e1c231 | 15 | while (true) { |
joschaihl | 0:ca4e25e1c231 | 16 | Thread::wait(1000); |
joschaihl | 0:ca4e25e1c231 | 17 | pc.printf("Hallo Welt!!!\r\n"); |
joschaihl | 0:ca4e25e1c231 | 18 | } |
joschaihl | 0:ca4e25e1c231 | 19 | } |
joschaihl | 0:ca4e25e1c231 | 20 | |
joschaihl | 0:ca4e25e1c231 | 21 | void led_thread() { |
joschaihl | 0:ca4e25e1c231 | 22 | while(true) { |
joschaihl | 0:ca4e25e1c231 | 23 | Thread::wait(200); |
joschaihl | 0:ca4e25e1c231 | 24 | led1 = !led1; |
joschaihl | 0:ca4e25e1c231 | 25 | } |
joschaihl | 0:ca4e25e1c231 | 26 | } |
joschaihl | 0:ca4e25e1c231 | 27 | |
joschaihl | 0:ca4e25e1c231 | 28 | void gui_thread() { |
joschaihl | 0:ca4e25e1c231 | 29 | uint16_t x1, y1; |
joschaihl | 0:ca4e25e1c231 | 30 | BSP_LCD_Init(); |
joschaihl | 0:ca4e25e1c231 | 31 | BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS); |
joschaihl | 0:ca4e25e1c231 | 32 | |
joschaihl | 0:ca4e25e1c231 | 33 | /* Touchscreen initialization */ |
joschaihl | 0:ca4e25e1c231 | 34 | if (BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()) == TS_ERROR) { |
joschaihl | 0:ca4e25e1c231 | 35 | printf("BSP_TS_Init error\n"); |
joschaihl | 0:ca4e25e1c231 | 36 | } |
joschaihl | 0:ca4e25e1c231 | 37 | |
joschaihl | 0:ca4e25e1c231 | 38 | /* Clear the LCD */ |
joschaihl | 0:ca4e25e1c231 | 39 | BSP_LCD_Clear(LCD_COLOR_WHITE); |
joschaihl | 0:ca4e25e1c231 | 40 | |
joschaihl | 0:ca4e25e1c231 | 41 | /* Set Touchscreen Demo1 description */ |
joschaihl | 0:ca4e25e1c231 | 42 | BSP_LCD_SetTextColor(LCD_COLOR_BLUE); |
joschaihl | 0:ca4e25e1c231 | 43 | BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 40); |
joschaihl | 0:ca4e25e1c231 | 44 | BSP_LCD_SetTextColor(LCD_COLOR_WHITE); |
joschaihl | 0:ca4e25e1c231 | 45 | BSP_LCD_SetBackColor(LCD_COLOR_BLUE); |
joschaihl | 0:ca4e25e1c231 | 46 | BSP_LCD_SetFont(&Font24); |
joschaihl | 0:ca4e25e1c231 | 47 | BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Touchscreen basic example", CENTER_MODE); |
joschaihl | 0:ca4e25e1c231 | 48 | |
joschaihl | 0:ca4e25e1c231 | 49 | while (1) { |
joschaihl | 0:ca4e25e1c231 | 50 | BSP_TS_GetState(&TS_State); |
joschaihl | 0:ca4e25e1c231 | 51 | if(TS_State.touchDetected) { |
joschaihl | 0:ca4e25e1c231 | 52 | /* One or dual touch have been detected */ |
joschaihl | 0:ca4e25e1c231 | 53 | |
joschaihl | 0:ca4e25e1c231 | 54 | /* Get X and Y position of the first touch post calibrated */ |
joschaihl | 0:ca4e25e1c231 | 55 | x1 = TS_State.touchX[0]; |
joschaihl | 0:ca4e25e1c231 | 56 | y1 = TS_State.touchY[0]; |
joschaihl | 0:ca4e25e1c231 | 57 | printf("Touch Detected x=%d y=%d\n", x1, y1); |
joschaihl | 0:ca4e25e1c231 | 58 | |
joschaihl | 0:ca4e25e1c231 | 59 | BSP_LCD_SetTextColor(LCD_COLOR_BLUE); |
joschaihl | 0:ca4e25e1c231 | 60 | BSP_LCD_FillCircle(x1, y1, 20); |
joschaihl | 0:ca4e25e1c231 | 61 | |
joschaihl | 0:ca4e25e1c231 | 62 | wait_ms(10); |
joschaihl | 0:ca4e25e1c231 | 63 | } |
joschaihl | 0:ca4e25e1c231 | 64 | } |
joschaihl | 0:ca4e25e1c231 | 65 | } |
joschaihl | 0:ca4e25e1c231 | 66 | |
joschaihl | 0:ca4e25e1c231 | 67 | int main() |
joschaihl | 0:ca4e25e1c231 | 68 | { |
joschaihl | 0:ca4e25e1c231 | 69 | pc.baud(115200*2); |
joschaihl | 0:ca4e25e1c231 | 70 | pc.printf("*** Joscha ***\r\n"); |
joschaihl | 0:ca4e25e1c231 | 71 | Thread printThread(osPriorityNormal), ledThread(osPriorityNormal), guiThread(osPriorityNormal); |
joschaihl | 0:ca4e25e1c231 | 72 | |
joschaihl | 0:ca4e25e1c231 | 73 | |
joschaihl | 0:ca4e25e1c231 | 74 | t1.start(print_thread); |
joschaihl | 0:ca4e25e1c231 | 75 | t2.start(led_thread); |
joschaihl | 0:ca4e25e1c231 | 76 | t3.start(gui_thread); |
joschaihl | 0:ca4e25e1c231 | 77 | |
joschaihl | 0:ca4e25e1c231 | 78 | while(1) { |
joschaihl | 0:ca4e25e1c231 | 79 | } |
joschaihl | 0:ca4e25e1c231 | 80 | |
joschaihl | 0:ca4e25e1c231 | 81 | |
joschaihl | 0:ca4e25e1c231 | 82 | } |