2023-10-24 07:54 AM
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.
Solved! Go to Solution.
2023-10-24 09:18 AM - edited 2023-10-24 09:22 AM
add extern I2C_HandleTypeDef hi2c3; to Model.cpp
Pass your FlexButton state to Model and do what you need there
2023-10-24 09:18 AM - edited 2023-10-24 09:22 AM
add extern I2C_HandleTypeDef hi2c3; to Model.cpp
Pass your FlexButton state to Model and do what you need there