# HG changeset patch # User sl # Date 1404838781 -7200 # Node ID 36894fc4dad6acd5c04516f0cf3192af8bd5a992 # Parent d235c10ff460fd75faab4740ed460690d78c2b0d Adding APIs for string and requests. diff -r d235c10ff460 -r 36894fc4dad6 FutabaVfd.cpp --- a/FutabaVfd.cpp Mon Jul 07 22:27:56 2014 +0200 +++ b/FutabaVfd.cpp Tue Jul 08 18:59:41 2014 +0200 @@ -82,7 +82,7 @@ iFrameBeta(NULL), iFrameGamma(NULL), iNeedFullFrameUpdate(0), - iRequest(ERequestNone),iPowerOn(false) + iRequest(EMiniDisplayRequestNone),iPowerOn(false) { //ResetBuffers(); } @@ -547,7 +547,7 @@ report[6]=0x44; //Command ID if (Write(report)==report.Size()) { - iRequest=ERequestDeviceId; + iRequest=EMiniDisplayRequestDeviceId; } } @@ -573,7 +573,7 @@ report[6]=0x52; //Command ID if (Write(report)==report.Size()) { - iRequest=ERequestFirmwareRevision; + iRequest=EMiniDisplayRequestFirmwareRevision; } } @@ -598,7 +598,7 @@ report[6]=0x4D; //Command ID if (Write(report)==report.Size()) { - iRequest=ERequestPowerSupplyStatus; + iRequest=EMiniDisplayRequestPowerSupplyStatus; } } @@ -636,22 +636,22 @@ /** */ -GP1212A01A::Request GP1212A01A::AttemptRequestCompletion() +TMiniDisplayRequest GP1212A01A::AttemptRequestCompletion() { if (!RequestPending()) { - return ERequestNone; + return EMiniDisplayRequestNone; } int res=Read(iInputReport); if (!res) { - return ERequestNone; + return EMiniDisplayRequestNone; } //Process our request - if (CurrentRequest()==GP1212A01A::ERequestPowerSupplyStatus) + if (CurrentRequest()==EMiniDisplayRequestPowerSupplyStatus) { if (iInputReport[1]==0x4F && iInputReport[2]==0x4E) { @@ -663,9 +663,9 @@ } } - Request completed=iRequest; + TMiniDisplayRequest completed=iRequest; //Our request was completed - iRequest=ERequestNone; + iRequest=EMiniDisplayRequestNone; return completed; } diff -r d235c10ff460 -r 36894fc4dad6 FutabaVfd.h --- a/FutabaVfd.h Mon Jul 07 22:27:56 2014 +0200 +++ b/FutabaVfd.h Tue Jul 08 18:59:41 2014 +0200 @@ -8,6 +8,7 @@ #include "hidapi.h" #include "HidDevice.h" #include "BitArray.h" +#include "MiniDisplay.h" #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -117,13 +118,7 @@ class GP1212A01A : public GP1212XXXX { public: - enum Request - { - ERequestNone, - ERequestDeviceId, - ERequestFirmwareRevision, - ERequestPowerSupplyStatus - }; + public: GP1212A01A(); @@ -163,10 +158,10 @@ void SetFrameDifferencing(bool aOn){iUseFrameDifferencing=aOn;} bool FrameDifferencing() const {return iUseFrameDifferencing;} // - bool RequestPending(){return iRequest!=ERequestNone;} - Request CurrentRequest(){return iRequest;} - void CancelRequest(){iRequest=ERequestNone;} - Request AttemptRequestCompletion(); + bool RequestPending(){return iRequest!=EMiniDisplayRequestNone;} + TMiniDisplayRequest CurrentRequest(){return iRequest;} + void CancelRequest(){iRequest=EMiniDisplayRequestNone;} + TMiniDisplayRequest AttemptRequestCompletion(); FutabaVfdReport& InputReport() {return iInputReport;} bool PowerOn(){return iPowerOn;} @@ -208,7 +203,7 @@ //unsigned char iFrameBeta[256*64]; //unsigned char *iFrontBuffer; //unsigned char *iBackBuffer; - Request iRequest; + TMiniDisplayRequest iRequest; FutabaVfdReport iInputReport; bool iPowerOn; }; diff -r d235c10ff460 -r 36894fc4dad6 MiniDisplay.cpp --- a/MiniDisplay.cpp Mon Jul 07 22:27:56 2014 +0200 +++ b/MiniDisplay.cpp Tue Jul 08 18:59:41 2014 +0200 @@ -22,7 +22,7 @@ } void MiniDisplayClose(MiniDisplayDevice aDevice) - { + { delete aDevice; //device = NULL; } @@ -45,7 +45,7 @@ { return; } - + ((GP1212A01A*)aDevice)->SetAllPixels(0xFF); } @@ -56,7 +56,7 @@ { return; } - + ((GP1212A01A*)aDevice)->SwapBuffers(); } @@ -122,3 +122,57 @@ return ((GP1212A01A*)aDevice)->SetPixel(aX,aY,aValue); } +//------------------------------------------------------------- +wchar_t* MiniDisplayVendor(MiniDisplayDevice aDevice) + { + return ((GP1212A01A*)aDevice)->Vendor(); + } + +//------------------------------------------------------------- +wchar_t* MiniDisplayProduct(MiniDisplayDevice aDevice) + { + return ((GP1212A01A*)aDevice)->Product(); + } + +//------------------------------------------------------------- +wchar_t* MiniDisplaySerialNumber(MiniDisplayDevice aDevice) + { + return ((GP1212A01A*)aDevice)->SerialNumber(); + } + +//------------------------------------------------------------- +void MiniDisplayRequestDeviceId(MiniDisplayDevice aDevice) + { + ((GP1212A01A*)aDevice)->RequestDeviceId(); + } + +//------------------------------------------------------------- +void MiniDisplayRequestPowerSupplyStatus(MiniDisplayDevice aDevice) + { + ((GP1212A01A*)aDevice)->RequestPowerSupplyStatus(); + } + +//------------------------------------------------------------- +void MiniDisplayRequestFirmwareRevision(MiniDisplayDevice aDevice) + { + ((GP1212A01A*)aDevice)->RequestFirmwareRevision(); + } + +//------------------------------------------------------------- +bool MiniDisplayRequestPending(MiniDisplayDevice aDevice) + { + return ((GP1212A01A*)aDevice)->RequestPending(); + } + +//------------------------------------------------------------- +TMiniDisplayRequest MiniDisplayCurrentRequest(MiniDisplayDevice aDevice) + { + return ((GP1212A01A*)aDevice)->CurrentRequest(); + } + +//------------------------------------------------------------- +void MiniDisplayCancelRequest(MiniDisplayDevice aDevice) + { + ((GP1212A01A*)aDevice)->CancelRequest(); + } + diff -r d235c10ff460 -r 36894fc4dad6 MiniDisplay.h --- a/MiniDisplay.h Mon Jul 07 22:27:56 2014 +0200 +++ b/MiniDisplay.h Tue Jul 08 18:59:41 2014 +0200 @@ -13,7 +13,7 @@ */ // We are using the Visual Studio Compiler and building Shared libraries -#if defined (_WIN32) +#if defined (_WIN32) #if defined(MiniDisplay_EXPORTS) #define MDAPI __declspec(dllexport) #else @@ -25,6 +25,15 @@ typedef void* MiniDisplayDevice; +typedef enum + { + EMiniDisplayRequestNone, + EMiniDisplayRequestDeviceId, + EMiniDisplayRequestFirmwareRevision, + EMiniDisplayRequestPowerSupplyStatus + } +TMiniDisplayRequest; + //Open & Close functions extern "C" MDAPI MiniDisplayDevice MiniDisplayOpen(); extern "C" MDAPI void MiniDisplayClose(MiniDisplayDevice aDevice); @@ -93,6 +102,66 @@ //TODO: Have an API to specify pixel depth +/** +Provide vendor name. +@param [IN] The device to apply this command to. +@return Vendor name. +*/ +extern "C" MDAPI wchar_t* MiniDisplayVendor(MiniDisplayDevice aDevice); + +/** +Provide product name. +@param [IN] The device to apply this command to. +@return Product name. +*/ +extern "C" MDAPI wchar_t* MiniDisplayProduct(MiniDisplayDevice aDevice); + +/** +Provide Serial number. +@param [IN] The device to apply this command to. +@return Serial number name. +*/ +extern "C" MDAPI wchar_t* MiniDisplaySerialNumber(MiniDisplayDevice aDevice); + +/** +Request device ID. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplayRequestDeviceId(MiniDisplayDevice aDevice); + +/** +Request power status. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplayRequestPowerSupplyStatus(MiniDisplayDevice aDevice); + +/** +Request firmware version. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplayRequestFirmwareRevision(MiniDisplayDevice aDevice); + +/** +Tell whether or not a request is pending. +@param [IN] The device to apply this command to. +@return true if we have a request pending, false otherwise. +*/ +extern "C" MDAPI bool MiniDisplayRequestPending(MiniDisplayDevice aDevice); + + +/** +Provide the current request if any. +@param [IN] The device to apply this command to. +@return The current request if any. +*/ +extern "C" MDAPI TMiniDisplayRequest MiniDisplayCurrentRequest(MiniDisplayDevice aDevice); + + +/** +Cancel any pending request. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplayCancelRequest(MiniDisplayDevice aDevice); #endif