inc/FutabaVfd.h
author sl
Thu, 22 May 2014 07:50:02 +0200
changeset 14 4a5538e0ccbf
parent 13 69f1fcfdf6a5
child 15 e5b84f315be7
permissions -rw-r--r--
Moving base HID classes into separate files.
     1 
     2 
     3 #ifndef FUTABA_VFD_H
     4 #define FUTABA_VFD_H
     5 
     6 #include "hidapi.h"
     7 #include "HidDevice.h"
     8 
     9 //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
    10 //+1 was added for our header
    11 const int KFutabaMaxCommandOutputReport = 33;
    12 //TODO: Get ride of that constant once we figure out a way to get it from hidapi
    13 const int KFutabaMaxHidReportSize = 65;
    14 
    15 const int KHidReportIdIndex=0;
    16 const int KFutabaHidReportSizeIndex=1;
    17 //Define Futaba vendor ID to filter our list of device
    18 const unsigned short KFutabaVendorId = 0x1008;
    19 const unsigned short KFutabaProductIdGP1212A01A = 0x100C;
    20 const unsigned short KFutabaProductIdGP1212A02A = 0x1013; //Or is it 0x1015
    21 
    22 
    23 //typedef struct hid_device_info HidDeviceInfo;
    24 
    25 
    26 
    27 /**
    28 */
    29 class FutabaVfdReport: public HidReport<KFutabaMaxHidReportSize>
    30 	{
    31 
    32 private:
    33 
    34 	};
    35 
    36 
    37 
    38 /**
    39 Define a generic Futaba VFD command.
    40 */
    41 class FutabaVfdCommand
    42     {
    43 public:
    44     FutabaVfdCommand();
    45     ~FutabaVfdCommand();
    46     //
    47     //void Create(int aMaxSize);
    48     //void Delete();
    49 
    50     //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
    51 
    52     void Reset();
    53 
    54 private:
    55     //unsigned char* iBuffer;
    56     FutabaVfdReport iReports[KFutabaMaxCommandOutputReport];
    57     int iSize;
    58     int iMaxSize;
    59     };
    60 
    61 /**
    62 */
    63 class FutabaVfd : public HidDevice
    64 	{
    65 public:
    66 	virtual int MinBrightness()=0;
    67 	virtual int MaxBrightness()=0;
    68 	virtual void SetBrightness(int aBrightness)=0;
    69 	virtual void Clear()=0;
    70 	};
    71 
    72 
    73 /**
    74 */
    75 class FutabaGraphicVfd : public FutabaVfd
    76 	{
    77 public:
    78 	virtual int WidthInPixels()=0;
    79 	virtual int HeightInPixels()=0;
    80 	virtual void SetPixel(int aX, int aY, bool aOn)=0;
    81 	virtual void SetAllPixels(bool aOn)=0;
    82 
    83 	};
    84 
    85 /**
    86 Common functionality between GP1212A01A and GP1212A02A
    87 */
    88 class GP1212XXXX : public FutabaGraphicVfd
    89 	{
    90 public:
    91 	//From FutabaVfd
    92 	virtual int MinBrightness(){return 0;};
    93 	virtual int MaxBrightness(){return 5;};
    94 	};
    95 
    96 /**
    97 GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
    98 The module do not include character ROM, the customer will compile the character
    99 by themselves (from main system).
   100 */
   101 class GP1212A01A : public GP1212XXXX
   102 	{
   103 public:
   104 	int Open();
   105 	//From FutabaGraphicVfd
   106 	virtual int WidthInPixels(){return 256;};
   107 	virtual int HeightInPixels(){return 64;};
   108 	virtual void SetPixel(int aX, int aY, bool aOn);
   109 	virtual void SetAllPixels(bool aOn);
   110 	//From FutabaVfd
   111 	virtual void SetBrightness(int aBrightness);
   112 	virtual void Clear();
   113 	//
   114 	void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
   115 
   116 private:
   117 	///
   118 	//FutabaVfdReport iReport;
   119 	///
   120 	unsigned char iPixelBuffer[256][128];
   121 	};
   122 
   123 
   124 #endif