This repository contains a single-instance module called "button" that provides debounce functionality for a push button. It also includes a program (main.cpp) that utilizes the button module according to the specified requirements.
- Test-Driven Development (TDD) approach
- Dual targeting strategy for high code coverage (100%)
- Enables internal pull-up resistor of the button pin
- Updates debounced state of the button with an update function
- Stable and reliable button state detection (5 consecutive states)
- Detects debounced "RELEASED" and "PRESSED" states
- Detects debounced "RISING" and "FALLING" edges
- Availability of edges within one interval
- Unique event reading for each edge
To get started with the button module, follow these steps:
- Clone this repository to your local machine.
- Connect a push button to pin 34 of ESP32.
- Set up your development environment and ensure you have the necessary dependencies installed.
- Include the button module in your project.
- Initialize the button module and configure it according to your requirements.
- Call the update function of the button module periodically to update the debounced state.
- Utilize the button module's functions to detect button states, edges, and perform necessary actions based on them.
To build and run the tests for the button module, you can use cmake. Here's how: -Make sure you have cmake installed on your system.
- Open a terminal and navigate to the project directory.
- Create a build directory:
mkdir build
cd build
Generate the build files with cmake:
cmake ..
Build and run the test:
make coverage_test_button
The Unity tests will be executed, and you will see the test results in the terminal. and when you open the build folder you will see a index.html file Ensure that all the tests pass successfully.
Contributions are welcome! If you have any ideas, suggestions, or improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License. Feel free to use and modify the code according to the terms of the license.
- 👨💻 All about me is at My Website