Skip to content

Commit 8c4b48b

Browse files
authored
Merge branch 'master' into master
2 parents f4ef0dd + 7440f0e commit 8c4b48b

1,522 files changed

Lines changed: 4486843 additions & 11307 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
*~
22
Hue_Controller/secrets.h
33
.idea
4+
*.DS_Store
5+
CircuitPython_Logger/secrets\.py

.travis.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,31 @@ python:
55
- "3.6"
66

77
cache:
8-
pip: true
8+
9+
cache:
10+
pip: true
11+
directories:
12+
- ~/arduino_ide
13+
- ~/.arduino15/packages/
14+
- ~/Arduino
15+
16+
env:
17+
global:
18+
- ARDUINO_IDE_VERSION="1.8.7"
19+
- PRETTYNAME="Adafruit Learning System Guides"
20+
- PLATFORM_CHECK_ONLY_ON_FILE=true
21+
22+
before_install:
23+
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
924

1025
install:
26+
- ./arduino_libinstall
1127
- pip install --force-reinstall pylint==1.9.2
1228

1329
script:
1430
- ./pylint_check
31+
- build_main_platforms
32+
- build_aux_platforms
33+
- build_cplay_platforms
34+
- build_m4_platforms
35+
- build_io_platforms

3D_Printed_Bionic_Eye/.trinket.test

Whitespace-only changes.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*******************************************************************
2+
Bionic Eye sketch for Adafruit Trinket.
3+
4+
by Bill Earl
5+
for Adafruit Industries
6+
7+
Required library is the Adafruit_SoftServo library
8+
available at https://github.com/adafruit/Adafruit_SoftServo
9+
The standard Arduino IDE servo library will not work with 8 bit
10+
AVR microcontrollers like Trinket and Gemma due to differences
11+
in available timer hardware and programming. We simply refresh
12+
by piggy-backing on the timer0 millis() counter
13+
14+
Trinket: Bat+ Gnd Pin #0 Pin #1
15+
Connection: Servo+ Servo- Tilt Rotate
16+
(Red) (Brown) Servo Servo
17+
(Orange)(Orange)
18+
19+
*******************************************************************/
20+
21+
#include <Adafruit_SoftServo.h> // SoftwareServo (works on non PWM pins)
22+
23+
#define TILTSERVOPIN 0 // Servo control line (orange) on Trinket Pin #0
24+
#define ROTATESERVOPIN 1 // Servo control line (orange) on Trinket Pin #1
25+
26+
Adafruit_SoftServo TiltServo, RotateServo; //create TWO servo objects
27+
28+
void setup()
29+
{
30+
// Set up the interrupt that will refresh the servo for us automagically
31+
OCR0A = 0xAF; // any number is OK
32+
TIMSK |= _BV(OCIE0A); // Turn on the compare interrupt (below!)
33+
34+
TiltServo.attach(TILTSERVOPIN); // Attach the servo to pin 0 on Trinket
35+
RotateServo.attach(ROTATESERVOPIN); // Attach the servo to pin 1 on Trinket
36+
delay(15); // Wait 15ms for the servo to reach the position
37+
}
38+
39+
void loop()
40+
{
41+
delay(100);
42+
TiltServo.detach(); // release the servo
43+
RotateServo.detach(); // release the servo
44+
45+
if(random(100) > 80) // on average, move once every 500ms
46+
{
47+
TiltServo.attach(TILTSERVOPIN); // Attach the servo to pin 0 on Trinket
48+
TiltServo.write(random(120, 180)); // Tell servo to go to position
49+
}
50+
if(random(100) > 90) // on average, move once every 500ms
51+
{
52+
RotateServo.attach(ROTATESERVOPIN); // Attach the servo to pin 1 on Trinket
53+
RotateServo.write(random(0, 180)); // Tell servo to go to position
54+
}
55+
}
56+
57+
// We'll take advantage of the built in millis() timer that goes off
58+
// to keep track of time, and refresh the servo every 20 milliseconds
59+
// The SIGNAL(TIMER0_COMPA_vect) function is the interrupt that will be
60+
// Called by the microcontroller every 2 milliseconds
61+
volatile uint8_t counter = 0;
62+
SIGNAL(TIMER0_COMPA_vect)
63+
{
64+
// this gets called every 2 milliseconds
65+
counter += 2;
66+
// every 20 milliseconds, refresh the servos!
67+
if (counter >= 20)
68+
{
69+
counter = 0;
70+
TiltServo.refresh();
71+
RotateServo.refresh();
72+
}
73+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Bionic Eye sketch for Adafruit Trinket.
2+
#
3+
# written by Bill Earl for Arduino
4+
# ported to CircuitPython by Mikey Sklar
5+
# for Adafruit Industries
6+
#
7+
# Required library is the Adafruit_SoftServo library
8+
# available at https://github.com/adafruit/Adafruit_SoftServo
9+
# The standard Arduino IDE servo library will not work with 8 bit
10+
# AVR microcontrollers like Trinket and Gemma due to differences
11+
# in available timer hardware and programming. We simply refresh
12+
# by piggy-backing on the timer0 millis() counter
13+
#
14+
# Trinket: Bat+ Gnd Pin #0 Pin #2
15+
# Connection: Servo+ Servo- Tilt Rotate
16+
# (Red) (Black) Servo Servo
17+
# (Orange)(Orange)
18+
19+
import time
20+
import random
21+
import board
22+
import pulseio
23+
from adafruit_motor import servo
24+
25+
# we are intentionally avoiding Trinket Pin #1 (board.A0)
26+
# as it does not have PWM capability
27+
tilt_servo_pin = board.A2 # servo control line (orange) Trinket Pin #0
28+
rotate_servo_pin = board.A1 # servo control line (orange) Trinket Pin #2
29+
30+
# servo object setup for the M0 boards:
31+
tilt_pwm = pulseio.PWMOut(tilt_servo_pin, duty_cycle=2 ** 15, frequency=50)
32+
rotate_pwm = pulseio.PWMOut(rotate_servo_pin, duty_cycle=2 ** 15, frequency=50)
33+
tilt_servo = servo.Servo(tilt_pwm)
34+
rotate_servo = servo.Servo(rotate_pwm)
35+
36+
# servo timing and angle range
37+
tilt_min = 120 # lower limit to tilt rotation range
38+
max_rotate = 180 # rotation range limited to half circle
39+
40+
while True:
41+
42+
# servo tilt - on average move every 500ms
43+
if random.randint(0,100) > 80:
44+
tilt_servo.angle = random.randint(tilt_min, max_rotate)
45+
time.sleep(.25)
46+
47+
# servo rotate - on average move every 500ms
48+
if random.randint(0,100) > 90:
49+
rotate_servo.angle = random.randint(0, max_rotate)
50+
time.sleep(.25)

3D_Printed_Bionic_Eye/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 3D_Printed_Bionic_Eye
2+
3+
Code to accompany this Adafruit tutorial:
4+
https://learn.adafruit.com/3d-printed-bionic-eye
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// Fiery demon horns (rawr!) for Adafruit Trinket/Gemma.
2+
// Adafruit invests time and resources providing this open source code,
3+
// please support Adafruit and open-source hardware by purchasing
4+
// products from Adafruit!
5+
#include <Adafruit_NeoPixel.h>
6+
#include <avr/power.h>
7+
8+
#define N_HORNS 1
9+
#define N_LEDS 30 // Per horn
10+
#define PIN 0
11+
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(N_HORNS * N_LEDS, PIN);
12+
13+
// /\ -> Fire-like effect is the sum of multiple triangle
14+
// ____/ \____ waves in motion, with a 'warm' color map applied.
15+
#define N_WAVES 6 // Number of simultaneous waves (per horn)
16+
// Coordinate space for waves is 16x the pixel spacing,
17+
// allowing fixed-point math to be used instead of floats.
18+
struct {
19+
int16_t lower; // Lower bound of wave
20+
int16_t upper; // Upper bound of wave
21+
int16_t mid; // Midpoint (peak) ((lower+upper)/2)
22+
uint8_t vlower; // Velocity of lower bound
23+
uint8_t vupper; // Velocity of upper bound
24+
uint16_t intensity; // Brightness at peak
25+
} wave[N_HORNS][N_WAVES];
26+
long fade; // Decreases brightness as wave moves
27+
28+
// Gamma correction improves appearance of midrange colors
29+
uint8_t gamma[] PROGMEM = {
30+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
32+
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
33+
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
34+
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
35+
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
36+
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
37+
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
38+
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
39+
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
40+
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
41+
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
42+
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
43+
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
44+
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
45+
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
46+
47+
static void random_wave(uint8_t h,uint8_t w) { // Randomize one wave struct
48+
wave[h][w].upper = -1; // Always start just below head of strip
49+
wave[h][w].lower = -16 * (3 + random(4)); // Lower end starts ~3-7 pixels back
50+
wave[h][w].mid = (wave[h][w].lower + wave[h][w].upper) / 2;
51+
wave[h][w].vlower = 3 + random(4); // Lower end moves at ~1/8 to 1/4 pixel/frame
52+
wave[h][w].vupper = wave[h][w].vlower + random(4); // Upper end moves a bit faster, spreading wave
53+
wave[h][w].intensity = 300 + random(600);
54+
}
55+
56+
void setup() {
57+
uint8_t h, w;
58+
59+
randomSeed(analogRead(1));
60+
pixels.begin();
61+
for(h=0; h<N_HORNS; h++) {
62+
for(w=0; w<N_WAVES; w++) random_wave(h, w);
63+
}
64+
fade = 234 + N_LEDS / 2;
65+
if(fade > 255) fade = 255;
66+
67+
// A ~100 Hz timer interrupt on Timer/Counter1 makes everything run
68+
// at regular intervals, regardless of current amount of motion.
69+
#if F_CPU == 16000000L
70+
clock_prescale_set(clock_div_1);
71+
TCCR1 = _BV(PWM1A) | _BV(CS13) | _BV(CS11) | _BV(CS10); // 1:1024 prescale
72+
OCR1C = F_CPU / 1024 / 100 - 1;
73+
#else
74+
TCCR1 = _BV(PWM1A) | _BV(CS13) | _BV(CS11); // 1:512 prescale
75+
OCR1C = F_CPU / 512 / 100 - 1;
76+
#endif
77+
GTCCR = 0; // No PWM out
78+
TIMSK |= _BV(TOIE1); // Enable overflow interrupt
79+
}
80+
81+
void loop() { } // Not used -- everything's in interrupt below
82+
83+
ISR(TIMER1_OVF_vect) {
84+
uint8_t h, w, i, r, g, b;
85+
int16_t x;
86+
uint16_t sum;
87+
88+
for(h=0; h<N_HORNS; h++) { // For each horn...
89+
for(x=7, i=0; i<N_LEDS; i++, x+=16) { // For each LED along horn...
90+
for(sum=w=0; w<N_WAVES; w++) { // For each wave of horn...
91+
if((x < wave[h][w].lower) || (x > wave[h][w].upper)) continue; // Out of range
92+
if(x <= wave[h][w].mid) { // Lower half of wave (ramping up to peak brightness)
93+
sum += wave[h][w].intensity * (x - wave[h][w].lower) / (wave[h][w].mid - wave[h][w].lower);
94+
} else { // Upper half of wave (ramping down from peak)
95+
sum += wave[h][w].intensity * (wave[h][w].upper - x) / (wave[h][w].upper - wave[h][w].mid);
96+
}
97+
}
98+
// Now the magnitude (sum) is remapped to color for the LEDs.
99+
// A blackbody palette is used - fades white-yellow-red-black.
100+
if(sum < 255) { // 0-254 = black to red-1
101+
r = pgm_read_byte(&gamma[sum]);
102+
g = b = 0;
103+
} else if(sum < 510) { // 255-509 = red to yellow-1
104+
r = 255;
105+
g = pgm_read_byte(&gamma[sum - 255]);
106+
b = 0;
107+
} else if(sum < 765) { // 510-764 = yellow to white-1
108+
r = g = 255;
109+
b = pgm_read_byte(&gamma[sum - 510]);
110+
} else { // 765+ = white
111+
r = g = b = 255;
112+
}
113+
pixels.setPixelColor(h * N_LEDS + i, r, g, b);
114+
}
115+
116+
for(w=0; w<N_WAVES; w++) { // Update wave positions for each horn
117+
wave[h][w].lower += wave[h][w].vlower; // Advance lower position
118+
if(wave[h][w].lower >= (N_LEDS * 16)) { // Off end of strip?
119+
random_wave(h, w); // Yes, 'reboot' wave
120+
} else { // No, adjust other values...
121+
wave[h][w].upper += wave[h][w].vupper;
122+
wave[h][w].mid = (wave[h][w].lower + wave[h][w].upper) / 2;
123+
wave[h][w].intensity = (wave[h][w].intensity * fade) / 256; // Dimmer
124+
}
125+
}
126+
}
127+
pixels.show();
128+
}

0 commit comments

Comments
 (0)