COSA
An Object-Oriented Platform for Arduino Programming
HammingCodec_7_4.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_HAMMINGCODEC_7_4_HH
22 #define COSA_HAMMINGCODEC_7_4_HH
23 
24 #include <VWI.h>
25 
38 class HammingCodec_7_4 : public VWI::Codec {
39 public:
45  VWI::Codec(7, 0x12d5, 8)
46  {
47  }
48 
54  virtual const uint8_t* preamble()
55  {
56  return (s_preamble);
57  }
58 
65  virtual uint8_t encode4(uint8_t nibble)
66  {
67  return (pgm_read_byte(&s_symbols[nibble & 0xf]));
68  };
69 
76  virtual uint8_t decode4(uint8_t symbol)
77  {
78  symbol &= SYMBOL_MASK;
79  uint8_t code = pgm_read_byte(&s_codes[symbol >> 1]);
80  return ((symbol & 0x01) ? (code & 0x0f) : (code >> 4));
81  }
82 
83 private:
85  static const uint8_t s_symbols[] PROGMEM;
86 
88  static const uint8_t s_codes[] PROGMEM;
89 
91  static const uint8_t s_preamble[] PROGMEM;
92 };
93 
94 #endif
Definition: VWI.hh:64
virtual uint8_t decode4(uint8_t symbol)
virtual const uint8_t * preamble()
virtual uint8_t encode4(uint8_t nibble)
Codec(uint8_t bits_per_symbol, uint16_t start_symbol, uint8_t preamble_max=VWI::Transmitter::PREAMBLE_MAX)
Definition: VWI.cpp:59
const uint8_t SYMBOL_MASK
Definition: VWI.hh:88