Skip to content

Commit

Permalink
Added functions addTicksToInternalTickCounter() and addMicrosToIntern…
Browse files Browse the repository at this point in the history
…alTickCounter().
  • Loading branch information
Armin committed Mar 6, 2023
1 parent 7a9a1d0 commit e235273
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
- Removed field "bool hasStopBit" and parameter "bool aSendStopBit" from PulseDistanceWidthProtocolConstants structure and related functions.
- Changed a lot of "unsigned int" types to "uint16_t" types.
- Improved overflow handling.
- Improved software PWM generation.
- Added FAST protocol.
- Improved handling of PULSE_DISTANCE + PULSE_WIDTH protocols.
- New example ReceiveAndSendDistanceWidth.
- Removed the automatic restarting of the receiver timer after sending with SEND_PWM_BY_TIMER enabled.
- Split ISR into ISR and function IRPinChangeInterruptHandler().
- Added functions addTicksToInternalTickCounter() and addMicrosToInternalTickCounter().

## 4.0.0
- Added decoding of PulseDistanceWidth protocols and therfore changed function decodeDistance() to decodeDistanceWidth() and filename ir_DistanceProtocol.hpp to ir_DistanceWidthProtocol.hpp.
Expand Down
7 changes: 7 additions & 0 deletions src/IRReceive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ void IRrecv::startWithTicksToAdd(uint16_t aTicksToAddToGapCounter) {
start();
}

void IRrecv::addTicksToInternalTickCounter(uint16_t aTicksToAddToInternalTickCounter) {
irparams.TickCounterForISR += aTicksToAddToInternalTickCounter;
}

void IRrecv::addMicrosToInternalTickCounter(uint16_t aMicrosecondsToAddToInternalTickCounter) {
irparams.TickCounterForISR += aMicrosecondsToAddToInternalTickCounter / MICROS_PER_TICK;
}
/**
* Restarts receiver after send. Is a NOP if sending does not require a timer.
*/
Expand Down
11 changes: 7 additions & 4 deletions src/IRremoteInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
* Declarations for the receiver Interrupt Service Routine
****************************************************/
// ISR State-Machine : Receiver States
#define IR_REC_STATE_IDLE 0
#define IR_REC_STATE_MARK 1
#define IR_REC_STATE_SPACE 2
#define IR_REC_STATE_STOP 3 // set to IR_REC_STATE_IDLE only by resume()
#define IR_REC_STATE_IDLE 0 // Counting the gap time and waiting for the start bit to arrive
#define IR_REC_STATE_MARK 1 // A mark was received and we are counting the duration of it.
#define IR_REC_STATE_SPACE 2 // A space was received and we are counting the duration of it. If space is too long, we assume end of frame.
#define IR_REC_STATE_STOP 3 // Stopped until set to IR_REC_STATE_IDLE which can only be done by resume()

/**
* This struct contains the data and control used for receiver static functions and the ISR (interrupt service routine)
Expand Down Expand Up @@ -190,6 +190,9 @@ class IRrecv {
void startWithTicksToAdd(uint16_t aTicksToAddToGapCounter);
void restartAfterSend();

void addTicksToInternalTickCounter(uint16_t aTicksToAddToInternalTickCounter);
void addMicrosToInternalTickCounter(uint16_t aMicrosecondsToAddToInternalTickCounter);

bool available();
IRData* read(); // returns decoded data
// write is a method of class IRsend below
Expand Down

0 comments on commit e235273

Please sign in to comment.