Skip to content

Commit

Permalink
Implemented IrSequence* readFlash(const microseconds_t *, size_t).
Browse files Browse the repository at this point in the history
Resolves #9.
  • Loading branch information
bengtmartensson committed Jul 4, 2019
1 parent d7ff245 commit 6db7a18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/oppo_raw/oppo_raw.ino
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,18 @@ const microseconds_t repeat_resolution[] PROGMEM = { 9024U, 2256U, 564U, 65535U

static void sendRaw(const microseconds_t intro_P[], size_t lengthIntro, const microseconds_t repeat_P[],
size_t lengthRepeat, frequency_t frequency, unsigned times) {
/*
microseconds_t intro[lengthIntro];
microseconds_t repeat[lengthRepeat];
memcpy_PF(intro, (uint_farptr_t) intro_P, sizeof(microseconds_t) * lengthIntro);
memcpy_PF(repeat, (uint_farptr_t) repeat_P, sizeof(microseconds_t) * lengthRepeat);
IrSignal irSignal(intro, lengthIntro, repeat, lengthRepeat, NULL, 0U, frequency);
*/
IrSequence* intro = IrSequence::readFlash(intro_P, lengthIntro);
IrSequence* repeat = IrSequence::readFlash(repeat_P, lengthRepeat);
IrSequence* ending = new IrSequence();
IrSignal irSignal(*intro, *repeat, *ending, frequency);
irsend->sendIrSignal(irSignal, times);
}

Expand Down
8 changes: 8 additions & 0 deletions src/IrSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ void IrSequence::dump(Stream& stream, bool usingSigns) const {
}
stream.println();
}

#ifdef ARDUINO
IrSequence* IrSequence::readFlash(const microseconds_t *flashData, size_t length) {
microseconds_t* data = new microseconds_t[length];
memcpy_PF(data, (uint_farptr_t) flashData, sizeof(microseconds_t) * length);
return new IrSequence(data, length, true);
}
#endif
4 changes: 4 additions & 0 deletions src/IrSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ class IrSequence {
void dumpWithSigns(Stream& stream) const {
dump(stream, true);
};

#ifdef ARDUINO
static IrSequence* readFlash(const microseconds_t *flashData, size_t length);
#endif
};

0 comments on commit 6db7a18

Please sign in to comment.