|
15 | 15 | #define Firmata_h |
16 | 16 |
|
17 | 17 | #include "Boards.h" /* Hardware Abstraction Layer + Wiring/Arduino */ |
18 | | -#include "FirmataConstants.h" |
| 18 | +#include "FirmataDefines.h" |
19 | 19 | #include "FirmataMarshaller.h" |
20 | 20 | #include "FirmataParser.h" |
21 | 21 |
|
|
48 | 48 | #define ENCODER 0x09 // same as PIN_MODE_ENCODER |
49 | 49 | #define IGNORE 0x7F // same as PIN_MODE_IGNORE |
50 | 50 |
|
51 | | -extern "C" { |
52 | | - // callback function types |
53 | | - typedef void (*callbackFunction)(uint8_t, int); |
54 | | - typedef void (*systemCallbackFunction)(void); |
55 | | - typedef void (*stringCallbackFunction)(char *); |
56 | | - typedef void (*sysexCallbackFunction)(uint8_t command, uint8_t argc, uint8_t *argv); |
57 | | -} |
| 51 | +namespace firmata { |
58 | 52 |
|
59 | 53 | // TODO make it a subclass of a generic Serial/Stream base class |
60 | 54 | class FirmataClass |
61 | 55 | { |
62 | 56 | public: |
| 57 | + typedef void (*callbackFunction)(uint8_t, int); |
| 58 | + typedef void (*systemCallbackFunction)(void); |
| 59 | + typedef void (*stringCallbackFunction)(char *); |
| 60 | + typedef void (*sysexCallbackFunction)(uint8_t command, uint8_t argc, uint8_t *argv); |
| 61 | + |
63 | 62 | FirmataClass(); |
64 | 63 |
|
65 | 64 | /* Arduino constructors */ |
@@ -92,10 +91,10 @@ class FirmataClass |
92 | 91 | void write(byte c); |
93 | 92 |
|
94 | 93 | /* attach & detach callback functions to messages */ |
95 | | - void attach(uint8_t command, ::callbackFunction newFunction); |
96 | | - void attach(uint8_t command, ::systemCallbackFunction newFunction); |
97 | | - void attach(uint8_t command, ::stringCallbackFunction newFunction); |
98 | | - void attach(uint8_t command, ::sysexCallbackFunction newFunction); |
| 94 | + void attach(uint8_t command, callbackFunction newFunction); |
| 95 | + void attach(uint8_t command, systemCallbackFunction newFunction); |
| 96 | + void attach(uint8_t command, stringCallbackFunction newFunction); |
| 97 | + void attach(uint8_t command, sysexCallbackFunction newFunction); |
99 | 98 | void detach(uint8_t command); |
100 | 99 |
|
101 | 100 | /* access pin state and config */ |
@@ -156,7 +155,17 @@ class FirmataClass |
156 | 155 | inline static void staticSystemResetCallback (void *) { if ( currentSystemResetCallback ) { currentSystemResetCallback(); } } |
157 | 156 | }; |
158 | 157 |
|
159 | | -extern FirmataClass Firmata; |
| 158 | +} // namespace firmata |
| 159 | + |
| 160 | +extern "C" { |
| 161 | + // callback function types |
| 162 | + typedef firmata::FirmataClass::callbackFunction callbackFunction; |
| 163 | + typedef firmata::FirmataClass::systemCallbackFunction systemCallbackFunction; |
| 164 | + typedef firmata::FirmataClass::stringCallbackFunction stringCallbackFunction; |
| 165 | + typedef firmata::FirmataClass::sysexCallbackFunction sysexCallbackFunction; |
| 166 | +} |
| 167 | + |
| 168 | +extern firmata::FirmataClass Firmata; |
160 | 169 |
|
161 | 170 | /*============================================================================== |
162 | 171 | * MACROS |
|
0 commit comments