COSA
An Object-Oriented Platform for Arduino Programming
VirtualWireCodec.cpp
Go to the documentation of this file.
1 
22 #include "VirtualWireCodec.hh"
23 
24 const uint8_t VirtualWireCodec::s_symbols[] __PROGMEM = {
25  0xd, 0xe, 0x13, 0x15, 0x16, 0x19, 0x1a, 0x1c,
26  0x23, 0x25, 0x26, 0x29, 0x2a, 0x2c, 0x32, 0x34
27 };
28 
29 /*
30  * Calculating the start symbol (6-bits per symbol):
31  * 0x2a, 0x2a => 10.1010, 10.1010 (preamble 6-bit).
32  * 0x38, 0x2c => 10.1100, 11.1000 => 1011,0011.1000 => 0xb38
33  */
34 const uint8_t VirtualWireCodec::s_preamble[] __PROGMEM = {
35  0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x38, 0x2c
36 };
37 
38 uint8_t
40 {
41  symbol &= SYMBOL_MASK;
42  // FIX: Binary search for better speed
43  for (uint8_t i = 0; i < membersof(s_symbols); i++)
44  if (symbol == pgm_read_byte(&s_symbols[i]))
45  return (i);
46  return (0);
47 }
48 
#define membersof(x)
Definition: Types.h:165
virtual uint8_t decode4(uint8_t symbol)
const uint8_t VirtualWireCodec::s_symbols[] __PROGMEM
const uint8_t SYMBOL_MASK
Definition: VWI.hh:88