cancel
Showing results for 
Search instead for 
Did you mean: 

toggle button to send a data frame to a car display via the FDCAN bus using STM32 microcontrollers

sana1
Associate III

I'm new to TouchGFX and I'm trying to use a toggle button to send a data frame to a car display via the FDCAN bus using STM32 microcontrollers. I'm not sure if it's possible to achieve this functionality with TouchGFX and STM32, and if it is, I'm unsure where i  configure the filter, transmit header, and add messages in the main.c function!! If anyone has experience working with this setup, I would greatly appreciate any guidance or assistance you can provide.

1 ACCEPTED SOLUTION

Accepted Solutions
GaetanGodart
ST Employee

Hello @sana1 ,

 

To summarize, you have a STM32 running a TouchGFX application connected to a car through a FDCAN bus. You want to send a message/notification to the car when a button is pressed on your TouchGFX application.

To do so you first need to fetch the action in TouchGFX, transfer it to your main.c (STM32 application) and then send it through your FDCAN bus.

I can help you on the first part (sending from TouchGFX application to main.c).
However, I cannot help you on using your FDCAN bus as I do not know how it works and I have no experience with it.

 

To send a notification or data from a TouchGFX application to the main.c you need to use the MVP design. Find an article about it here : MVP design 

 

Basically, what you have to do is to fetch the action (this can be done by using an interaction calling a new virtual function in your screen :

GaetanGodart_0-1713256833492.png
This way, a virtual function is called whenever you click that toggle button.
You then have to implement that function in your screen1view.hpp and screen1view.cpp and you have to propagate the notification to the model (screen1view.ccp => screen1presenter.cpp => model.cpp).
Then, from the model.cpp, you can include your main.h and be able to call any function from your main.
You just have to create a function in your main to send your message by calling your function to send data through your FDCAN bus which should look something like :
sendDataToCar("BSI RAPIDE ID 0xB6 period 50ms 00 00 0F A0 00 00 00 50");

 

Here are some resources that could help you :

 - TouchGFX tutorial 3 to understand how to communicate with the MVP : TouchGFX tutorial 3 

 - TouchGFX technical video guide playlist : playlist youtube TouchGFX 

 - official TouchGFX (old version) guide on how to control hardware through GUI : control led from GUI (this is basically what you want to do)

 - third party TouchGFX guide send data to main.c : send Data from UI to MCU (this is basically what you want to do)

 

You should have all you need there. I hope this helps you.

 

If this message solves your issue, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

6 REPLIES 6
SofLit
ST Employee

Hello,

Not sure to understand what do you mean by « toggle button with TouchGFX »?

You need to clarify that point. What do you want to do?

The CAN code need to be located in your main or elsewhere in .c files not in the GUI. 
As I said in one of my previous answers to one of your previous posts you need to study well the relationship between the GUI and your low level application. Model.cpp is the border between the GUI and your low level application.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
sana1
Associate III

sana1_0-1713012017667.png

Hello, what I mean about the toggle button is that when I press the button for the " speed40 km" , it triggers a virtual function called 'speed40'. In this function, I want to send this  data frame to a display of car So, I'm unsure whether I should configure the filter, transmit header, and add message in the main.c file or in the Screen1View.cpp file.

sana1_1-1713012203276.jpeg

thank u a lot  .

The filters are only used for reception. Tx operation does need filter config.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

i know that but i want to configure filtre for choose how receive the data  that i send 


@sana1 wrote:

i know that but i want to configure filtre for choose how receive the data  that i send 


Sorry. I didn't understand!! what do you mean by "receive the data  that i send ". Are you using loopback mode?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
GaetanGodart
ST Employee

Hello @sana1 ,

 

To summarize, you have a STM32 running a TouchGFX application connected to a car through a FDCAN bus. You want to send a message/notification to the car when a button is pressed on your TouchGFX application.

To do so you first need to fetch the action in TouchGFX, transfer it to your main.c (STM32 application) and then send it through your FDCAN bus.

I can help you on the first part (sending from TouchGFX application to main.c).
However, I cannot help you on using your FDCAN bus as I do not know how it works and I have no experience with it.

 

To send a notification or data from a TouchGFX application to the main.c you need to use the MVP design. Find an article about it here : MVP design 

 

Basically, what you have to do is to fetch the action (this can be done by using an interaction calling a new virtual function in your screen :

GaetanGodart_0-1713256833492.png
This way, a virtual function is called whenever you click that toggle button.
You then have to implement that function in your screen1view.hpp and screen1view.cpp and you have to propagate the notification to the model (screen1view.ccp => screen1presenter.cpp => model.cpp).
Then, from the model.cpp, you can include your main.h and be able to call any function from your main.
You just have to create a function in your main to send your message by calling your function to send data through your FDCAN bus which should look something like :
sendDataToCar("BSI RAPIDE ID 0xB6 period 50ms 00 00 0F A0 00 00 00 50");

 

Here are some resources that could help you :

 - TouchGFX tutorial 3 to understand how to communicate with the MVP : TouchGFX tutorial 3 

 - TouchGFX technical video guide playlist : playlist youtube TouchGFX 

 - official TouchGFX (old version) guide on how to control hardware through GUI : control led from GUI (this is basically what you want to do)

 - third party TouchGFX guide send data to main.c : send Data from UI to MCU (this is basically what you want to do)

 

You should have all you need there. I hope this helps you.

 

If this message solves your issue, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)