# HG changeset patch # User sl # Date 1404761567 -7200 # Node ID d8186e7b69bfa46300ebf36d0b4799cf6c8c04e8 # Parent dd5eef0de75accb4e6bf186d25beb33c5812edd8 Implementing and C API to control our MiniDisplay. diff -r dd5eef0de75a -r d8186e7b69bf MiniDisplay.cpp --- a/MiniDisplay.cpp Sun Jun 29 20:38:15 2014 +0200 +++ b/MiniDisplay.cpp Mon Jul 07 21:32:47 2014 +0200 @@ -0,0 +1,95 @@ + +#include "MiniDisplay.h" +#include "FutabaVfd.h" + + + + + +//Open & Close functions +MiniDisplayDevice MiniDisplayOpen() + { + GP1212A01A* device=NULL; + device=new GP1212A01A(); + int success = device->Open(); + if (!success) + { + delete device; + return NULL; + } + + return device; + } + +void MiniDisplayClose(MiniDisplayDevice aDevice) + { + delete aDevice; + //device = NULL; + } + + +void MiniDisplayClear(MiniDisplayDevice aDevice) + { + if (!aDevice) + { + return; + } + + ((GP1212A01A*)aDevice)->SetAllPixels(0x00); + } + + +void MiniDisplayFill(MiniDisplayDevice aDevice) + { + if (!aDevice) + { + return; + } + + ((GP1212A01A*)aDevice)->SetAllPixels(0xFF); + } + + +void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice) + { + if (!aDevice) + { + return; + } + + ((GP1212A01A*)aDevice)->SwapBuffers(); + } + +//------------------------------------------------------------- +int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice) + { + if (!aDevice) + { + return 0; + } + + return ((GP1212A01A*)aDevice)->MaxBrightness(); + } + +//------------------------------------------------------------- +int MiniDisplayMinBrightness(MiniDisplayDevice aDevice) + { + if (!aDevice) + { + return 0; + } + + return ((GP1212A01A*)aDevice)->MinBrightness(); + } + +//------------------------------------------------------------- +void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness) + { + if (!aDevice) + { + return; + } + + ((GP1212A01A*)aDevice)->SetBrightness(aBrightness); + } + diff -r dd5eef0de75a -r d8186e7b69bf MiniDisplay.h --- a/MiniDisplay.h Sun Jun 29 20:38:15 2014 +0200 +++ b/MiniDisplay.h Mon Jul 07 21:32:47 2014 +0200 @@ -5,23 +5,68 @@ #ifndef MINI_DISPLAY_H #define MINI_DISPLAY_H -/** +/* Cmake will define MyLibrary_EXPORTS on Windows when it +configures to build a shared library. If you are going to use +another build system on windows or create the visual studio +projects by hand you need to define MyLibrary_EXPORTS when +building a DLL on windows. */ -class IMiniDisplay - { -public: - - }; +// We are using the Visual Studio Compiler and building Shared libraries +#if defined (_WIN32) + #if defined(MiniDisplay_EXPORTS) + #define MDAPI __declspec(dllexport) + #else + #define MDAPI __declspec(dllimport) + #endif /* MyLibrary_EXPORTS */ +#else /* defined (_WIN32) */ + #define MDAPI +#endif + +typedef void* MiniDisplayDevice; + +//Open & Close functions +extern "C" MDAPI MiniDisplayDevice MiniDisplayOpen(); +extern "C" MDAPI void MiniDisplayClose(MiniDisplayDevice aDevice); /** +Clear our MiniDisplay. +@param [IN] The device to apply this command to. */ -class MiniDisplay - { - static IMiniDisplay* Create(); +extern "C" MDAPI void MiniDisplayClear(MiniDisplayDevice aDevice); - }; +/** +Fill our MiniDisplay. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplayFill(MiniDisplayDevice aDevice); +/** +Swap our MiniDisplay buffers committing our back buffer content to the screen. +@param [IN] The device to apply this command to. +*/ +extern "C" MDAPI void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice); + +/** +Provide maximum brightness level for the given device. +@param [IN] The device to apply this command to. +@return Maximum brightness level. +*/ +extern "C" MDAPI int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice); + +/** +Provide minimum brightness level for the given device. +@param [IN] The device to apply this command to. +@return Minimum brightness level. +*/ +extern "C" MDAPI int MiniDisplayMinBrightness(MiniDisplayDevice aDevice); + +/** +Set device brightness level. +@param [IN] The device to apply this command to. +@param [IN] Brightness level +*/ +extern "C" MDAPI void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness); #endif