GP1212A02: Implementing DataMemory frame cycle experiment, no frame rate improvement.
Adding support for firmware revision query.
1.1 --- a/Display.h Sat Aug 30 18:43:54 2014 +0200
1.2 +++ b/Display.h Sun Aug 31 17:42:10 2014 +0200
1.3 @@ -5,12 +5,13 @@
1.4 #ifndef DISPLAY_H
1.5 #define DISPLAY_H
1.6
1.7 +#include "HidDevice.h"
1.8 const int KMaxDisplayStringLength = 256;
1.9
1.10 /**
1.11 Define an interface to some basic display functionality
1.12 */
1.13 -class DisplayBase
1.14 +class DisplayBase: public HidDevice
1.15 {
1.16 public:
1.17 DisplayBase():iRequest(EMiniDisplayRequestNone),iPowerOn(false)
2.1 --- a/FutabaGP1212A02.cpp Sat Aug 30 18:43:54 2014 +0200
2.2 +++ b/FutabaGP1212A02.cpp Sun Aug 31 17:42:10 2014 +0200
2.3 @@ -7,6 +7,9 @@
2.4
2.5 const int KNumberOfFrameBeforeDiffAlgo = 3;
2.6
2.7 +const unsigned short KMaxDataMemoryAddress = 0x4FFF;
2.8 +const unsigned short KFrameSizeInBytes = 0x800;
2.9 +
2.10 //
2.11 // class GP1212A02A
2.12 //
2.13 @@ -87,6 +90,7 @@
2.14 //Select current BMP box
2.15 BmpBoxSelect(EBmpBoxIdOne);
2.16
2.17 + iNextFrameAddress = 0x0000;
2.18
2.19 }
2.20 return success;
2.21 @@ -410,12 +414,20 @@
2.22 if (OffScreenMode())
2.23 {
2.24 //Send pixel directly into BMP box
2.25 - BmpBoxDataInput(FrameBufferSizeInBytes(),iFrameNext->Ptr());
2.26 + //BmpBoxDataInput(FrameBufferSizeInBytes(),iFrameNext->Ptr());
2.27 //Send pixel data directly into the display window
2.28 //BmpDataInput(ETargetDisplayWindow,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
2.29 //Send pixel data first to Data Memory then copy into the selected BMP box
2.30 //BmpDataInput(ETargetDataMemory,0x0000,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
2.31 //BmpBoxDataMemoryTransfer(0x0000);
2.32 + //Send pixel data first to Data Memory then copy into the selected BMP box, cycling through our Data Memory frmae
2.33 + BmpDataInput(ETargetDataMemory,iNextFrameAddress,EDirectionY, FrameBufferSizeInBytes(),iFrameNext->Ptr());
2.34 + BmpBoxDataMemoryTransfer(iNextFrameAddress);
2.35 + iNextFrameAddress+=KFrameSizeInBytes;
2.36 + if (iNextFrameAddress>KMaxDataMemoryAddress)
2.37 + {
2.38 + iNextFrameAddress=0x0000;
2.39 + }
2.40
2.41 //Cycle through our frame buffers
2.42 //We keep track of previous frame which is in fact our device back buffer.
2.43 @@ -456,6 +468,28 @@
2.44
2.45 /**
2.46 */
2.47 +void GP1212A02A::Request(TMiniDisplayRequest aRequest)
2.48 + {
2.49 + switch (aRequest)
2.50 + {
2.51 + case EMiniDisplayRequestDeviceId:
2.52 + RequestDeviceId();
2.53 + break;
2.54 + case EMiniDisplayRequestFirmwareRevision:
2.55 + RequestFirmwareRevision();
2.56 + break;
2.57 + case EMiniDisplayRequestPowerSupplyStatus:
2.58 + RequestPowerSupplyStatus();
2.59 + break;
2.60 + default:
2.61 + //Not supported
2.62 + break;
2.63 + };
2.64 + }
2.65 +
2.66 +
2.67 +/**
2.68 +*/
2.69 void GP1212A02A::ResetBuffers()
2.70 {
2.71 //iNextFrame->ClearAll();
2.72 @@ -471,10 +505,32 @@
2.73 }
2.74
2.75 /**
2.76 +ID code
2.77 +[Code] 1BH,6AH,49H,44H
2.78 +[Function] Send the ID code to the Host system. ID code is software version.
2.79 */
2.80 void GP1212A02A::RequestFirmwareRevision()
2.81 {
2.82 - //Not supported
2.83 + if (RequestPending())
2.84 + {
2.85 + //Abort silently for now
2.86 + return;
2.87 + }
2.88 +
2.89 + //1BH,6AH,49H,44H
2.90 + //Send Software Revision Read Command
2.91 + FutabaVfdReport report;
2.92 + report[0]=0x00; //Report ID
2.93 + report[1]=0x04; //Report length
2.94 + report[2]=0x1B; //Command ID
2.95 + report[3]=0x6A; //Command ID
2.96 + report[4]=0x49; //Command ID
2.97 + report[5]=0x44; //Command ID
2.98 + if (Write(report)==report.Size())
2.99 + {
2.100 + SetRequest(EMiniDisplayRequestFirmwareRevision);
2.101 + }
2.102 +
2.103 }
2.104
2.105 /**
2.106 @@ -520,8 +576,31 @@
2.107 */
2.108 TMiniDisplayRequest GP1212A02A::AttemptRequestCompletion()
2.109 {
2.110 - //That display does not support any requests
2.111 - return EMiniDisplayRequestNone;
2.112 + if (!RequestPending())
2.113 + {
2.114 + return EMiniDisplayRequestNone;
2.115 + }
2.116 +
2.117 + int res=Read(iInputReport);
2.118 +
2.119 + if (!res)
2.120 + {
2.121 + return EMiniDisplayRequestNone;
2.122 + }
2.123 +
2.124 + //Process our request
2.125 + if (CurrentRequest()==EMiniDisplayRequestFirmwareRevision)
2.126 + {
2.127 + unsigned char* ptr=&iInputReport[2];
2.128 + iInputReport[7]=0x00;
2.129 + strcpy(iFirmwareRevision,(const char*)ptr);
2.130 + }
2.131 +
2.132 + TMiniDisplayRequest completed=CurrentRequest();
2.133 + //Our request was completed
2.134 + SetRequest(EMiniDisplayRequestNone);
2.135 +
2.136 + return completed;
2.137 }
2.138
2.139
3.1 --- a/FutabaGP1212A02.h Sat Aug 30 18:43:54 2014 +0200
3.2 +++ b/FutabaGP1212A02.h Sun Aug 31 17:42:10 2014 +0200
3.3 @@ -30,18 +30,13 @@
3.4 virtual void SetPixel(unsigned char aX, unsigned char aY, bool aOn);
3.5 virtual void SetAllPixels(unsigned char aPattern);
3.6 virtual int FrameBufferSizeInBytes() const {return KGP12xFrameBufferSizeInBytes;}
3.7 - //virtual void BitBlit(const BitArray& aBitmap, int aSrcWidth, int aSrcHeight, int aTargetX, int aTargetY) const;
3.8 virtual void SetBrightness(int aBrightness);
3.9 virtual void Clear();
3.10 virtual void Fill();
3.11 + virtual void Request(TMiniDisplayRequest aRequest);
3.12
3.13 - //Specific to GP1212A02A
3.14
3.15 -
3.16 - //
3.17 - void RequestDeviceId();
3.18 - void RequestFirmwareRevision();
3.19 - void RequestPowerSupplyStatus();
3.20 +
3.21 //
3.22 void ToggleOffScreenMode();
3.23 void SetOffScreenMode(bool aOn);
3.24 @@ -70,7 +65,6 @@
3.25 ETargetDataMemory=0x31
3.26 };
3.27
3.28 -
3.29 enum TDirection
3.30 {
3.31 EDirectionY=0x30,
3.32 @@ -78,6 +72,8 @@
3.33 };
3.34
3.35
3.36 +private:
3.37 + //Specific to GP1212A02A
3.38 //General setting command
3.39 void BmpDataInput(TTarget aTarget, unsigned short aAddress, TDirection aDirection, unsigned short aSize, unsigned char* aPixels);
3.40
3.41 @@ -88,6 +84,12 @@
3.42 void BmpBoxDataInput(unsigned short aSize, unsigned char* aPixels);
3.43
3.44 private:
3.45 + void RequestDeviceId();
3.46 + void RequestFirmwareRevision();
3.47 + void RequestPowerSupplyStatus();
3.48 +
3.49 +
3.50 +private:
3.51 unsigned char OffScreenY() const;
3.52 void SendClearCommand();
3.53 void OffScreenTranslation(unsigned char& aX, unsigned char& aY);
3.54 @@ -122,6 +124,8 @@
3.55 char iDeviceId[KFutabaMaxHidReportSize];
3.56 char iFirmwareRevision[KFutabaMaxHidReportSize];
3.57 bool iPowerOn;
3.58 + //
3.59 + unsigned short iNextFrameAddress;
3.60 };
3.61
3.62
4.1 --- a/FutabaVfd.h Sat Aug 30 18:43:54 2014 +0200
4.2 +++ b/FutabaVfd.h Sun Aug 31 17:42:10 2014 +0200
4.3 @@ -6,7 +6,6 @@
4.4 #define FUTABA_VFD_H
4.5
4.6 #include "hidapi.h"
4.7 -#include "HidDevice.h"
4.8 #include "BitArray.h"
4.9 #include "MiniDisplay.h"
4.10 #include "Display.h"
4.11 @@ -71,7 +70,7 @@
4.12
4.13 /**
4.14 */
4.15 -class FutabaGraphicDisplay : public GraphicDisplay, public HidDevice
4.16 +class FutabaGraphicDisplay : public GraphicDisplay
4.17 {
4.18 public:
4.19 //From DisplayBase
5.1 --- a/MiniDisplay.cpp Sat Aug 30 18:43:54 2014 +0200
5.2 +++ b/MiniDisplay.cpp Sun Aug 31 17:42:10 2014 +0200
5.3 @@ -141,19 +141,19 @@
5.4 //-------------------------------------------------------------
5.5 wchar_t* MiniDisplayVendor(MiniDisplayDevice aDevice)
5.6 {
5.7 - return ((GP1212A01A*)aDevice)->Vendor();
5.8 + return ((GraphicDisplay*)aDevice)->Vendor();
5.9 }
5.10
5.11 //-------------------------------------------------------------
5.12 wchar_t* MiniDisplayProduct(MiniDisplayDevice aDevice)
5.13 {
5.14 - return ((GP1212A01A*)aDevice)->Product();
5.15 + return ((GraphicDisplay*)aDevice)->Product();
5.16 }
5.17
5.18 //-------------------------------------------------------------
5.19 wchar_t* MiniDisplaySerialNumber(MiniDisplayDevice aDevice)
5.20 {
5.21 - return ((GP1212A01A*)aDevice)->SerialNumber();
5.22 + return ((GraphicDisplay*)aDevice)->SerialNumber();
5.23 }
5.24
5.25 //-------------------------------------------------------------
5.26 @@ -177,7 +177,7 @@
5.27 //-------------------------------------------------------------
5.28 void MiniDisplayCancelRequest(MiniDisplayDevice aDevice)
5.29 {
5.30 - ((GP1212A01A*)aDevice)->CancelRequest();
5.31 + ((GraphicDisplay*)aDevice)->CancelRequest();
5.32 }
5.33
5.34 //-------------------------------------------------------------