Little Robot Friends
Arduino Library Reference
version 1.1
|
Collection of custom types and handy functions used throughout the LRF codebase. More...
#include <Arduino.h>
Go to the source code of this file.
Classes | |
struct | LRFColorValue |
Data structure for holding RGB color values. More... | |
struct | LRFPatternStruct |
Structure for driving LED light patterns. More... | |
union | LRFPattern |
Allows for access of pattern data as a structure or raw integer. More... | |
struct | LRFSoundStruct |
Structure for driving expressive robot sounds. More... | |
union | LRFSound |
Allows for access of sound data as a structure or raw integer. More... | |
Macros | |
#define | LRFSoundStruct_Blank {LRFNote_NULL,0,0,0,0} |
an empty sound (used frequenty in LRFExpressionData and LRFSignatureData) | |
Enumerations | |
enum | LRFColor |
Constants for looking up color values stored in program memory (PROGMEM) More... | |
enum | LRFPatternMode |
Predefined pattern animations. More... | |
enum | LRFNote |
Constants for notes in the musical scale. More... | |
enum | LRFOctave |
Constants for octaves in the musical scale. More... | |
enum | LRFIntonation |
Constants for speech intonation (or pitch bend) More... | |
enum | LRFDuration |
Constants for fixed note durations based on musical timingWe found that a short list of fixed durations covered a pretty wide range of sound timings that would be required when created new sounds. By taking this approach, we are also able to pack a lot more sound data into a smaller space - meaning more sounds for all! These constants map to a lookup table (in LRFUtils.h) that contains the actual duration values in milliseconds (as an unsigned int). More... | |
Functions | |
void | lrf_utils_color_lookup (LRFColor color, LRFColorValue *value) |
Utility for looking up LRFColorValue data from LRFColor constant. More... | |
void | lrf_utils_color_lookup_random (LRFColorValue *value) |
Utility for generating a random LRFColorValue. More... | |
unsigned int | lrf_utils_duration_lookup (LRFDuration duration) |
Utility for looking up duration values (in milliseconds) from a LRFDuration constant. More... | |
unsigned int | lrf_utils_note_to_frequency (LRFNote note, LRFOctave octave) |
Utility for looking up frequency values from LRFNote and LRFOctave constants. More... | |
enum LRFColor |
The LRF uses 16 predefined colors for all its light patterns. These values (LRFColorValue) can be viewed in the implementation of this file (LRFUtils.cpp). These values can be changed, but be sure to update any references you might make to your new custom color, as they may affect built in patterns in the LRFExpressionData.cpp or LRFSignatureData.cpp files.
Definition at line 46 of file LRFUtils.h.
enum LRFPatternMode |
Every pattern contains a pattern 'mode' that defines how it animates between the start and target colors (LRFColor). There are a handful of animations that cover a wide range of possibilties.
Check out the list of patterns below for a full explaination, and of course - these patterns can always be customized further!
Definition at line 90 of file LRFUtils.h.
enum LRFNote |
Most sounds uttered by the LRF are pinned to the frequencies of common musical notes. These frequencies are stored in program memory (in LRFUtils.cpp) as a lookup table.
This enum is packed to 4-bits (with 13 possible values)
Definition at line 174 of file LRFUtils.h.
enum LRFOctave |
The octave constants allow for shifting our stored note frequencies into higher ranges for a wider variety of sounds. Not all notes are playable for all octaves, since some of them overload the frequency timer - so it's kinda trial and error.
This enum is packed to 3-bits (with 7 possible values)
Definition at line 198 of file LRFUtils.h.
enum LRFIntonation |
In order to make LRF sounds have extra character, the frequency of each sound can be altered over the duration of its playback. This is akin to intonation in speech. By combining a variety of notes, intonations and durations you can get some really complex expressions!
This enum is packed to 3-bits (with 5 possible values)
Definition at line 217 of file LRFUtils.h.
enum LRFDuration |
This enum is packed to 3-bits (with 8 possible values)
Definition at line 234 of file LRFUtils.h.
void lrf_utils_color_lookup | ( | LRFColor | color, |
LRFColorValue * | value | ||
) |
color | The LRFColor constant to lookup |
value | A pointer to a LRFColorValue variable where the value will be written |
Usage:
LRFColorValue color; // define the variable for holding the value lrf_utils_color_lookup(LRFColor_Red, &color); // pass the red constant AND the address to our 'color' variable Serial.print(color.red,DEC) // print the red parameter for our color (should be 40)
Definition at line 85 of file LRFUtils.cpp.
void lrf_utils_color_lookup_random | ( | LRFColorValue * | value | ) |
value | A pointer to a LRFColorValue variable where the value will be written |
Usage:
LRFColorValue color; // define the variable for holding the value lrf_utils_color_lookup_random(&color); // pass the address to our 'color' variable Serial.print(color.red,DEC) // print the red parameter for our color (should be ???)
Definition at line 79 of file LRFUtils.cpp.
unsigned int lrf_utils_duration_lookup | ( | LRFDuration | duration | ) |
duration | The LRFDuration constant to lookup |
Usage:
unsigned int duration; // define the variable for holding the value duration = lrf_utils_duration_lookup(LRFDuration_Medium); // lookup the medium duration value from program memory Serial.print(duration,DEC) // print the medium duration in milliseconds (should be 200)
Definition at line 93 of file LRFUtils.cpp.
unsigned int lrf_utils_note_to_frequency | ( | LRFNote | note, |
LRFOctave | octave = LRFOctave_1 |
||
) |
note | The musical note constant |
octave | The musical octave constant |
Usage:
unsigned int freq; // define the variable for holding the value freq = lrf_utils_note_to_frequency(LRFNote_C, LRFOctave_3); // lookup the frequency value from program memory Serial.print(freq,DEC) // print the value lrf_speaker_on(); // turn on the speaker lrf_speaker_set_frequency(freq); // set the frequency delay(1000); // delay for 1s lrf_speaker_off(); // turn off the speaker
Definition at line 98 of file LRFUtils.cpp.