Now the Dev-C++ example for the EDU05 is ready.
Here is the link to download the project files: box.com/s/qn3or2y3j1lz20x8bgk4
[code]#include
#include <windows.h>
#include
using namespace std;
typedef int (__stdcall *VOID2INT)(void);
typedef int (__stdcall *INT2INT)(int);
typedef void (__stdcall *VOID2VOID)(void);
typedef void (__stdcall *INT2VOID)(int);
typedef void (__stdcall *CHARPINT2VOID)(char *, int);
typedef void (__stdcall *INTINT2VOID)(int, int);
VOID2INT OpenDevice;
VOID2VOID CloseDevice;
INT2INT ReadAnalogChannel;
INTINT2VOID SetPWM;
INT2VOID OutputAllDigital;
INT2VOID ClearDigitalChannel;
VOID2VOID ClearAllDigital;
INT2VOID SetDigitalChannel;
VOID2VOID SetAllDigital;
VOID2INT ReadAllDigital;
INT2VOID InOutMode;
VOID2INT Connected;
VOID2VOID LCDClear;
CHARPINT2VOID LCDWriteString;
HINSTANCE hDLL;
int foundDLL = 0;
int init();
int main(void)
{
int dataIn;
int h;
char message1[] = “Hello World!”;
h = init();
if (!h)
{
cout << "EDU05D.DLL opened" << endl;
foundDLL = 1;
}
else
{
cout << "Error to open / read EDU05D.DLL " << endl;
cout << "Error code: " << h << endl;
cout << "Press Enter to exit." << endl;
cin.get();
}
if (foundDLL)
{
h = OpenDevice();
switch (h)
{
case 0:
cout << "Card not found." << endl;
break;
case 1:
cout << "Card connected." << endl;
break;
}
}
if (foundDLL)
{
cout << "Press Enter to write \"Hello World!\" on LCD" << endl;
cin.get();
InOutMode(0);
LCDClear();
LCDWriteString(message1,0);
//LCDWriteString("Hello World!",0); // alternative method
cout << "Press Enter to \"Set All Digital\"" << endl;
cin.get();
InOutMode(0);
SetAllDigital();
cout << "Press Enter to \"Output All Digital 0x55\"" << endl;
cin.get();
OutputAllDigital(0x55);
cout << "Press Enter to \"Clear All Digital\"" << endl;
cin.get();
ClearAllDigital();
cout << "Press Enter to \"Read All Digital\"" << endl;
cin.get();
InOutMode(1);
int i = ReadAllDigital();
cout << i << endl;
cout << "Press Enter to \"Set PWM 2 to 255\"" << endl;
cin.get();
SetPWM(2, 255);
cout << "Press Enter to \"Read Analog channel #1\"" << endl;
cin.get();
dataIn = ReadAnalogChannel(1);
cout << dataIn << endl;
cout << "Press Enter to \"Close Device\" and to \"Free Library\"" << endl;
cin.get();
CloseDevice();
FreeLibrary(hDLL);
}
return EXIT_SUCCESS;
}
int init()
{
hDLL = LoadLibrary(“EDU05D.dll”);
if (hDLL == NULL)
{
return -1;
}
else
{
OpenDevice = (VOID2INT) GetProcAddress(hDLL, “OpenDevice”);
CloseDevice = (VOID2VOID) GetProcAddress(hDLL, “CloseDevice”);
ReadAnalogChannel = (INT2INT) GetProcAddress(hDLL, “ReadAnalogChannel”);
SetPWM = (INTINT2VOID) GetProcAddress(hDLL, “SetPWM”);
OutputAllDigital = (INT2VOID) GetProcAddress(hDLL, “OutputAllDigital”);
ClearDigitalChannel = (INT2VOID) GetProcAddress(hDLL, “ClearDigitalChannel”);
ClearAllDigital = (VOID2VOID) GetProcAddress(hDLL, “ClearAllDigital”);
SetDigitalChannel = (INT2VOID) GetProcAddress(hDLL, “SetDigitalChannel”);
SetAllDigital = (VOID2VOID) GetProcAddress(hDLL, “SetAllDigital”);
ReadAllDigital = (VOID2INT) GetProcAddress(hDLL, “ReadAllDigital”);
InOutMode = (INT2VOID) GetProcAddress(hDLL, “InOutMode”);
Connected = (VOID2INT) GetProcAddress(hDLL, “Connected”);
LCDClear = (VOID2VOID) GetProcAddress(hDLL, “LCDClear”);
LCDWriteString = (CHARPINT2VOID) GetProcAddress(hDLL, “LCDWriteString”);
if (!OpenDevice || !CloseDevice || !ReadAnalogChannel || !SetPWM
|| !OutputAllDigital || !ClearDigitalChannel
|| !ClearAllDigital || !SetDigitalChannel || !SetAllDigital
|| !ReadAllDigital || !InOutMode || !Connected
|| !LCDClear || !LCDWriteString)
{
FreeLibrary(hDLL);
return -2;
}
return 0;
}
}[/code]