Skip to content

Commit

Permalink
Merge pull request #102 from Makuna/NeoBitmapFile
Browse files Browse the repository at this point in the history
NeoBitmapFile
  • Loading branch information
Makuna committed Apr 23, 2016
2 parents fd18321 + 6d90159 commit 1069338
Show file tree
Hide file tree
Showing 10 changed files with 460 additions and 6 deletions.
96 changes: 96 additions & 0 deletions examples/NeoPixelBitmap/NeoPixelBitmap.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// NeoPixelBuffer
// This example will animate pixels using a bitmap stored on a SD card
//
//
// This will demonstrate the use of the NeoBitmapFile object
// NOTE: The images provided in the example directory should be copied to
// the root of the SD card so the below code will find it.
// NOTE: This sample and the included images were built for a 144 pixel strip so
// running this with a smaller string may not look as interesting. Try providing
// your own 24 bit bitmap for better results.

#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>
#include <SPI.h>
#include <SD.h>

const int chipSelect = D8; // make sure to set this to your SD carder reader CS

//typedef NeoGrbFeature MyPixelColorFeature;
typedef NeoGrbwFeature MyPixelColorFeature;

const uint16_t PixelCount = 144; // the sample images are meant for 144 pixels
const uint16_t PixelPin = 2;
const uint16_t AnimCount = 1; // we only need one

NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object

// our NeoBitmapFile will use the same color feature as NeoPixelBus and
// we want it to use the SD File object
NeoBitmapFile<MyPixelColorFeature, File> image;

uint16_t animState;

void LoopAnimUpdate(const AnimationParam& param)
{
// wait for this animation to complete,
// we are using it as a timer of sorts
if (param.state == AnimationState_Completed)
{
// done, time to restart this position tracking animation/timer
animations.RestartAnimation(param.index);

// draw the complete row at animState to the complete strip
image.Blt(strip, 0, 0, animState, image.Width());
animState = (animState + 1) % image.Height(); // increment and wrap
}
}

void setup() {
Serial.begin(115200);
while (!Serial); // wait for serial attach

strip.Begin();
strip.Show();

Serial.print("Initializing SD card...");

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect))
{
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");

// open the file
File bitmapFile = SD.open("strings.bmp");
if (!bitmapFile)
{
Serial.println("File open fail, or not present");
// don't do anything more:
return;
}

// initialize the image with the file
if (!image.Begin(bitmapFile))
{
Serial.println("File format fail, not a supported bitmap");
// don't do anything more:
return;
}

animState = 0;
// we use the index 0 animation to time how often we rotate all the pixels
animations.StartAnimation(0, 30, LoopAnimUpdate);
}

void loop() {
// this is all that is needed to keep it running
// and avoiding using delay() is always a good thing for
// any timing related routines
animations.UpdateAnimations();
strip.Show();
}
Binary file added examples/NeoPixelBitmap/Strings.bmp
Binary file not shown.
Binary file added examples/NeoPixelBitmap/StringsW.bmp
Binary file not shown.
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ NeoBufferMethod KEYWORD1
NeoBufferProgmemMethod KEYWORD1
NeoBuffer KEYWORD1
NeoVerticalSpriteSheet KEYWORD1
NeoBitmapFile KEYWORD1

#######################################
# Methods and Functions (KEYWORD2)
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "https://github.com/Makuna/NeoPixelBus"
},
"version": "2.1.1",
"version": "2.1.2",
"frameworks": "arduino",
"platforms": "*"
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=NeoPixelBus by Makuna
version=2.1.1
version=2.1.2
author=Michael C. Miller ([email protected])
maintainer=Michael C. Miller ([email protected])
sentence=A library that makes controlling NeoPixels (WS2811, WS2812 & SK6812) easy.
Expand Down
5 changes: 3 additions & 2 deletions src/NeoPixelBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ License along with NeoPixel. If not, see
#include "internal/HtmlColor.h"
#include "internal/RgbwColor.h"

#include "internal/NeoColorFeatures.h"

#include "internal/Layouts.h"
#include "internal/NeoTopology.h"
#include "internal/NeoTiles.h"
Expand All @@ -44,12 +46,11 @@ License along with NeoPixel. If not, see
#include "internal/NeoBufferMethods.h"
#include "internal/NeoBuffer.h"
#include "internal/NeoSpriteSheet.h"
#include "internal/NeoBitmapFile.h"

#include "internal/NeoEase.h"
#include "internal/NeoGamma.h"

#include "internal/NeoColorFeatures.h"

#if defined(ARDUINO_ARCH_ESP8266)
#include "internal/NeoEsp8266DmaMethod.h"
#include "internal/NeoEsp8266UartMethod.h"
Expand Down
Loading

0 comments on commit 1069338

Please sign in to comment.