inc/FutabaVfd.h
changeset 14 4a5538e0ccbf
parent 13 69f1fcfdf6a5
child 15 e5b84f315be7
     1.1 --- a/inc/FutabaVfd.h	Thu May 22 07:30:05 2014 +0200
     1.2 +++ b/inc/FutabaVfd.h	Thu May 22 07:50:02 2014 +0200
     1.3 @@ -4,6 +4,7 @@
     1.4  #define FUTABA_VFD_H
     1.5  
     1.6  #include "hidapi.h"
     1.7 +#include "HidDevice.h"
     1.8  
     1.9  //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
    1.10  //+1 was added for our header
    1.11 @@ -21,61 +22,6 @@
    1.12  
    1.13  //typedef struct hid_device_info HidDeviceInfo;
    1.14  
    1.15 -/**
    1.16 -TODO: move to another header
    1.17 -*/
    1.18 -template <int S>
    1.19 -class HidReport
    1.20 -	{
    1.21 -public:
    1.22 -	HidReport(){Reset();};
    1.23 -	void Reset();
    1.24 -	inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
    1.25 -	const unsigned char* Buffer() const {return iBuffer;};
    1.26 -	unsigned char* Buffer() {return iBuffer;};
    1.27 -protected:
    1.28 -	unsigned char iBuffer[S];
    1.29 -	};
    1.30 -
    1.31 -template <int S>
    1.32 -void HidReport<S>::Reset()
    1.33 -    {
    1.34 -    memset(iBuffer,0,sizeof(iBuffer));
    1.35 -    }
    1.36 -
    1.37 -/**
    1.38 -TODO: move to another header
    1.39 -*/
    1.40 -class HidDevice
    1.41 -	{
    1.42 -public:
    1.43 -	int Open(const char* aPath);
    1.44 -	int Open(unsigned short aVendorId, unsigned short aProductId, const wchar_t* aSerialNumber);
    1.45 -	void Close();
    1.46 -    bool IsOpen();
    1.47 -	//
    1.48 -	int SetNonBlocking(int aNonBlocking);
    1.49 -	//
    1.50 -	template<int S>
    1.51 -	int Write(const HidReport<S>& aOutputReport);
    1.52 -	//
    1.53 -	const wchar_t* Error();
    1.54 -
    1.55 -
    1.56 -
    1.57 -private:
    1.58 -	///Our USB HID device
    1.59 -	hid_device* iHidDevice;
    1.60 -	};
    1.61 -
    1.62 -
    1.63 -/**
    1.64 -*/
    1.65 -template<int S>
    1.66 -int HidDevice::Write(const HidReport<S>& aOutputReport)
    1.67 -	{
    1.68 -	return hid_write(iHidDevice,aOutputReport.Buffer(),S);
    1.69 -	}
    1.70  
    1.71  
    1.72  /**