Public Types
- enum ModuleId {
VRBOT,
EASYVR
}
- enum Language {
ENGLISH,
ITALIAN,
JAPANESE,
GERMAN,
SPANISH,
FRENCH
}
- enum Group {
TRIGGER,
PASSWORD
}
- enum Wordset {
TRIGGER_SET,
ACTION_SET,
DIRECTION_SET,
NUMBER_SET
}
- enum Knob {
LOOSER,
LOOSE,
TYPICAL,
STRICT,
STRICTER
}
- enum Level {
EASY,
NORMAL,
HARD,
HARDER,
HARDEST
}
- enum Baudrate {
B115200,
B57600,
B38400,
B19200,
B9600
}
- enum WakeMode {
WAKE_ON_CHAR,
WAKE_ON_WHISTLE,
WAKE_ON_LOUDSOUND,
WAKE_ON_2CLAPS,
WAKE_ON_3CLAPS
}
- enum ClapSense {
CLAP_SENSE_LOW,
CLAP_SENSE_MID,
CLAP_SENSE_HIGH
}
- enum PinConfig {
OUTPUT_LOW,
OUTPUT_HIGH,
INPUT_HIZ,
INPUT_STRONG,
INPUT_WEAK
}
- enum PinNumber {
IO1,
IO2,
IO3
}
- enum SoundVolume {
VOL_MIN,
VOL_HALF,
VOL_FULL,
VOL_DOUBLE
}
- enum SoundIndex { BEEP
}
Public Member Functions
- EasyVR (Stream &s)
- bool detect ()
- bool stop ()
- int8_t getID ()
- bool setLanguage (int8_t lang)
- bool setTimeout (int8_t seconds)
- bool setKnob (int8_t knob)
- bool setLevel (int8_t level)
- bool setDelay (uint16_t millis)
- bool changeBaudrate (int8_t baud)
- bool sleep (int8_t mode)
- bool addCommand (int8_t group, int8_t index)
- bool removeCommand (int8_t group, int8_t index)
- bool setCommandLabel (int8_t group, int8_t index, const char *name)
- bool eraseCommand (int8_t group, int8_t index)
- bool getGroupMask (uint32_t &mask)
- int8_t getCommandCount (int8_t group)
- bool dumpCommand (int8_t group, int8_t index, char *name, uint8_t &training)
- void trainCommand (int8_t group, int8_t index)
- void recognizeCommand (int8_t group)
- void recognizeWord (int8_t wordset)
- bool hasFinished ()
- int8_t getCommand ()
- int8_t getWord ()
- int16_t getError ()
- bool isTimeout ()
- bool isConflict ()
- bool isMemoryFull ()
- bool setPinOutput (int8_t pin, int8_t value)
- int8_t getPinInput (int8_t pin, int8_t config)
- void playSoundAsync (int16_t index, int8_t volume)
- bool playSound (int16_t index, int8_t volume)
- bool dumpSoundTable (char *name, int16_t &count)
- bool resetAll ()
Detailed Description
An implementation of the EasyVR communication protocol.
Member Enumeration Documentation
Module identification number (firmware version)
- Enumerator:
VRBOT |
Identifies a VRbot module
|
EASYVR |
Identifies an EasyVR module
|
Language to use for recognition of built-in words
- Enumerator:
ENGLISH |
Uses the US English word sets
|
ITALIAN |
Uses the Italian word sets
|
JAPANESE |
Uses the Japanese word sets
|
GERMAN |
Uses the German word sets
|
SPANISH |
Uses the Spanish word sets
|
FRENCH |
Uses the French word sets
|
Special group numbers for recognition of custom commands
- Enumerator:
TRIGGER |
The trigger group (shared with built-in trigger word)
|
PASSWORD |
The password group (uses speaker verification technology)
|
Index of built-in word sets
- Enumerator:
TRIGGER_SET |
The built-in trigger word set
|
ACTION_SET |
The built-in action word set
|
DIRECTION_SET |
The built-in direction word set
|
NUMBER_SET |
The built-in number word set
|
Confidence thresholds for the knob settings, used for recognition of built-in words (except trigger)
- Enumerator:
LOOSER |
Lowest threshold, most results reported
|
LOOSE |
Lower threshold, more results reported
|
TYPICAL |
Typical threshold (deafult)
|
STRICT |
Higher threshold, fewer results reported
|
STRICTER |
Highest threshold, fewest results reported
|
Strictness values for the level settings, used for recognition of custom commands (except triggers)
- Enumerator:
EASY |
Lowest value, most results reported
|
NORMAL |
Typical value (default)
|
HARD |
Slightly higher value, fewer results reported
|
HARDER |
Higher value, fewer results reported
|
HARDEST |
Highest value, fewest results reported
|
Constants to use for baudrate settings
- Enumerator:
B115200 |
115200 bps
|
B57600 |
57600 bps
|
B38400 |
38400 bps
|
B19200 |
19200 bps
|
B9600 |
9600 bps (default)
|
Constants for choosing wake-up method in sleep mode
- Enumerator:
WAKE_ON_CHAR |
Wake up on any character received
|
WAKE_ON_WHISTLE |
Wake up on whistle or any character received
|
WAKE_ON_LOUDSOUND |
Wake up on a loud sound or any character received
|
WAKE_ON_2CLAPS |
Wake up on double hands-clap or any character received
|
WAKE_ON_3CLAPS |
Wake up on triple hands-clap or any character received
|
Hands-clap sensitivity for wakeup from sleep mode. Use in combination with WAKE_ON_2CLAPS or WAKE_ON_3CLAPS
- Enumerator:
CLAP_SENSE_LOW |
Lowest threshold
|
CLAP_SENSE_MID |
Typical threshold
|
CLAP_SENSE_HIGH |
Highest threshold
|
Pin configuration options for the extra I/O connector
- Enumerator:
OUTPUT_LOW |
Pin is a low output (0V)
|
OUTPUT_HIGH |
Pin is a high output (3V)
|
INPUT_HIZ |
Pin is an high impedance input
|
INPUT_STRONG |
Pin is an input with strong pull-up (~10K)
|
INPUT_WEAK |
Pin is an input with weak pull-up (~200K)
|
Available pin numbers on the extra I/O connector
- Enumerator:
IO1 |
Pin IO1
|
IO2 |
Pin IO2
|
IO3 |
Pin IO3
|
Some quick volume settings for the sound playback functions (any value in the range 0-31 can be used)
- Enumerator:
VOL_MIN |
Lowest volume (almost mute)
|
VOL_HALF |
Half scale volume (softer)
|
VOL_FULL |
Full scale volume (normal)
|
VOL_DOUBLE |
Double gain volume (louder)
|
Special sound index values, always available even when no soundtable is present
- Enumerator:
-
Constructor & Destructor Documentation
Creates an EasyVR object, using a communication object implementing the Stream interface (such as HardwareSerial, or the modified SoftwareSerial and NewSoftSerial).
- Parameters:
-
| s | the Stream object to use for communication with the EasyVR module |
Member Function Documentation
Detects an EasyVR module, waking it from sleep mode and checking it responds correctly.
- Return values:
-
| is | true if a compatible module has been found |
Interrupts pending recognition or playback operations.
- Return values:
-
| is | true if the request is satisfied and the module is back to ready |
Gets the module identification number (firmware version).
- Return values:
-
bool setLanguage |
( |
int8_t |
lang |
) |
|
Sets the language to use for recognition of built-in words.
- Parameters:
-
- Return values:
-
| is | true if the operation is successful |
bool setTimeout |
( |
int8_t |
seconds |
) |
|
Sets the timeout to use for any recognition task.
- Parameters:
-
| seconds | (0-31) is the maximum time the module keep listening for a word or a command |
- Return values:
-
| is | true if the operation is successful |
bool setKnob |
( |
int8_t |
knob |
) |
|
Sets the confidence threshold to use for recognition of built-in words.
- Parameters:
-
| knob | (0-4) is one of values in Knob |
- Return values:
-
| is | true if the operation is successful |
bool setLevel |
( |
int8_t |
level |
) |
|
Sets the strictness level to use for recognition of custom commands.
- Parameters:
-
| level | (1-5) is one of values in Level |
- Return values:
-
| is | true if the operation is successful |
bool setDelay |
( |
uint16_t |
millis |
) |
|
Sets the delay before any reply of the module.
- Parameters:
-
| millis | (0-1000) is the delay duration in milliseconds, rounded to 10 units in range 10-100 and to 100 units in range 100-1000. |
- Return values:
-
| is | true if the operation is successful |
bool changeBaudrate |
( |
int8_t |
baud |
) |
|
Sets the new communication speed. You need to modify the baudrate of the underlying Stream object accordingly, after the function returns successfully.
- Parameters:
-
- Return values:
-
| is | true if the operation is successful |
bool sleep |
( |
int8_t |
mode |
) |
|
Puts the module in sleep mode.
- Parameters:
-
| mode | is one of values in WakeMode, optionally combined with one of the values in ClapSense |
- Return values:
-
| is | true if the operation is successful |
bool addCommand |
( |
int8_t |
group, |
|
|
int8_t |
index | |
|
) |
| | |
Adds a new custom command to a group.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
- Return values:
-
| is | true if the operation is successful |
bool removeCommand |
( |
int8_t |
group, |
|
|
int8_t |
index | |
|
) |
| | |
Removes a custom command from a group.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
- Return values:
-
| is | true if the operation is successful |
bool setCommandLabel |
( |
int8_t |
group, |
|
|
int8_t |
index, |
|
|
const char * |
name | |
|
) |
| | |
Sets the name of a custom command.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
- Return values:
-
| is | true if the operation is successful |
bool eraseCommand |
( |
int8_t |
group, |
|
|
int8_t |
index | |
|
) |
| | |
Erases the training data of a custom command.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
- Return values:
-
| is | true if the operation is successful |
bool getGroupMask |
( |
uint32_t & |
mask |
) |
|
Gets a bit mask of groups that contain at least one command.
- Parameters:
-
| mask | is a variable to hold the group mask when the function returns |
- Return values:
-
| is | true if the operation is successful |
int8_t getCommandCount |
( |
int8_t |
group |
) |
|
Gets the number of commands in the specified group.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
- Return values:
-
bool dumpCommand |
( |
int8_t |
group, |
|
|
int8_t |
index, |
|
|
char * |
name, |
|
|
uint8_t & |
training | |
|
) |
| | |
Retrieves the name and training data of a custom command.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
| name | points to an array of at least 32 characters that holds the command label when the function returns |
| training | is a variable that holds the training count when the function returns. Additional information about training is available through the functions isConflict() and getWord() or getCommand() |
- Return values:
-
| is | true if the operation is successful |
void trainCommand |
( |
int8_t |
group, |
|
|
int8_t |
index | |
|
) |
| | |
Starts training of a custom command. Results are available after hasFinished() returns true.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
| index | (0-31) is the index of the command within the selected group |
- Note:
- The module is busy until training completes and it cannot accept other commands. You can interrupt training with stop().
void recognizeCommand |
( |
int8_t |
group |
) |
|
Starts recognition of a custom command. Results are available after hasFinished() returns true.
- Parameters:
-
| group | (0-16) is the target group, or one of the values in Groups |
- Note:
- The module is busy until recognition completes and it cannot accept other commands. You can interrupt recognition with stop().
void recognizeWord |
( |
int8_t |
wordset |
) |
|
Starts recognition of a built-in word. Results are available after hasFinished() returns true.
- Parameters:
-
| wordset | (0-3) is the target word set, or one of the values in Wordset |
- Note:
- The module is busy until recognition completes and it cannot accept other commands. You can interrupt recognition with stop().
Polls the status of on-going recognition, training or asynchronous playback tasks.
- Return values:
-
| is | true if the operation has completed |
Gets the recognised command index if any.
- Return values:
-
| (0-31) | is the command index if recognition is successful, (-1) if no command has been recognized or an error occured |
Gets the recognised built-in word index if any.
- Return values:
-
| (0-31) | is the command index if recognition is successful, (-1) if no built-in word has been recognized or an error occured |
Gets the last error code if any.
- Return values:
-
| (0-255) | is the error code, (-1) if no error occured |
Retrieves the timeout indicator.
- Return values:
-
| is | true if a timeout occurred |
Retrieves the conflict indicator.
- Return values:
-
| is | true is a conflict occurred during training. To know what caused the conflict, use getCommand() and getWord() (only valid for triggers) |
Retrieves the memory full indicator (only valid after addCommand() returned false).
- Return values:
-
| is | true if a command could not be added because of memory size constaints (up to 32 custom commands can be created) |
bool setPinOutput |
( |
int8_t |
pin, |
|
|
int8_t |
value | |
|
) |
| | |
Configures an I/O pin as an output and sets its value
- Parameters:
-
| pin | (1-3) is one of values in PinNumber |
| pin | (0-1) is one of the output values in PinConfig, or Arduino style HIGH and LOW macros |
- Return values:
-
| is | true if the operation is successful |
int8_t getPinInput |
( |
int8_t |
pin, |
|
|
int8_t |
config | |
|
) |
| | |
Configures an I/O pin as an input with optional pull-up and return its value
- Parameters:
-
- Return values:
-
void playSoundAsync |
( |
int16_t |
index, |
|
|
int8_t |
volume | |
|
) |
| | |
Starts playback of a sound from the sound table. Manually check for completion with hasFinished().
- Parameters:
-
| index | is the index of the target sound in the sound table |
| volume | (0-31) may be one of the values in SoundVolume |
- Note:
- The module is busy until playback completes and it cannot accept other commands. You can interrupt playback with stop().
bool playSound |
( |
int16_t |
index, |
|
|
int8_t |
volume | |
|
) |
| | |
Plays a sound from the sound table and waits for completion
- Parameters:
-
| index | is the index of the target sound in the sound table |
| volume | (0-31) may be one of the values in SoundVolume |
- Return values:
-
| is | true if the operation is successful |
- Note:
- To alter the maximum time for the wait, define the EASYVR_PLAY_TIMEOUT macro before including the EasyVR library.
bool dumpSoundTable |
( |
char * |
name, |
|
|
int16_t & |
count | |
|
) |
| | |
Retrieves the name of the sound table and the number of sounds it contains
- Parameters:
-
| name | points to an array of at least 32 characters that holds the sound table label when the function returns |
| count | is a variable that holds the number of sounds when the function returns |
- Return values:
-
| is | true if the operation is successful |
Empties internal memory for custom commands and groups.
- Return values:
-
| is | true if the operation is successful |
- Note:
- It will take about 35 seconds for the whole process to complete and it cannot be interrupted. During this time the module cannot accept any other command. The sound table data is not affected.