Display can now be opened, closed and reopened thanks to the following fixes.
Fixing issue with non-virtual destructor.
Fixing issue with deletion of void pointer.
11 #include "MiniDisplay.h"
14 #define MIN(a,b) (((a)<(b))?(a):(b))
18 #define MAX(a,b) (((a)>(b))?(a):(b))
22 //This was computed from our number of pixels as follow 256x64/8/64 = 32 + 1 = 33
23 //+1 was added for our header
24 const int KFutabaMaxCommandOutputReport = 33;
25 //TODO: Get ride of that constant once we figure out a way to get it from hidapi
26 const int KFutabaMaxHidReportSize = 65;
28 const int KHidReportIdIndex=0;
29 const int KFutabaHidReportSizeIndex=1;
30 //Define Futaba vendor ID to filter our list of device
31 const unsigned short KFutabaVendorId = 0x1008;
32 const unsigned short KFutabaProductIdGP1212A01A = 0x100C;
33 const unsigned short KFutabaProductIdGP1212A02A = 0x1013; //Or is it 0x1015
34 const int KGP12xWidthInPixels = 256;
35 const int KGP12xHeightInPixels = 64;
36 const int KGP12xPixelsPerByte = 8;
37 const int KGP12xFrameBufferSizeInBytes = KGP12xWidthInPixels*KGP12xHeightInPixels/KGP12xPixelsPerByte; //256*64/8=2048
38 const int KGP12xFrameBufferPixelCount = KGP12xWidthInPixels*KGP12xHeightInPixels;
40 //typedef struct hid_device_info HidDeviceInfo;
43 Define a Futaba HID report.
45 class FutabaVfdReport: public HidReport<KFutabaMaxHidReportSize>
54 Define a generic Futaba VFD command.
56 class FutabaVfdCommand
62 //void Create(int aMaxSize);
65 //inline unsigned char& operator[](int aIndex){return iBuffer[aIndex];}
70 //unsigned char* iBuffer;
71 FutabaVfdReport iReports[KFutabaMaxCommandOutputReport];
78 class FutabaVfd : public HidDevice
81 virtual int MinBrightness() const=0;
82 virtual int MaxBrightness() const=0;
83 virtual void SetBrightness(int aBrightness)=0;
84 virtual void Clear()=0;
90 class FutabaGraphicVfd : public FutabaVfd
93 virtual int WidthInPixels() const=0;
94 virtual int HeightInPixels() const=0;
95 virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn)=0;
96 virtual void SetAllPixels(unsigned char aOn)=0;
97 virtual int FrameBufferSizeInBytes() const=0;
98 //virtual int BitBlit(unsigned char* aSrc, unsigned char aSrcWidth, unsigned char aSrcHeight, unsigned char aTargetX, unsigned char aTargetY) const=0;
103 Common functionality between GP1212A01A and GP1212A02A
105 class GP1212XXXX : public FutabaGraphicVfd
109 virtual int MinBrightness() const {return 0;}
110 virtual int MaxBrightness() const {return 5;}
114 GP1212A01A is a graphic display module using a FUTABA 256x64dots VFD.
115 The module do not include character ROM, the customer will compile the character
116 by themselves (from main system).
118 class GP1212A01A : public GP1212XXXX
129 //From FutabaGraphicVfd
130 virtual int WidthInPixels() const {return KGP12xWidthInPixels;}
131 virtual int HeightInPixels() const {return KGP12xHeightInPixels;}
132 virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn);
133 virtual void SetAllPixels(unsigned char aPattern);
134 virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
135 virtual void BitBlit(const BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const;
137 virtual void SetBrightness(int aBrightness);
138 virtual void Clear();
140 //Specific to GP1212A01A
141 void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char aValue);
142 void SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char* aPixels);
143 //Define display position within our display RAM
144 void SetDisplayPosition(unsigned char aX, unsigned char aY);
145 unsigned char DisplayPositionX() const {return iDisplayPositionX;}
146 unsigned char DisplayPositionY() const {return iDisplayPositionY;}
150 void RequestDeviceId();
151 void RequestFirmwareRevision();
152 void RequestPowerSupplyStatus();
154 void ToggleOffScreenMode();
155 void SetOffScreenMode(bool aOn);
156 bool OffScreenMode() const {return iOffScreenMode;}
158 void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;}
159 bool FrameDifferencing() const {return iUseFrameDifferencing;}
161 bool RequestPending(){return iRequest!=EMiniDisplayRequestNone;}
162 TMiniDisplayRequest CurrentRequest(){return iRequest;}
163 void CancelRequest(){iRequest=EMiniDisplayRequestNone;}
164 TMiniDisplayRequest AttemptRequestCompletion();
165 FutabaVfdReport& InputReport() {return iInputReport;}
168 char* FirmwareRevision();
177 void SetDisplayPosition(DW aDw,unsigned char aX, unsigned char aY);
178 unsigned char OffScreenY() const;
179 void SendClearCommand();
180 void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
182 void SendModifiedPixelBlocks();
185 unsigned char iDisplayPositionX;
186 unsigned char iDisplayPositionY;
187 ///Off screen mode is the recommended default settings to avoid tearing.
188 ///Though turning it off can be useful for debugging
190 ///Frame differences algo is used to reduce USB bus traffic and improve frame rate in typical use case
191 bool iUseFrameDifferencing;
193 //FutabaVfdReport iReport;
195 //unsigned char iFrameBuffer[256*64];
196 BitArray* iFrameNext;
197 BitArray* iFrameCurrent;
198 BitArray* iFramePrevious;
200 BitArray* iFrameAlpha;
201 BitArray* iFrameBeta;
202 BitArray* iFrameGamma;
204 int iNeedFullFrameUpdate;
205 //unsigned char iFrameBeta[256*64];
206 //unsigned char *iFrontBuffer;
207 //unsigned char *iBackBuffer;
208 TMiniDisplayRequest iRequest;
209 FutabaVfdReport iInputReport;
211 char iDeviceId[KFutabaMaxHidReportSize];
212 char iFirmwareRevision[KFutabaMaxHidReportSize];