- Keypad v1: Synchronous scanning
-
This file implements a 4x4 keyboard with synchronous scanning. Each column is activated one at a time, and for each activation all rows are read to determine which key was pressed. Scanning is managed synchronously via polling.
-
- Columns are configured as
open-drainoutputs, while rows are configured aspull-upinputs. - A
keypad_readfunction waits for a key to be released and then detects its press. - Scanning is polled with a 1 ms delay for debounce.
Synchronous scanning can be inefficient if the microcontroller is busy with other operations.
- Columns are configured as
-
- Keypad v2: Asynchronous scanning with timer
-
This file implements a 4x4 keyboard with asynchronous scanning using a hardware timer (TIM2). The columns are scanned by the timer that periodically triggers the reading of the rows. The use of interrupts makes the management of the keys more efficient than the synchronous version.
-
- The columns are outputs and the rows are inputs with pull-ups.
- A hardware timer scans the columns asynchronously.
- An interrupt detects the pressed keys without having to block the main flow.
Asynchronous scanning that allows the microcontroller to perform other operations while managing the keyboard.
-
- Keypad v3: Advanced management with queue
-
This file implements a 4x4 keyboard with asynchronous scanning and advanced management via a queue. Key presses are stored in a circular queue, allowing efficient processing of incoming keys.
-
- Column scanning is handled by a hardware timer (TIM4).
- Key presses are put into a circular queue to be read later.
- Key state management (pressed/released) is handled via state transitions.
Uses a queue to store key presses, improving efficiency in handling multiple rapidly pressed keys.
-
- Keypad 4: String Automation and Advanced management with queue
-
This file integrates keypad reading with string construction and processing. It uses a timer (TIM2) to automate saving strings to a queue, ensuring that strings read from the keypad are processed asynchronously.
-
- String construction: The function
build_string()reads characters from the keypad (usingkeypad_read()) and concatenates them into a temporary string. - String queue: The current string is duplicated and put into a queue (FIFO)using str_enqueue().
- Timer automation: The TIM2 timer interrupt (TIM2_IRQHandler) handles saving the string to the queue, reading it with str_dequeue(), and printing the final string.
- Memory management: Strings are dynamically allocated to avoid leaks, and then freed after processing.
- String construction: The function
-
- Visual Studio Code with the PlatformIO.
stm32_unict_liblibrary provided by the university for the STM32 microcontroller.- Keypad 4x4.
This repository is licensed under the MIT license. See the LICENSE file for more details.
Alessandro Ferrante