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@25: #include "BitArray.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@25: const int KGP12xWidthInPixels = 256; sl@25: const int KGP12xHeightInPixels = 64; sl@25: const int KGP12xPixelsPerByte = 8; sl@25: const int KGP12xFrameBufferSizeInBytes = KGP12xWidthInPixels*KGP12xHeightInPixels/KGP12xPixelsPerByte; //256*64/8=2048 sl@25: const int KGP12xFrameBufferPixelCount = KGP12xWidthInPixels*KGP12xHeightInPixels; 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: 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@23: virtual int MinBrightness() const=0; sl@23: virtual int MaxBrightness() const=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@23: virtual int WidthInPixels() const=0; sl@23: virtual int HeightInPixels() const=0; sl@23: virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn)=0; sl@23: virtual void SetAllPixels(unsigned char aOn)=0; sl@23: virtual int FrameBufferSizeInBytes() const=0; sl@25: //virtual int BitBlit(unsigned char* aSrc, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const=0; sl@25: 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@23: virtual int MinBrightness() const {return 0;}; sl@23: virtual int MaxBrightness() const {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@23: GP1212A01A(); sl@25: ~GP1212A01A(); sl@23: // sl@10: int Open(); sl@10: //From FutabaGraphicVfd sl@25: virtual int WidthInPixels() const {return KGP12xWidthInPixels;}; sl@25: virtual int HeightInPixels() const {return KGP12xHeightInPixels;}; sl@23: virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn); sl@23: virtual void SetAllPixels(unsigned char aPattern); sl@25: virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}; sl@26: virtual void BitBlit(BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const; sl@10: //From FutabaVfd sl@10: virtual void SetBrightness(int aBrightness); sl@10: virtual void Clear(); sl@19: sl@19: //Specific to GP1212A01A sl@23: void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char aValue); sl@23: void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char* aPixels); sl@19: // sl@23: void SetDisplayPosition(unsigned char aX, unsigned char aY); sl@23: void SwapBuffers(); sl@21: // sl@19: void RequestId(); sl@19: void RequestFirmwareRevision(); sl@19: void RequestPowerSupplyStatus(); sl@23: // sl@23: void ToggleOffScreenMode(); sl@23: bool OffScreenMode() const {return iOffScreenMode;}; sl@25: // sl@25: sl@23: sl@22: private: sl@22: enum DW sl@22: { sl@22: DW1=0xC0, sl@22: DW2=0xD0 sl@22: }; sl@22: sl@23: void SetDisplayPosition(DW aDw,unsigned char aX, unsigned char aY); sl@23: unsigned char OffScreenY() const; sl@23: void SendClearCommand(); sl@23: void OffScreenTranslation(unsigned char& aX, unsigned char& aY); sl@25: void ResetBuffers(); sl@22: sl@10: private: sl@23: unsigned char iDisplayPositionX; sl@23: unsigned char iDisplayPositionY; sl@23: ///Off screen mode is the recommended default settings to avoid tearing. sl@23: ///Though turning it off can be useful for debugging sl@23: bool iOffScreenMode; sl@10: /// sl@10: //FutabaVfdReport iReport; sl@10: /// sl@25: //unsigned char iFrameBuffer[256*64]; sl@25: BitArray* iFrameBuffer; sl@25: //unsigned char iFrameBeta[256*64]; sl@25: //unsigned char *iFrontBuffer; sl@25: //unsigned char *iBackBuffer; sl@10: }; sl@10: sl@9: sl@9: #endif