Skip to content

Commit c0a0008

Browse files
authored
Merge pull request #69 from blair-robot-project/merge_multi_module
Merge multi module
2 parents 6f8136f + 170d649 commit c0a0008

File tree

360 files changed

+11981
-10647
lines changed

Some content is hidden

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

360 files changed

+11981
-10647
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ gradle-app.setting
1313
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
1414
# gradle/wrapper/gradle-wrapper.properties
1515

16+
# IntelliJ files
1617
.idea/
1718
*.idea
1819
gen/
1920
classes/
2021
out/
22+
build
23+
*build
24+
*.iml
25+
*.ipr
26+
*.iws
2127

2228
# GradleRIO files
2329
robot2017.iml
@@ -31,3 +37,6 @@ robot2017.iws
3137
#Other
3238
.metadata/
3339
.DS_Store
40+
41+
#Copied log files
42+
logs/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ script:
88
notifications:
99
email:
1010
on_success: never
11-
on_failure: always # default: always
11+
on_failure: always # default: always

Arduino/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
*.obj
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Compiled Dynamic libraries
12+
*.so
13+
*.dylib
14+
*.dll
15+
16+
# Fortran module files
17+
*.mod
18+
*.smod
19+
20+
# Compiled Static libraries
21+
*.lai
22+
*.la
23+
*.a
24+
*.lib
25+
26+
# Executables
27+
*.exe
28+
*.out
29+
*.app
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include <Adafruit_NeoPixel.h>
2+
#ifdef __AVR__
3+
#include <avr/power.h>
4+
#endif
5+
6+
#define PIN 6
7+
8+
// Parameter 1 = number of pixels in strip
9+
// Parameter 2 = Arduino pin number (most are valid)
10+
// Parameter 3 = pixel type flags, add together as needed:
11+
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
12+
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
13+
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
14+
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
15+
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
16+
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
17+
18+
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
19+
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
20+
// and minimize distance between Arduino and first pixel. Avoid connecting
21+
// on a live circuit...if you must, connect GND first./*
22+
/* Analog input, analog output, serial output
23+
24+
Reads an analog input pin, maps the result to a range from 0 to 255
25+
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
26+
Also prints the results to the serial monitor.
27+
28+
The circuit:
29+
* potentiometer connected to analog pin 0.
30+
Center pin of the potentiometer goes to the analog pin.
31+
side pins of the potentiometer go to +5V and ground
32+
* LED connected from digital pin 9 to ground
33+
34+
created 29 Dec. 2008
35+
modified 9 Apr 2012
36+
by Tom Igoe
37+
38+
This example code is in the public domain.
39+
40+
*/
41+
42+
// These constants won't change. They're used to give names
43+
// to the pins used:
44+
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
45+
const int analogOutPin = 9; // Analog output pin that the LED is attached to
46+
47+
int sensorValue = 0; // value read from the pot
48+
int outputValue = 0; // value output to the PWM (analog out)
49+
50+
void setup() {
51+
// initialize serial communications at 9600 bps:
52+
strip.begin();
53+
Serial.begin(9600);
54+
}
55+
56+
void loop() {
57+
// read the analog in value:
58+
sensorValue = analogRead(analogInPin);
59+
// map it to the range of the analog out:
60+
outputValue = map(sensorValue, 0, 1023, 0, 255);
61+
// change the analog out value:
62+
analogWrite(analogOutPin, outputValue);
63+
64+
// print the results to the serial monitor:
65+
Serial.print("sensor = ");
66+
Serial.print(sensorValue);
67+
Serial.print("\t output = ");
68+
Serial.println(outputValue);
69+
70+
// wait 2 milliseconds before the next loop
71+
// for the analog-to-digital converter to settle
72+
// after the last reading:
73+
uint16_t i;
74+
setRed(10, outputValue);
75+
strip.show();
76+
delay(2);
77+
}
78+
79+
void setRed(uint16_t wait, uint8_t color) {
80+
uint16_t i;
81+
for (i = 0; i < strip.numPixels(); i++) {
82+
strip.setPixelColor(i, 0, color, color/2);
83+
}
84+
85+
delay(wait);
86+
}

Arduino/AutoTeleop/AutoTeleop.ino

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
#include <Wire.h>
2+
#include <Adafruit_NeoPixel.h>
3+
4+
#define PIN 6
5+
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);
6+
7+
String state;
8+
9+
uint32_t red = strip.Color(60,0,0);
10+
uint32_t green = strip.Color(0,100,15);
11+
uint32_t oyellow = strip.Color(140,40,0);
12+
uint32_t blue = strip.Color(0,0,100);
13+
uint32_t orange = strip.Color(140,10,0);
14+
uint32_t yellow = strip.Color(90,20,0);
15+
uint32_t purple = strip.Color(55,0,75);
16+
uint32_t pink = strip.Color(80,0,65);
17+
uint32_t lgreen = strip.Color(10,80,10);
18+
uint32_t lblue = strip.Color(15,35,135);
19+
uint32_t cyan = strip.Color(0,80,60);
20+
uint32_t white = strip.Color(40,40,40);
21+
22+
const int rgbChangeSpeed = 18;
23+
24+
//highest value a color would reach.
25+
const int colorMax = 108;
26+
int rred = colorMax;
27+
int rgreen = 0;
28+
int rblue = 0;
29+
30+
//information about the white pixel bit that flows around
31+
int currentPos = 0;
32+
const int whiteLength = 7;
33+
const int whiteSpeed = 2;
34+
35+
int tempIndex;
36+
37+
//last position position that the white pixel bit was at.
38+
int lastPos = strip.numPixels();
39+
//previous color that gets overwritten by the white pixel bit.
40+
uint32_t lastColor;
41+
42+
uint32_t ra1 = purple;
43+
uint32_t ra2 = pink;
44+
uint32_t ba1 = lgreen;
45+
uint32_t ba2 = cyan;
46+
uint32_t rt1 = red;
47+
uint32_t rt2 = orange;
48+
uint32_t bt1 = blue;
49+
uint32_t bt2 = purple;
50+
51+
int loopCounter;
52+
boolean rippleInvert = false;
53+
int ripplePos = 0;
54+
55+
void setup() {
56+
// put your setup code here, to run once:
57+
Wire.begin(4);
58+
Serial.begin(9600);
59+
Wire.onReceive(receiveEventWire);
60+
strip.begin();
61+
strip.show();
62+
state = "init";
63+
}
64+
65+
void loop() {
66+
if (loopCounter % 2 == 0) {
67+
ripplePos++;
68+
loopCounter = 1;
69+
} else {
70+
loopCounter++;
71+
}
72+
73+
if (ripplePos > strip.numPixels() / 2) {
74+
ripplePos = ripplePos % (strip.numPixels()/2);
75+
rippleInvert = !rippleInvert;
76+
}
77+
78+
if (state.equals("init")) {
79+
//if you've completed a cycle (ie current position is now 0, last position is 150)
80+
if (currentPos < lastPos || currentPos > 149) {
81+
//store lastColor, then find your next incremented color
82+
lastColor = strip.Color(rred,rgreen,rblue);
83+
nextRGB();
84+
}
85+
lastPos = currentPos;
86+
tempIndex = currentPos;
87+
//sets the little white pixel bit to white.
88+
while (tempIndex != (currentPos + whiteLength) % 150) {
89+
strip.setPixelColor(tempIndex,100,100,100);
90+
tempIndex = (tempIndex + 1) % 150;
91+
}
92+
//if you're behind the white thing, get set to the new color
93+
for (int i = 0; i < currentPos; i++) {
94+
strip.setPixelColor(i,rred,rgreen,rblue);
95+
}
96+
//if you're beyond the white thing, get set to the old color.
97+
for (int i = currentPos + whiteLength + 1; i < 150; i++) {
98+
strip.setPixelColor(i,lastColor);
99+
}
100+
//update strip, move white pixel bit forward by speed defined above
101+
strip.show();
102+
currentPos += whiteSpeed;
103+
currentPos %= 150;
104+
delay(17);
105+
} else if (state.equals("red_auto")) {
106+
for (int i = 0; i < strip.numPixels(); i++) {
107+
setColor(i, ra1, ra2);
108+
}
109+
} else if (state.equals("blue_auto")) {
110+
for (int i = 0; i < strip.numPixels(); i++) {
111+
setColor(i, ba1, ba2);
112+
}
113+
} else if (state.equals("red_teleop")) {
114+
for (int i = 0; i < strip.numPixels(); i++) {
115+
setColor(i, rt1, rt2);
116+
}
117+
} else if (state.equals("blue_teleop")) {
118+
for (int i = 0; i < strip.numPixels(); i++) {
119+
setColor(i, bt1, bt2);
120+
}
121+
}
122+
strip.show();
123+
delay(1);
124+
}
125+
126+
void receiveEventWire(int numBytes) {
127+
//Serial.println("just entered event");
128+
String temp = "";
129+
while(Wire.available() > 0){
130+
char n = (char) Wire.read();
131+
temp+=n;
132+
}
133+
134+
state = temp;
135+
}
136+
137+
void setColor(int i, uint32_t c1, uint32_t c2) {
138+
if (!rippleInvert) {
139+
if (i < strip.numPixels()/2 - ripplePos || i > strip.numPixels()/2+ripplePos) {
140+
strip.setPixelColor(i,c2);
141+
} else if (i == strip.numPixels()/2 - ripplePos || i == strip.numPixels()/2+ripplePos){
142+
strip.setPixelColor(i,90,90,90);
143+
} else {
144+
strip.setPixelColor(i,c1);
145+
}
146+
} else {
147+
if (i < strip.numPixels()/2 - ripplePos || i > strip.numPixels()/2+ripplePos) {
148+
strip.setPixelColor(i,c1);
149+
} else if (i == strip.numPixels()/2 - ripplePos || i == strip.numPixels()/2+ripplePos) {
150+
strip.setPixelColor(i,90,90,90);
151+
}
152+
else {
153+
strip.setPixelColor(i,c2);
154+
}
155+
}
156+
}
157+
158+
void nextRGB() {
159+
if (rred == colorMax && rgreen < colorMax && rblue == 0) {
160+
rgreen += rgbChangeSpeed;
161+
} else if (rgreen == colorMax && rred > 0 && rblue == 0) {
162+
rred -= rgbChangeSpeed * 1.5;
163+
} else if (rgreen == colorMax && rblue < colorMax && rred == 0) {
164+
rblue += rgbChangeSpeed;
165+
} else if (rblue == colorMax && rgreen > 0 && rred == 0) {
166+
rgreen -= rgbChangeSpeed;
167+
} else if (rblue == colorMax && rred < colorMax && rgreen == 0) {
168+
rred += rgbChangeSpeed;
169+
} else if (rred == colorMax && rblue > 0 && rgreen == 0) {
170+
rblue -= rgbChangeSpeed * .5;
171+
}
172+
}

0 commit comments

Comments
 (0)