Skip to content

Commit

Permalink
new file: .github/Compile-Examples.yml
Browse files Browse the repository at this point in the history
	new file:   .github/Spell-Check.yml
	renamed:    .github/workflows/arduino.yml -> .github/workflows/Arduino-Lint-Action.yml
	modified:   README.md
	modified:   examples/Button/Button.ino
	modified:   examples/ResetSet/ResetSet.ino
	modified:   examples/Toggle/Toggle.ino
	modified:   library.properties
	modified:   src/ADebouncer.h
  • Loading branch information
MicroBeaut committed Apr 18, 2024
1 parent 03cfd82 commit 0616e34
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 8 deletions.
100 changes: 100 additions & 0 deletions .github/Compile-Examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Compile Examples

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"
pull_request:
paths:
- ".github/workflows/compile-examples.yml"
- "examples/**"
- "src/**"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
build:
name: ${{ matrix.board.fqbn }}
runs-on: ubuntu-latest

env:
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: arduino:avr:nano
platforms: |
- name: arduino:avr
artifact-name-suffix: arduino-avr-nano
- fqbn: arduino:avr:mega
platforms: |
- name: arduino:avr
artifact-name-suffix: arduino-avr-mega
- fqbn: arduino:avr:leonardo
platforms: |
- name: arduino:avr
artifact-name-suffix: arduino-avr-leonardo
- fqbn: arduino:megaavr:nona4809
platforms: |
- name: arduino:megaavr
artifact-name-suffix: arduino-megaavr-nona4809
- fqbn: arduino:sam:arduino_due_x_dbg
platforms: |
- name: arduino:sam
artifact-name-suffix: arduino-sam-arduino_due_x_dbg
- fqbn: arduino:samd:mkrzero
platforms: |
- name: arduino:samd
artifact-name-suffix: arduino-samd-mkrzero
- fqbn: arduino:mbed_portenta:envie_m7:target_core=cm4
platforms: |
- name: arduino:mbed_portenta
artifact-name-suffix: arduino-mbed_portenta-envie_m7-target_core-cm4
- fqbn: arduino:mbed_portenta:envie_m7
platforms: |
- name: arduino:mbed_portenta
artifact-name-suffix: arduino-mbed_portenta-envie_m7
- fqbn: arduino:mbed_nano:nano33ble
platforms: |
- name: arduino:mbed_nano
artifact-name-suffix: arduino-mbed_nano-nano33ble
- fqbn: arduino:mbed_nano:nanorp2040connect
platforms: |
- name: arduino:mbed_nano
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Compile examples
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fqbn: ${{ matrix.board.fqbn }}
platforms: ${{ matrix.board.platforms }}
libraries: |
# Install the library from the local path.
- source-path: ./
# Additional library dependencies can be listed here.
# See: https://github.com/arduino/compile-sketches#libraries
sketch-paths: |
- examples
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save sketches report as workflow artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
path: ${{ env.SKETCHES_REPORTS_PATH }}
name: sketches-report-${{ matrix.board.artifact-name-suffix }}
22 changes: 22 additions & 0 deletions .github/Spell-Check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Spell Check

# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
on:
push:
pull_request:
schedule:
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Spell check
uses: codespell-project/actions-codespell@master
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ArduinoLintAction
name: Arduino Lint Action

# Controls when the workflow will run
on:
Expand All @@ -21,10 +21,10 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Arduino Lint
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
compliance: strict
compliance: strict
76 changes: 74 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Advanced-Debouncer
[![Arduino-Lint-Action](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Arduino-Lint-Action.yml/badge.svg)](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Arduino-Lint-Action.yml)
[![Spell-Check](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Spell-Check.yml/badge.svg)](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Spell-Check.yml)
[![Compile-Examples](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Compile-Examples.yml/badge.svg)](https://github.com/MicroBeaut/ADebouncer/actions/workflows/Compile-Examples.yml)
![Github](https://img.shields.io/github/v/release/MicroBeaut/ADebouncer)
The advanced debounce removes the resulting ripple signal and provides a clean transition at its output with `delayed` and `instant` modes.

## Delayed Mode
The delayed mode responds to the signal to update the output when input is stable for the fully qualified debounce period.
<p align="center">
<img src="./images/adebouncer-delayed.svg" width="100%" />
<img src="./images/adebouncer-delayed.svg" width="%" />
<h3 align="center">Delayed Mode Timing Diagram</h3>
</p>

Expand Down Expand Up @@ -156,11 +160,52 @@ if (debouncer.falling()) toggle = !toggle;
Declare debounce mode as delayed mode. Debounce the input signal from the button and update LED_BUILTIN with the debounced state.

Click [ here](examples/Button/Button.ino) the Button sketch.
```c
#include "ADebouncer.h"

#define buttonPin 2 // Define the button input pin.
#define debouncePeroid 10 // Define the debounce period in milliseconds

ADebouncer debouncer; // Declare debouncer variable.

void setup() {
pinMode(buttonPin, INPUT_PULLUP); // Set the button mode as input pullup.
pinMode(LED_BUILTIN, OUTPUT); // Set the LED_BUILTIN mode as output.
debouncer.mode(DELAYED, debouncePeroid, HIGH); // Set the debounce mode as delayed mode and debounce period as 10 ms, with the initial output in a HIGH state.
}

void loop() {
bool buttonState = debouncer.debounce(digitalRead(buttonPin)); // Save the debounced of the button state.
digitalWrite(LED_BUILTIN, buttonState); // Update LED_BUILTIN with the button state.
}
```

## Toggle
Declare debounce mode as delayed mode. Debounce the input signal from the button. Toggle the state when pressing the button and update LED_BUILTIN with the toggle state.

Click [ here](examples/Toggle/Toggle.ino) the Toggle sketch.
```c
#include "ADebouncer.h"

#define buttonPin 12 // Define the button input pin.
#define debouncePeroid 10 // Define the debounce period in milliseconds

ADebouncer debouncer; // Declare debouncer variable.
bool state; // Declare state variable.

void setup() {
pinMode(buttonPin, INPUT_PULLUP); // Set the button mode as input pullup.
pinMode(LED_BUILTIN, OUTPUT); // Set the LED_BUILTIN mode as output.
debouncer.mode(DELAYED, debouncePeroid, HIGH); // Set the debounce mode as delayed mode and debounce period, with the initial output in a HIGH state.
state = HIGH; // Initial state in a HIGH state.
}

void loop() {
debouncer.debounce(digitalRead(buttonPin)); // Debounce input of the button state.
if (debouncer.falling()) state = !state; // Toggle state of the state variable.
digitalWrite(LED_BUILTIN, state); // Update LED_BUILTIN with the state.
}
```

## ResetSet
This example is designed to have a set button and a reset button to Reset-Set the state.
Expand All @@ -173,4 +218,31 @@ Both set and reset buttons have the same debounce period. in this example, will

The LED_BUILTIN will be updated with the state value.

Click [ here](examples/ResetSet/ResetSet.ino) the ResetSet sketch.
Click [ here](examples/ResetSet/ResetSet.ino) the ResetSet sketch.
```c
#include "ADebouncer.h"

#define setPin 12 // Define the set input pin.
#define resetPin 11 // Define the reset input pin.
#define debouncePeroid 1000 // Define the debounce period in milliseconds

ADebouncer setButton; // Declare set debouncer variable.
ADebouncer resetButton; // Declare reset debouncer variable.
bool state; // Declare state variable for ResetSet.

void setup() {
pinMode(setPin, INPUT_PULLUP); // Set the button mode as input pullup.
pinMode(resetPin, INPUT_PULLUP); // Set the button mode as input pullup.
pinMode(LED_BUILTIN, OUTPUT); // Set the LED_BUILTIN mode as output.
setButton.mode(DELAYED, debouncePeroid, HIGH); // Set the debounce mode as delayed mode and debounce period, with the initial output in a HIGH state.
resetButton.mode(INSTANT, debouncePeroid, HIGH); // Set the debounce mode as instant mode and debounce period, with the initial output in a HIGH state.
state = LOW; // Initial state in a LOW state.
}

void loop() {
setButton.debounce(digitalRead(setPin)); // Debounce input of the set button state.
resetButton.debounce(digitalRead(resetPin)); // Debounce input of the reset button state.
state = (state | !setButton.debounced()) & resetButton.debounced(); // Reset and Set the state
digitalWrite(LED_BUILTIN, state); // Update LED_BUILTIN with the state.
}
```
6 changes: 6 additions & 0 deletions examples/Button/Button.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Declare debounce mode as delayed mode.
Debounce the input signal from the button
and update LED_BUILTIN with the debounced state.
*/

#include "ADebouncer.h"

#define buttonPin 2 // Define the button input pin.
Expand Down
6 changes: 6 additions & 0 deletions examples/ResetSet/ResetSet.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Declare debounce mode as delayed mode.
Debounce the input signal from the button.
Toggle the state when pressing the button and update LED_BUILTIN with the toggle state.
*/

#include "ADebouncer.h"

#define setPin 12 // Define the set input pin.
Expand Down
12 changes: 12 additions & 0 deletions examples/Toggle/Toggle.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
This example is designed to have a set button and a reset button to Reset-Set the state.
- Declare debouncer for the set button. set the debounce as a delayed mode
- Declare debouncer for the reset button. Set the debounce as an instant mode
Both set and reset buttons have the same debounce period. in this example, will be set to debounce period for 1 second,
- To set the state, press the set button for 1 second.
- To reset the state, the state will be instantly reset after pressing the reset button.
The LED_BUILTIN will be updated with the state value.
*/

#include "ADebouncer.h"

#define buttonPin 12 // Define the button input pin.
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ADebouncer
version=1.1.0
version=1.1.1
author=MicroBeaut
maintainer=MicroBeaut
sentence=Advanced Debouncer Library for Arduino.
Expand Down
2 changes: 1 addition & 1 deletion src/ADebouncer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <Arduino.h>

#define ADEBOUNCER_VERSION "1.1.0"
#define ADEBOUNCER_VERSION "1.1.1"
#define ADEBOUNCER_AUTHOR "MicroBeaut"

enum debounce_t : boolean {DELAYED, INSTANT};
Expand Down

0 comments on commit 0616e34

Please sign in to comment.