cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

alba_4439266
New Contributor

Hello,

I have created a trackpad using the PSoc 4 MCU that will be utilized as a BLE Mouse to control a cursor on a computer screen. I would also like to collect information on the position of the finger on the trackpad. Up until now, I have used the Launch tuner to log this position data, however, I would ideally like this to be done on a computer software. How can change the provided BLE HID Mouse code by Cypress to read information related to the position of the finger on the trackpad rather than the displacement?

 

Thank you,

0 Likes
1 Solution
VenkataD_41
Moderator
Moderator

Hi,

In PSoC 4 BLE the data transmitted over BLE is byte data. So if you want to senf the word data, it will go in byte format.

The maximum size of the characteristic can be set is 512 bytes. Also, the maximum MTU size that can be set is 512 bytes. 

If you want to send data more than 512 bytes, you need to set multiple characteristics or send the data through multiple notifications. 

In case if you are using PSoC 42 BLE family device, please set the TX and RX buffers as 251 bytes (maximum). 

Please note that tempHandle.value.val represents a uint8 pointer which says that type of data transmitted over BLE is byte data.

Thanks and regards

Ganesh

View solution in original post

0 Likes
14 Replies
VenkataD_41
Moderator
Moderator

Hi,

Can you please tell us the code example are you referring to for your present application (if any)? 

You can use the following API in CapSense component datasheet

uint32 CapSense_GetXYCoordinates (uint32 widgetId) which returns the X and Y co-ordinates. 

You can create a custom service and custom characteristic which can stores these X and Y co-ordinates and send these values using notifications.

Kindly let me know if the above information helps or if you need other/more information.

Thanks

Ganesh

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

Additional to previous response, we recommend you to go through the following code example if you are developing a Trackpad remote with BLE.

https://www.cypress.com/documentation/development-kitsboards/cy5672-proctm-ble-remote-control-refere...

Thanks and regards

Ganesh

 

0 Likes
alba_4439266
New Contributor

Hello,

Thank you for the documentation. I am not looking to develop a remote trackpad--just a trackpad. I would like to use the dongle/CySmart to view and log the x/y positional data from the trackpad via Bluetooth. Is this the best documentation to follow/modify in order to do so? or is there a different document that would help me further. 

 

Thank you,

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

In the code example CE224821 obtained from the link below, you can see how to get the X and Y co-ordinates of the finger from the Trackpad using the API CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID);.

https://www.cypress.com/documentation/code-examples/ce224821-psoc-4-capsense-touchpad-gestures

If you want to transmit these data over the air, you can use a custom service and send a notification if your trackpad is in peripheral side. Please find the attached projects for Central_Client and Peripheral_Server where you can find the APIs used in Central and peripheral side to transmit the data across two peers.

Thanks and regards

Ganesh

0 Likes
alba_4439266
New Contributor

Hello,

Do you have any examples on how to save and access API's, specifically, the "CapSense_GetXYCoordinates"? It seems that is what I am looking for. Also, do you have any documentation on creating custom services? I am new to Cypress and could use any guidance provided.

 

Thank you so much for your help. 

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

Do you have any examples on how to save and access API's, specifically, the "CapSense_GetXYCoordinates"?

Please refer the code example CE224821 obtained from the link below:

https://www.cypress.com/documentation/code-examples/ce224821-psoc-4-capsense-touchpad-gestures

Also, do you have any documentation on creating custom services?

Please go through the following application note:

https://www.cypress.com/documentation/application-notes/an91162-creating-bluetooth-low-energy-custom...

Thanks

Ganesh

 

 

0 Likes
alba_4439266
New Contributor

Hello,

Thank you. This worked perfectly well. I created one custom BLE service containing two characteristics (one with the x value and one with the y value). I can see both values being updated using the dongle. Ideally, I would like to log both piece of information on the dongle. Is there a way to do this?

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

Please refer section 2.11 Log Window in the CySmart for Windows application note obtained from the link below which tells you how to save the data to the log.

https://www.cypress.com/file/232316/download

You need to extract the characteristic data from the log file using a custom script.

Thanks

Ganesh

 

0 Likes
alba_4439266
New Contributor

Thank you. That was very helpful. Now, I would like to send the X-coordinate and Y-coordinate as an array. Currently I have this code sending only YCoordinate info:

tempHandle.attrHandle = CYBLE_LEDCAPSENSE_CAPSENSE2_CHAR_HANDLE;
tempHandle.value.val = (uint8 *)&YCoor ;
tempHandle.value.len = 2;

 

How can I update tempHandle.value.val to send two pieces of information? I tried to make this an array and got errors.

Thank you for all your help. The Cypress Community is incredibly impressive in how quickly supportive, helpful responses are given. 

 

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

You can use something like this:

uint8 data[2];

data[0] = YCoor;

data[1] = XCoor;

tempHandle.attrHandle = CYBLE_LEDCAPSENSE_CAPSENSE2_CHAR_HANDLE;
tempHandle.value.val = data;
tempHandle.value.len = 2;

Please try this and let me know if you see any issues.

Thanks

Ganesh

0 Likes
alba_4439266
New Contributor

Hello,

Thank you--that method worked. The trouble I am now having is that by assigning the variable "data" to a uint8, I cannot report values greater than 255. My trackpad is 340 (maximum X position) by 440 (maximum Y position), therefore I am missing a lot of values. How can I fix this issue? I noticed that the setting tempHandle.value.val requires a uint8 variable. 

 

Let me know if you need more clarification on this issue. I so appreciate your help.

0 Likes
alba_4439266
New Contributor

Hello,

I am just following up on my previous question. I appreciate your  help.

0 Likes
VenkataD_41
Moderator
Moderator

Hi,

In PSoC 4 BLE the data transmitted over BLE is byte data. So if you want to senf the word data, it will go in byte format.

The maximum size of the characteristic can be set is 512 bytes. Also, the maximum MTU size that can be set is 512 bytes. 

If you want to send data more than 512 bytes, you need to set multiple characteristics or send the data through multiple notifications. 

In case if you are using PSoC 42 BLE family device, please set the TX and RX buffers as 251 bytes (maximum). 

Please note that tempHandle.value.val represents a uint8 pointer which says that type of data transmitted over BLE is byte data.

Thanks and regards

Ganesh

View solution in original post

0 Likes
VenkataD_41
Moderator
Moderator

Hi, 

Please go through the following 'Throughput' code example for PSoC 4 BLE. In this code example notifications are sent from BLE server to client such that maximum throughput is achieved. Please refer MTU size and and Characteristic size settings especially. You can ignore the TX/RX size setting since the Max TX/RX size setting depends on the BLE spec 4.1 or 4.2 . The Max TX/RX size for BLE 4.1 is 27 where as the Max TX/RX size setting for BLE 4.2 is 251.

https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day024_Thr...

Thanks and regards

Ganesh

0 Likes