Skip to main content
Associate
October 24, 2023
Solved

Sending an I2C command using TouchGFX UI

  • October 24, 2023
  • 1 reply
  • 1204 views

Board: STM32F429I-disco1

How can I send an I2C command when a button is being pressed? 

So I set up a FlexButton to act as a toggle button and set its interaction to call a function (ToggleMute) which I would need to implement.

My idea was just to use the HAL_I2C_Master_Transmit function in the ToggleMute function which is in the file Screen1View.cpp/hpp but the issue that I ran into is that the variable hi2c3 which I need to pass to the HAL_I2C function is privately declared in main.c meaning I cannot access it. So I do not know what to do.

I thought of maybe having to use the Model and ModelListener files by making a function in main.c which is the functionality of the ToggleMute function so that way my ToggleMute function in Screen1View can just call that function in main. Even if that is correct I would not know how to go about it exactly. 

This topic has been closed for replies.
Best answer by Karl Yamashita

add extern I2C_HandleTypeDef hi2c3; to Model.cpp

Pass your FlexButton state to Model and do what you need there

1 reply

Karl Yamashita
Karl YamashitaBest answer
Principal
October 24, 2023

add extern I2C_HandleTypeDef hi2c3; to Model.cpp

Pass your FlexButton state to Model and do what you need there

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source