atMETEO
An ATmega based weather station
Files | Classes | Typedefs | Enumerations

Sensors::BitDecoder transforms continuous bit streams (for example from RF demodulation) into bytes. More...

Collaboration diagram for Bit Decoder:

Files

file  bitdecoder.h
 Sensors::BitDecoder transforms continuous bit streams (for example from RF demodulation) into bytes.
 

Classes

struct  Sensors::MsbBitNumbering< T >
 Configuration parameter for BitDecoder that leads to new bits being added with MSB bit numbering (most significant bit first). More...
 
struct  Sensors::LsbBitNumbering< T >
 Configuration parameter for BitDecoder that leads to new bits being added with LSB bit numbering (least significant bit first). More...
 
struct  Sensors::NoParity< T >
 Configuration parameter for BitDecoder that disables parity checking. More...
 
struct  Sensors::EvenParity< T >
 Configuration parameter for BitDecoder that enables even parity checking. More...
 
struct  Sensors::OddParity< T >
 Configuration parameter for BitDecoder that enables odd parity checking. More...
 
class  Sensors::BitDecoderBase< T, BitDecoder >
 BitDecoder base implementation. More...
 
class  Sensors::BitDecoder< T, TParity, TBitNumbering >
 Applies bit numbering and a parity method to transform continuous bit streams (for example from RF demodulation) into bytes. More...
 

Typedefs

template<template< typename > class TParity, template< typename > class TBitNumbering>
using Sensors::ByteDecoder = BitDecoder< uint8_t, TParity, TBitNumbering >
 A ByteDecoder is a BitDecoder operating on a single data byte. More...
 

Enumerations

enum  Sensors::BitDecoderStatus : uint8_t { Sensors::BitDecoderStatus::Complete = 0, Sensors::BitDecoderStatus::Incomplete, Sensors::BitDecoderStatus::ParityError }
 BitDecoder status returned from BitDecoder::addBit(). More...
 

Detailed Description

Sensors::BitDecoder transforms continuous bit streams (for example from RF demodulation) into bytes.


Class Documentation

◆ Sensors::MsbBitNumbering

struct Sensors::MsbBitNumbering

template<typename T>
struct Sensors::MsbBitNumbering< T >

Configuration parameter for BitDecoder that leads to new bits being added with MSB bit numbering (most significant bit first).

◆ Sensors::LsbBitNumbering

struct Sensors::LsbBitNumbering

template<typename T>
struct Sensors::LsbBitNumbering< T >

Configuration parameter for BitDecoder that leads to new bits being added with LSB bit numbering (least significant bit first).

◆ Sensors::NoParity

struct Sensors::NoParity

template<typename T>
struct Sensors::NoParity< T >

Configuration parameter for BitDecoder that disables parity checking.

◆ Sensors::EvenParity

struct Sensors::EvenParity

template<typename T>
struct Sensors::EvenParity< T >

Configuration parameter for BitDecoder that enables even parity checking.

◆ Sensors::OddParity

struct Sensors::OddParity

template<typename T>
struct Sensors::OddParity< T >

Configuration parameter for BitDecoder that enables odd parity checking.

◆ Sensors::BitDecoderBase

class Sensors::BitDecoderBase

template<typename T, typename BitDecoder>
class Sensors::BitDecoderBase< T, BitDecoder >

BitDecoder base implementation.

Attention
Implementation detail. This class must not be used directly, it only serves as super class for BitDecoder.

Public Member Functions

BitDecoderStatus addBit (bool value)
 Adds the bit value to the BitDecoder state. More...
 
getData () const
 Returns the converted data. More...
 
void reset ()
 Resets the decoder state. More...
 

Member Function Documentation

◆ addBit()

template<typename T, typename BitDecoder>
BitDecoderStatus Sensors::BitDecoderBase< T, BitDecoder >::addBit ( bool  value)
inline

Adds the bit value to the BitDecoder state.

Parameters
valueBit value to add.
Returns
Decoder state after adding the bit value.

◆ getData()

template<typename T, typename BitDecoder>
T Sensors::BitDecoderBase< T, BitDecoder >::getData ( ) const
inline

Returns the converted data.

Returns
The converted data.

◆ reset()

template<typename T, typename BitDecoder>
void Sensors::BitDecoderBase< T, BitDecoder >::reset ( )
inline

Resets the decoder state.

This method typically needs to be called when addBit() returned the status BitDecoderStatus::ParityError so that a fresh decoder run starts.

◆ Sensors::BitDecoder

class Sensors::BitDecoder

template<typename T, template< typename > class TParity, template< typename > class TBitNumbering>
class Sensors::BitDecoder< T, TParity, TBitNumbering >

Applies bit numbering and a parity method to transform continuous bit streams (for example from RF demodulation) into bytes.

Usage:

using namespace Sensors;
while (...) {
switch (decoder.addBit(bit)) {
break;
handle_complete_byte(decoder.getData());
break;
default:
decoder.reset();
break;
}
}
Template Parameters
TThe data type to convert to (for example uint8_t or uint16_t).
TParityThe parity algorithm to be applied (NoParity, EvenParity, OddParity).
TBitNumberingThe bit numbering to be applied (MsbBitNumbering, LsbBitNumbering).
See also
BitDecoderStatus

Additional Inherited Members

- Public Member Functions inherited from Sensors::BitDecoderBase< T, BitDecoder< T, TParity, TBitNumbering > >
BitDecoderStatus addBit (bool value)
 Adds the bit value to the BitDecoder state. More...
 
getData () const
 Returns the converted data. More...
 
void reset ()
 Resets the decoder state. More...
 

Typedef Documentation

◆ ByteDecoder

template<template< typename > class TParity, template< typename > class TBitNumbering>
using Sensors::ByteDecoder = typedef BitDecoder<uint8_t, TParity, TBitNumbering>

A ByteDecoder is a BitDecoder operating on a single data byte.

Enumeration Type Documentation

◆ BitDecoderStatus

enum Sensors::BitDecoderStatus : uint8_t
strong

BitDecoder status returned from BitDecoder::addBit().

Enumerator
Complete 

The BitDecoder data is complete. The decoded data can be accessed using BitDecoder::getData().

Incomplete 

The BitDecoder data is incomplete. More bits have to be added using BitDecoder::addBit() before the data can be accessed.

ParityError 

The parity bit in the BitDecoder data is incorrect. Typically BitDecoder::reset() needs to be called to start a fresh decoder run.