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