eBoard ①⑧⑨
Written for SIA 2017/2018
neo_animation.cpp File Reference

a simple neo-animation example More...

#include <eBoard.h>
+ Include dependency graph for neo_animation.cpp:

Go to the source code of this file.

Macros

#define IGNORE_SIZE
 
#define EBOARD_USE_UTILITY   0x0
 
#define EBOARD_DEBUG_MODE   0x0
 
#define EBOARD_CHECK_PINS   0x0
 
#define EBOARD_CHECK_PINS_PWM   0x0
 
#define EBOARD_NANO   0x1
 
#define EBOARD_NEO   0x1
 
#define PIXELS_COUNT   5
 
#define RED   240
 
#define GREEN   120
 
#define BLUE   0
 

Functions

void shiftPx (uint8_t &pixBuf)
 this will perform a single shift operation! More...
 
int main ()
 

Variables

NeoPixel pixels = NeoPixel( 5 )
 the NeoPixel-object we use More...
 

Detailed Description

a simple neo-animation example

Definition in file neo_animation.cpp.

Macro Definition Documentation

◆ BLUE

#define BLUE   0

Definition at line 16 of file neo_animation.cpp.

Referenced by shiftPx().

◆ EBOARD_CHECK_PINS

#define EBOARD_CHECK_PINS   0x0

Definition at line 8 of file neo_animation.cpp.

◆ EBOARD_CHECK_PINS_PWM

#define EBOARD_CHECK_PINS_PWM   0x0

Definition at line 9 of file neo_animation.cpp.

◆ EBOARD_DEBUG_MODE

#define EBOARD_DEBUG_MODE   0x0

Definition at line 7 of file neo_animation.cpp.

◆ EBOARD_NANO

#define EBOARD_NANO   0x1

Definition at line 10 of file neo_animation.cpp.

◆ EBOARD_NEO

#define EBOARD_NEO   0x1

Definition at line 11 of file neo_animation.cpp.

◆ EBOARD_USE_UTILITY

#define EBOARD_USE_UTILITY   0x0

Definition at line 6 of file neo_animation.cpp.

◆ GREEN

#define GREEN   120

Definition at line 15 of file neo_animation.cpp.

Referenced by shiftPx().

◆ IGNORE_SIZE

#define IGNORE_SIZE

Definition at line 5 of file neo_animation.cpp.

◆ PIXELS_COUNT

#define PIXELS_COUNT   5

Definition at line 13 of file neo_animation.cpp.

Referenced by shiftPx().

◆ RED

#define RED   240

Definition at line 14 of file neo_animation.cpp.

Referenced by shiftPx().

Function Documentation

◆ main()

int main ( void  )
out.gif
Note
you can copy paste this code into your ARDUINO IDE - keep in mind to change the path!

Compiled Size for ARUDINO NANO: 2,870 bytes
[Version 3.8.10d]
Compiled Size for ARUDINO NANO: 2,778 bytes

Definition at line 44 of file neo_animation.cpp.

References NeoPixel::begin(), pixels, NeoPixel::setBrightness(), and shiftPx().

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 }
NeoPixel pixels
the NeoPixel-object we use
void shiftPx(uint8_t &pixBuf)
this will perform a single shift operation!
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) ...
+ Here is the call graph for this function:

◆ shiftPx()

void shiftPx ( uint8_t &  pixBuf)

this will perform a single shift operation!

Parameters
pixBufthe pixelBuffer [reference]

Definition at line 24 of file neo_animation.cpp.

References BLUE, NeoPixel::Color(), GREEN, pixels, PIXELS_COUNT, RED, NeoPixel::setPixelColor(), and NeoPixel::show().

Referenced by main().

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 }
#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()
#define RED
#define GREEN
#define PIXELS_COUNT
void show(void)
this will reveal the setPixels [via NeoPixel::setPixelColor() etc...]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ pixels

NeoPixel pixels = NeoPixel( 5 )

the NeoPixel-object we use

Definition at line 18 of file neo_animation.cpp.

Referenced by main(), and shiftPx().