inc/FutabaVfd.h
author sl
Thu, 22 May 2014 09:31:23 +0200
changeset 18 14662967f913
parent 14 4a5538e0ccbf
child 19 0d9d062609eb
permissions -rw-r--r--
Implementing Futaba GP1212A01A brightness support.
Test application now using Futaba class to send some of our commands.
     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 Common functionality between GP1212A01A and GP1212A02A
    86 */
    87 class GP1212XXXX : public FutabaGraphicVfd
    88 	{
    89 public:
    90 	//From FutabaVfd
    91 	virtual int MinBrightness(){return 0;};
    92 	virtual int MaxBrightness(){return 5;};
    93 	};
    94 
    95 /**
    96 GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
    97 The module do not include character ROM, the customer will compile the character
    98 by themselves (from main system).
    99 */
   100 class GP1212A01A : public GP1212XXXX
   101 	{
   102 public:
   103 	int Open();
   104 	//From FutabaGraphicVfd
   105 	virtual int WidthInPixels(){return 256;};
   106 	virtual int HeightInPixels(){return 64;};
   107 	virtual void SetPixel(int aX, int aY, bool aOn);
   108 	virtual void SetAllPixels(bool aOn);
   109 	//From FutabaVfd
   110 	virtual void SetBrightness(int aBrightness);
   111 	virtual void Clear();
   112 	//
   113 	void SetPixelBlock(int aX, int aY, int aHeight, int aSize, unsigned char aValue);
   114 
   115 private:
   116 	///
   117 	//FutabaVfdReport iReport;
   118 	///
   119 	unsigned char iPixelBuffer[256][128];
   120 	};
   121 
   122 
   123 #endif