MDM166AA: Clock and Clear adjustments.
5 #include "FutabaGP1212A02.h"
10 const unsigned short KMaxDataMemoryAddress = 0x4FFF;
11 const unsigned short KFrameSizeInBytes = 0x800;
14 static void sleep(unsigned int mseconds)
16 clock_t goal = mseconds + clock();
17 while (goal > clock());
24 GP1212A02A::GP1212A02A():
25 iDisplayPositionX(0),iDisplayPositionY(0),
27 iUseFrameDifferencing(true),
34 iNeedFullFrameUpdate(0)
37 iFirmwareRevision[0]=0;
43 GP1212A02A::~GP1212A02A()
58 iNeedFullFrameUpdate=0;
63 int GP1212A02A::Open()
65 int success = HidDevice::Open(KFutabaVendorId,KFutabaProductIdGP1212A02A,NULL);
68 //Allocate both frames
71 iFrameAlpha=new BitArrayLow(KGP12xFrameBufferPixelCount);
75 iFrameBeta=new BitArrayLow(KGP12xFrameBufferPixelCount);
79 iFrameGamma=new BitArrayLow(KGP12xFrameBufferPixelCount);
81 iFrameNext=iFrameAlpha;
82 iFrameCurrent=iFrameBeta;
83 iFramePrevious=iFrameGamma;
86 //To make sure it is synced properly
87 iNeedFullFrameUpdate=0;
95 //BMP box setup could be removed if we don't use it anymore
97 BmpBoxSetting(EBmpBoxIdOne,0x0000,256,64);
98 //Select current BMP box
99 BmpBoxSelect(EBmpBoxIdOne);
101 iNextFrameAddress = 0x0000;
105 SendCommandFontAction(EFontDelete);
107 //SendCommandSelectFontSize(EFontLarge);
108 //SendCommandReset();
112 unsigned char charPixels[]={ 0xFF,0xFF,0xFF,0xFF,
127 0xFF,0xFF,0xFF,0xFF};
130 //SendCommandFontAction(EFontStore);
131 for (unsigned short i=0;i<16;i++)
133 //SendCommandFontAction(EFontDelete);
135 SendCommandDefineCharacter(EFont16x32,0x0030+i,charPixels);
136 //SendCommandFontAction(EFontStore);
142 //SendCommandFontAction(EFontTransfer);
145 //SendCommandDefineCharacter(EFont16x32,0x0031,charPixels);
146 //SendCommandFontAction(EFontStore);
159 [Code] 1BH,5CH,42H,Pn,aL,aH,Pw,Ph
160 [Function] Setting the BMP box. BMP box can be defined the 3 area to DW. The position of BMP
161 box is set based on the address of DW.
162 * To write data in BMP box, BMP box select is necessary.
163 * Specifiable horizontal size is 256dot (100H) MAX. If horizontal size specify 256dot, Pw = 00H
164 Pn = Number of a BMP box
165 aL = Lower byte of address
166 aH = Upper byte of address
174 0000H <= aL + aH * 100 <= 07FFH
175 01H <= Pw <= 00H (=100H)
178 void GP1212A02A::BmpBoxSetting(TBmpBoxId aBoxId, unsigned short aAddress, int aWidth, int aHeight)
180 //TODO: check parameters validity
181 //1BH,5CH,42H,Pn,aL,aH,Pw,Ph
182 FutabaVfdReport report;
183 report[0]=0x00; //Report ID
184 report[1]=0x08; //Report length.
185 report[2]=0x1B; //Command ID
186 report[3]=0x5C; //Command ID
187 report[4]=0x42; //Command ID
189 report[6]=(unsigned char)aAddress; //aL = DM lower byte
190 report[7]=aAddress>>8; //aH = DM upper byte
191 report[8]=(aWidth==256?0x00:aWidth); //Pw = BMP box width 00==256
192 report[9]=aHeight/8; //Ph = BMP box height.
198 [Function]Select of BMP box
199 * Execution "BMP box select" is necessary before "Setting the Text box".
200 * In case of writing by the specified dot writing, it is necessary to cancel this command.
202 Pn = 30H - Remove the BMP box
207 void GP1212A02A::BmpBoxSelect(TBmpBoxId aBoxId)
209 //TODO: check parameters validity
210 FutabaVfdReport report;
211 report[0]=0x00; //Report ID
212 report[1]=0x04; //Report length.
213 report[2]=0x1B; //Command ID
214 report[3]=0x5C; //Command ID
215 report[4]=0x48; //Command ID
216 report[5]=aBoxId; //BMP box ID
223 void GP1212A02A::SetPixel(unsigned char aX, unsigned char aY, unsigned int aPixel)
226 //int byteOffset=(aX*HeightInPixels()+aY)/8;
227 //int bitOffset=(aX*HeightInPixels()+aY)%8;
228 //iNextFrame[byteOffset] |= ( (aOn?0x01:0x00) << bitOffset );
230 //Pixel is on if any of the non-alpha component is not null
231 bool on = (aPixel&0x00FFFFFF)!=0x00000000;
237 iFrameNext->SetBit(aX*HeightInPixels()+aY);
241 iFrameNext->ClearBit(aX*HeightInPixels()+aY);
246 //Just specify a one pixel block
254 void GP1212A02A::BitBlit(const BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const
256 //TODO: amend loop values so that we don't keep on looping past our frame buffer dimensions.
257 for (int i=0;i<aSrcWidth;i++)
259 for (int j=0;j<aSrcHeight;j++)
261 iFrameNext->SetBitValue((aTargetX+i)*HeightInPixels()+aTargetY+j,aBitmap[+i*aSrcHeight+j]);
268 Clear our client side back buffer.
269 Call to SwapBuffers must follow to actually clear the display.
271 void GP1212A02A::Clear()
273 //memset(iNextFrame->Ptr(),0x00,FrameBufferSizeInBytes());
276 iFrameNext->ClearAll();
286 Must be followed by a SwapBuffers call.
288 void GP1212A02A::Fill()
294 Set all pixels on our screen to the desired value.
295 This operation is performed off screen to avoid tearing.
296 @param 8 pixels pattern
298 void GP1212A02A::SetAllPixels(unsigned char aPattern)
300 //With a single buffer
301 //unsigned char screen[2048]; //One screen worth of pixels
302 //memset(screen,0xFF,sizeof(screen));
303 //SetPixelBlock(0,0,63,sizeof(screen),screen);
308 memset(iFrameNext->Ptr(),aPattern,FrameBufferSizeInBytes());
312 //Using pattern SetPixelBlock variant.
323 [Code] 1BH,4AH,Pm,aL,aH,Ps,nL,nH,Pd...Pd
324 [Function] The BMP data is written in the DW(Display Window) or the Data memory.
325 Pm= DW or Data memory
328 Ps = Direction of writing
329 nL = number of BMP data length lower byte
330 nH = number of BMP data length upper byte
332 * If X direction is selected as Ps and data is written in the last address, the data in the last address is
333 overwritten with the remaining data.
334 [Definable area] Pm = 30H : DW
335 Pm = 31H: Data memory
336 0000H <= aL + aH * 100 <= 07FFH (DW)
337 0000H <= aL + aH * 100 <= 4FFFH (Data memory)
338 Ps = 30H: Y direction
339 Ps = 31H: X direction
340 0001H <= nL + nH * 100 <= 0100H(DW: X direction)
341 0001H <= nL + nH * 100 <= 0800H(DW: Y direction)
342 0001H <= nL + nH * 100 <= 0A00H(Data memory: X direction)
343 0001H <= nL + nH * 100 <= 5000H(Data memory: Y direction)
345 void GP1212A02A::BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels)
347 FutabaVfdReport report;
348 report[0]=0x00; //Report ID
349 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
350 report[2]=0x1B; //Command ID
351 report[3]=0x4A; //Command ID
352 report[4]=aTarget; //Display Window or Data Memory
353 report[5]=(unsigned char)aAddress; //aL = DW lower byte
354 report[6]=aAddress>>8; //aH = DW upper byte
355 report[7]=aDirection; //Direction of writing: Y or X
356 report[8]=(unsigned char)aSize; //Size of pixel data in bytes (LSB)
357 report[9]=aSize>>8; //Size of pixel data in bytes (MSB)
358 int sizeWritten=MIN(aSize,report.Size()-10);
359 memcpy(report.Buffer()+10, aPixels, sizeWritten);
362 int remainingSize=aSize;
363 //We need to keep on sending our pixel data until we are done
364 while (report[1]==64)
367 remainingSize-=sizeWritten;
368 report[0]=0x00; //Report ID
369 report[1]=(remainingSize<=report.Size()-2?remainingSize:64); //Report length, should be 64 or the remaining size
370 sizeWritten=(report[1]==64?63:report[1]);
371 memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten);
379 [Code] 1BH,5CH,44H,aL,aH
380 [Function] BMP data transfer from Data memory to DW.
381 Although source data is updated, data in BMP box is not updated. To reflect the update,
382 re-executing this command is necessary.
383 aL = Lower byte of address
384 aH = Upper byte of address
386 0000H <= aL + aH * 100 <= 4FFFH
388 void GP1212A02A::BmpBoxDataMemoryTransfer(unsigned short aAddress)
390 FutabaVfdReport report;
391 report[0]=0x00; //Report ID
392 report[1]=0x05; //Report length.
393 report[2]=0x1B; //Command ID
394 report[3]=0x5C; //Command ID
395 report[4]=0x44; //Command ID
396 report[5]=(unsigned char)aAddress; //aL = DM lower byte
397 report[6]=aAddress>>8; //aH = DM upper byte
402 Input BMP data in the BMP box
403 [Code] 1BH,5CH,5DH,nL,nH,Pd...Pd
404 [Function] BMP data is written the BMP box
405 * Number of definable data is due to BMP box size. If the data is over range, the over range data is
406 rewritten the final address.
407 nL = Lower byte of number of definition byte
408 nH = Upper byte of number of definition byte
410 [Definable area] Pn : BMP box size (Pw * Ph)
412 void GP1212A02A::BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels)
414 FutabaVfdReport report;
415 report[0]=0x00; //Report ID
416 report[1]=(aSize<=report.Size()-7?aSize+0x05:64); //Report length. -7 is for our header first 10 bytes. +5 is for our Futaba header size
417 report[2]=0x1B; //Command ID
418 report[3]=0x5C; //Command ID
419 report[4]=0x5D; //Display Window or Data Memory
420 report[5]=(unsigned char)aSize; //Size of pixel data in bytes (LSB)
421 report[6]=aSize>>8; //Size of pixel data in bytes (MSB)
422 int sizeWritten=MIN(aSize,report.Size()-7);
423 memcpy(report.Buffer()+7, aPixels, sizeWritten);
426 int remainingSize=aSize;
427 //We need to keep on sending our pixel data until we are done
428 while (report[1]==64)
431 remainingSize-=sizeWritten;
432 report[0]=0x00; //Report ID
433 report[1]=(remainingSize<=report.Size()-2?remainingSize:64); //Report length, should be 64 or the remaining size
434 sizeWritten=(report[1]==64?63:report[1]);
435 memcpy(report.Buffer()+2, aPixels+(aSize-remainingSize), sizeWritten);
441 Using this function is advised against as is causes tearing.
444 void GP1212A02A::SendCommandClear()
447 //Send Clear Display Command
448 FutabaVfdReport report;
449 report[0]=0x00; //Report ID
450 report[1]=0x04; //Report length
451 report[2]=0x1B; //Command ID
452 report[3]=0x4A; //Command ID
453 report[4]=0x43; //Command ID
454 report[5]=0x44; //Command ID
460 Returns to default setting.
461 * The other command is not receive until this command complete. Please don’t send the any data
462 from a host during “BUSY”
463 * Delete the User definable font to the RAM.
464 * If the VFD Power Off, VFD Power turn ON after the RESET command.
466 void GP1212A02A::SendCommandReset()
469 //Send Clear Display Command
470 FutabaVfdReport report;
471 report[0]=0x00; //Report ID
472 report[1]=0x04; //Report length
473 report[2]=0x1B; //Command ID
474 report[3]=0x4A; //Command ID
475 report[4]=0x52; //Command ID
476 report[5]=0x53; //Command ID
478 //Wait until reset is done. Is that needed?
485 Provide Y coordinate of our off screen buffer.
487 unsigned char GP1212A02A::OffScreenY() const
489 //Overflowing is fine this is just what we want
490 return iDisplayPositionY+HeightInPixels();
494 Put our off screen buffer on screen.
495 On screen buffer goes off screen.
497 void GP1212A02A::SwapBuffers()
499 //Only perform buffer swapping if off screen mode is enabled
502 //Send pixel directly into BMP box
503 //BmpBoxDataInput(FrameBufferSizeInBytes(),iFrameNext->Ptr());
505 //This appears to be the fastest scheme when running on our HTPC
506 //Send pixel data directly into the display window
507 BmpDataInput(ETargetDisplayWindow,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
509 //Send pixel data first to Data Memory then copy into the selected BMP box
510 //BmpDataInput(ETargetDataMemory,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
511 //BmpBoxDataMemoryTransfer(0x0000);
513 //Send pixel data first to Data Memory then copy into the selected BMP box, cycling through our Data Memory frame
515 BmpDataInput(ETargetDataMemory,iNextFrameAddress,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
516 BmpBoxDataMemoryTransfer(iNextFrameAddress);
517 iNextFrameAddress+=KFrameSizeInBytes;
518 if (iNextFrameAddress>KMaxDataMemoryAddress)
520 iNextFrameAddress=0x0000;
524 //Cycle through our frame buffers
525 //We keep track of previous frame which is in fact our device back buffer.
526 //We can then compare previous and next frame and send only the differences to our device.
527 //This mechanism allows us to reduce traffic over our USB bus thus improving our frame rate from 14 FPS to 30 FPS.
528 //Keep our previous frame pointer
529 BitArrayLow* previousFrame=iFramePrevious;
530 //Current frame becomes the previous one
531 iFramePrevious = iFrameCurrent;
532 //Next frame becomes the current one
533 iFrameCurrent = iFrameNext;
534 //Next frame is now our former previous
535 iFrameNext = previousFrame;
540 //Define the edge of our pixel block
541 //Pixel blocks of 32x32 seems to run almost as fast as full screen update in worse case scenarii.
542 //Though I wonder if in some situations 16 could be better. Make this an attribute at some point if need be.
543 const int KPixelBlockEdge = 32;
544 const int KPixelBlockSizeInBits = KPixelBlockEdge*KPixelBlockEdge;
545 const int KPixelBlockSizeInBytes = KPixelBlockSizeInBits/8;
549 Translate the given pixel coordinate according to our off screen mode.
551 void GP1212A02A::OffScreenTranslation(unsigned char& aX, unsigned char& aY)
555 aX+=WidthInPixels()-iDisplayPositionX;
556 aY+=HeightInPixels()-iDisplayPositionY;
563 void GP1212A02A::Request(TMiniDisplayRequest aRequest)
567 case EMiniDisplayRequestDeviceId:
570 case EMiniDisplayRequestFirmwareRevision:
571 RequestFirmwareRevision();
573 case EMiniDisplayRequestPowerSupplyStatus:
574 RequestPowerSupplyStatus();
585 void GP1212A02A::ResetBuffers()
587 //iNextFrame->ClearAll();
588 //memset(iFrameAlpha,0x00,sizeof(iFrameAlpha));
589 //memset(iFrameBeta,0x00,sizeof(iFrameBeta));
594 void GP1212A02A::RequestDeviceId()
601 [Code] 1BH,6AH,49H,44H
602 [Function] Send the ID code to the Host system. ID code is software version.
604 void GP1212A02A::RequestFirmwareRevision()
606 if (RequestPending())
608 //Abort silently for now
613 //Send Software Revision Read Command
614 FutabaVfdReport report;
615 report[0]=0x00; //Report ID
616 report[1]=0x04; //Report length
617 report[2]=0x1B; //Command ID
618 report[3]=0x6A; //Command ID
619 report[4]=0x49; //Command ID
620 report[5]=0x44; //Command ID
621 if (Write(report)==report.Size())
623 SetRequest(EMiniDisplayRequestFirmwareRevision);
630 void GP1212A02A::RequestPowerSupplyStatus()
637 This is for development purposes only.
638 Production application should stick to off-screen mode to avoid tearing.
640 void GP1212A02A::ToggleOffScreenMode()
642 SetOffScreenMode(!iOffScreenMode);
646 * @brief GP1212A02A::SetOffScreenMode
650 void GP1212A02A::SetOffScreenMode(bool aOn)
652 if (aOn==iOffScreenMode)
660 //Clean up our buffers upon switching modes
667 Tries to complete our current request if we have one pending.
669 TMiniDisplayRequest GP1212A02A::AttemptRequestCompletion()
671 if (!RequestPending())
673 return EMiniDisplayRequestNone;
676 int res=Read(iInputReport);
680 return EMiniDisplayRequestNone;
683 //Process our request
684 if (CurrentRequest()==EMiniDisplayRequestFirmwareRevision)
686 unsigned char* ptr=&iInputReport[2];
687 iInputReport[7]=0x00;
688 strcpy(iFirmwareRevision,(const char*)ptr);
691 TMiniDisplayRequest completed=CurrentRequest();
692 //Our request was completed
693 SetRequest(EMiniDisplayRequestNone);
700 Set our screen brightness.
701 @param The desired brightness level. Must be between MinBrightness and MaxBrightness.
703 void GP1212A02A::SetBrightness(int aBrightness)
705 if (aBrightness<MinBrightness()||aBrightness>MaxBrightness())
707 //Brightness out of range.
708 //Just ignore that request.
712 FutabaVfdReport report;
713 report[0]=0x00; //Report ID
714 report[1]=0x04; //Report size
715 report[2]=0x1B; //Command ID
716 report[3]=0x4A; //Command ID
717 report[4]=0x44; //Command ID
718 report[5]=0x30+aBrightness; //Brightness level
725 [Function]Control of the power supply for VFD
726 * If VFD power ON or OFF, at interval of 10s or more.
727 * When the VFD power off, VFD display is turn off, but the module can receive a data and
729 Ps = VFD Power control
731 Ps = 30H : VFD Power OFF
732 Ps = 31H : VFD Power ON (Default)
734 void GP1212A02A::SendCommandPower(TPowerStatus aPowerStatus)
736 FutabaVfdReport report;
737 report[0]=0x00; //Report ID
738 report[1]=0x04; //Report size
739 report[2]=0x1B; //Command ID
740 report[3]=0x4A; //Command ID
741 report[4]=0x42; //Command ID
742 report[5]=aPowerStatus; //ON or OFF
748 void GP1212A02A::TurnPowerOn()
750 SendCommandPower(EPowerOn);
756 void GP1212A02A::TurnPowerOff()
758 SendCommandPower(EPowerOff);
763 Provide the length of our character string for the given clock format.
764 @param The clock format to evaluate.
765 @return Number of characters for the given clock format.
767 int GP1212A02A::ClockCharCount(TClockFormat aFormat)
785 @return Clock character width in pixels.
787 int GP1212A02A::ClockCharWidthInPixels(TFontSizeLogical aSize)
805 @return Clock character height in pixels.
807 int GP1212A02A::ClockCharHeightInPixels(TFontSizeLogical aSize)
825 Return the Display Window address for centering the clock corresponding to the given parameters.
827 unsigned short GP1212A02A::ClockCenterAddress(TClockFormat aFormat, TFontSizeLogical aSize)
829 int charCount=ClockCharCount(aFormat);
830 int halfWidth=(ClockCharWidthInPixels(aSize)*charCount)/2;
831 int halfHeight=(ClockCharHeightInPixels(aSize))/2;
832 int x=(WidthInPixels()/2)-halfWidth;
833 int y=(HeightInPixels()/2)-halfHeight;
836 int xOffset=x*8; //Not sure why...
838 unsigned short address = yOffset+xOffset;
845 void GP1212A02A::ShowClock()
847 SendCommandClockDisplay(EClock24,ClockCenterAddress(EClock24,EFontLarge),EFontLarge);
852 void GP1212A02A::HideClock()
854 SendCommandClockCancel();
860 [Code]1BH,6BH,53H,Pd,Ph,Pm
861 [Function]Setting the clock data. The setting data is cleared, if the Reset command is input or power
871 * Clock setting is canceled, when Pd is input value that is larger than 07H, or Ph is input value that is
872 larger than 18H,or Pm is input value that is larger than 3CH.
874 void GP1212A02A::SendCommandClockSetting(TWeekDay aWeekDay, unsigned char aHour, unsigned char aMinute)
876 FutabaVfdReport report;
877 report[0]=0x00; //Report ID
878 report[1]=0x06; //Report size
879 report[2]=0x1B; //Command ID
880 report[3]=0x6B; //Command ID
881 report[4]=0x53; //Command ID
882 report[5]=aWeekDay; //Sunday to Saturday
891 Set display clock settings according to local system time.
892 This needs to be redone whenever we open or turn on our display.
894 void GP1212A02A::SetClockSetting()
897 struct tm * timeinfo;
900 timeinfo = localtime ( &rawtime );
902 SendCommandClockSetting((TWeekDay)timeinfo->tm_wday,timeinfo->tm_hour,timeinfo->tm_min);
908 [Code] 1BH,6BH,55H,Ps,aL,aH,Pf
909 [Function] Clock is displayed. The display position and the font size can be freely decided.
910 Ps = Display type select
912 Pf = Font size select
914 Ps = 00H : 24hour Ex.[12:34]
915 Ps = 01H : 24hour + day of the week Ex.[Wed._12:34]
916 Ps = 10H : 12hour Ex.[PM_00:34]
917 Ps = 11H : 12hour + day of the week Ex.[Wed._PM_00:34]
922 * When the clock data is not input, clock is not displayed.
923 * The clock display is maintained until Clock display cancel "Clear display" RESET command is input
924 or power is turned off.
925 The clock display area
926 Graphic can be displayed excluding the clock display area.
927 The self adjustment for the position
928 that cannot be displayed.
929 * Excluding the clock display area can be input other display commands.
931 void GP1212A02A::SendCommandClockDisplay(TClockFormat aClockFormat, unsigned short aAddress, TFontSizeLogical aSize)
933 FutabaVfdReport report;
934 report[0]=0x00; //Report ID
935 report[1]=0x07; //Report size
936 report[2]=0x1B; //Command ID
937 report[3]=0x6B; //Command ID
938 report[4]=0x55; //Command ID
939 report[5]=aClockFormat; //
940 report[6]=(unsigned char)aAddress; //aL
941 report[7]=aAddress>>8; //aH
950 [Code] 1BH,6BH,3DH,58H
951 [Function] Clock display is canceled.
953 void GP1212A02A::SendCommandClockCancel()
955 FutabaVfdReport report;
956 report[0]=0x00; //Report ID
957 report[1]=0x04; //Report size
958 report[2]=0x1B; //Command ID
959 report[3]=0x6B; //Command ID
960 report[4]=0x3D; //Command ID
968 @return Size in bytes of a character for a given font size.
970 int GP1212A02A::CharacterSizeInBytes(TFontSize aFontSize)
994 Define the User definable font (RAM)
995 [Code] 1BH,6AH,47H,Pf,cL,(cH),Pd...Pd
996 [Function] Define the User definable font into RAM. A maximum 16 characters can be defined
997 within each font size.
998 The User definable fonts are displayed the defined code. It is a same process to normal fonts.
999 The User definable fonts are valid until they redefined, Reset command, or the power off.
1000 If define the user definable font over 16 characters, at first defined user definable font is removed
1001 If the defined code is specified, existing data is re-written.
1002 If the 16x16, 24x24, 32x32 size define, it must specify the “cH”
1004 cL = Lower byte of User definable font code
1005 cH = Upper byte of User definable font code
1006 Pd = Definition data
1008 Pf = 30H : 6x8 dot (Pd=6 byte)
1009 Pf = 31H : 8x16 dot (Pd=16 byte)
1010 Pf = 32H : 12x24 dot (Pd=36 byte)
1011 Pf = 33H : 16x32 dot (Pd=64 byte)
1012 Pf = 34H : 16x16 dot (Pd=32 byte)
1013 Pf = 35H : 24x24 dot (Pd=72 byte)
1014 Pf = 36H : 32x32 dot (Pd=128 byte)
1015 cL = ANK code (Pf=30H~33H : 1 byte code)
1016 cL,cH = Shift-JIS code (Pf=34H~36H : 2 byte code)
1018 void GP1212A02A::SendCommandDefineCharacter(TFontSize aFontSize, unsigned short aCharacterCode, unsigned char* aPixels)
1020 unsigned char reportSize=0;
1021 unsigned char headerSize=0;
1022 unsigned char dataSize=CharacterSizeInBytes(aFontSize);
1023 FutabaVfdReport report;
1025 if (aFontSize>=EFont16x16)
1029 reportSize = (dataSize<=report.Size()-headerSize?dataSize+0x06:64); //Report length. -7 is for our header first 7 bytes. +5 is for our Futaba header size
1030 report[7] = aCharacterCode>>8;
1036 reportSize = (dataSize<=report.Size()-headerSize?dataSize+0x05:64); //Report length. -7 is for our header first 7 bytes. +5 is for our Futaba header size
1040 report[0]=0x00; //Report ID
1041 report[1]=reportSize; //Report size
1042 report[2]=0x1B; //Command ID
1043 report[3]=0x6A; //Command ID
1044 report[4]=0x47; //Command ID
1045 report[5]=aFontSize; //
1046 report[6] = (unsigned char) aCharacterCode;
1047 //7th byte was set above already
1048 int sizeWritten=MIN(dataSize,report.Size()-headerSize);
1049 memcpy(report.Buffer()+headerSize, aPixels, sizeWritten);
1052 int remainingSize=dataSize;
1053 //We need to keep on sending our pixel data until we are done
1054 while (report[1]==64)
1057 remainingSize-=sizeWritten;
1058 report[0]=0x00; //Report ID
1059 report[1]=(remainingSize<=report.Size()-2?remainingSize:64); //Report length, should be 64 or the remaining size
1060 sizeWritten=(report[1]==64?63:report[1]);
1061 memcpy(report.Buffer()+2, aPixels+(dataSize-remainingSize), sizeWritten);
1068 User definable font store / transfer / delete
1069 [Code] 1BH,6AH,45H,Ps
1070 [Function] Store, transfer, or delete the User definable font to FROM.
1071 * Define the user definable font, after the user definable font is stored
1072 * The user definable font store is stored the all defined user definable font data.
1073 * The use definable font delete is deleted the all defined to FROM and RAM user definable font data.
1074 Ps = store / transfer / delete
1080 void GP1212A02A::SendCommandFontAction(TFontAction aFontAction)
1082 FutabaVfdReport report;
1083 report[0]=0x00; //Report ID
1084 report[1]=0x04; //Report size
1085 report[2]=0x1B; //Command ID
1086 report[3]=0x6A; //Command ID
1087 report[4]=0x45; //Command ID
1088 report[5]=aFontAction; //Ps
1095 [Code]1BH,4AH,46H,Pf
1096 [Function]Setting the font size
1100 Pf = 31H?8x16dot and 16x16 dot
1101 Pf = 32H?12x24 dot and 24x24 dot
1102 Pf = 33H?16x32 dot and 32x32 dot
1104 void GP1212A02A::SendCommandSelectFontSize(TFontSizeLogical aFontSoze)
1106 FutabaVfdReport report;
1107 report[0]=0x00; //Report ID
1108 report[1]=0x04; //Report size
1109 report[2]=0x1B; //Command ID
1110 report[3]=0x4A; //Command ID
1111 report[4]=0x46; //Command ID
1112 report[5]=aFontSoze; //Pf