cancel
Showing results for 
Search instead for 
Did you mean: 

Sending an I2C command using TouchGFX UI

MexiAxel
Associate II

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Karl Yamashita
Lead III

add extern I2C_HandleTypeDef hi2c3; to Model.cpp

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

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

View solution in original post

1 REPLY 1
Karl Yamashita
Lead III

add extern I2C_HandleTypeDef hi2c3; to Model.cpp

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

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.