Implementing and C API to control our MiniDisplay.
13 #define MIN(a,b) (((a)<(b))?(a):(b))
17 #define MAX(a,b) (((a)>(b))?(a):(b))
21 //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
22 //+1 was added for our header
23 const int KFutabaMaxCommandOutputReport = 33;
24 //TODO: Get ride of that constant once we figure out a way to get it from hidapi
25 const int KFutabaMaxHidReportSize = 65;
27 const int KHidReportIdIndex=0;
28 const int KFutabaHidReportSizeIndex=1;
29 //Define Futaba vendor ID to filter our list of device
30 const unsigned short KFutabaVendorId = 0x1008;
31 const unsigned short KFutabaProductIdGP1212A01A = 0x100C;
32 const unsigned short KFutabaProductIdGP1212A02A = 0x1013; //Or is it 0x1015
33 const int KGP12xWidthInPixels = 256;
34 const int KGP12xHeightInPixels = 64;
35 const int KGP12xPixelsPerByte = 8;
36 const int KGP12xFrameBufferSizeInBytes = KGP12xWidthInPixels*KGP12xHeightInPixels/KGP12xPixelsPerByte; //256*64/8=2048
37 const int KGP12xFrameBufferPixelCount = KGP12xWidthInPixels*KGP12xHeightInPixels;
39 //typedef struct hid_device_info HidDeviceInfo;
42 Define a Futaba HID report.
44 class FutabaVfdReport: public HidReport<KFutabaMaxHidReportSize>
53 Define a generic Futaba VFD command.
55 class FutabaVfdCommand
61 //void Create(int aMaxSize);
64 //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
69 //unsigned char* iBuffer;
70 FutabaVfdReport iReports[KFutabaMaxCommandOutputReport];
77 class FutabaVfd : public HidDevice
80 virtual int MinBrightness() const=0;
81 virtual int MaxBrightness() const=0;
82 virtual void SetBrightness(int aBrightness)=0;
83 virtual void Clear()=0;
89 class FutabaGraphicVfd : public FutabaVfd
92 virtual int WidthInPixels() const=0;
93 virtual int HeightInPixels() const=0;
94 virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn)=0;
95 virtual void SetAllPixels(unsigned char aOn)=0;
96 virtual int FrameBufferSizeInBytes() const=0;
97 //virtual int BitBlit(unsigned char* aSrc, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const=0;
102 Common functionality between GP1212A01A and GP1212A02A
104 class GP1212XXXX : public FutabaGraphicVfd
108 virtual int MinBrightness() const {return 0;}
109 virtual int MaxBrightness() const {return 5;}
113 GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
114 The module do not include character ROM, the customer will compile the character
115 by themselves (from main system).
117 class GP1212A01A : public GP1212XXXX
124 ERequestFirmwareRevision,
125 ERequestPowerSupplyStatus
134 //From FutabaGraphicVfd
135 virtual int WidthInPixels() const {return KGP12xWidthInPixels;}
136 virtual int HeightInPixels() const {return KGP12xHeightInPixels;}
137 virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn);
138 virtual void SetAllPixels(unsigned char aPattern);
139 virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
140 virtual void BitBlit(const BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const;
142 virtual void SetBrightness(int aBrightness);
143 virtual void Clear();
145 //Specific to GP1212A01A
146 void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char aValue);
147 void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char* aPixels);
148 //Define display position within our display RAM
149 void SetDisplayPosition(unsigned char aX, unsigned char aY);
150 unsigned char DisplayPositionX() const {return iDisplayPositionX;}
151 unsigned char DisplayPositionY() const {return iDisplayPositionY;}
155 void RequestDeviceId();
156 void RequestFirmwareRevision();
157 void RequestPowerSupplyStatus();
159 void ToggleOffScreenMode();
160 void SetOffScreenMode(bool aOn);
161 bool OffScreenMode() const {return iOffScreenMode;}
163 void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
164 bool FrameDifferencing() const {return iUseFrameDifferencing;}
166 bool RequestPending(){return iRequest!=ERequestNone;}
167 Request CurrentRequest(){return iRequest;}
168 void CancelRequest(){iRequest=ERequestNone;}
169 Request AttemptRequestCompletion();
170 FutabaVfdReport& InputReport() {return iInputReport;}
171 bool PowerOn(){return iPowerOn;}
180 void SetDisplayPosition(DW aDw,unsigned char aX, unsigned char aY);
181 unsigned char OffScreenY() const;
182 void SendClearCommand();
183 void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
185 void SendModifiedPixelBlocks();
188 unsigned char iDisplayPositionX;
189 unsigned char iDisplayPositionY;
190 ///Off screen mode is the recommended default settings to avoid tearing.
191 ///Though turning it off can be useful for debugging
193 ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
194 bool iUseFrameDifferencing;
196 //FutabaVfdReport iReport;
198 //unsigned char iFrameBuffer[256*64];
199 BitArray* iFrameNext;
200 BitArray* iFrameCurrent;
201 BitArray* iFramePrevious;
203 BitArray* iFrameAlpha;
204 BitArray* iFrameBeta;
205 BitArray* iFrameGamma;
207 int iNeedFullFrameUpdate;
208 //unsigned char iFrameBeta[256*64];
209 //unsigned char *iFrontBuffer;
210 //unsigned char *iBackBuffer;
212 FutabaVfdReport iInputReport;