42 lines
935 B
C++
42 lines
935 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_ */
|