// *************************************************************************
//
// Documentation LC_libraries, it's all in the book :
// https://github.com/leftCoast/LC_libraryDocs/blob/main/LC_libraries.pdf
// *************************************************************************
#include <SD.h>
#include <neoPixel.h>
#include <bmpImage.h>
#define SD_CS 4
#define BMP_PATH "/swish30.bmp"
neoPixel theBar(30,2);
bmpImage theImage(BMP_PATH);
int numLines;
int line;
void setup() {
SD.begin(SD_CS);
Serial.begin(115200);
if (theImage.openDocFile(FILE_READ)) {
numLines = theImage.getHeight();
line = 0;
} else {
Serial.println("Can't open file. Shutting down.");
while(1);
}
theBar.begin();
}
void drawLine(bmpImage* theImage,int line,neoPixel* thePixels) {
RGBpack thePixel;
colorObj aColor;
int width;
width = theImage->getWidth(); // Get the width.
for (int x=0;x<width;x++) { // Left to right..
thePixel = theImage->getRawPixel(x,line); // Grab a packed pixel color.
aColor.setColor(&thePixel); // Set the color object to this packed pixel color.
thePixels->setPixelColor(x,&aColor); // Drop it into the neopixel call.
} //
thePixels->show(); // Let Adafruit blit out the image.
}
void loop() {
if (line==numLines) {
line = 0;
}
drawLine(&theImage,line++,&theBar);
delay(10);
}