#include "DynamicKeyboardController.h"\r
\r
+\r
+#ifdef __MACOSX__\r
+#include <SerialMac.hpp>\r
+#else\r
#include <ArduinoSerial\SerialWindows.hpp>\r
+#endif\r
\r
#include <cstdio>\r
\r
{\r
try\r
{\r
+#ifdef WIN32\r
_comPort = new SerialWindows(port, baudrate);\r
+#elif __MACOSX__\r
+ _comPort = new SerialMac(port, baudrate);\r
+#endif\r
}\r
catch (...)\r
{\r
{\r
if (!_comPort)\r
return false;\r
- _comPort->WriteData("I",1);\r
+ _comPort->WriteData((void *)("I"),1);\r
+#ifdef WIN32\r
Sleep(1000);\r
-\r
+#else\r
+ sleep(1000);\r
+#endif\r
/*\r
we currently receive 2 bytes for 16 keys states, max DC, min DC and boost duration\r
We may receive more bytes in the future if we handle more keys\r
#ifndef __DYNAMICKEYBOARDCONTROLLER__\r
#define __DYNAMICKEYBOARDCONTROLLER__\r
\r
+#ifdef __MACOSX__\r
+#include <Serial.hpp>\r
+#define EXPORTED\r
+#else\r
#include <ArduinoSerial\Serial.hpp>\r
+#define EXPORTED __declspec(dllexport)\r
+#endif\r
\r
#include <iostream>\r
\r
port is the COM port for the communication with the Arduino Board\r
baudrate is the baudrate for the communication, the default value may be sufficient\r
*/\r
- __declspec(dllexport) DynamicKeyboardController(char *port, int baudrate = 115200);\r
+\r
+ EXPORTED DynamicKeyboardController(char *port, int baudrate = 115200);\r
\r
/* sets a configuration on keys\r
XY is the configuration. Here 1 represent a raised key, \r
0 a lowered key.\r
*/\r
- __declspec(dllexport) void setConfiguration(UINT16 config);\r
+ EXPORTED void setConfiguration(UINT16 config);\r
/*\r
raise the specified keys\r
1 raises a key, 0 does not change its state\r
*/\r
- __declspec(dllexport) void raiseKeys(UINT16 config);\r
+ EXPORTED void raiseKeys(UINT16 config);\r
/*\r
lowers the specified keys\r
1 lowers a key, 0 does not change its state\r
*/\r
- __declspec(dllexport) void lowerKeys(UINT16 config);\r
+ EXPORTED void lowerKeys(UINT16 config);\r
\r
/*\r
higher duty cycle values results to higher voltage\r
the values are choosen with empirical tests, \r
depending on the solenoids and the power supply\r
*/\r
- __declspec(dllexport) void setMaximumDutyCycle(UINT8 val) const;\r
- __declspec(dllexport) void setMinimumDutyCycle(UINT8 val) const;\r
+ EXPORTED void setMaximumDutyCycle(UINT8 val) const;\r
+ EXPORTED void setMinimumDutyCycle(UINT8 val) const;\r
\r
/*\r
The shorter the boost mode the better since it goes beyond the standards\r
The longer the boost mode is, the longer we should wait before changing \r
the keys state again.\r
*/\r
- __declspec(dllexport) void setBoostDuration(UINT16) const;\r
+ EXPORTED void setBoostDuration(UINT16) const;\r
\r
/*\r
returns the state of the solenoids, the max and min duty cycle and the boost duration\r
*/\r
- __declspec(dllexport) bool getState(UINT16 &solenoids, UINT8 &minDutyCycle, UINT8 &maxDutyCycle, UINT16 &boostDuration) const;\r
+ EXPORTED bool getState(UINT16 &solenoids, UINT8 &minDutyCycle, UINT8 &maxDutyCycle, UINT16 &boostDuration) const;\r
\r
/*\r
returns on the stream the state of the solenoids, the max and min duty cycle and the boost duration\r
*/\r
- __declspec(dllexport) friend std::ostream& operator<< (std::ostream& stream, const DynamicKeyboardController& controller);\r
+ EXPORTED friend std::ostream& operator<< (std::ostream& stream, const DynamicKeyboardController& controller);\r
\r
protected:\r
Serial *_comPort;\r