Gesture control PPT based on ble

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Gesture control PPT based on ble

Gesture control PPT based on ble

1 Introduction

Two development boards transmit control information through ble. One development board connects to paj7620 and provides gesture information through IIC bus. The other development board uses ble and USB HID. Ble is used to receive data, and USB HID is used to simulate keyboard input and control ppt

nxf56274_0-1618816281761.png

                 Figure  1

2 Preparation

We need two development boards qn908x and gesture control device paj7620. We use IAR as development enviroment.The example we use is temperature_sensor, and

temperature_ colloctor. The SDK version is 2.2.3

 

3 Code

3.1  temperature_sensor code

We want to implement IIC to read gesture information from paj7620 and send data.

The pins used by IIC are PA6 and PA7

Simply encapsulate the IIC reading and writing code in the code to create i2c_ operation.c and i2c_ operation.h. Realize IIC initialization and reading / writing register function in it

nxf56274_1-1618816281828.png

                       Figure  2

nxf56274_2-1618816281867.png

                       Figure  3

 

3.1.1 After having these functions, we begin to write gesture recognition code. First, we add two blank files paj7620.c and paj7620.h into our project.

 

Select bank register area

nxf56274_3-1618816281931.png

                              Figure 4

 

Wake up paj7620 to read device state

nxf56274_4-1618816281970.png

                   Figure 5

 

Initialize device

nxf56274_5-1618816282039.png

                   Figure 6

 

Gesture test function

nxf56274_6-1618816282053.png

                                  Figure 7

 

3.1.2 When you are ready to read the device information,

You should initialize IIC and paj7620 in BleApp_Init function

nxf56274_7-1618816282094.png

                               Figure 8

In principle, we need to create a custom service for the PAJ device, but we replace the temperature data as our gesture control data. If you want to create a custom service, refer to this link custom profile

 

3.1.3 Create a timer that sends gesture data regularly.

In file temerature_sensor.c

Define a timerstatic tmrTimerID_t dataTimerId;

Allocate a timer, dataTimerId = TMR_AllocateTimer();

Define the callback function of this timer

nxf56274_8-1618816282129.png

                                          Figure 9

Start timer

nxf56274_9-1618816282166.png

                                   Figure 10

Close the low power mode. #define cPWR_UsePowerDownMode 0

3.2 temperature_collector code

The most important thing here is to port USB HID into our project. The USB  example

we use is the USB keyboard and mouse.

3.2.1 Add the OSA and USB folder under the example to the project directory, and copy the file to the corresponding folder according to the file structure of the original example.

nxf56274_10-1618816282200.png

                     Figure 11

3.2.2 Add header file directory after completion

nxf56274_11-1618816282245.png

                                          Figure 12

At the same time, in this tab, add two macro definitions

USB_STACK_FREERTOS_HEAP_SIZE=16384

USB_STACK_FREERTOS

 

3.2.3 Next, we need to modify the main function in usb example . Open composite.c file.

nxf56274_12-1618816282295.png

                     Figure 13

It calls the APP_task. So this function also need to be modified.

nxf56274_13-1618816282323.png

                                  Figure 14

3.2.4Find hid_mouse.cComment function USB_DeviceHidMouseAction

Find hid_keyboard.h. Define the gesture information.

macro_gesture.PNG

                                Figure 15

Find hid_keyboard.c. We need to modify the function USB_DeviceHidKeyboardAction as following figure.

nxf56274_15-1618816282485.png

                                                 Figure 16

 

Among them, we also need to implement the following function. When the up hand gesture is detected, the previous ppt will be played. The down hand gesture will be the next PPT, the left hand gesture will exit PPT, and the forward hand gesture will play ppt

nxf56274_16-1618816282625.png

                                                 Figure 17

It also refers to an external variable gesture_from_server. The variable definition

is in file temperature_ collocation.c,.

 

 

3.2.5 After that, let's go to BleApp_Statemachinehandler function

in temperature_colloctor.c.

In case mApppRunning_c, we will call usb_main to initialize USB HID

nxf56274_17-1618816282665.png

                                                 Figure 18

3.2.6 In BleApp_PrintTemperature, we will save the gesture data to gesture_from_server

nxf56274_18-1618816282756.png

                                                        Figure 19

We finished the all steps.

 

 

 

 

Labels (2)
Attachments
No ratings
Version history
Last update:
‎04-25-2021 10:56 PM
Updated by: