2024-04-12 04:36 PM
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.
Solved! Go to Solution.
2024-04-16 01:57 AM - edited 2024-04-16 02:00 AM
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 :
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,
2024-04-12 11:17 PM
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.
2024-04-13 05:53 AM
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.
thank u a lot .
2024-04-13 07:39 AM
The filters are only used for reception. Tx operation does need filter config.
2024-04-13 07:55 AM
i know that but i want to configure filtre for choose how receive the data that i send
2024-04-13 10:07 AM
@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?
2024-04-16 01:57 AM - edited 2024-04-16 02:00 AM
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 :
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,