eBoard ①⑧⑨
Written for SIA 2017/2018
neo_animation.cpp
Go to the documentation of this file.
1 
4 
5 #define IGNORE_SIZE
6 #define EBOARD_USE_UTILITY 0x0
7 #define EBOARD_DEBUG_MODE 0x0
8 #define EBOARD_CHECK_PINS 0x0
9 #define EBOARD_CHECK_PINS_PWM 0x0
10 #define EBOARD_NANO 0x1
11 #define EBOARD_NEO 0x1
12 #include <eBoard.h>
13 #define PIXELS_COUNT 5
14 #define RED 240
15 #define GREEN 120
16 #define BLUE 0
19 
24 void shiftPx(uint8_t &pixBuf)
25 {
26  for(uint8_t i = 1; i < (PIXELS_COUNT+1); i++)
27  pixels.setPixelColor(i-1,(bitRead(pixBuf,i))?(NeoPixel::Color((RED/((PIXELS_COUNT+1)-i)),(GREEN/((PIXELS_COUNT+1)-i)),(BLUE/((PIXELS_COUNT+1)-i)))):(0));
28  //lock communication here
29  pixels.show();
30  //unlock communication here
31  pixBuf <<= 1;
32  //if inverted: pixBuf >>= 1
33 }
34 
44 int main()
45 {
46  uint8_t pixBuf, j;
47  pixels.begin();
49  for(;;) {
50  pixBuf = 0x3;
51  //if inverted: pixBuf = 192
52  for(j = 0; j < 7; j++) {
53  shiftPx(pixBuf);
54  delay(120 + 4*j); // you can do anything in this time!
55  }
56  }
57  return 0;
58 }
#define BLUE
NeoPixel pixels
the NeoPixel-object we use
void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b)
sets the rgb color of a specific pixel
static uint32_t Color(uint8_t r, uint8_t g, uint8_t b)
returns a color value that can be used with NeoPixel::setPixelColor()
int main()
#define RED
void shiftPx(uint8_t &pixBuf)
this will perform a single shift operation!
#define GREEN
#define PIXELS_COUNT
void setBrightness(uint8_t val)
changes the brightness for all further acceses via NeoPixel::setPixelColor()
void begin(void)
this has to be called to start the communcation (you should call NeoPixel::setPin() before) ...
[NEO] this allows you to access Adafruit LED-stripes
void show(void)
this will reveal the setPixels [via NeoPixel::setPixelColor() etc...]