Implementing and C API to control our MiniDisplay.
1.1 --- a/MiniDisplay.cpp Sun Jun 29 20:38:15 2014 +0200
1.2 +++ b/MiniDisplay.cpp Mon Jul 07 21:32:47 2014 +0200
1.3 @@ -0,0 +1,95 @@
1.4 +
1.5 +#include "MiniDisplay.h"
1.6 +#include "FutabaVfd.h"
1.7 +
1.8 +
1.9 +
1.10 +
1.11 +
1.12 +//Open & Close functions
1.13 +MiniDisplayDevice MiniDisplayOpen()
1.14 + {
1.15 + GP1212A01A* device=NULL;
1.16 + device=new GP1212A01A();
1.17 + int success = device->Open();
1.18 + if (!success)
1.19 + {
1.20 + delete device;
1.21 + return NULL;
1.22 + }
1.23 +
1.24 + return device;
1.25 + }
1.26 +
1.27 +void MiniDisplayClose(MiniDisplayDevice aDevice)
1.28 + {
1.29 + delete aDevice;
1.30 + //device = NULL;
1.31 + }
1.32 +
1.33 +
1.34 +void MiniDisplayClear(MiniDisplayDevice aDevice)
1.35 + {
1.36 + if (!aDevice)
1.37 + {
1.38 + return;
1.39 + }
1.40 +
1.41 + ((GP1212A01A*)aDevice)->SetAllPixels(0x00);
1.42 + }
1.43 +
1.44 +
1.45 +void MiniDisplayFill(MiniDisplayDevice aDevice)
1.46 + {
1.47 + if (!aDevice)
1.48 + {
1.49 + return;
1.50 + }
1.51 +
1.52 + ((GP1212A01A*)aDevice)->SetAllPixels(0xFF);
1.53 + }
1.54 +
1.55 +
1.56 +void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice)
1.57 + {
1.58 + if (!aDevice)
1.59 + {
1.60 + return;
1.61 + }
1.62 +
1.63 + ((GP1212A01A*)aDevice)->SwapBuffers();
1.64 + }
1.65 +
1.66 +//-------------------------------------------------------------
1.67 +int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice)
1.68 + {
1.69 + if (!aDevice)
1.70 + {
1.71 + return 0;
1.72 + }
1.73 +
1.74 + return ((GP1212A01A*)aDevice)->MaxBrightness();
1.75 + }
1.76 +
1.77 +//-------------------------------------------------------------
1.78 +int MiniDisplayMinBrightness(MiniDisplayDevice aDevice)
1.79 + {
1.80 + if (!aDevice)
1.81 + {
1.82 + return 0;
1.83 + }
1.84 +
1.85 + return ((GP1212A01A*)aDevice)->MinBrightness();
1.86 + }
1.87 +
1.88 +//-------------------------------------------------------------
1.89 +void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness)
1.90 + {
1.91 + if (!aDevice)
1.92 + {
1.93 + return;
1.94 + }
1.95 +
1.96 + ((GP1212A01A*)aDevice)->SetBrightness(aBrightness);
1.97 + }
1.98 +
2.1 --- a/MiniDisplay.h Sun Jun 29 20:38:15 2014 +0200
2.2 +++ b/MiniDisplay.h Mon Jul 07 21:32:47 2014 +0200
2.3 @@ -5,23 +5,68 @@
2.4 #ifndef MINI_DISPLAY_H
2.5 #define MINI_DISPLAY_H
2.6
2.7 -/**
2.8 +/* Cmake will define MyLibrary_EXPORTS on Windows when it
2.9 +configures to build a shared library. If you are going to use
2.10 +another build system on windows or create the visual studio
2.11 +projects by hand you need to define MyLibrary_EXPORTS when
2.12 +building a DLL on windows.
2.13 */
2.14 -class IMiniDisplay
2.15 - {
2.16 -public:
2.17 -
2.18 - };
2.19 +// We are using the Visual Studio Compiler and building Shared libraries
2.20
2.21 +#if defined (_WIN32)
2.22 + #if defined(MiniDisplay_EXPORTS)
2.23 + #define MDAPI __declspec(dllexport)
2.24 + #else
2.25 + #define MDAPI __declspec(dllimport)
2.26 + #endif /* MyLibrary_EXPORTS */
2.27 +#else /* defined (_WIN32) */
2.28 + #define MDAPI
2.29 +#endif
2.30 +
2.31 +typedef void* MiniDisplayDevice;
2.32 +
2.33 +//Open & Close functions
2.34 +extern "C" MDAPI MiniDisplayDevice MiniDisplayOpen();
2.35 +extern "C" MDAPI void MiniDisplayClose(MiniDisplayDevice aDevice);
2.36
2.37 /**
2.38 +Clear our MiniDisplay.
2.39 +@param [IN] The device to apply this command to.
2.40 */
2.41 -class MiniDisplay
2.42 - {
2.43 - static IMiniDisplay* Create();
2.44 +extern "C" MDAPI void MiniDisplayClear(MiniDisplayDevice aDevice);
2.45
2.46 - };
2.47 +/**
2.48 +Fill our MiniDisplay.
2.49 +@param [IN] The device to apply this command to.
2.50 +*/
2.51 +extern "C" MDAPI void MiniDisplayFill(MiniDisplayDevice aDevice);
2.52
2.53 +/**
2.54 +Swap our MiniDisplay buffers committing our back buffer content to the screen.
2.55 +@param [IN] The device to apply this command to.
2.56 +*/
2.57 +extern "C" MDAPI void MiniDisplaySwapBuffers(MiniDisplayDevice aDevice);
2.58 +
2.59 +/**
2.60 +Provide maximum brightness level for the given device.
2.61 +@param [IN] The device to apply this command to.
2.62 +@return Maximum brightness level.
2.63 +*/
2.64 +extern "C" MDAPI int MiniDisplayMaxBrightness(MiniDisplayDevice aDevice);
2.65 +
2.66 +/**
2.67 +Provide minimum brightness level for the given device.
2.68 +@param [IN] The device to apply this command to.
2.69 +@return Minimum brightness level.
2.70 +*/
2.71 +extern "C" MDAPI int MiniDisplayMinBrightness(MiniDisplayDevice aDevice);
2.72 +
2.73 +/**
2.74 +Set device brightness level.
2.75 +@param [IN] The device to apply this command to.
2.76 +@param [IN] Brightness level
2.77 +*/
2.78 +extern "C" MDAPI void MiniDisplaySetBrightness(MiniDisplayDevice aDevice, int aBrightness);
2.79
2.80
2.81 #endif