keuzeproject mdev 1ITF groep: E3
Fork of RemoteIR by
Diff: TransmitterIR.cpp
- Revision:
- 12:0767bcde0d32
- Parent:
- 11:268cc2ab63bd
--- a/TransmitterIR.cpp Mon Sep 20 00:54:59 2010 +0000 +++ b/TransmitterIR.cpp Mon Feb 01 10:20:31 2016 +0000 @@ -68,6 +68,8 @@ work.leader = 0; work.data = 0; work.trailer = 0; + + data.format = format; data.bitlength = bitlength; @@ -89,6 +91,10 @@ ticker.detach(); ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_SONY); break; + case RemoteIR::RC6: + ticker.detach(); + ticker.attach_us(this, &TransmitterIR::tick, RemoteIR::TUS_RC6); + break; } UNLOCK(); @@ -111,6 +117,7 @@ */ static const int LEADER_NEC_HEAD = 16; static const int LEADER_NEC_TAIL = 8; + if (work.leader < LEADER_NEC_HEAD) { tx.write(0.5); } else { @@ -120,6 +127,21 @@ if ((LEADER_NEC_HEAD + LEADER_NEC_TAIL) <= work.leader) { work.state = Data; } + } else if (data.format == RemoteIR::RC6){ + //RC6 + static const int LEADER_RC6_HEAD = 6; + static const int LEADER_RC6_TAIL = 2; + static const int LEADER_RC6_TOGGLE= 888; + if (work.leader < LEADER_RC6_HEAD) { + tx.write(0.5); + + } else { + tx.write(0.0); + } + work.leader++; + if ((LEADER_RC6_HEAD + LEADER_RC6_TAIL) <= work.leader) { + work.state = Toggle; + } } else if (data.format == RemoteIR::AEHA) { /* * AEHA. @@ -153,6 +175,23 @@ } else { } break; + work.state = Leader; + + case Toggle: + if (0 != (data.buffer[work.bitcount / 8] & (1 << work.bitcount % 8))) { + if (1 <= work.data) { + tx.write(0.5); + } else { + work.data++; + } + + + } else { + work.data++; + } + + + break; case Data: if (data.format == RemoteIR::NEC) { /* @@ -182,6 +221,28 @@ if (data.bitlength <= work.bitcount) { work.state = Trailer; } + } else if (data.format == RemoteIR::RC6) { + //RC6 + + if (0 != (data.buffer[work.bitcount / 8] & (1 << work.bitcount % 8))) { + if (1 <= work.data) { + tx.write(0.5); + } else { + work.data++; + } + } else { + if (0 <= work.data) { + tx.write(0.0); + + } else { + work.data++; + } + + } + if (data.bitlength <= work.bitcount) { + work.state = Trailer; + } + } else if (data.format == RemoteIR::AEHA) { /* * AEHA. @@ -205,7 +266,9 @@ } else { work.data++; } + } + } if (data.bitlength <= work.bitcount) { work.state = Trailer; @@ -258,6 +321,20 @@ work.state = Idle; //ticker.detach(); } + } else if (data.format == RemoteIR::RC6) { + //RC6 + static const int TRAILER_RC6_HEAD = 0; + static const int TRAILER_RC6_TAIL = 1; + if (work.trailer < TRAILER_RC6_HEAD) { + tx.write(0.5); + } else { + tx.write(0.0); + } + work.trailer++; + if ((TRAILER_RC6_HEAD + TRAILER_RC6_TAIL) <= work.trailer) { + work.state = Idle; + //ticker.detach(); + } } else if (data.format == RemoteIR::AEHA) { /* * AEHA.