2025-03-19 2:37 AM - edited 2025-03-19 3:24 AM
Sorry for the confusing title. Basically what I want to do is, I have an STM32F746G-DISCO, I made a screen with 6 toggle buttons, when the toggle buttons are toggled on, the controller should give a trigger as long as the button is turned on, however, I want these buttons to automatically turn off at 8 PM (GMT+3), my main concern is creating a trigger from these buttons (preferably from the Arduino pins) and also keeping track of the time and closing the toggle buttons.
The idea is that each button will be connected to the power source of a machine which will only give power as long as the button turned is on from the microcontroller screen while also turning them off so they don't get turned on outside of work hours, kind of like a switch to turn on a light bulb
2025-03-19 5:17 AM
Hello @Simecrafter and welcome to the community!
Since you have already added your 6 toggle buttons, now you have to get your trigger.
To do so you can create an interaction at the top right corner of your screen.
That interaction will be triggered when the button is clicked (so you have to do 6 interactions since you have 6 buttons) and it will call a new virtual function :
Inside that new function, you will check that the button has been toggled "on" by using getState(), you can find the API here .
Now that you know that the button has bene set to "on", you have to give your trigger.
I don't know what you want because you say "as long as the button is turned on".
So if you only want to the trigger to happen after the change, you can just call a function or start a RTOS task.
But if you want to get a frequent trigger, you can set a variable to true when the button is on and have either the handleTickEvent check for that value or have another look or task check for that value.
You also mention that you want the button to be set to "off" at a certain time.
To do so, you would need a real time clock to call an interrupt at that time and then you can just call forceState(bool) from ,the API.
I hope this helps you! :smiling_face_with_smiling_eyes:
If this message solves your issue, I invite you to select it as "best answer".
Regards,