Hi, I tried to hook a callback to the button release, but somehow didn’t work…
BTW I’m using Pro C++ competition template.
If I press and release the L1 button, it will display something on the screen, but it won’t spin the claw motor…
Yes it needs to be called once but if it’s not inside the loop, it will be read once and if it’s not true, it will be skipped over and never read again. Once usercontrol is run, the code “gets stuck” in the while loop. Anything outside of it and before it is literally read once and then completely forgotten. If, however, you left it as such, to get it to be checked you would have to call the function inside of the while which causes its own complexities. Putting it in the while loop just checks for if the button is being pressed, it doesn’t call the function unless the check (the button being released) is true.
Can you show what you have in the while loop? Are you sure you’re not setting the claw motor to something else during the while loop that would cause it to not move?
No u have to give it a function pointer not the function name. Also, he said that the lcd did display something meaning the function was activated. The problem is about the motor not spinning
91364T, you’re confounding the pressed/released and pressing functions. Once you call the pressed/released function, the callback is set and does NOT need be be called again. The only time you would need to call pressed/released multiple times is if you wanted to change what function the callback uses.
Since the text showed up on the brain, we know the callback is working. The callback and the loop run concurrently, which means there is likely something in the usercontrol loop that is causing the motors to stop, which would more than likely be the drive control logic.