Async loading of our tabs.
Displaying progress bar during tab loading.
19 FutabaVfdCommand::FutabaVfdCommand():/*iBuffer(NULL),*/iSize(0),iMaxSize(0)
23 FutabaVfdCommand::~FutabaVfdCommand()
32 void FutabaVfdCommand::Reset()
34 memset(iReports,0,sizeof(iReports));
43 void FutabaVfdCommand::Create(int aMaxSize)
45 iBuffer=new unsigned char[aMaxSize];
58 void FutabaVfdCommand::Delete()
74 GP1212A01A::GP1212A01A():
75 iDisplayPositionX(0),iDisplayPositionY(0),
76 iOffScreenMode(true),iFrameBuffer(NULL)
83 GP1212A01A::~GP1212A01A()
91 int GP1212A01A::Open()
93 int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A01A,NULL);
98 iFrameBuffer=new BitArray(KGP12xFrameBufferPixelCount);
100 //Since we can't get our display position we for it to our default
101 //This makes sure frames are in sync from the start
102 SetDisplayPosition(iDisplayPositionX,iDisplayPositionY);
103 //Now clear both front and back buffer on host and device
114 void GP1212A01A::SetPixel(unsigned char aX, unsigned char aY, bool aOn)
116 //Just specify a one pixel block
117 //SetPixelBlock(aX,aY,0x00,0x01,aOn);
119 //int byteOffset=(aX*HeightInPixels()+aY)/8;
120 //int bitOffset=(aX*HeightInPixels()+aY)%8;
121 //iFrameBuffer[byteOffset] |= ( (aOn?0x01:0x00) << bitOffset );
124 iFrameBuffer->SetBit(aX*HeightInPixels()+aY);
128 iFrameBuffer->ClearBit(aX*HeightInPixels()+aY);
134 void GP1212A01A::BitBlit(const BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const
136 //TODO: amend loop values so that we don't keep on looping past our frame buffer dimensions.
137 for (int i=0;i<aSrcWidth;i++)
139 for (int j=0;j<aSrcHeight;j++)
141 iFrameBuffer->SetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]);
147 Set all pixels on our screen to the desired value.
148 This operation is performed off screen to avoid tearing.
149 @param 8 pixels pattern
151 void GP1212A01A::SetAllPixels(unsigned char aPattern)
153 //With a single buffer
154 //unsigned char screen[2048]; //One screen worth of pixels
155 //memset(screen,0xFF,sizeof(screen));
156 //SetPixelBlock(0,0,63,sizeof(screen),screen);
158 //Using pattern SetPixelBlock variant.
159 memset(iFrameBuffer->Ptr(),aPattern,FrameBufferSizeInBytes());
166 Set our screen brightness.
167 @param The desired brightness level. Must be between MinBrightness and MaxBrightness.
169 void GP1212A01A::SetBrightness(int aBrightness)
171 if (aBrightness<MinBrightness()||aBrightness>MaxBrightness())
173 //Brightness out of range.
174 //Just ignore that request.
178 FutabaVfdReport report;
179 report[0]=0x00; //Report ID
180 report[1]=0x06; //Report size
181 report[2]=0x1B; //Command ID
182 report[3]=0x5C; //Command ID
183 report[4]=0x3F; //Command ID
184 report[5]=0x4C; //Command ID
185 report[6]=0x44; //Command ID
186 report[7]=0x30+aBrightness; //Brightness level
192 Set the defined pixel block to the given value.
193 @param X coordinate of our pixel block starting point.
194 @param Y coordinate of our pixel block starting point.
195 @param The height of our pixel block.
196 @param The size of our pixel data. Number of pixels divided by 8.
197 @param The value set to 8 pixels used as a pattern.
199 void GP1212A01A::SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char aValue)
201 OffScreenTranslation(aX,aY);
202 FutabaVfdReport report;
203 report[0]=0x00; //Report ID
204 report[1]=(aSize<=report.Size()-10?aSize+0x08:64); //Report length. -10 is for our header first 10 bytes. +8 is for our Futaba header size
205 report[2]=0x1B; //Command ID
206 report[3]=0x5B; //Command ID
207 report[4]=0xF0; //Command ID
210 report[7]=aHeight; //Y length before return. Though outside the specs, setting this to zero apparently allows us to modify a single pixel without touching any other.
211 report[8]=aSize>>8; //Size of pixel data in bytes (MSB)
212 report[9]=aSize; //Size of pixel data in bytes (LSB)
213 int sizeWritten=MIN(aSize,report.Size()-10);
214 memset(report.Buffer()+10, aValue, sizeWritten);
217 int remainingSize=aSize;
218 //We need to keep on sending our pixel data until we are done
219 while (report[1]==64)
222 remainingSize-=sizeWritten;
223 report[0]=0x00; //Report ID
224 report[1]=(remainingSize<=report.Size()-2?remainingSize:64); //Report length, should be 64 or the remaining size
225 sizeWritten=(report[1]==64?63:report[1]);
226 memset(report.Buffer()+2, aValue, sizeWritten);
232 Set the defined pixel block to the given value.
233 @param X coordinate of our pixel block starting point.
234 @param Y coordinate of our pixel block starting point.
235 @param The height of our pixel block.
236 @param The size of our pixel data. Number of pixels divided by 8.
237 @param Pointer to our pixel data.
239 void GP1212A01A::SetPixelBlock(unsigned char aX, unsigned char aY, int aHeight, int aSize, unsigned char* aPixels)
241 OffScreenTranslation(aX,aY);
242 FutabaVfdReport report;
243 report[0]=0x00; //Report ID
244 report[1]=(aSize<=report.Size()-10?aSize+0x08:64); //Report length. -10 is for our header first 10 bytes. +8 is for our Futaba header size
245 report[2]=0x1B; //Command ID
246 report[3]=0x5B; //Command ID
247 report[4]=0xF0; //Command ID
250 report[7]=aHeight; //Y length before return. Though outside the specs, setting this to zero apparently allows us to modify a single pixel without touching any other.
251 report[8]=aSize>>8; //Size of pixel data in bytes (MSB)
252 report[9]=aSize; //Size of pixel data in bytes (LSB)
253 int sizeWritten=MIN(aSize,report.Size()-10);
254 memcpy(report.Buffer()+10, aPixels, sizeWritten);
257 int remainingSize=aSize;
258 //We need to keep on sending our pixel data until we are done
259 while (report[1]==64)
262 remainingSize-=sizeWritten;
263 report[0]=0x00; //Report ID
264 report[1]=(remainingSize<=report.Size()-2?remainingSize:64); //Report length, should be 64 or the remaining size
265 sizeWritten=(report[1]==64?63:report[1]);
266 memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten);
273 Clear our client side back buffer.
274 Call to SwapBuffers must follow to actually clear the display.
276 void GP1212A01A::Clear()
278 //memset(iFrameBuffer->Ptr(),0x00,FrameBufferSizeInBytes());
279 iFrameBuffer->ClearAll();
283 Using this function is advised against as is causes tearing.
286 void GP1212A01A::SendClearCommand()
289 //Send Clear Display Command
290 FutabaVfdReport report;
291 report[0]=0x00; //Report ID
292 report[1]=0x04; //Report length
293 report[2]=0x1B; //Command ID
294 report[3]=0x5B; //Command ID
295 report[4]=0x32; //Command ID
296 report[5]=0x4A; //Command ID
301 Change our display position within our buffer.
303 void GP1212A01A::SetDisplayPosition(DW aDw,unsigned char aX, unsigned char aY)
306 //Send Display Position Settings Command
307 FutabaVfdReport report;
308 report[0]=0x00; //Report ID
309 report[1]=0x05; //Report length
310 report[2]=0x1B; //Command ID
311 report[3]=0x5B; //Command ID
312 report[4]=aDw; //Specify our DW
313 report[5]=aX; //X coordinate of our DW top-left corner
314 report[6]=aY; //Y coordinate of our DW top-left corner
319 Change our display position within our buffer.
321 void GP1212A01A::SetDisplayPosition(unsigned char aX, unsigned char aY)
323 //Specs apparently says both DW should remain the same
325 SetDisplayPosition(GP1212A01A::DW1,aX,aY);
326 SetDisplayPosition(GP1212A01A::DW2,aX,aY);
327 iDisplayPositionX=aX;
328 iDisplayPositionY=aY;
332 Provide Y coordinate of our off screen buffer.
334 unsigned char GP1212A01A::OffScreenY() const
336 //Overflowing is fine this is just what we want
337 return iDisplayPositionY+HeightInPixels();
341 Put our off screen buffer on screen.
342 On screen buffer goes off screen.
344 void GP1212A01A::SwapBuffers()
346 //Only perform buffer swapping if off screen mode is enabled
349 //Send host back buffer to device back buffer
350 SetPixelBlock(0,0,63,FrameBufferSizeInBytes(),iFrameBuffer->Ptr());
351 //Swap device front and back buffer
352 SetDisplayPosition(iDisplayPositionX,OffScreenY());
354 //unsigned char* backBuffer=iBackBuffer;
355 //iBackBuffer = iFrontBuffer;
356 //iFrontBuffer = backBuffer;
361 Translate the given pixel coordinate according to our off screen mode.
363 void GP1212A01A::OffScreenTranslation(unsigned char& aX, unsigned char& aY)
367 aX+=WidthInPixels()-iDisplayPositionX;
368 aY+=HeightInPixels()-iDisplayPositionY;
375 void GP1212A01A::ResetBuffers()
377 //iFrameBuffer->ClearAll();
378 //memset(iFrameBuffer,0x00,sizeof(iFrameBuffer));
379 //memset(iFrameBeta,0x00,sizeof(iFrameBeta));
384 void GP1212A01A::RequestId()
386 //1BH,5BH,63H,49H,44H
387 //Send Read ID command
388 FutabaVfdReport report;
389 report[0]=0x00; //Report ID
390 report[1]=0x05; //Report length
391 report[2]=0x1B; //Command ID
392 report[3]=0x5B; //Command ID
393 report[4]=0x63; //Command ID
394 report[5]=0x49; //Command ID
395 report[6]=0x44; //Command ID
401 void GP1212A01A::RequestFirmwareRevision()
403 //1BH,5BH,63H,46H,52H
404 //Send Software Revision Read Command
405 FutabaVfdReport report;
406 report[0]=0x00; //Report ID
407 report[1]=0x05; //Report length
408 report[2]=0x1B; //Command ID
409 report[3]=0x5B; //Command ID
410 report[4]=0x63; //Command ID
411 report[5]=0x46; //Command ID
412 report[6]=0x52; //Command ID
418 void GP1212A01A::RequestPowerSupplyStatus()
420 //1BH,5BH,63H,50H,4DH
421 //Send Power Suppply Monitor Command
422 FutabaVfdReport report;
423 report[0]=0x00; //Report ID
424 report[1]=0x05; //Report length
425 report[2]=0x1B; //Command ID
426 report[3]=0x5B; //Command ID
427 report[4]=0x63; //Command ID
428 report[5]=0x50; //Command ID
429 report[6]=0x4D; //Command ID
435 This is for development purposes only.
436 Production application should stick to off-screen mode to avoid tearing.
438 void GP1212A01A::ToggleOffScreenMode()
440 iOffScreenMode=!iOffScreenMode;
441 //Clean up our buffers upon switching modes
442 SetDisplayPosition(0,0);