Skip to content

how to create a buffer? #76

Answered by rlogiacco
TheRealDestroyer asked this question in Q&A
Discussion options

You must be logged in to vote

You don't really need a circular buffer in your case because you apparently are receiving only two ir codes, anyway, assuming you do not want to store more than 100 codes and you are willing to blindly discard the oldest ones in case you receive more than 100:

#include <CircularBuffer.h>
#include <IRremote.h>

CircularBuffer<unsigned long, 100> buffer;

void main() { 
  // omitted
}

void loop() {
  decode_results results;
  if (irrecv.decode(&results)) {
    buffer.push(results.value); // adds the received value to the tail of buffer
    irrecv.resume();
  }

  // here your buffer can have any number of entries and you can decide what to do and when to process them
  // as an example, to…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rlogiacco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants