├── .gitignore
├── hardware
├── IcosaLEDron-FeatherWing-Dome-Cover.stl
├── IcosaLEDron-FeatherWing-Dome-Cover-Thicker.stl
├── IcosaLEDron-FeatherWing-Triangle-Full-Set.stl
├── IcosaLEDron-FeatherWing-Triangle-w-Screw-Holes.stl
├── IcosaLEDron-FeatherWing-Triangle-w-Switch-Holder.stl
├── IcosaLEDron-FeatherWing-Triangle-w-Feather-End-Holder.stl
├── IcosaLEDron-FeatherWing-Triangle-w-Feather-USB-Holder.stl
└── README.md
├── README.md
├── Patterns.h
├── IcosaLEDron.ino
├── Map.h
├── Sensors.h
└── GradientPalettes.h
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Dome-Cover.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Dome-Cover.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Dome-Cover-Thicker.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Dome-Cover-Thicker.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Triangle-Full-Set.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Triangle-Full-Set.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Triangle-w-Screw-Holes.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Triangle-w-Screw-Holes.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Triangle-w-Switch-Holder.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Triangle-w-Switch-Holder.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Triangle-w-Feather-End-Holder.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Triangle-w-Feather-End-Holder.stl
--------------------------------------------------------------------------------
/hardware/IcosaLEDron-FeatherWing-Triangle-w-Feather-USB-Holder.stl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jasoncoon/icosaLEDron/HEAD/hardware/IcosaLEDron-FeatherWing-Triangle-w-Feather-USB-Holder.stl
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | IcosaLEDron
2 | ===========
3 |
4 | 20-sided regular icosahedron made of PCBs with WS2812B-Mini 3535 RGB LEDs, LiPo battery, accelerometer, gyro, compass & other sensors.
5 |
6 | Hardware
7 | --------
8 |
9 | * 20 custom triangle PCBs
10 | * 20 WS2812B-Mini 3535 addressable RGB LEDs
11 | * [Adafruit Feather nRF52840 Sense](https://www.adafruit.com/product/4516)
12 | * [Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
13 | * [SPDT Slide Switch](https://www.adafruit.com/product/805)
14 | * 3D printed, snap together inner frame
15 | * Wire, solder, heat-shrink, etc
16 |
17 | Software
18 | --------
19 |
20 | * [Arduino IDE](https://www.arduino.cc/en/main/software)
21 | * [Adafruit LSM6DS Library](https://github.com/adafruit/Adafruit_LSM6DS)
22 | * [FastLED Library](https://github.com/FastLED/FastLED)
23 |
24 | Details
25 | -------
26 |
27 | More coming soon...
--------------------------------------------------------------------------------
/hardware/README.md:
--------------------------------------------------------------------------------
1 | # IcosaLEDron 3D printed parts
2 |
3 | Remixed from the fantastic [Snap-together Icosahedron (d20)](https://www.thingiverse.com/thing:2778943) by [aveday\_](https://www.thingiverse.com/aveday_)
4 |
5 | Parts:
6 |
7 | I printed all parts at high speed, 0.2mm layer height, no brim or raft.
8 |
9 | The triangular frame parts can all be printed without supports:
10 |
11 | - 17 x [IcosaLEDron-FeatherWing-Triangle-w-Screw-Holes.stl](IcosaLEDron-FeatherWing-Triangle-w-Screw-Holes.stl)
12 | - 1 x [IcosaLEDron-FeatherWing-Triangle-w-Switch-Holder.stl](IcosaLEDron-FeatherWing-Triangle-w-Switch-Holder.stl)
13 | - 1 x [IcosaLEDron-FeatherWing-Triangle-w-Feather-USB-Holder.stl](IcosaLEDron-FeatherWing-Triangle-w-Feather-USB-Holder.stl)
14 | - 1 x [IcosaLEDron-FeatherWing-Triangle-w-Feather-End-Holder.stl](IcosaLEDron-FeatherWing-Triangle-w-Feather-End-Holder.stl)
15 |
16 | I did have to enable supports, touching build plate only, for the dome covers:
17 |
18 | - 20 x [IcosaLEDron-FeatherWing-Dome-Cover.stl](IcosaLEDron-FeatherWing-Dome-Cover.stl)
19 |
--------------------------------------------------------------------------------
/Patterns.h:
--------------------------------------------------------------------------------
1 | /*
2 | IcosaLEDron: https://github.com/jasoncoon/IcosaLEDron
3 | Copyright (C) 2020 Jason Coon
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 | You should have received a copy of the GNU General Public License
13 | along with this program. If not, see .
14 | */
15 |
16 | float mapf(float x, float in_min, float in_max, uint8_t out_min, uint8_t out_max) {
17 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
18 | }
19 |
20 | void accelHSV() {
21 | uint8_t x = mapf(accelX, -10.0, 10.0, 0, 255);
22 | uint8_t y = mapf(accelY, -10.0, 10.0, 0, 255);
23 | // uint8_t z = mapf(accelZ, -10.0, 10.0, 0, 255);
24 |
25 | EVERY_N_MILLIS(100) {
26 | Serial.print(x);
27 | Serial.print(" ");
28 | Serial.print(y);
29 | // Serial.print(" ");
30 | // Serial.print(z);
31 | Serial.println(" ");
32 | }
33 |
34 | CHSV color = CHSV(x, 255, y);
35 |
36 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
37 | leds[i] = color;
38 | }
39 | }
40 |
41 | void complementaryRollPitchHSV() {
42 | uint8_t roll = mapf(complementaryRoll + 180.0, 0, 360.0, 0, 255);
43 | uint8_t pitch = mapf(complementaryPitch + 180.0, 0, 360.0, 0, 255);
44 |
45 | // EVERY_N_MILLIS(100) {
46 | // Serial.print(x);
47 | // Serial.print(" ");
48 | // Serial.print(y);
49 | // Serial.println(" ");
50 | // }
51 |
52 | CHSV color = CHSV(roll, 255, pitch);
53 |
54 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
55 | leds[i] = color;
56 | }
57 | }
58 |
59 | void paletteShift()
60 | {
61 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
62 | leds[i] = ColorFromPalette(currentPalette, i + hue, 255, LINEARBLEND);
63 | }
64 | }
65 |
66 | void rainbow()
67 | {
68 | // FastLED's built-in rainbow generator
69 | fill_rainbow( leds, NUM_LEDS, hue, 7);
70 | }
71 |
72 | void addGlitter( fract8 chanceOfGlitter)
73 | {
74 | if ( random8() < chanceOfGlitter) {
75 | leds[ random16(NUM_LEDS) ] += CRGB::White;
76 | }
77 | }
78 |
79 | void rainbowWithGlitter()
80 | {
81 | // built-in FastLED rainbow, plus some random sparkly glitter
82 | rainbow();
83 | addGlitter(80);
84 | }
85 |
86 | void confetti()
87 | {
88 | // random colored speckles that blink in and fade smoothly
89 | fadeToBlackBy( leds, NUM_LEDS, 10);
90 | int pos = random16(NUM_LEDS);
91 | leds[pos] += CHSV( hue + random8(64), 200, 255);
92 | }
93 |
94 | void sinelon()
95 | {
96 | // a colored dot sweeping back and forth, with fading trails
97 | fadeToBlackBy( leds, NUM_LEDS, 20);
98 | int pos = beatsin16( 13, 0, NUM_LEDS - 1 );
99 | leds[pos] += CHSV( hue, 255, 192);
100 | }
101 |
102 | void bpm()
103 | {
104 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
105 | uint8_t BeatsPerMinute = 62;
106 | CRGBPalette16 palette = PartyColors_p;
107 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
108 | for ( int i = 0; i < NUM_LEDS; i++) { //9948
109 | leds[i] = ColorFromPalette(palette, hue + (i * 2), beat - hue + (i * 10));
110 | }
111 | }
112 |
113 | void juggle() {
114 | // eight colored dots, weaving in and out of sync with each other
115 | fadeToBlackBy( leds, NUM_LEDS, 20);
116 | byte dothue = 0;
117 | for ( int i = 0; i < 8; i++) {
118 | leds[beatsin16( i + 7, 0, NUM_LEDS - 1 )] |= CHSV(dothue, 200, 255);
119 | dothue += 32;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/IcosaLEDron.ino:
--------------------------------------------------------------------------------
1 | /*
2 | IcosaLEDron: https://github.com/jasoncoon/IcosaLEDron
3 | Copyright (C) 2020 Jason Coon
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 | You should have received a copy of the GNU General Public License
13 | along with this program. If not, see .
14 | */
15 |
16 | /*
17 | Uses an Adafruit Adafruit Feather nRF52840 Sense, with onboard sensors: https://learn.adafruit.com/adafruit-feather-sense/overview
18 |
19 | ST Micro series 9-DoF motion - LSM6DS33 Accel/Gyro + LIS3MDL magnetometer
20 | APDS9960 Proximity, Light, Color, and Gesture Sensor
21 | PDM Microphone sound sensor
22 | SHT Humidity
23 | BMP280 temperature and barometric pressure/altitude
24 |
25 | In Arduino, select board: Adafruit Feather nRF52840 Express
26 | */
27 |
28 | #include
29 | #include "Sensors.h"
30 | #include "GradientPalettes.h"
31 |
32 | #define DATA_PIN 5
33 | #define LED_TYPE WS2812B
34 | #define COLOR_ORDER GRB
35 | #define NUM_LEDS 20
36 |
37 | #define MILLI_AMPS 500
38 | #define FRAMES_PER_SECOND 120
39 |
40 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
41 |
42 | CRGB leds[NUM_LEDS];
43 |
44 | uint8_t speed = 16;
45 | uint8_t hue = 0;
46 | uint8_t secondsPerPalette = 10;
47 | uint8_t secondsPerPattern = 10;
48 | uint8_t currentPatternNumber = 0; // Index number of which pattern is current
49 |
50 | const float Pi = 3.14159;
51 |
52 | #include "Map.h"
53 | #include "Patterns.h"
54 |
55 | // List of patterns to cycle through. Each is defined as a separate function below.
56 | typedef void (*SimplePatternList[])();
57 | SimplePatternList patterns = {
58 | complementaryRollPitchHSV,
59 | // accelHSV,
60 | // xRainbow,
61 | // xyRainbow,
62 | // yRainbow,
63 | // yzRainbow,
64 | // zRainbow,
65 | // xzRainbow,
66 | // angleRainbow,
67 | // xPalette,
68 | // xyPalette,
69 | // yPalette,
70 | // yzPalette,
71 | // zPalette,
72 | // xzPalette,
73 | // paletteShift,
74 | // rainbow,
75 | // rainbowWithGlitter,
76 | // confetti,
77 | // sinelon,
78 | // juggle,
79 | // bpm
80 | };
81 |
82 | void setup(void) {
83 | Serial.begin(115200);
84 |
85 | // delay(1000);
86 |
87 | FastLED.addLeds(leds, NUM_LEDS);
88 | FastLED.setDither(true);
89 | FastLED.setBrightness(128);
90 | FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
91 | leds[0] = CRGB::Red;
92 | FastLED.show();
93 |
94 | // initialize the sensors
95 | // bmp280.begin();
96 | // lis3mdl.begin_I2C();
97 | lsm6ds33.begin_I2C();
98 | // sht30.begin();
99 |
100 | calibrateIMU(250, 250);
101 | }
102 |
103 | void loop(void) {
104 | // change to a new cpt-city gradient palette
105 | EVERY_N_SECONDS( secondsPerPalette ) {
106 | currentPaletteIndex = addmod8( currentPaletteIndex, 1, gradientPaletteCount);
107 | targetPalette = gradientPalettes[ currentPaletteIndex ];
108 | }
109 |
110 | EVERY_N_MILLISECONDS(40) {
111 | nblendPaletteTowardPalette( currentPalette, targetPalette, 8); // slowly blend the current palette to the next
112 | hue++; // slowly cycle the "base color" through the rainbow
113 | }
114 |
115 | if (readIMU()) {
116 | long currentTime = micros();
117 | lastInterval = currentTime - lastTime; // expecting this to be ~104Hz +- 4%
118 | lastTime = currentTime;
119 |
120 | doImuCalculations();
121 | printCalculations();
122 | }
123 |
124 | // Call the current pattern function once, updating the 'leds' array
125 | patterns[currentPatternNumber]();
126 |
127 | FastLED.show();
128 |
129 | EVERY_N_SECONDS( secondsPerPattern ) {
130 | nextPattern(); // change patterns periodically
131 | // Serial.println(currentPatternNumber);
132 | }
133 | }
134 |
135 | void nextPattern()
136 | {
137 | // add one to the current pattern number, and wrap around at the end
138 | currentPatternNumber = (currentPatternNumber + 1) % ARRAY_SIZE(patterns);
139 | }
140 |
--------------------------------------------------------------------------------
/Map.h:
--------------------------------------------------------------------------------
1 | /*
2 | IcosaLEDron: https://github.com/jasoncoon/IcosaLEDron
3 | Copyright (C) 2020 Jason Coon
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 | This program is distributed in the hope that it will be useful,
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | GNU General Public License for more details.
12 | You should have received a copy of the GNU General Public License
13 | along with this program. If not, see .
14 | */
15 |
16 | // These coordinates were mapped while holding the IcosaLEDron with the face with the first LED and USB port flat on top
17 | // with the USB port towards the back, and the point of that triangle face pointing forward.
18 | // Looking down on the IcosaLEDron, the origin is at the bottom left corner, with x increasing from the left towards the right,
19 | // y increasing from the front to the back, and z increasing from the bottom towards the top.
20 |
21 | const uint8_t coordsX[NUM_LEDS] = { 128, 43, 85, 170, 213, 255, 213, 128, 43, 0, 0, 43, 128, 213, 255, 213, 170, 85, 43, 128 };
22 | const uint8_t coordsY[NUM_LEDS] = { 170, 85, 0, 0, 85, 170, 255, 255, 255, 170, 85, 0, 0, 0, 85, 170, 255, 255, 170, 85 };
23 | const uint8_t coordsZ[NUM_LEDS] = { 255, 204, 153, 153, 204, 153, 153, 204, 153, 153, 102, 102, 51, 51, 102, 51, 102, 102, 51, 0 };
24 | const uint8_t angles[NUM_LEDS] = { 255, 28, 85, 142, 198, 198, 227, 255, 0, 28, 57, 85, 113, 142, 170, 170, 227, 0, 28, 113 };
25 |
26 | uint8_t hues = 1;
27 |
28 | void xRainbow() {
29 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
30 | uint8_t x = coordsX[i];
31 |
32 | leds[i] = CHSV(beat8(speed) - (x * hues), 255, 255);
33 | }
34 | }
35 |
36 | void xyRainbow() {
37 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
38 | uint8_t x = coordsX[i];
39 | uint8_t y = coordsY[i];
40 |
41 | leds[i] = CHSV(beat8(speed) - ((x + y) * hues), 255, 255);
42 | }
43 | }
44 |
45 | void yRainbow() {
46 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
47 | uint8_t y = coordsY[i];
48 |
49 | leds[i] = CHSV(beat8(speed) - (y * hues), 255, 255);
50 | }
51 | }
52 |
53 | void yzRainbow() {
54 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
55 | uint8_t y = coordsY[i];
56 | uint8_t z = coordsZ[i];
57 |
58 | leds[i] = CHSV(beat8(speed) - ((y + z) * hues), 255, 255);
59 | }
60 | }
61 |
62 | void zRainbow() {
63 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
64 | uint8_t z = coordsY[i];
65 |
66 | leds[i] = CHSV(beat8(speed) - (z * hues), 255, 255);
67 | }
68 | }
69 |
70 | void xzRainbow() {
71 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
72 | uint8_t x = coordsX[i];
73 | uint8_t z = coordsZ[i];
74 |
75 | leds[i] = CHSV(beat8(speed) - ((x + z) * hues), 255, 255);
76 | }
77 | }
78 |
79 | void xyzRainbow() {
80 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
81 | uint8_t x = coordsX[i];
82 | uint8_t y = coordsY[i];
83 | uint8_t z = coordsZ[i];
84 |
85 | leds[i] = CHSV(beat8(speed) - ((x + y + z) * hues), 255, 255);
86 | }
87 | }
88 |
89 | void angleRainbow() {
90 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
91 | uint8_t a = angles[i];
92 |
93 | leds[i] = CHSV(beat8(speed) - (a * hues), 255, 255);
94 | }
95 | }
96 |
97 | void xPalette() {
98 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
99 | uint8_t x = coordsX[i];
100 |
101 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - (x * hues));
102 | }
103 | }
104 |
105 | void xyPalette() {
106 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
107 | uint8_t x = coordsX[i];
108 | uint8_t y = coordsY[i];
109 |
110 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - ((x + y) * hues));
111 | }
112 | }
113 |
114 | void yPalette() {
115 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
116 | uint8_t y = coordsY[i];
117 |
118 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - (y * hues));
119 | }
120 | }
121 |
122 | void yzPalette() {
123 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
124 | uint8_t y = coordsY[i];
125 | uint8_t z = coordsZ[i];
126 |
127 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - ((y + z) * hues));
128 | }
129 | }
130 |
131 | void zPalette() {
132 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
133 | uint8_t z = coordsZ[i];
134 |
135 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - (z * hues));
136 | }
137 | }
138 |
139 | void xzPalette() {
140 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
141 | uint8_t x = coordsX[i];
142 | uint8_t z = coordsZ[i];
143 |
144 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - ((x + z) * hues));
145 | }
146 | }
147 |
148 | void anglePalette() {
149 | for (uint8_t i = 0; i < NUM_LEDS; i++) {
150 | uint8_t a = angles[i];
151 |
152 | leds[i] = ColorFromPalette(currentPalette, beat8(speed) - (a * hues));
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/Sensors.h:
--------------------------------------------------------------------------------
1 | // Adapted from Adafruit's Arduino Sensor Example: https://learn.adafruit.com/adafruit-feather-sense/arduino-sensor-example
2 | // and owennewo's roll pitch yaw example: // https://github.com/arduino-libraries/Arduino_LSM6DS3/blob/5eac7f5e6145c4747da27698faf3a548d2893a2b/examples/RollPitchYaw/RollPitchYaw.ino
3 | // Can be used with this processing sketch to visualize roll pitch yaw: https://github.com/arduino-libraries/Arduino_LSM6DS3/blob/5eac7f5e6145c4747da27698faf3a548d2893a2b/examples/RollPitchYaw/data/processing/RollPitchYaw3d.pde
4 |
5 | //#include
6 | //#include
7 | #include
8 | //#include
9 | //#include
10 |
11 | //#include
12 |
13 | //Adafruit_BMP280 bmp280; // temperautre, barometric pressure
14 | //Adafruit_LIS3MDL lis3mdl; // magnetometer
15 | Adafruit_LSM6DS33 lsm6ds33; // accelerometer, gyroscope
16 | //Adafruit_SHT31 sht30; // humidity
17 |
18 | float temperature, pressure, altitude;
19 | float magnetic_x, magnetic_y, magnetic_z;
20 | float humidity;
21 | //int32_t mic;
22 | //
23 | //extern PDMClass PDM;
24 | //short sampleBuffer[256]; // buffer to read samples into, each sample is 16-bits
25 | //volatile int samplesRead; // number of samples read
26 |
27 | float accelX, accelY, accelZ, // units m/s/s i.e. accelZ if often 9.8 (gravity)
28 | gyroX, gyroY, gyroZ, // units dps (degrees per second)
29 | gyroDriftX, gyroDriftY, gyroDriftZ, // units dps
30 | gyroRoll, gyroPitch, gyroYaw, // units degrees (expect major drift)
31 | gyroCorrectedRoll, gyroCorrectedPitch, gyroCorrectedYaw, // units degrees (expect minor drift)
32 | accRoll, accPitch, accYaw, // units degrees (roll and pitch noisy, yaw not possible)
33 | complementaryRoll, complementaryPitch, complementaryYaw; // units degrees (excellent roll, pitch, yaw minor drift)
34 |
35 | long lastTime;
36 | long lastInterval;
37 |
38 | sensors_event_t accel;
39 | sensors_event_t gyro;
40 | sensors_event_t temp;
41 |
42 | bool readIMU() {
43 | lsm6ds33.getEvent(&accel, &gyro, &temp);
44 | accelX = accel.acceleration.x;
45 | accelY = accel.acceleration.y;
46 | accelZ = accel.acceleration.z;
47 | gyroX = gyro.gyro.x;
48 | gyroY = gyro.gyro.y;
49 | gyroZ = gyro.gyro.z;
50 | return true;
51 | }
52 |
53 | /*
54 | the gyro's x,y,z values drift by a steady amount. if we measure this when arduino is still
55 | we can correct the drift when doing real measurements later
56 | */
57 | void calibrateIMU(int delayMillis, int calibrationMillis) {
58 | int calibrationCount = 0;
59 |
60 | delay(delayMillis); // to avoid shakes after pressing reset button
61 |
62 | float sumX, sumY, sumZ;
63 | int startTime = millis();
64 | while (millis() < startTime + calibrationMillis) {
65 | if (readIMU()) {
66 | // in an ideal world gyroX/Y/Z == 0, anything higher or lower represents drift
67 | sumX += gyroX;
68 | sumY += gyroY;
69 | sumZ += gyroZ;
70 |
71 | calibrationCount++;
72 | }
73 | }
74 |
75 | if (calibrationCount == 0) {
76 | Serial.println("Failed to calibrate");
77 | }
78 |
79 | gyroDriftX = sumX / calibrationCount;
80 | gyroDriftY = sumY / calibrationCount;
81 | gyroDriftZ = sumZ / calibrationCount;
82 |
83 | }
84 |
85 | void doImuCalculations() {
86 | accRoll = atan2(accelY, accelZ) * 180 / M_PI;
87 | accPitch = atan2(-accelX, sqrt(accelY * accelY + accelZ * accelZ)) * 180 / M_PI;
88 |
89 | float lastFrequency = (float) 1000000.0 / lastInterval;
90 | gyroRoll = gyroRoll + (gyroX / lastFrequency);
91 | gyroPitch = gyroPitch + (gyroY / lastFrequency);
92 | gyroYaw = gyroYaw + (gyroZ / lastFrequency);
93 |
94 | gyroCorrectedRoll = gyroCorrectedRoll + ((gyroX - gyroDriftX) / lastFrequency);
95 | gyroCorrectedPitch = gyroCorrectedPitch + ((gyroY - gyroDriftY) / lastFrequency);
96 | gyroCorrectedYaw = gyroCorrectedYaw + ((gyroZ - gyroDriftZ) / lastFrequency);
97 |
98 | complementaryRoll = complementaryRoll + ((gyroX - gyroDriftX) / lastFrequency);
99 | complementaryPitch = complementaryPitch + ((gyroY - gyroDriftY) / lastFrequency);
100 | complementaryYaw = complementaryYaw + ((gyroZ - gyroDriftZ) / lastFrequency);
101 |
102 | complementaryRoll = 0.98 * complementaryRoll + 0.02 * accRoll;
103 | complementaryPitch = 0.98 * complementaryPitch + 0.02 * accPitch;
104 | }
105 |
106 | /**
107 | This comma separated format is best 'viewed' using 'serial plotter' or processing.org client (see https://github.com/arduino-libraries/Arduino_LSM6DS3/blob/5eac7f5e6145c4747da27698faf3a548d2893a2b/examples/RollPitchYaw/data/processing/RollPitchYaw3d.pde)
108 | */
109 | void printCalculations() {
110 | Serial.print(gyroRoll);
111 | Serial.print(',');
112 | Serial.print(gyroPitch);
113 | Serial.print(',');
114 | Serial.print(gyroYaw);
115 | Serial.print(',');
116 | Serial.print(gyroCorrectedRoll);
117 | Serial.print(',');
118 | Serial.print(gyroCorrectedPitch);
119 | Serial.print(',');
120 | Serial.print(gyroCorrectedYaw);
121 | Serial.print(',');
122 | Serial.print(accRoll);
123 | Serial.print(',');
124 | Serial.print(accPitch);
125 | Serial.print(',');
126 | Serial.print(accYaw);
127 | Serial.print(',');
128 | Serial.print(complementaryRoll);
129 | Serial.print(',');
130 | Serial.print(complementaryPitch);
131 | Serial.print(',');
132 | Serial.print(complementaryYaw);
133 | Serial.println("");
134 | }
135 |
--------------------------------------------------------------------------------
/GradientPalettes.h:
--------------------------------------------------------------------------------
1 | // From ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
2 |
3 | ///////////////////////////////////////////////////////////////////////
4 |
5 | // Forward declarations of an array of cpt-city gradient palettes, and
6 | // a count of how many there are. The actual color palette definitions
7 | // are at the bottom of this file.
8 | extern const TProgmemRGBGradientPalettePtr gradientPalettes[];
9 |
10 | uint8_t currentPaletteIndex = 0;
11 |
12 | CRGBPalette16 currentPalette( CRGB::Black);
13 | CRGBPalette16 targetPalette( gradientPalettes[0] );
14 |
15 | // Gradient Color Palette definitions for 33 different cpt-city color palettes.
16 | // 956 bytes of PROGMEM for all of the palettes together,
17 | // +618 bytes of PROGMEM for gradient palette code (AVR).
18 | // 1,494 bytes total for all 34 color palettes and associated code.
19 |
20 | // Gradient palette "ib_jul01_gp", originally from
21 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/xmas/tn/ib_jul01.png.index.html
22 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
23 | // Size: 16 bytes of program space.
24 |
25 | DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
26 | 0, 194, 1, 1,
27 | 94, 1, 29, 18,
28 | 132, 57, 131, 28,
29 | 255, 113, 1, 1
30 | };
31 |
32 | // Gradient palette "es_vintage_57_gp", originally from
33 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html
34 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
35 | // Size: 20 bytes of program space.
36 |
37 | DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
38 | 0, 2, 1, 1,
39 | 53, 18, 1, 0,
40 | 104, 69, 29, 1,
41 | 153, 167, 135, 10,
42 | 255, 46, 56, 4
43 | };
44 |
45 | // Gradient palette "es_vintage_01_gp", originally from
46 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
47 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
48 | // Size: 32 bytes of program space.
49 |
50 | DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
51 | 0, 4, 1, 1,
52 | 51, 16, 0, 1,
53 | 76, 97, 104, 3,
54 | 101, 255, 131, 19,
55 | 127, 67, 9, 4,
56 | 153, 16, 0, 1,
57 | 229, 4, 1, 1,
58 | 255, 4, 1, 1
59 | };
60 |
61 | // Gradient palette "es_rivendell_15_gp", originally from
62 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html
63 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
64 | // Size: 20 bytes of program space.
65 |
66 | DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
67 | 0, 1, 14, 5,
68 | 101, 16, 36, 14,
69 | 165, 56, 68, 30,
70 | 242, 150, 156, 99,
71 | 255, 150, 156, 99
72 | };
73 |
74 | // Gradient palette "rgi_15_gp", originally from
75 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
76 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
77 | // Size: 36 bytes of program space.
78 |
79 | DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
80 | 0, 4, 1, 31,
81 | 31, 55, 1, 16,
82 | 63, 197, 3, 7,
83 | 95, 59, 2, 17,
84 | 127, 6, 2, 34,
85 | 159, 39, 6, 33,
86 | 191, 112, 13, 32,
87 | 223, 56, 9, 35,
88 | 255, 22, 6, 38
89 | };
90 |
91 | // Gradient palette "retro2_16_gp", originally from
92 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
93 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
94 | // Size: 8 bytes of program space.
95 |
96 | DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
97 | 0, 188, 135, 1,
98 | 255, 46, 7, 1
99 | };
100 |
101 | // Gradient palette "Analogous_1_gp", originally from
102 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
103 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
104 | // Size: 20 bytes of program space.
105 |
106 | DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
107 | 0, 3, 0, 255,
108 | 63, 23, 0, 255,
109 | 127, 67, 0, 255,
110 | 191, 142, 0, 45,
111 | 255, 255, 0, 0
112 | };
113 |
114 | // Gradient palette "es_pinksplash_08_gp", originally from
115 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
116 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
117 | // Size: 20 bytes of program space.
118 |
119 | DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
120 | 0, 126, 11, 255,
121 | 127, 197, 1, 22,
122 | 175, 210, 157, 172,
123 | 221, 157, 3, 112,
124 | 255, 157, 3, 112
125 | };
126 |
127 | // Gradient palette "es_pinksplash_07_gp", originally from
128 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html
129 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
130 | // Size: 28 bytes of program space.
131 |
132 | DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
133 | 0, 229, 1, 1,
134 | 61, 242, 4, 63,
135 | 101, 255, 12, 255,
136 | 127, 249, 81, 252,
137 | 153, 255, 11, 235,
138 | 193, 244, 5, 68,
139 | 255, 232, 1, 5
140 | };
141 |
142 | // Gradient palette "Coral_reef_gp", originally from
143 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html
144 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
145 | // Size: 24 bytes of program space.
146 |
147 | DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
148 | 0, 40, 199, 197,
149 | 50, 10, 152, 155,
150 | 96, 1, 111, 120,
151 | 96, 43, 127, 162,
152 | 139, 10, 73, 111,
153 | 255, 1, 34, 71
154 | };
155 |
156 | // Gradient palette "es_ocean_breeze_068_gp", originally from
157 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html
158 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
159 | // Size: 24 bytes of program space.
160 |
161 | DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
162 | 0, 100, 156, 153,
163 | 51, 1, 99, 137,
164 | 101, 1, 68, 84,
165 | 104, 35, 142, 168,
166 | 178, 0, 63, 117,
167 | 255, 1, 10, 10
168 | };
169 |
170 | // Gradient palette "es_ocean_breeze_036_gp", originally from
171 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
172 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
173 | // Size: 16 bytes of program space.
174 |
175 | DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
176 | 0, 1, 6, 7,
177 | 89, 1, 99, 111,
178 | 153, 144, 209, 255,
179 | 255, 0, 73, 82
180 | };
181 |
182 | // Gradient palette "departure_gp", originally from
183 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
184 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
185 | // Size: 88 bytes of program space.
186 |
187 | DEFINE_GRADIENT_PALETTE( departure_gp ) {
188 | 0, 8, 3, 0,
189 | 42, 23, 7, 0,
190 | 63, 75, 38, 6,
191 | 84, 169, 99, 38,
192 | 106, 213, 169, 119,
193 | 116, 255, 255, 255,
194 | 138, 135, 255, 138,
195 | 148, 22, 255, 24,
196 | 170, 0, 255, 0,
197 | 191, 0, 136, 0,
198 | 212, 0, 55, 0,
199 | 255, 0, 55, 0
200 | };
201 |
202 | // Gradient palette "es_landscape_64_gp", originally from
203 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
204 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
205 | // Size: 36 bytes of program space.
206 |
207 | DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
208 | 0, 0, 0, 0,
209 | 37, 2, 25, 1,
210 | 76, 15, 115, 5,
211 | 127, 79, 213, 1,
212 | 128, 126, 211, 47,
213 | 130, 188, 209, 247,
214 | 153, 144, 182, 205,
215 | 204, 59, 117, 250,
216 | 255, 1, 37, 192
217 | };
218 |
219 | // Gradient palette "es_landscape_33_gp", originally from
220 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
221 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
222 | // Size: 24 bytes of program space.
223 |
224 | DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
225 | 0, 1, 5, 0,
226 | 19, 32, 23, 1,
227 | 38, 161, 55, 1,
228 | 63, 229, 144, 1,
229 | 66, 39, 142, 74,
230 | 255, 1, 4, 1
231 | };
232 |
233 | // Gradient palette "rainbowsherbet_gp", originally from
234 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
235 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
236 | // Size: 28 bytes of program space.
237 |
238 | DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
239 | 0, 255, 33, 4,
240 | 43, 255, 68, 25,
241 | 86, 255, 7, 25,
242 | 127, 255, 82, 103,
243 | 170, 255, 255, 242,
244 | 209, 42, 255, 22,
245 | 255, 87, 255, 65
246 | };
247 |
248 | // Gradient palette "gr65_hult_gp", originally from
249 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
250 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
251 | // Size: 24 bytes of program space.
252 |
253 | DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
254 | 0, 247, 176, 247,
255 | 48, 255, 136, 255,
256 | 89, 220, 29, 226,
257 | 160, 7, 82, 178,
258 | 216, 1, 124, 109,
259 | 255, 1, 124, 109
260 | };
261 |
262 | // Gradient palette "gr64_hult_gp", originally from
263 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
264 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
265 | // Size: 32 bytes of program space.
266 |
267 | DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
268 | 0, 1, 124, 109,
269 | 66, 1, 93, 79,
270 | 104, 52, 65, 1,
271 | 130, 115, 127, 1,
272 | 150, 52, 65, 1,
273 | 201, 1, 86, 72,
274 | 239, 0, 55, 45,
275 | 255, 0, 55, 45
276 | };
277 |
278 | // Gradient palette "GMT_drywet_gp", originally from
279 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
280 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
281 | // Size: 28 bytes of program space.
282 |
283 | DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
284 | 0, 47, 30, 2,
285 | 42, 213, 147, 24,
286 | 84, 103, 219, 52,
287 | 127, 3, 219, 207,
288 | 170, 1, 48, 214,
289 | 212, 1, 1, 111,
290 | 255, 1, 7, 33
291 | };
292 |
293 | // Gradient palette "ib15_gp", originally from
294 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
295 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
296 | // Size: 24 bytes of program space.
297 |
298 | DEFINE_GRADIENT_PALETTE( ib15_gp ) {
299 | 0, 113, 91, 147,
300 | 72, 157, 88, 78,
301 | 89, 208, 85, 33,
302 | 107, 255, 29, 11,
303 | 141, 137, 31, 39,
304 | 255, 59, 33, 89
305 | };
306 |
307 | // Gradient palette "Fuschia_7_gp", originally from
308 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html
309 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
310 | // Size: 20 bytes of program space.
311 |
312 | DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
313 | 0, 43, 3, 153,
314 | 63, 100, 4, 103,
315 | 127, 188, 5, 66,
316 | 191, 161, 11, 115,
317 | 255, 135, 20, 182
318 | };
319 |
320 | // Gradient palette "es_emerald_dragon_08_gp", originally from
321 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html
322 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
323 | // Size: 16 bytes of program space.
324 |
325 | DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
326 | 0, 97, 255, 1,
327 | 101, 47, 133, 1,
328 | 178, 13, 43, 1,
329 | 255, 2, 10, 1
330 | };
331 |
332 | // Gradient palette "lava_gp", originally from
333 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
334 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
335 | // Size: 52 bytes of program space.
336 |
337 | DEFINE_GRADIENT_PALETTE( lava_gp ) {
338 | 0, 0, 0, 0,
339 | 46, 18, 0, 0,
340 | 96, 113, 0, 0,
341 | 108, 142, 3, 1,
342 | 119, 175, 17, 1,
343 | 146, 213, 44, 2,
344 | 174, 255, 82, 4,
345 | 188, 255, 115, 4,
346 | 202, 255, 156, 4,
347 | 218, 255, 203, 4,
348 | 234, 255, 255, 4,
349 | 244, 255, 255, 71,
350 | 255, 255, 255, 255
351 | };
352 |
353 | // Gradient palette "fire_gp", originally from
354 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html
355 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
356 | // Size: 28 bytes of program space.
357 |
358 | DEFINE_GRADIENT_PALETTE( fire_gp ) {
359 | 0, 1, 1, 0,
360 | 76, 32, 5, 0,
361 | 146, 192, 24, 0,
362 | 197, 220, 105, 5,
363 | 240, 252, 255, 31,
364 | 250, 252, 255, 111,
365 | 255, 255, 255, 255
366 | };
367 |
368 | // Gradient palette "Colorfull_gp", originally from
369 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
370 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
371 | // Size: 44 bytes of program space.
372 |
373 | DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
374 | 0, 10, 85, 5,
375 | 25, 29, 109, 18,
376 | 60, 59, 138, 42,
377 | 93, 83, 99, 52,
378 | 106, 110, 66, 64,
379 | 109, 123, 49, 65,
380 | 113, 139, 35, 66,
381 | 116, 192, 117, 98,
382 | 124, 255, 255, 137,
383 | 168, 100, 180, 155,
384 | 255, 22, 121, 174
385 | };
386 |
387 | // Gradient palette "Magenta_Evening_gp", originally from
388 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html
389 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
390 | // Size: 28 bytes of program space.
391 |
392 | DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
393 | 0, 71, 27, 39,
394 | 31, 130, 11, 51,
395 | 63, 213, 2, 64,
396 | 70, 232, 1, 66,
397 | 76, 252, 1, 69,
398 | 108, 123, 2, 51,
399 | 255, 46, 9, 35
400 | };
401 |
402 | // Gradient palette "Pink_Purple_gp", originally from
403 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
404 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
405 | // Size: 44 bytes of program space.
406 |
407 | DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
408 | 0, 19, 2, 39,
409 | 25, 26, 4, 45,
410 | 51, 33, 6, 52,
411 | 76, 68, 62, 125,
412 | 102, 118, 187, 240,
413 | 109, 163, 215, 247,
414 | 114, 217, 244, 255,
415 | 122, 159, 149, 221,
416 | 149, 113, 78, 188,
417 | 183, 128, 57, 155,
418 | 255, 146, 40, 123
419 | };
420 |
421 | // Gradient palette "Sunset_Real_gp", originally from
422 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
423 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
424 | // Size: 28 bytes of program space.
425 |
426 | DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
427 | 0, 120, 0, 0,
428 | 22, 179, 22, 0,
429 | 51, 255, 104, 0,
430 | 85, 167, 22, 18,
431 | 135, 100, 0, 103,
432 | 198, 16, 0, 130,
433 | 255, 0, 0, 160
434 | };
435 |
436 | // Gradient palette "es_autumn_19_gp", originally from
437 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
438 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
439 | // Size: 52 bytes of program space.
440 |
441 | DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
442 | 0, 26, 1, 1,
443 | 51, 67, 4, 1,
444 | 84, 118, 14, 1,
445 | 104, 137, 152, 52,
446 | 112, 113, 65, 1,
447 | 122, 133, 149, 59,
448 | 124, 137, 152, 52,
449 | 135, 113, 65, 1,
450 | 142, 139, 154, 46,
451 | 163, 113, 13, 1,
452 | 204, 55, 3, 1,
453 | 249, 17, 1, 1,
454 | 255, 17, 1, 1
455 | };
456 |
457 | // Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
458 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
459 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
460 | // Size: 28 bytes of program space.
461 |
462 | DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
463 | 0, 0, 0, 0,
464 | 42, 0, 0, 45,
465 | 84, 0, 0, 255,
466 | 127, 42, 0, 255,
467 | 170, 255, 0, 255,
468 | 212, 255, 55, 255,
469 | 255, 255, 255, 255
470 | };
471 |
472 | // Gradient palette "BlacK_Magenta_Red_gp", originally from
473 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
474 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
475 | // Size: 20 bytes of program space.
476 |
477 | DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
478 | 0, 0, 0, 0,
479 | 63, 42, 0, 45,
480 | 127, 255, 0, 255,
481 | 191, 255, 0, 45,
482 | 255, 255, 0, 0
483 | };
484 |
485 | // Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
486 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
487 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
488 | // Size: 28 bytes of program space.
489 |
490 | DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
491 | 0, 0, 0, 0,
492 | 42, 42, 0, 0,
493 | 84, 255, 0, 0,
494 | 127, 255, 0, 45,
495 | 170, 255, 0, 255,
496 | 212, 255, 55, 45,
497 | 255, 255, 255, 0
498 | };
499 |
500 | // Gradient palette "Blue_Cyan_Yellow_gp", originally from
501 | // http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
502 | // converted for FastLED with gammas (2.6, 2.2, 2.5)
503 | // Size: 20 bytes of program space.
504 |
505 | DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
506 | 0, 0, 0, 255,
507 | 63, 0, 55, 255,
508 | 127, 0, 255, 255,
509 | 191, 42, 255, 45,
510 | 255, 255, 255, 0
511 | };
512 |
513 |
514 | // Single array of defined cpt-city color palettes.
515 | // This will let us programmatically choose one based on
516 | // a number, rather than having to activate each explicitly
517 | // by name every time.
518 | // Since it is const, this array could also be moved
519 | // into PROGMEM to save SRAM, but for simplicity of illustration
520 | // we'll keep it in a regular SRAM array.
521 | //
522 | // This list of color palettes acts as a "playlist"; you can
523 | // add or delete, or re-arrange as you wish.
524 | const TProgmemRGBGradientPalettePtr gradientPalettes[] = {
525 | Sunset_Real_gp,
526 | es_rivendell_15_gp,
527 | es_ocean_breeze_036_gp,
528 | rgi_15_gp,
529 | retro2_16_gp,
530 | Analogous_1_gp,
531 | es_pinksplash_08_gp,
532 | Coral_reef_gp,
533 | es_ocean_breeze_068_gp,
534 | es_pinksplash_07_gp,
535 | es_vintage_01_gp,
536 | departure_gp,
537 | es_landscape_64_gp,
538 | es_landscape_33_gp,
539 | rainbowsherbet_gp,
540 | gr65_hult_gp,
541 | gr64_hult_gp,
542 | GMT_drywet_gp,
543 | ib_jul01_gp,
544 | es_vintage_57_gp,
545 | ib15_gp,
546 | Fuschia_7_gp,
547 | es_emerald_dragon_08_gp,
548 | lava_gp,
549 | fire_gp,
550 | Colorfull_gp,
551 | Magenta_Evening_gp,
552 | Pink_Purple_gp,
553 | es_autumn_19_gp,
554 | BlacK_Blue_Magenta_White_gp,
555 | BlacK_Magenta_Red_gp,
556 | BlacK_Red_Magenta_Yellow_gp,
557 | Blue_Cyan_Yellow_gp
558 | };
559 |
560 |
561 | // Count of how many cpt-city gradients are defined:
562 | const uint8_t gradientPaletteCount =
563 | sizeof( gradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
564 |
--------------------------------------------------------------------------------