sl@20: // sl@20: // sl@20: // sl@9: sl@9: #ifndef FUTABA_VFD_H sl@9: #define FUTABA_VFD_H sl@9: sl@9: #include "hidapi.h" sl@14: #include "HidDevice.h" sl@9: sl@20: #ifndef MIN sl@20: #define MIN(a,b) (((a)<(b))?(a):(b)) sl@20: #endif sl@20: sl@20: #ifndef MAX sl@20: #define MAX(a,b) (((a)>(b))?(a):(b)) sl@20: #endif sl@20: sl@20: sl@9: //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33 sl@9: //+1 was added for our header sl@9: const int KFutabaMaxCommandOutputReport = 33; sl@9: //TODO: Get ride of that constant once we figure out a way to get it from hidapi sl@10: const int KFutabaMaxHidReportSize = 65; sl@10: sl@10: const int KHidReportIdIndex=0; sl@10: const int KFutabaHidReportSizeIndex=1; sl@10: //Define Futaba vendor ID to filter our list of device sl@10: const unsigned short KFutabaVendorId = 0x1008; sl@10: const unsigned short KFutabaProductIdGP1212A01A = 0x100C; sl@10: const unsigned short KFutabaProductIdGP1212A02A = 0x1013; //Or is it 0x1015 sl@10: sl@10: sl@10: //typedef struct hid_device_info HidDeviceInfo; sl@10: sl@10: /** sl@20: Define a Futaba HID report. sl@10: */ sl@10: class FutabaVfdReport: public HidReport sl@10: { sl@13: sl@10: private: sl@13: sl@10: }; sl@10: sl@9: sl@9: sl@9: /** sl@9: Define a generic Futaba VFD command. sl@9: */ sl@9: class FutabaVfdCommand sl@9: { sl@9: public: sl@9: FutabaVfdCommand(); sl@9: ~FutabaVfdCommand(); sl@9: // sl@9: //void Create(int aMaxSize); sl@9: //void Delete(); sl@9: sl@9: //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];} sl@9: sl@9: void Reset(); sl@9: sl@9: private: sl@9: //unsigned char* iBuffer; sl@10: FutabaVfdReport iReports[KFutabaMaxCommandOutputReport]; sl@9: int iSize; sl@9: int iMaxSize; sl@9: }; sl@9: sl@10: /** sl@10: */ sl@11: class FutabaVfd : public HidDevice sl@10: { sl@10: public: sl@10: virtual int MinBrightness()=0; sl@10: virtual int MaxBrightness()=0; sl@10: virtual void SetBrightness(int aBrightness)=0; sl@10: virtual void Clear()=0; sl@10: }; sl@10: sl@10: sl@10: /** sl@10: */ sl@10: class FutabaGraphicVfd : public FutabaVfd sl@10: { sl@10: public: sl@10: virtual int WidthInPixels()=0; sl@10: virtual int HeightInPixels()=0; sl@10: virtual void SetPixel(int aX, int aY, bool aOn)=0; sl@10: virtual void SetAllPixels(bool aOn)=0; sl@10: }; sl@10: sl@10: /** sl@10: Common functionality between GP1212A01A and GP1212A02A sl@10: */ sl@10: class GP1212XXXX : public FutabaGraphicVfd sl@10: { sl@10: public: sl@10: //From FutabaVfd sl@10: virtual int MinBrightness(){return 0;}; sl@10: virtual int MaxBrightness(){return 5;}; sl@10: }; sl@10: sl@10: /** sl@10: GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD. sl@10: The module do not include character ROM, the customer will compile the character sl@10: by themselves (from main system). sl@10: */ sl@10: class GP1212A01A : public GP1212XXXX sl@10: { sl@10: public: sl@21: enum DW sl@21: { sl@21: DW1=12, sl@21: DW2=13 sl@21: }; sl@21: sl@10: int Open(); sl@10: //From FutabaGraphicVfd sl@10: virtual int WidthInPixels(){return 256;}; sl@10: virtual int HeightInPixels(){return 64;}; sl@10: virtual void SetPixel(int aX, int aY, bool aOn); sl@10: virtual void SetAllPixels(bool aOn); sl@10: //From FutabaVfd sl@10: virtual void SetBrightness(int aBrightness); sl@10: virtual void Clear(); sl@19: sl@19: //Specific to GP1212A01A sl@10: void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue); sl@20: void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char* aPixels); sl@19: // sl@21: void SetDisplayPosition(DW aDw,int aX, int aY); sl@21: // sl@19: void RequestId(); sl@19: void RequestFirmwareRevision(); sl@19: void RequestPowerSupplyStatus(); sl@10: private: sl@10: /// sl@10: //FutabaVfdReport iReport; sl@10: /// sl@10: unsigned char iPixelBuffer[256][128]; sl@10: }; sl@10: sl@9: sl@9: #endif