42 lines
1004 B
C++
42 lines
1004 B
C++
/*
|
||
* Bitmap2Signal.hpp
|
||
*
|
||
* Created on: 13 авг. 2020 г.
|
||
* Author: s.maksimenko
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_
|
||
#define UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_
|
||
|
||
#include <cstddef>
|
||
#include <stdint.h>
|
||
|
||
#include "../systemic/ISignal.hh"
|
||
|
||
namespace schematic {
|
||
|
||
class BitmapU16ToSignal : public systemic::ISignal
|
||
{
|
||
public:
|
||
struct Setting {
|
||
uint16_t iFirstBit;// Индекс первого значащего бита
|
||
uint16_t nBits;// Число значащих битов
|
||
bool bInvCode;// Признак инверсного кода
|
||
};
|
||
private:
|
||
Setting mSett;
|
||
volatile uint16_t& mBitmap;
|
||
public:
|
||
BitmapU16ToSignal( volatile uint16_t& bitmapU16, const Setting& sett) :
|
||
mBitmap(bitmapU16), mSett(sett){}
|
||
operator float() const {
|
||
return ((mBitmap ^ (mSett.bInvCode ? ~0: 0)) >> mSett.iFirstBit) & ((1u << mSett.nBits) - 1);
|
||
}
|
||
};// !BitmapU16ToSignal
|
||
|
||
} // namespace schematic
|
||
|
||
|
||
|
||
#endif /* UMLIBRARY_SCHEMATIC_BITMAPU16TOSIGNAL_HPP_ */
|