Skip to content

Commit 1069338

Browse files
committed
Merge pull request #102 from Makuna/NeoBitmapFile
NeoBitmapFile
2 parents fd18321 + 6d90159 commit 1069338

10 files changed

Lines changed: 460 additions & 6 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// NeoPixelBuffer
2+
// This example will animate pixels using a bitmap stored on a SD card
3+
//
4+
//
5+
// This will demonstrate the use of the NeoBitmapFile object
6+
// NOTE: The images provided in the example directory should be copied to
7+
// the root of the SD card so the below code will find it.
8+
// NOTE: This sample and the included images were built for a 144 pixel strip so
9+
// running this with a smaller string may not look as interesting. Try providing
10+
// your own 24 bit bitmap for better results.
11+
12+
#include <NeoPixelBus.h>
13+
#include <NeoPixelAnimator.h>
14+
#include <SPI.h>
15+
#include <SD.h>
16+
17+
const int chipSelect = D8; // make sure to set this to your SD carder reader CS
18+
19+
//typedef NeoGrbFeature MyPixelColorFeature;
20+
typedef NeoGrbwFeature MyPixelColorFeature;
21+
22+
const uint16_t PixelCount = 144; // the sample images are meant for 144 pixels
23+
const uint16_t PixelPin = 2;
24+
const uint16_t AnimCount = 1; // we only need one
25+
26+
NeoPixelBus<MyPixelColorFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
27+
NeoPixelAnimator animations(AnimCount); // NeoPixel animation management object
28+
29+
// our NeoBitmapFile will use the same color feature as NeoPixelBus and
30+
// we want it to use the SD File object
31+
NeoBitmapFile<MyPixelColorFeature, File> image;
32+
33+
uint16_t animState;
34+
35+
void LoopAnimUpdate(const AnimationParam& param)
36+
{
37+
// wait for this animation to complete,
38+
// we are using it as a timer of sorts
39+
if (param.state == AnimationState_Completed)
40+
{
41+
// done, time to restart this position tracking animation/timer
42+
animations.RestartAnimation(param.index);
43+
44+
// draw the complete row at animState to the complete strip
45+
image.Blt(strip, 0, 0, animState, image.Width());
46+
animState = (animState + 1) % image.Height(); // increment and wrap
47+
}
48+
}
49+
50+
void setup() {
51+
Serial.begin(115200);
52+
while (!Serial); // wait for serial attach
53+
54+
strip.Begin();
55+
strip.Show();
56+
57+
Serial.print("Initializing SD card...");
58+
59+
// see if the card is present and can be initialized:
60+
if (!SD.begin(chipSelect))
61+
{
62+
Serial.println("Card failed, or not present");
63+
// don't do anything more:
64+
return;
65+
}
66+
Serial.println("card initialized.");
67+
68+
// open the file
69+
File bitmapFile = SD.open("strings.bmp");
70+
if (!bitmapFile)
71+
{
72+
Serial.println("File open fail, or not present");
73+
// don't do anything more:
74+
return;
75+
}
76+
77+
// initialize the image with the file
78+
if (!image.Begin(bitmapFile))
79+
{
80+
Serial.println("File format fail, not a supported bitmap");
81+
// don't do anything more:
82+
return;
83+
}
84+
85+
animState = 0;
86+
// we use the index 0 animation to time how often we rotate all the pixels
87+
animations.StartAnimation(0, 30, LoopAnimUpdate);
88+
}
89+
90+
void loop() {
91+
// this is all that is needed to keep it running
92+
// and avoiding using delay() is always a good thing for
93+
// any timing related routines
94+
animations.UpdateAnimations();
95+
strip.Show();
96+
}
60.8 KB
Binary file not shown.
81.1 KB
Binary file not shown.

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ NeoBufferMethod KEYWORD1
6565
NeoBufferProgmemMethod KEYWORD1
6666
NeoBuffer KEYWORD1
6767
NeoVerticalSpriteSheet KEYWORD1
68+
NeoBitmapFile KEYWORD1
6869

6970
#######################################
7071
# Methods and Functions (KEYWORD2)

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "git",
88
"url": "https://github.com/Makuna/NeoPixelBus"
99
},
10-
"version": "2.1.1",
10+
"version": "2.1.2",
1111
"frameworks": "arduino",
1212
"platforms": "*"
1313
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=NeoPixelBus by Makuna
2-
version=2.1.1
2+
version=2.1.2
33
author=Michael C. Miller (makuna@live.com)
44
maintainer=Michael C. Miller (makuna@live.com)
55
sentence=A library that makes controlling NeoPixels (WS2811, WS2812 & SK6812) easy.

src/NeoPixelBus.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ License along with NeoPixel. If not, see
3535
#include "internal/HtmlColor.h"
3636
#include "internal/RgbwColor.h"
3737

38+
#include "internal/NeoColorFeatures.h"
39+
3840
#include "internal/Layouts.h"
3941
#include "internal/NeoTopology.h"
4042
#include "internal/NeoTiles.h"
@@ -44,12 +46,11 @@ License along with NeoPixel. If not, see
4446
#include "internal/NeoBufferMethods.h"
4547
#include "internal/NeoBuffer.h"
4648
#include "internal/NeoSpriteSheet.h"
49+
#include "internal/NeoBitmapFile.h"
4750

4851
#include "internal/NeoEase.h"
4952
#include "internal/NeoGamma.h"
5053

51-
#include "internal/NeoColorFeatures.h"
52-
5354
#if defined(ARDUINO_ARCH_ESP8266)
5455
#include "internal/NeoEsp8266DmaMethod.h"
5556
#include "internal/NeoEsp8266UartMethod.h"

0 commit comments

Comments
 (0)