Code commenté du projet LED

Dependencies:   BSP_DISCO_F746NG

Committer:
treina
Date:
Thu Jun 16 09:58:06 2022 +0000
Revision:
6:72febbe3ea91
Parent:
5:071136c3eefa
azd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JohnnyK 3:4f5dc253eb7b 1 /**
JohnnyK 3:4f5dc253eb7b 2 * @file indev.c
JohnnyK 3:4f5dc253eb7b 3 *
JohnnyK 3:4f5dc253eb7b 4 */
JohnnyK 3:4f5dc253eb7b 5
JohnnyK 3:4f5dc253eb7b 6 /*********************
JohnnyK 3:4f5dc253eb7b 7 * INCLUDES
JohnnyK 3:4f5dc253eb7b 8 *********************/
JohnnyK 3:4f5dc253eb7b 9 #include "hal_stm_lvgl/tft/tft.h"
JohnnyK 5:071136c3eefa 10 #include "lvgl/lvgl.h"
JohnnyK 3:4f5dc253eb7b 11
JohnnyK 5:071136c3eefa 12 #include "stm32f7xx.h"
JohnnyK 3:4f5dc253eb7b 13 #include "stm32746g_discovery.h"
JohnnyK 3:4f5dc253eb7b 14 #include "stm32746g_discovery_ts.h"
JohnnyK 3:4f5dc253eb7b 15
JohnnyK 3:4f5dc253eb7b 16 /*********************
JohnnyK 3:4f5dc253eb7b 17 * DEFINES
JohnnyK 3:4f5dc253eb7b 18 *********************/
JohnnyK 3:4f5dc253eb7b 19
JohnnyK 3:4f5dc253eb7b 20 /**********************
JohnnyK 3:4f5dc253eb7b 21 * TYPEDEFS
JohnnyK 3:4f5dc253eb7b 22 **********************/
JohnnyK 3:4f5dc253eb7b 23
JohnnyK 3:4f5dc253eb7b 24 /**********************
JohnnyK 3:4f5dc253eb7b 25 * STATIC PROTOTYPES
JohnnyK 3:4f5dc253eb7b 26 **********************/
JohnnyK 5:071136c3eefa 27 static void touchpad_read(lv_indev_drv_t *drv, lv_indev_data_t *data);
JohnnyK 3:4f5dc253eb7b 28
JohnnyK 3:4f5dc253eb7b 29 /**********************
JohnnyK 3:4f5dc253eb7b 30 * STATIC VARIABLES
JohnnyK 3:4f5dc253eb7b 31 **********************/
JohnnyK 3:4f5dc253eb7b 32 static TS_StateTypeDef TS_State;
JohnnyK 3:4f5dc253eb7b 33
JohnnyK 3:4f5dc253eb7b 34 /**********************
JohnnyK 3:4f5dc253eb7b 35 * MACROS
JohnnyK 3:4f5dc253eb7b 36 **********************/
JohnnyK 3:4f5dc253eb7b 37
JohnnyK 3:4f5dc253eb7b 38 /**********************
JohnnyK 3:4f5dc253eb7b 39 * GLOBAL FUNCTIONS
JohnnyK 3:4f5dc253eb7b 40 **********************/
JohnnyK 3:4f5dc253eb7b 41
JohnnyK 3:4f5dc253eb7b 42 /**
JohnnyK 3:4f5dc253eb7b 43 * Initialize your input devices here
JohnnyK 3:4f5dc253eb7b 44 */
JohnnyK 3:4f5dc253eb7b 45 void touchpad_init(void)
JohnnyK 3:4f5dc253eb7b 46 {
JohnnyK 3:4f5dc253eb7b 47 BSP_TS_Init(TFT_HOR_RES, TFT_VER_RES);
JohnnyK 3:4f5dc253eb7b 48
JohnnyK 5:071136c3eefa 49 static lv_indev_drv_t indev_drv; /*Descriptor of an input device driver*/
JohnnyK 3:4f5dc253eb7b 50 lv_indev_drv_init(&indev_drv); /*Basic initialization*/
JohnnyK 3:4f5dc253eb7b 51 indev_drv.type = LV_INDEV_TYPE_POINTER; /*The touchpad is pointer type device*/
JohnnyK 3:4f5dc253eb7b 52 indev_drv.read_cb = touchpad_read;
JohnnyK 3:4f5dc253eb7b 53
JohnnyK 3:4f5dc253eb7b 54 lv_indev_drv_register(&indev_drv);
JohnnyK 3:4f5dc253eb7b 55 }
JohnnyK 3:4f5dc253eb7b 56
JohnnyK 3:4f5dc253eb7b 57 /**********************
JohnnyK 3:4f5dc253eb7b 58 * STATIC FUNCTIONS
JohnnyK 3:4f5dc253eb7b 59 **********************/
JohnnyK 3:4f5dc253eb7b 60
JohnnyK 3:4f5dc253eb7b 61 /**
JohnnyK 3:4f5dc253eb7b 62 * Read an input device
JohnnyK 3:4f5dc253eb7b 63 * @param indev_id id of the input device to read
JohnnyK 3:4f5dc253eb7b 64 * @param x put the x coordinate here
JohnnyK 3:4f5dc253eb7b 65 * @param y put the y coordinate here
JohnnyK 3:4f5dc253eb7b 66 * @return true: the device is pressed, false: released
JohnnyK 3:4f5dc253eb7b 67 */
JohnnyK 5:071136c3eefa 68 static void touchpad_read(lv_indev_drv_t *indev, lv_indev_data_t *data)
JohnnyK 3:4f5dc253eb7b 69 {
JohnnyK 3:4f5dc253eb7b 70 /* Read your touchpad */
JohnnyK 3:4f5dc253eb7b 71 static int16_t last_x = 0;
JohnnyK 3:4f5dc253eb7b 72 static int16_t last_y = 0;
JohnnyK 3:4f5dc253eb7b 73 //BSP_LED_Toggle(LED1);
JohnnyK 3:4f5dc253eb7b 74
JohnnyK 3:4f5dc253eb7b 75 BSP_TS_GetState(&TS_State);
JohnnyK 3:4f5dc253eb7b 76 if(TS_State.touchDetected) {
JohnnyK 3:4f5dc253eb7b 77 data->point.x = TS_State.touchX[0];
JohnnyK 3:4f5dc253eb7b 78 data->point.y = TS_State.touchY[0];
JohnnyK 3:4f5dc253eb7b 79 last_x = data->point.x;
JohnnyK 3:4f5dc253eb7b 80 last_y = data->point.y;
JohnnyK 3:4f5dc253eb7b 81 data->state = LV_INDEV_STATE_PR;
JohnnyK 3:4f5dc253eb7b 82 } else {
JohnnyK 3:4f5dc253eb7b 83 data->point.x = last_x;
JohnnyK 3:4f5dc253eb7b 84 data->point.y = last_y;
JohnnyK 3:4f5dc253eb7b 85 data->state = LV_INDEV_STATE_REL;
JohnnyK 3:4f5dc253eb7b 86 }
JohnnyK 3:4f5dc253eb7b 87 }