25 #include "LRFHardware.h"
26 #include "LRFMemory.h"
28 #define LRF_DURATION_BASE_UNIT 50
30 #define LRF_DURATIONS_COUNT 8
31 #define LRF_SCALE_COUNT 12
32 #define LRF_COLORS_COUNT 16
34 const unsigned int PROGMEM lrfDurations[LRF_DURATIONS_COUNT] = {
36 LRF_DURATION_BASE_UNIT * 1,
37 LRF_DURATION_BASE_UNIT * 2,
38 LRF_DURATION_BASE_UNIT * 4,
39 LRF_DURATION_BASE_UNIT * 8,
40 LRF_DURATION_BASE_UNIT * 16,
41 LRF_DURATION_BASE_UNIT * 32,
42 LRF_DURATION_BASE_UNIT * 64,
45 const unsigned int PROGMEM lrfScale[LRF_SCALE_COUNT] = {
46 55, 58, 62, 65, 69, 73, 78, 82, 87, 92, 98, 104
49 const unsigned char PROGMEM lrfColors[LRF_COLORS_COUNT * 3] = {
51 LRF_RGB_VALUE_HIGH,0,0,
52 0,LRF_RGB_VALUE_HIGH,0,
53 0,0,LRF_RGB_VALUE_HIGH,
54 LRF_RGB_VALUE_HIGH,LRF_RGB_VALUE_MED,0,
55 0,LRF_RGB_VALUE_HIGH,LRF_RGB_VALUE_HIGH,
56 LRF_RGB_VALUE_SOFT,0,LRF_RGB_VALUE_HIGH,
58 LRF_RGB_VALUE_MED,LRF_RGB_VALUE_HIGH,0,
59 LRF_RGB_VALUE_HIGH,0,LRF_RGB_VALUE_MED,
61 LRF_RGB_VALUE_SOFT,0,0,
62 0,LRF_RGB_VALUE_SOFT,0,
63 0,0,LRF_RGB_VALUE_SOFT,
64 LRF_RGB_VALUE_SOFT,LRF_RGB_VALUE_SOFT,0,
65 0,LRF_RGB_VALUE_SOFT,LRF_RGB_VALUE_SOFT,
66 LRF_RGB_VALUE_SOFT,0,LRF_RGB_VALUE_SOFT,
67 LRF_RGB_VALUE_MED,LRF_RGB_VALUE_MED,LRF_RGB_VALUE_MED
70 bool lrf_utils_is_holiday_hardware(
void)
72 if(lrf_memory_read(LRF_MEMORY_HARDWARE_VERSION_MAJOR_ADDR) == 0x01 &&
73 lrf_memory_read(LRF_MEMORY_HARDWARE_VERSION_MINOR_ADDR) == 0x00)
81 unsigned char color = 1 + (rand()%8);
87 unsigned char idx = color * 3;
88 value->
red = pgm_read_byte(&lrfColors[idx]);
89 value->
green = pgm_read_byte(&lrfColors[idx+1]);
90 value->
blue = pgm_read_byte(&lrfColors[idx+2]);
95 return pgm_read_word(&lrfDurations[(
unsigned char)duration]);
110 freq = pgm_read_word(&lrfScale[note]);
117 freq *= pow(2,octave);
124 freq = F_CPU / freq / 2 - 1;
LRFColor
Constants for looking up color values stored in program memory (PROGMEM)
LRFDuration
Constants for fixed note durations based on musical timingWe found that a short list of fixed duratio...
void lrf_utils_color_lookup(LRFColor color, LRFColorValue *value)
Utility for looking up LRFColorValue data from LRFColor constant.
lowest possible octave (some notes are unplayable)
LRFNote
Constants for notes in the musical scale.
unsigned char blue
Blue value (8-bits)
Data structure for holding RGB color values.
void lrf_utils_color_lookup_random(LRFColorValue *value)
Utility for generating a random LRFColorValue.
unsigned int lrf_utils_note_to_frequency(LRFNote note, LRFOctave octave)
Utility for looking up frequency values from LRFNote and LRFOctave constants.
unsigned char green
Green value (8-bits)
Collection of custom types and handy functions used throughout the LRF codebase.
LRFOctave
Constants for octaves in the musical scale.
unsigned int lrf_utils_duration_lookup(LRFDuration duration)
Utility for looking up duration values (in milliseconds) from a LRFDuration constant.
unsigned char red
Red value (8-bits)