Skip to content

Commit 99ce27f

Browse files
committed
Made functions inline to reduce inter-bit delays
1 parent ff3f312 commit 99ce27f

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

SimpleNeopixelDemo/SimpleNeopixelDemo.ino

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
// These values depend on which pin your string is connected to and what board you are using
1313
// More info on how to find these at http://www.arduino.cc/en/Reference/PortManipulation
1414

15-
// These values are for digital pin 8 on an Arduino Yun or digital pin 12 on a DueMilinove/UNO
15+
// These values are for the pin that connects to the Data Input pin on the LED strip. They correspond to...
16+
17+
// Arduino Yun: Digital Pin 8
18+
// DueMilinove/UNO: Digital Pin 12
19+
// Arduino MeagL PWM Pin 4
20+
21+
// You'll need to look up the port/bit combination for other boards.
22+
1623
// Note that you could also include the DigitalWriteFast header file to not need to to this lookup.
1724

1825
#define PIXEL_PORT PORTB // Port of the pin the pixels are connected to
@@ -43,7 +50,7 @@
4350
// Actually send a bit to the string. We must to drop to asm to enusre that the complier does
4451
// not reorder things and make it so the delay happens in the wrong place.
4552

46-
void sendBit( bool bitVal ) {
53+
inline void sendBit( bool bitVal ) {
4754

4855
if ( bitVal ) { // 0 bit
4956

@@ -98,7 +105,7 @@ void sendBit( bool bitVal ) {
98105
}
99106

100107

101-
void sendByte( unsigned char byte ) {
108+
inline void sendByte( unsigned char byte ) {
102109

103110
for( unsigned char bit = 0 ; bit < 8 ; bit++ ) {
104111

@@ -128,7 +135,7 @@ void ledsetup() {
128135

129136
}
130137

131-
void sendPixel( unsigned char r, unsigned char g , unsigned char b ) {
138+
inline void sendPixel( unsigned char r, unsigned char g , unsigned char b ) {
132139

133140
sendByte(g); // Neopixel wants colors in green then red then blue order
134141
sendByte(r);
@@ -332,13 +339,13 @@ void detonate( unsigned char r , unsigned char g , unsigned char b , unsigned in
332339

333340
void setup() {
334341

335-
ledsetup();
342+
ledsetup();
336343

337344
}
338345

339346

340347
void loop() {
341-
348+
342349
// Some example procedures showing how to display to the pixels:
343350
colorWipe(255, 0, 0, 0); // Red
344351
colorWipe(0, 255, 0, 0); // Green

0 commit comments

Comments
 (0)