EasyVR Library
1.3
|
An implementation of the EasyVR communication protocol.
enum ModuleId |
enum Language |
enum Group |
enum Wordset |
enum Knob |
Confidence thresholds for the knob settings, used for recognition of built-in words or custom grammars (not used for the mixed trigger group)
enum Level |
Strictness values for the level settings, used for recognition of custom commands (not used for the mixed trigger group)
enum Baudrate |
enum WakeMode |
Constants for choosing wake-up method in sleep mode
enum ClapSense |
Hands-clap sensitivity for wakeup from sleep mode. Use in combination with WAKE_ON_2CLAPS or WAKE_ON_3CLAPS
enum PinConfig |
enum PinNumber |
enum SoundVolume |
enum SoundIndex |
enum GrammarFlag |
enum RejectionLevel |
enum ErrorCode |
Error codes used by various functions
EasyVR | ( | Stream & | s | ) |
bool detect | ( | ) |
Detects an EasyVR module, waking it from sleep mode and checking it responds correctly.
true | if a compatible module has been found |
bool stop | ( | ) |
Interrupts pending recognition or playback operations.
true | if the request is satisfied and the module is back to ready |
int8_t getID | ( | ) |
Gets the module identification number (firmware version).
integer | is one of the values in ModuleId |
bool setLanguage | ( | int8_t | lang | ) |
Sets the language to use for recognition of built-in words.
lang | (0-5) is one of values in Language |
true | if the operation is successful |
bool setTimeout | ( | int8_t | seconds | ) |
Sets the timeout to use for any recognition task.
seconds | (0-31) is the maximum time the module keep listening for a word or a command |
true | if the operation is successful |
bool setKnob | ( | int8_t | knob | ) |
Sets the confidence threshold to use for recognition of built-in words.
knob | (0-4) is one of values in Knob |
true | if the operation is successful |
bool setLevel | ( | int8_t | level | ) |
Sets the strictness level to use for recognition of custom commands.
level | (1-5) is one of values in Level |
true | if the operation is successful |
bool setDelay | ( | uint16_t | millis | ) |
Sets the delay before any reply of the module.
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. |
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.
baud | is one of values in Baudrate |
true | if the operation is successful |
bool sleep | ( | int8_t | mode | ) |
bool addCommand | ( | int8_t | group, |
int8_t | index | ||
) |
Adds a new custom command to a group.
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 |
true | if the operation is successful |
bool removeCommand | ( | int8_t | group, |
int8_t | index | ||
) |
Removes a custom command from a group.
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 |
true | if the operation is successful |
bool setCommandLabel | ( | int8_t | group, |
int8_t | index, | ||
const char * | name | ||
) |
Sets the name of a custom command.
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 |
true | if the operation is successful |
bool eraseCommand | ( | int8_t | group, |
int8_t | index | ||
) |
Erases the training data of a custom command.
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 | is a string containing the label to be assigned to the specified command |
true | if the operation is successful |
bool getGroupMask | ( | uint32_t & | mask | ) |
Gets a bit mask of groups that contain at least one command.
mask | is a variable to hold the group mask when the function returns |
true | if the operation is successful |
int8_t getCommandCount | ( | int8_t | group | ) |
Gets the number of commands in the specified group.
group | (0-16) is the target group, or one of the values in #Groups |
integer | is the count of commands (negative in case of errors) |
bool dumpCommand | ( | int8_t | group, |
int8_t | index, | ||
char * | name, | ||
uint8_t & | training | ||
) |
Retrieves the name and training data of a custom command.
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() |
true | if the operation is successful |
int8_t getGrammarsCount | ( | void | ) |
Gets the total number of grammars available, including built-in and custom.
integer | is the count of grammars (negative in case of errors) |
bool dumpGrammar | ( | int8_t | grammar, |
uint8_t & | flags, | ||
uint8_t & | count | ||
) |
Retrieves the contents of a built-in or a custom grammar. Command labels contained in the grammar can be obtained by calling getNextWordLabel()
grammar | (0-31) is the target grammar, or one of the values in Wordset |
flags | is a variable that holds some grammar flags when the function returns. See GrammarFlag |
count | is a variable that holds the number of words in the grammar when the function returns. |
true | if the operation is successful |
bool getNextWordLabel | ( | char * | name | ) |
Retrieves the name of a command contained in a custom grammar. It must be called after dumpGrammar()
name | points to an array of at least 32 characters that holds the command label when the function returns |
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.
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 |
void recognizeCommand | ( | int8_t | group | ) |
Starts recognition of a custom command. Results are available after hasFinished() returns true.
group | (0-16) is the target group, or one of the values in #Groups |
void recognizeWord | ( | int8_t | wordset | ) |
Starts recognition of a built-in word. Results are available after hasFinished() returns true.
wordset | (0-3) is the target word set, or one of the values in Wordset, (4-31) is the target custom grammar, if present |
bool hasFinished | ( | ) |
Polls the status of on-going recognition, training or asynchronous playback tasks.
true | if the operation has completed |
int8_t getCommand | ( | ) |
Gets the recognised command index if any.
(0-31) | is the command index if recognition is successful, (-1) if no command has been recognized or an error occurred |
int8_t getWord | ( | ) |
Gets the recognised word index if any, from built-in sets or custom grammars.
(0-31) | is the command index if recognition is successful, (-1) if no built-in word has been recognized or an error occurred |
int16_t getToken | ( | ) |
Gets the index of the received SonicNet token if any.
integer | is the index of the received SonicNet token (0-255 for 8-bit tokens or 0-15 for 4-bit tokens) if detection was successful, (-1) if no token has been received or an error occurred |
int16_t getError | ( | ) |
Gets the last error code if any.
(0-255) | is the error code, (-1) if no error occurred |
bool isTimeout | ( | ) |
Retrieves the timeout indicator.
true | if a timeout occurred |
bool isConflict | ( | ) |
Retrieves the conflict indicator.
true | is a conflict occurred during training. To know what caused the conflict, use getCommand() and getWord() (only valid for triggers) |
bool isMemoryFull | ( | ) |
Retrieves the memory full indicator (only valid after addCommand() returned false).
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 | ||
) |
int8_t getPinInput | ( | int8_t | pin, |
int8_t | config | ||
) |
void detectToken | ( | int8_t | bits, |
int8_t | rejection, | ||
uint16_t | timeout | ||
) |
Starts listening for a SonicNet token. Manually check for completion with hasFinished().
bits | (4 or 8) specifies the length of received tokens |
rejection | (0-2) specifies the noise rejection level, it can be one of the values in RejectionLevel |
timeout | (1-28090) is the maximum time in milliseconds to keep listening for a valid token or (0) to listen without time limits. |
void sendTokenAsync | ( | int8_t | bits, |
uint8_t | token | ||
) |
Starts immediate playback of a SonicNet token. Manually check for completion with hasFinished().
bits | (4 or 8) specifies the length of trasmitted token |
token | is the index of the SonicNet token to play (0-255 for 8-bit tokens or 0-15 for 4-bit tokens) |
bool sendToken | ( | int8_t | bits, |
uint8_t | token | ||
) |
Plays a SonicNet token and waits for completion.
bits | (4 or 8) specifies the length of trasmitted token |
token | is the index of the SonicNet token to play (0-255 for 8-bit tokens or 0-15 for 4-bit tokens) |
true | if the operation is successful |
bool embedToken | ( | int8_t | bits, |
uint8_t | token, | ||
uint16_t | delay | ||
) |
Schedules playback of a SonicNet token after the next sound starts playing.
bits | (4 or 8) specifies the length of trasmitted token |
token | is the index of the SonicNet token to play (0-255 for 8-bit tokens or 0-15 for 4-bit tokens) |
delay | (1-28090) is the time in milliseconds at which to send the token, since the beginning of the next sound playback |
true | if the operation is successful |
void playSoundAsync | ( | int16_t | index, |
int8_t | volume | ||
) |
Starts playback of a sound from the sound table. Manually check for completion with hasFinished().
index | is the index of the target sound in the sound table |
volume | (0-31) may be one of the values in SoundVolume |
bool playSound | ( | int16_t | index, |
int8_t | volume | ||
) |
Plays a sound from the sound table and waits for completion
index | is the index of the target sound in the sound table |
volume | (0-31) may be one of the values in SoundVolume |
true | if the operation is successful |
bool dumpSoundTable | ( | char * | name, |
int16_t & | count | ||
) |
Retrieves the name of the sound table and the number of sounds it contains
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 |
true | if the operation is successful |
bool playPhoneTone | ( | int8_t | tone, |
uint8_t | duration | ||
) |
Plays a phone tone and waits for completion
tone | is the index of the tone (0-9 for digits, 10 for '*' key, 11 for '#' key and 12-15 for extra keys 'A' to 'D', -1 for the dial tone) |
duration | (1-32) is the tone duration in 40 milliseconds units, or in seconds for the dial tone |
true | if the operation is successful |
bool resetAll | ( | ) |
Empties internal memory for custom commands and groups.
true | if the operation is successful |