Routines for handling buttons done the right way :)
If you ever struggled with handling buttons in your MCU project - struggle no more. Here is a good example of button routines for STM32 microcontrollers coded with HAL in CubeIDE.
No interrupt nor lame 20ms delay "debounce".
- pressing button
- pressing and releasing button
If you're short on space on PCB, you can use internall pull-up for button and ommit external resistors.
- long / short press detection
- multiple pressing detection