Skip to content

Commit

Permalink
Merge pull request #12 from cyrusbuilt/use_pin_specific_interrupt
Browse files Browse the repository at this point in the history
Use pin interrupts instead of specified ints
  • Loading branch information
cyrusbuilt authored Mar 31, 2023
2 parents f31c1bc + 9d62490 commit fe5bdc4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
Expand Down
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "HidProxWiegand"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.0.2
PROJECT_NUMBER = 1.0.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# HidProxWeigand :: HID Proximity RFID reader library for Arduino
![Build Status](https://github.com/cyrusbuilt/HidProxWeigand/actions/workflows/ci.yml/badge.svg)
[![Build Status](https://github.com/cyrusbuilt/HidProxWeigand/actions/workflows/ci.yml/badge.svg)](https://github.com/cyrusbuilt/HidProxWeigand/actions?query=workflow%3APlatformIO)

## LICENSE

Expand Down Expand Up @@ -56,9 +56,6 @@ the basic example in the **examples** folder:
#include <Arduino.h>
#include "HidProxWiegand.h"

#define RDR_INT0 0 // Reader interrupt for DATA 0.
#define RDR_INT1 1 // Reader interrupt for DATA 1.

#define PIN_DATA0 2 // The pin to use for DATA 0.
#define PIN_DATA1 3 // The pin to use for DATA 1.

Expand Down Expand Up @@ -103,7 +100,7 @@ void setup() {
reader1 = HidProxWeigand.addReader(PIN_DATA0, PIN_DATA1, cardReadHandler);

// Attach interrupt handlers for reader 1.
HidProxWiegand_AttachReaderInterrupts(RDR_INT0, RDR_INT1, handleInterrupt0, handleInterrupt1);
HidProxWiegand_AttachReaderInterrupts(PIN_DATA0, PIN_DATA1, handleInterrupt0, handleInterrupt1);
}

void loop() {
Expand Down
9 changes: 2 additions & 7 deletions examples/AdvancedExample/AdvancedExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
#include <Arduino.h>
#include "HidProxWiegand.h"

#define RDR_INT0 0 // Reader 1 interrupt for DATA 0.
#define RDR_INT1 1 // Reader 1 interrupt for DATA 1.
#define RDR_INT2 2 // Reader 2 interrupt for DATA 0.
#define RDR_INT3 3 // Reader 2 interrupt for DATA 1.

#define PIN_RDR1_DATA0 2 // The pin to use for reader 1, DATA 0.
#define PIN_RDR1_DATA1 3 // The pin to use for reader 1, DATA 1.
#define PIN_RDR2_DATA0 4 // The pin to use for reader 2, DATA 0.
Expand Down Expand Up @@ -104,8 +99,8 @@
reader2 = HidProxWiegand.addReader(PIN_RDR2_DATA0, PIN_RDR2_DATA1, cardRead2Handler);

// Attach interrupt handlers for readers 1 and 2.
HidProxWiegand_AttachReaderInterrupts(RDR_INT0, RDR_INT1, handleInterrupt0, handleInterrupt1);
HidProxWiegand_AttachReaderInterrupts(RDR_INT2, RDR_INT3, handleInterrupt2, handleInterrupt3);
HidProxWiegand_AttachReaderInterrupts(PIN_RDR1_DATA0, PIN_RDR1_DATA1, handleInterrupt0, handleInterrupt1);
HidProxWiegand_AttachReaderInterrupts(PIN_RDR2_DATA0, PIN_RDR2_DATA1, handleInterrupt2, handleInterrupt3);

// Init reader 1 outputs.
pinMode(PIN_RDR1_BUZZER, OUTPUT);
Expand Down
5 changes: 1 addition & 4 deletions examples/BasicExample/BasicExample.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <Arduino.h>
#include "HidProxWiegand.h"

#define RDR_INT0 0 // Reader interrupt for DATA 0.
#define RDR_INT1 1 // Reader interrupt for DATA 1.

#define PIN_DATA0 2 // The pin to use for DATA 0.
#define PIN_DATA1 3 // The pin to use for DATA 1.

Expand Down Expand Up @@ -52,7 +49,7 @@ void setup() {
reader1 = HidProxWiegand.addReader(PIN_DATA0, PIN_DATA1, cardReadHandler);

// Attach interrupt handlers for reader 1.
HidProxWiegand_AttachReaderInterrupts(RDR_INT0, RDR_INT1, handleInterrupt0, handleInterrupt1);
HidProxWiegand_AttachReaderInterrupts(PIN_DATA0, PIN_DATA1, handleInterrupt0, handleInterrupt1);
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"type": "git",
"url": "https://github.com/cyrusbuilt/HidProxWeigand.git"
},
"version": "1.0.2",
"version": "1.0.3",
"license": "GPL-3.0",
"frameworks": "arduino",
"platforms": "*"
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=HidProxWeigand
version=1.0.2
version=1.0.3
author=Cyrus Brunner
maintainer=Cyrus Brunner <[email protected]>
sentence=An interrupt-driven HID proximity RFID reader library that supports 35bit Corporate 1000 format and 26bit Wiegand format.
Expand Down
8 changes: 4 additions & 4 deletions src/HidProxWiegand.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* HidProxWiegand.cpp
* Version 1.0.2
* Version 1.0.3
* Author
* Cyrus Brunner
* Joseph Selby
Expand All @@ -11,9 +11,9 @@

#include "HidProxWiegand.h"

void HidProxWiegand_AttachReaderInterrupts(uint8_t int0, uint8_t int1, void (*int0Handler)(), void (*int1Handler)()) {
attachInterrupt(int0, int0Handler, FALLING);
attachInterrupt(int1, int1Handler, FALLING);
void HidProxWiegand_AttachReaderInterrupts(uint8_t pinData0, uint8_t pinData1, void (*int0Handler)(), void (*int1Handler)()) {
attachInterrupt(digitalPinToInterrupt(pinData0), int0Handler, FALLING);
attachInterrupt(digitalPinToInterrupt(pinData1), int1Handler, FALLING);
}

HidProxWiegandClass::HidProxWiegandClass() {
Expand Down
8 changes: 4 additions & 4 deletions src/HidProxWiegand.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* HidProxWiegand.h
* Version 1.0.2
* Version 1.0.3
* Author
* Cyrus Brunner
* Joseph Selby
Expand Down Expand Up @@ -38,12 +38,12 @@
/**
* @brief Helper method for attaching interrupt handlers for the two data lines the
* reader uses to transmit data pulses.
* @param int0 Interrupt for DATA 0.
* @param int1 Interrupt for DATA 1.
* @param pinData0 Pin for DATA 0.
* @param pinData1 Pin for DATA 1.
* @param int0Handler Callback method for handling interrupt for DATA 0.
* @param int1Handler Callback method for handling interrupt for DATA 1.
*/
void HidProxWiegand_AttachReaderInterrupts(uint8_t int0, uint8_t int1, void (*int0Handler)(), void (*int1Handler)());
void HidProxWiegand_AttachReaderInterrupts(uint8_t pinData0, uint8_t pinData1, void (*int0Handler)(), void (*int1Handler)());

/**
* @brief Proximity RFID info structure. This carries the necessary info needed for
Expand Down

0 comments on commit fe5bdc4

Please sign in to comment.