Created
October 17, 2015 20:07
-
-
Save dmiddlecamp/a50d9043b8f01b9fb2e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEFAULT_BRIGHTNESS 1 | |
#define NUM_PIXELS 8 | |
float pixels[NUM_PIXELS]; | |
#define KERNEL_SIZE 5 | |
float kernel[KERNEL_SIZE] = { 1, 0.8, 0.4, 0.8, 1 }; | |
int kernelPos = -1 * KERNEL_SIZE; | |
void resetPixels() { | |
for(int i=0;i<NUM_PIXELS;i++) { | |
pixels[i] = DEFAULT_BRIGHTNESS; | |
} | |
} | |
void calcPixels() { | |
for(int i=0;i<NUM_PIXELS;i++) { | |
int pixelIdx = kernelPos + i; | |
if ((pixelIdx > 0) && (pixelIdx < NUM_PIXELS)) { | |
int kernelIdx = (i % KERNEL_SIZE); | |
pixels[pixelIdx] = pixels[pixelIdx] * kernel[pixelIdx]; | |
} | |
} | |
} | |
void setup() { | |
} | |
void loop() { | |
resetPixels(); | |
calcPixels(); | |
kernelPos++; | |
if (kernelPos > (NUM_PIXELS + KERNEL_SIZE)) { | |
kernelPos = -1 * KERNEL_SIZE; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment