Reference for Uduino's Arduino library.
| Name | Description |
|---|---|
boardName | const char*Board name, as it will be detected by Unity |
#include<Uduino.h>
Uduino uduino("boardName"); | Name | Description |
|---|---|
boardName | const char*Board name, as it will be detected by Unity |
separator | const char*Separator |
#include<Uduino.h>
Uduino uduino("boardName", "|"); // Set the character | as separator | Name | Description |
|---|---|
commandName | const char*Command Name |
function | void*Function to trigger when the command is received |
Arduino
void Setup()
uduino.addCommand("commandName",MyFunction);
}
void MyFunction() {
// code
}
Unity
UduinoManager.Instance.sendCommand("commandName"); | Name | Description |
|---|---|
function | void*New function when the board is connected |
| Name | Description |
|---|---|
function | void*New function when the board is disconnected |
| Name | Description |
|---|---|
function | voidFunction |
void setup() {
uduino.addDefaultHandler(DefaultFunction);
}
void DefaultFuntion() {
// default function
} | Name | Description |
|---|---|
NumberOfParameters | intNumber of parameters |
Unity
UduinoManager.Instance.sendCommand("myCommand", 10, 3);
Arduino
void setup() {
uduino.addCommand("myCommand", Command);
}
void Command() {
int parameters = uduino.getNumberOfParameters(); // returns 2
if(parameters > 0) {
int valueOne = uduino.charToInt(uduino.getParameter(0)); // returns 10
int valueTwo = uduino.charToInt(uduino.getParameter(1)); // returns 3
}
} | Name | Description |
|---|---|
index | unsigned shortParameter index |
| Name | Description |
|---|---|
Parameter value | char*Value as text |
Unity
UduinoManager.Instance.sendCommand("myCommand", 10, 3);
Arduino
void setup() {
uduino.addCommand("myCommand", Command);
}
void Command() {
int parameters = uduino.getNumberOfParameters(); // returns 2
if(parameters > 0) {
int valueOne = uduino.charToInt(uduino.getParameter(0)); // returns 10
int valueTwo = uduino.charToInt(uduino.getParameter(1)); // returns 3
}
} | Name | Description |
|---|---|
Parameter value | char*Value as text |
Unity
UduinoManager.Instance.sendCommand("myCommand", 10, 3);
Arduino
void setup() {
uduino.addCommand("myCommand", Command);
}
void Command() {
int value;
char *arg = NULL;
arg = uduino.next();
if (arg != NULL) {
value = atoi(arg); // returns 10
}
int valueTwo;
arg = uduino.next();
if (arg != NULL) {
valueTwo = atoi(arg); // returns 3
}
} void loop() {
uduino.update();
} | Name | Description |
|---|---|
isConnected | boolReturns true if a board is connected |
Arduino
void loop() {
uduino.update();
if(uduino.isConnected()) {
//..code
}
} | Name | Description |
|---|---|
duration | unsigned intDuration of the delay in
milliseconds |
| Name | Description |
|---|---|
arg | char* intDuration of the delay in milliseconds |
Unity
void setup() {
uduino.addCommand("myCommand", Command);
}
void Command() {
int value;
char *arg = NULL;
arg = uduino.next();
if (arg != NULL)
value = atoi(arg);
} These settings can be changed in the Uduino.h main file. This file is located under /documents/Arduino/libraries/Uduino.h
| Name | Description |
|---|
// file Uduino.h, ligne ~47
#define MAX_COMMANDS 30
| Name | Description |
|---|
// file Uduino.h, ligne ~46
#define MAX_COMMAND_NAME 30
// sketch
void setup () {
//...
uduino.addCommand("ThisIsALongCommandNameVeryLong", myFunction);
//...
}
| Name | Description |
|---|---|
name | intdesc |
Use uduino.update() instead.
| Name | Description |
|---|---|
name | intdesc |
Use uduino.isConnected() instead.
| Name | Description |
|---|---|
name | intdesc |
Use uduino.nextParameter() or uduino.getParameter( int index)