forked from Makuna/NeoPixelBus
Buffers
This commit is contained in:
BIN
examples/NeoPixelBufferCylon/Cylon.pdn
Normal file
BIN
examples/NeoPixelBufferCylon/Cylon.pdn
Normal file
Binary file not shown.
30
examples/NeoPixelBufferCylon/CylonGrb.h
Normal file
30
examples/NeoPixelBufferCylon/CylonGrb.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// To recreate the data below, use the Paint.Net plugin "Arduino Progmem NeoPixel FileType"
|
||||
// to save as/export the included Cylon.pdn
|
||||
// Paint.Net - http://www.getpaint.net/download.html#download
|
||||
// Plugin - http://forums.getpaint.net/index.php?/topic/107921-arduino-neopixel-sketch-exporter/
|
||||
// This uses Flatten, GRB, Hexadecimal
|
||||
//
|
||||
|
||||
const uint16_t myImageWidth = 16;
|
||||
const uint16_t myImageHeight = 20;
|
||||
const uint8_t PROGMEM myImage[] = { // (16 x 20) GRB in Hexadecimal
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
30
examples/NeoPixelBufferCylon/CylonGrbw.h
Normal file
30
examples/NeoPixelBufferCylon/CylonGrbw.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// To recreate the data below, use the Paint.Net plugin "Arduino Progmem NeoPixel FileType"
|
||||
// to save as/export the included Cylon.pdn
|
||||
// Paint.Net - http://www.getpaint.net/download.html#download
|
||||
// Plugin - http://forums.getpaint.net/index.php?/topic/107921-arduino-neopixel-sketch-exporter/
|
||||
// This uses Flatten, GRBW, Hexadecimal
|
||||
//
|
||||
|
||||
const uint16_t myImageWidth = 16;
|
||||
const uint16_t myImageHeight = 20;
|
||||
const uint8_t PROGMEM myImage[] = { // (16 x 20) GRBW in Hexadecimal
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
72
examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino
Normal file
72
examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino
Normal file
@@ -0,0 +1,72 @@
|
||||
// NeoPixelBufferCylon
|
||||
// This example will move a Cylon Red Eye back and forth across the
|
||||
// the full collection of pixels on the strip.
|
||||
//
|
||||
// This will demonstrate the use of the NeoPixelVerticalSpriteSheet
|
||||
//
|
||||
|
||||
#include <NeoPixelBus.h>
|
||||
#include <NeoPixelAnimator.h>
|
||||
|
||||
// The actual image is contained in the data structure in one of the Cylon*.h files
|
||||
// You will need to use the one that has the same color feature as your NeoPixelBus
|
||||
// There are two provided, but you can create your own easily enough using
|
||||
// free versions of Paint.Net and the plugin
|
||||
#include "CylonGrb.h"
|
||||
typedef NeoGrbFeature MyPixelColorFeature;
|
||||
|
||||
// #include "CylonGrbw.h"
|
||||
// typedef NeoGrbwFeature MyPixelColorFeature;
|
||||
|
||||
const uint16_t PixelCount = 16; // the sample images are meant for 16 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
|
||||
|
||||
// sprite sheet stored in progmem using the same pixel feature as the NeoPixelBus
|
||||
NeoPixelVerticalSpriteSheet<NeoPixelBufferProgmemMethod<MyPixelColorFeature>> spriteSheet(
|
||||
myImageWidth, // image width and sprite width since its vertical sprite sheet
|
||||
myImageHeight, // image height
|
||||
1, // sprite is only one pixel high
|
||||
myImage);
|
||||
|
||||
uint16_t indexSprite;
|
||||
|
||||
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 next frame in the sprite
|
||||
spriteSheet.Blt(strip, 0, indexSprite);
|
||||
indexSprite = (indexSprite + 1) % myImageHeight; // increment and wrap
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
strip.Begin();
|
||||
strip.Show();
|
||||
|
||||
indexSprite = 0;
|
||||
|
||||
// we use the index 0 animation to time how often we rotate all the pixels
|
||||
animations.StartAnimation(0, 60, 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();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// NeoPixelCylon
|
||||
// This example will move a Cylong Red Eye back and forth across the
|
||||
// This example will move a Cylon Red Eye back and forth across the
|
||||
// the full collection of pixels on the strip.
|
||||
//
|
||||
// This will demonstrate the use of the NeoEase animation ease methods; that provide
|
||||
|
15
keywords.txt
15
keywords.txt
@@ -59,6 +59,12 @@ NeoHueBlendShortestDistance KEYWORD1
|
||||
NeoHueBlendLongestDistance KEYWORD1
|
||||
NeoHueBlendClockwiseDirection KEYWORD1
|
||||
NeoHueBlendCounterClockwiseDirection KEYWORD1
|
||||
NeoBufferContext KEYWORD1
|
||||
LayoutMapCallback KEYWORD1
|
||||
NeoPixelBufferMethod KEYWORD1
|
||||
NeoPixelBufferProgmemMethod KEYWORD1
|
||||
NeoPixelBuffer KEYWORD1
|
||||
NeoPixelVerticalSpriteSheet KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
@@ -121,10 +127,17 @@ CircularOut KEYWORD2
|
||||
CircularInOut KEYWORD2
|
||||
Gamma KEYWORD2
|
||||
Map KEYWORD2
|
||||
MapProbe KEYWORD2
|
||||
getWidth KEYWORD2
|
||||
getHeight KEYWORD2
|
||||
TopologyHint KEYWORD2
|
||||
Correct KEYWORD2
|
||||
SpriteWidth KEYWORD2
|
||||
SpriteHeight KEYWORD2
|
||||
SpriteCount KEYWORD2
|
||||
Blt KEYWORD2
|
||||
Width KEYWORD2
|
||||
Height KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
@@ -141,3 +154,5 @@ AnimationState_Completed LITERAL1
|
||||
NeoTopologyHint_FirstOnPanel LITERAL1
|
||||
NeoTopologyHint_InPanel LITERAL1
|
||||
NeoTopologyHint_LastOnPanel LITERAL1
|
||||
NeoTopologyHint_OutOfBounds LITERAL1
|
||||
PixelIndex_OutOfBounds LITERAL1
|
@@ -40,6 +40,11 @@ License along with NeoPixel. If not, see
|
||||
#include "internal/NeoTiles.h"
|
||||
#include "internal/NeoMosaic.h"
|
||||
|
||||
#include "internal/NeoBufferContext.h"
|
||||
#include "internal/NeoPixelBufferMethods.h"
|
||||
#include "internal/NeoPixelBuffer.h"
|
||||
#include "internal/NeoPixelSpriteSheet.h"
|
||||
|
||||
#include "internal/NeoEase.h"
|
||||
#include "internal/NeoGamma.h"
|
||||
|
||||
@@ -57,6 +62,9 @@ License along with NeoPixel. If not, see
|
||||
#error "Platform Currently Not Supported, please add an Issue at Github/Makuna/NeoPixelBus"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// '_state' flags for internal state
|
||||
#define NEO_DIRTY 0x80 // a change was made to pixel data that requires a show
|
||||
|
||||
@@ -77,6 +85,12 @@ public:
|
||||
|
||||
}
|
||||
|
||||
operator NeoBufferContext<T_COLOR_FEATURE>()
|
||||
{
|
||||
Dirty(); // we assume you are playing with bits
|
||||
return NeoBufferContext<T_COLOR_FEATURE>(_method.getPixels(), _method.getPixelsSize());
|
||||
}
|
||||
|
||||
void Begin()
|
||||
{
|
||||
_method.Initialize();
|
||||
@@ -268,6 +282,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
const uint16_t _countPixels; // Number of RGB LEDs in strip
|
||||
|
||||
|
@@ -28,6 +28,7 @@ License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
const uint16_t PixelIndex_OutOfBounds = 0xffff;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RowMajor
|
||||
|
48
src/internal/NeoBufferContext.h
Normal file
48
src/internal/NeoBufferContext.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoPixel library
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
// This is used to allow a template classes that share common buffer concept to
|
||||
// be able to pass that common information to functions
|
||||
// The template classes just need to expose a conversion operator to this type
|
||||
template <typename T_COLOR_FEATURE> struct NeoBufferContext
|
||||
{
|
||||
NeoBufferContext(uint8_t* pixels,
|
||||
size_t sizePixels) :
|
||||
Pixels(pixels),
|
||||
SizePixels(sizePixels)
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t PixelCount() const
|
||||
{
|
||||
return SizePixels / T_COLOR_FEATURE::PixelSize;
|
||||
};
|
||||
|
||||
uint8_t* Pixels;
|
||||
const size_t SizePixels;
|
||||
|
||||
};
|
@@ -35,8 +35,12 @@ public:
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
@@ -47,7 +51,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
@@ -58,10 +62,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||
uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
while (pDestBack > pPixelDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
@@ -82,11 +98,15 @@ public:
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = (uint32_t*)pPixelDest;
|
||||
uint32_t* pSrc = (uint32_t*)pPixelSrc;
|
||||
const uint32_t* pSrc = (const uint32_t*)pPixelSrc;
|
||||
|
||||
uint32_t* pEnd = pDest + count;
|
||||
while (pDest < pEnd)
|
||||
@@ -95,10 +115,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = (uint32_t*)pPixelDest;
|
||||
uint32_t* pSrc = (uint32_t*)pPixelSrc;
|
||||
const uint32_t* pSrc = (uint32_t*)pPixelSrc;
|
||||
uint32_t* pEnd = pDest + count;
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
@@ -106,12 +126,23 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, uint8_t* pPixelSrc, uint16_t count)
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = (uint32_t*)pPixelDest;
|
||||
uint32_t* pSrc = (uint32_t*)pPixelSrc;
|
||||
const uint32_t* pSrc = (const uint32_t*)pPixelSrc;
|
||||
uint32_t* pEnd = pDest + count;
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_dword(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = (uint32_t*)pPixelDest;
|
||||
const uint32_t* pSrc = (uint32_t*)pPixelSrc;
|
||||
uint32_t* pDestBack = pDest + count;
|
||||
uint32_t* pSrcBack = pSrc + count;
|
||||
const uint32_t* pSrcBack = pSrc + count;
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
@@ -144,6 +175,19 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.G = pgm_read_byte(p++);
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class NeoGrbwFeature : public Neo4Elements
|
||||
@@ -172,6 +216,20 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.G = pgm_read_byte(p++);
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p++);
|
||||
color.W = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class NeoRgbwFeature : public Neo4Elements
|
||||
@@ -199,6 +257,20 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.G = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p++);
|
||||
color.W = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class NeoRgbFeature : public Neo3Elements
|
||||
@@ -224,6 +296,19 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.G = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class NeoBrgFeature : public Neo3Elements
|
||||
@@ -249,6 +334,19 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.B = pgm_read_byte(p++);
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.G = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class NeoRbgFeature : public Neo3Elements
|
||||
@@ -274,4 +372,18 @@ public:
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||
|
||||
color.R = pgm_read_byte(p++);
|
||||
color.B = pgm_read_byte(p++);
|
||||
color.G = pgm_read_byte(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -53,8 +53,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t Map(uint16_t x, uint16_t y) const
|
||||
uint16_t Map(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x >= totalWidth)
|
||||
{
|
||||
x = totalWidth - 1;
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y >= totalHeight)
|
||||
{
|
||||
y = totalHeight - 1;
|
||||
}
|
||||
else if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
|
||||
@@ -63,8 +84,34 @@ public:
|
||||
return localIndex + tileOffset;
|
||||
}
|
||||
|
||||
NeoTopologyHint TopologyHint(uint16_t x, uint16_t y) const
|
||||
uint16_t MapProbe(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight)
|
||||
{
|
||||
return totalWidth * totalHeight; // count, out of bounds
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
|
||||
calculate(x, y, &localIndex, &tileOffset);
|
||||
|
||||
return localIndex + tileOffset;
|
||||
}
|
||||
|
||||
NeoTopologyHint TopologyHint(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight)
|
||||
{
|
||||
return NeoTopologyHint_OutOfBounds;
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
NeoTopologyHint result;
|
||||
@@ -105,19 +152,6 @@ private:
|
||||
|
||||
void calculate(uint16_t x, uint16_t y, uint16_t* pLocalIndex, uint16_t* pTileOffset) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x >= totalWidth)
|
||||
{
|
||||
x = totalWidth - 1;
|
||||
}
|
||||
|
||||
if (y >= totalHeight)
|
||||
{
|
||||
y = totalHeight - 1;
|
||||
}
|
||||
|
||||
uint16_t tileX = x / _topoWidth;
|
||||
uint16_t topoX = x % _topoWidth;
|
||||
|
||||
|
154
src/internal/NeoPixelBuffer.h
Normal file
154
src/internal/NeoPixelBuffer.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoPixel library
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
template<typename T_BUFFER_METHOD> class NeoPixelBuffer
|
||||
{
|
||||
public:
|
||||
NeoPixelBuffer(uint16_t width,
|
||||
uint16_t height,
|
||||
PGM_VOID_P pixels) :
|
||||
_method(width, height, pixels)
|
||||
{
|
||||
}
|
||||
|
||||
operator NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature>()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
uint16_t PixelCount() const
|
||||
{
|
||||
return _method.PixelCount();
|
||||
};
|
||||
|
||||
uint16_t Width() const
|
||||
{
|
||||
return _method.Width();
|
||||
};
|
||||
|
||||
uint16_t Height() const
|
||||
{
|
||||
return _method.Height();
|
||||
};
|
||||
|
||||
void SetPixelColor(uint16_t indexSprite,
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
typename T_BUFFER_METHOD::ColorObject color)
|
||||
{
|
||||
_method.SetPixelColor(pixelIndex(x, y), color);
|
||||
};
|
||||
|
||||
typename T_BUFFER_METHOD::ColorObject GetPixelColor(uint16_t indexSprite,
|
||||
int16_t x,
|
||||
int16_t y) const
|
||||
{
|
||||
return _method.GetPixelColor(pixelIndex(x, y));
|
||||
};
|
||||
|
||||
void ClearTo(typename T_BUFFER_METHOD::ColorObject color)
|
||||
{
|
||||
_method.ClearTo(color);
|
||||
};
|
||||
|
||||
void Blt(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer,
|
||||
uint16_t indexPixel)
|
||||
{
|
||||
uint16_t destPixelCount = destBuffer.PixelCount();
|
||||
// validate indexPixel
|
||||
if (indexPixel >= destPixelCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// calc how many we can copy
|
||||
uint16_t copyCount = destPixelCount - indexPixel;
|
||||
uint16_t srcPixelCount = PixelCount();
|
||||
if (copyCount > srcPixelCount)
|
||||
{
|
||||
copyCount = srcPixelCount;
|
||||
}
|
||||
|
||||
uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexPixel);
|
||||
_method.CopyPixels(pDest, _method.Pixels(), copyCount);
|
||||
}
|
||||
|
||||
void Blt(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer,
|
||||
int16_t xDest,
|
||||
int16_t yDest,
|
||||
int16_t xSrc,
|
||||
int16_t ySrc,
|
||||
int16_t wSrc,
|
||||
int16_t hSrc,
|
||||
LayoutMapCallback layoutMap)
|
||||
{
|
||||
uint16_t destPixelCount = destBuffer.PixelCount();
|
||||
|
||||
for (int16_t y = 0; y < hSrc; y++)
|
||||
{
|
||||
for (int16_t x = 0; x < wSrc; x++)
|
||||
{
|
||||
uint16_t indexDest = layoutMap(xDest + x, yDest + y);
|
||||
|
||||
if (indexDest < destPixelCount)
|
||||
{
|
||||
const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), pixelIndex(xSrc + x, ySrc + y));
|
||||
uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexDest);
|
||||
|
||||
_method.CopyPixels(pDest, pSrc, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Blt(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer,
|
||||
int16_t xDest,
|
||||
int16_t yDest,
|
||||
LayoutMapCallback layoutMap)
|
||||
{
|
||||
Blt(destBuffer, xDest, yDest, 0, 0, Width(), Height(), layoutMap);
|
||||
}
|
||||
|
||||
private:
|
||||
T_BUFFER_METHOD _method;
|
||||
|
||||
uint16_t pixelIndex(
|
||||
int16_t x,
|
||||
int16_t y)
|
||||
{
|
||||
uint16_t result = PixelIndex_OutOfBounds;
|
||||
|
||||
if (x >= 0 &&
|
||||
x < Width() &&
|
||||
y >= 0 &&
|
||||
y < Height())
|
||||
{
|
||||
result = x + y * Width();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
258
src/internal/NeoPixelBufferMethods.h
Normal file
258
src/internal/NeoPixelBufferMethods.h
Normal file
@@ -0,0 +1,258 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoPixel library
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifdef ARDUINO_ARCH_AVR
|
||||
|
||||
typedef uint16_t(*LayoutMapCallback)(int16_t x, int16_t y);
|
||||
|
||||
#else
|
||||
|
||||
#undef max
|
||||
#undef min
|
||||
#include <functional>
|
||||
typedef std::function<uint16_t(int16_t x, int16_t y)> LayoutMapCallback;
|
||||
|
||||
#endif
|
||||
|
||||
template<typename T_COLOR_FEATURE> class NeoPixelBufferMethod
|
||||
{
|
||||
public:
|
||||
NeoPixelBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = NULL) :
|
||||
_width(width),
|
||||
_height(height)
|
||||
{
|
||||
_pixels = (uint8_t*)malloc(PixelsSize());
|
||||
if (pixels)
|
||||
{
|
||||
// copy from progmem to initialize
|
||||
T_COLOR_FEATURE::movePixelsInc_P(_pixels, pixels, PixelCount());
|
||||
}
|
||||
}
|
||||
|
||||
operator NeoBufferContext<T_COLOR_FEATURE>()
|
||||
{
|
||||
return NeoBufferContext<T_COLOR_FEATURE>(Pixels(), PixelsSize());
|
||||
}
|
||||
|
||||
uint8_t* Pixels() const
|
||||
{
|
||||
return _pixels;
|
||||
};
|
||||
|
||||
size_t PixelsSize() const
|
||||
{
|
||||
return PixelSize() * PixelCount();
|
||||
};
|
||||
|
||||
size_t PixelSize() const
|
||||
{
|
||||
return T_COLOR_FEATURE::PixelSize;
|
||||
};
|
||||
|
||||
uint16_t PixelCount() const
|
||||
{
|
||||
return _width * _height;
|
||||
};
|
||||
|
||||
uint16_t Width() const
|
||||
{
|
||||
return _width;
|
||||
};
|
||||
|
||||
uint16_t Height() const
|
||||
{
|
||||
return _height;
|
||||
};
|
||||
|
||||
void SetPixelColor(uint16_t indexPixel, typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
if (indexPixel < PixelCount())
|
||||
{
|
||||
T_COLOR_FEATURE::applyPixelColor(_pixels, indexPixel, color);
|
||||
}
|
||||
};
|
||||
|
||||
void SetPixelColor(int16_t x, int16_t y, typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
if (x < 0 || x >= _width || y < 0 || y >= _height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t indexPixel = x + y * _width;
|
||||
T_COLOR_FEATURE::applyPixelColor(_pixels, indexPixel, color);
|
||||
};
|
||||
|
||||
typename T_COLOR_FEATURE::ColorObject GetPixelColor(uint16_t indexPixel) const
|
||||
{
|
||||
if (indexPixel >= PixelCount())
|
||||
{
|
||||
// Pixel # is out of bounds, this will get converted to a
|
||||
// color object type initialized to 0 (black)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return T_COLOR_FEATURE::retrievePixelColor(_pixels, indexPixel);
|
||||
};
|
||||
|
||||
typename T_COLOR_FEATURE::ColorObject GetPixelColor(int16_t x, int16_t y) const
|
||||
{
|
||||
if (x < 0 || x >= _width || y < 0 || y >= _height)
|
||||
{
|
||||
// Pixel # is out of bounds, this will get converted to a
|
||||
// color object type initialized to 0 (black)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t indexPixel = x + y * _width;
|
||||
return T_COLOR_FEATURE::retrievePixelColor(_pixels, indexPixel);
|
||||
};
|
||||
|
||||
void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
uint8_t temp[T_COLOR_FEATURE::PixelSize];
|
||||
|
||||
T_COLOR_FEATURE::applyPixelColor(temp, 0, color);
|
||||
|
||||
T_COLOR_FEATURE::replicatePixel(_pixels, temp, PixelCount());
|
||||
};
|
||||
|
||||
void CopyPixels(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
T_COLOR_FEATURE::movePixelsInc(pPixelDest, pPixelSrc, count);
|
||||
}
|
||||
|
||||
typedef typename T_COLOR_FEATURE::ColorObject ColorObject;
|
||||
typedef T_COLOR_FEATURE ColorFeature;
|
||||
|
||||
private:
|
||||
const uint16_t _width;
|
||||
const uint16_t _height;
|
||||
uint8_t* _pixels;
|
||||
};
|
||||
|
||||
template<typename T_COLOR_FEATURE> class NeoPixelBufferProgmemMethod
|
||||
{
|
||||
public:
|
||||
NeoPixelBufferProgmemMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
_pixels(pixels)
|
||||
{
|
||||
}
|
||||
|
||||
operator NeoBufferContext<T_COLOR_FEATURE>()
|
||||
{
|
||||
return NeoBufferContext<T_COLOR_FEATURE>(Pixels(), PixelsSize());
|
||||
}
|
||||
|
||||
uint8_t* Pixels() const
|
||||
{
|
||||
return (uint8_t*)_pixels;
|
||||
};
|
||||
|
||||
size_t PixelsSize() const
|
||||
{
|
||||
return PixelSize() * PixelCount();
|
||||
};
|
||||
|
||||
size_t PixelSize() const
|
||||
{
|
||||
return T_COLOR_FEATURE::PixelSize;
|
||||
};
|
||||
|
||||
uint16_t PixelCount() const
|
||||
{
|
||||
return _width * _height;
|
||||
};
|
||||
|
||||
uint16_t Width() const
|
||||
{
|
||||
return _width;
|
||||
};
|
||||
|
||||
uint16_t Height() const
|
||||
{
|
||||
return _height;
|
||||
};
|
||||
|
||||
void SetPixelColor(uint16_t indexPixel, typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
// PROGMEM is read only, this will do nothing
|
||||
};
|
||||
|
||||
void SetPixelColor(uint16_t x, uint16_t y, typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
// PROGMEM is read only, this will do nothing
|
||||
};
|
||||
|
||||
typename T_COLOR_FEATURE::ColorObject GetPixelColor(uint16_t indexPixel) const
|
||||
{
|
||||
if (indexPixel >= PixelCount())
|
||||
{
|
||||
// Pixel # is out of bounds, this will get converted to a
|
||||
// color object type initialized to 0 (black)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel);
|
||||
};
|
||||
|
||||
typename T_COLOR_FEATURE::ColorObject GetPixelColor(int16_t x, int16_t y) const
|
||||
{
|
||||
if (x < 0 || x >= _width || y < 0 || y >= _height)
|
||||
{
|
||||
// Pixel # is out of bounds, this will get converted to a
|
||||
// color object type initialized to 0 (black)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t indexPixel = x + y * _width;
|
||||
return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel);
|
||||
};
|
||||
|
||||
void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
|
||||
{
|
||||
// PROGMEM is read only, this will do nothing
|
||||
};
|
||||
|
||||
void CopyPixels(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
T_COLOR_FEATURE::movePixelsInc_P(pPixelDest, pPixelSrc, count);
|
||||
}
|
||||
|
||||
typedef typename T_COLOR_FEATURE::ColorObject ColorObject;
|
||||
typedef T_COLOR_FEATURE ColorFeature;
|
||||
|
||||
private:
|
||||
const uint16_t _width;
|
||||
const uint16_t _height;
|
||||
PGM_VOID_P _pixels;
|
||||
};
|
||||
|
163
src/internal/NeoPixelSpriteSheet.h
Normal file
163
src/internal/NeoPixelSpriteSheet.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoPixel library
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
template<typename T_BUFFER_METHOD> class NeoPixelVerticalSpriteSheet
|
||||
{
|
||||
public:
|
||||
NeoPixelVerticalSpriteSheet(uint16_t width,
|
||||
uint16_t height,
|
||||
uint16_t spriteHeight,
|
||||
PGM_VOID_P pixels) :
|
||||
_method(width, height, pixels),
|
||||
_spriteHeight(spriteHeight),
|
||||
_spriteCount(height / spriteHeight)
|
||||
{
|
||||
}
|
||||
|
||||
operator NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature>()
|
||||
{
|
||||
return _method;
|
||||
}
|
||||
|
||||
uint16_t SpriteWidth() const
|
||||
{
|
||||
return _method.Width();
|
||||
};
|
||||
|
||||
uint16_t SpriteHeight() const
|
||||
{
|
||||
return _spriteHeight;
|
||||
};
|
||||
|
||||
uint16_t SpriteCount() const
|
||||
{
|
||||
return _spriteCount;
|
||||
}
|
||||
|
||||
void SetPixelColor(uint16_t indexSprite,
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
typename T_BUFFER_METHOD::ColorObject color)
|
||||
{
|
||||
_method.SetPixelColor(pixelIndex(indexSprite, x, y), color);
|
||||
};
|
||||
|
||||
typename T_BUFFER_METHOD::ColorObject GetPixelColor(uint16_t indexSprite,
|
||||
int16_t x,
|
||||
int16_t y) const
|
||||
{
|
||||
return _method.GetPixelColor(pixelIndex(indexSprite, x, y));
|
||||
};
|
||||
|
||||
void ClearTo(typename T_BUFFER_METHOD::ColorObject color)
|
||||
{
|
||||
_method.ClearTo(color);
|
||||
};
|
||||
|
||||
void Blt(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer,
|
||||
uint16_t indexPixel,
|
||||
uint16_t indexSprite)
|
||||
{
|
||||
uint16_t destPixelCount = destBuffer.PixelCount();
|
||||
// validate indexPixel
|
||||
if (indexPixel >= destPixelCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// validate indexSprite
|
||||
if (indexSprite >= _spriteCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// calc how many we can copy
|
||||
uint16_t copyCount = destPixelCount - indexPixel;
|
||||
|
||||
if (copyCount > SpriteWidth())
|
||||
{
|
||||
copyCount = SpriteWidth();
|
||||
}
|
||||
|
||||
uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexPixel);
|
||||
const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), pixelIndex(indexSprite, 0, 0));
|
||||
_method.CopyPixels(pDest, pSrc, copyCount);
|
||||
}
|
||||
|
||||
void Blt(NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature> destBuffer,
|
||||
int16_t x,
|
||||
int16_t y,
|
||||
uint16_t indexSprite,
|
||||
LayoutMapCallback layoutMap)
|
||||
{
|
||||
if (indexSprite >= _spriteCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint16_t destPixelCount = destBuffer.PixelCount();
|
||||
|
||||
for (int16_t srcY = 0; srcY < SpriteHeight(); srcY++)
|
||||
{
|
||||
for (int16_t srcX = 0; srcX < SpriteWidth(); srcX++)
|
||||
{
|
||||
uint16_t indexDest = layoutMap(srcX + x, srcY + y);
|
||||
|
||||
if (indexDest < destPixelCount)
|
||||
{
|
||||
const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), pixelIndex(indexSprite, srcX, srcY));
|
||||
uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexDest);
|
||||
|
||||
_method.CopyPixels(pDest, pSrc, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
T_BUFFER_METHOD _method;
|
||||
|
||||
const uint16_t _spriteHeight;
|
||||
const uint16_t _spriteCount;
|
||||
|
||||
uint16_t pixelIndex(uint16_t indexSprite,
|
||||
int16_t x,
|
||||
int16_t y)
|
||||
{
|
||||
uint16_t result = PixelIndex_OutOfBounds;
|
||||
|
||||
if (indexSprite < _spriteCount &&
|
||||
x >= 0 &&
|
||||
x < SpriteWidth() &&
|
||||
y >= 0 &&
|
||||
y < SpriteHeight())
|
||||
{
|
||||
result = x + y * SpriteWidth() + indexSprite * _spriteHeight * SpriteWidth();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
95
src/internal/NeoTexture.h
Normal file
95
src/internal/NeoTexture.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Teture provides a texture object that can contain a matrix of Color
|
||||
values
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
NOTES:
|
||||
Where does the data come from?
|
||||
* Loaded by external routine
|
||||
|
||||
|
||||
|
||||
template<typename T_COLOR> class Texture
|
||||
{
|
||||
public:
|
||||
Texture(uint16_t width, uint16_t height, T_COLOR* pixels) :
|
||||
_width(width),
|
||||
_height(height),
|
||||
_pixels(pixels)
|
||||
{
|
||||
};
|
||||
|
||||
const T_COLOR* Blend(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, float progress)
|
||||
{
|
||||
x1 = constrain(x1, 0, _width - 1);
|
||||
y1 = constrain(y1, 0, _height - 1);
|
||||
x2 = constrain(x2, 0, _width - 1);
|
||||
y2 = constrain(y2, 0, _height - 1);
|
||||
|
||||
// calc cordinate of the four nearby pixels
|
||||
// first lerp our cordinates
|
||||
float xf = (static_cast<float>(x2) - x1) * progress + x1;
|
||||
float yf = (static_cast<float>(y2) - y1) * progress + y1;
|
||||
|
||||
uint16_t x = static_cast<uint16_t>(xf); // truncates to lower uint
|
||||
uint16_t y = static_cast<uint16_t>(yf); // truncates to lower uint
|
||||
uint16_t xn = x + 1;
|
||||
uint16_t yn = y + 1;
|
||||
|
||||
T_COLOR c00 = PixelAt(x, y);
|
||||
T_COLOR c01 = PixelAt(x, yn);
|
||||
T_COLOR c10 = PixelAt(xn, y);
|
||||
T_COLOR c11 = PixelAt(xn, yn);
|
||||
|
||||
// unitize progress cordinate to these pixels
|
||||
xf -= x;
|
||||
yf -= y;
|
||||
|
||||
return T_COLOR::BilinearBlend(c00, c01, c10, c11, xf, yf);
|
||||
};
|
||||
|
||||
const T_COLOR& PixelAt(uint16_t x, uint16_t y)
|
||||
{
|
||||
uint16_t xSafe = constrain(x, 0, _width - 1);
|
||||
uint16_t ySafe = constrain(y, 0, _height - 1);
|
||||
return pixelAt(xSafe, ySafe);
|
||||
}
|
||||
|
||||
private:
|
||||
const uint16_t _width;
|
||||
const uint16_t _height;
|
||||
const T_COLOR* _pixels;
|
||||
|
||||
const T_COLOR& pixelAt(uint16_t x, uint16_t y)
|
||||
{
|
||||
return *(_pixels + x + y * _width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Texture<RgbColor> RgbTexture;
|
||||
typedef Texture<RgbwColor> RgbwTexture;
|
||||
typedef Texture<HtmlColor> HtmlTexture;
|
||||
|
@@ -47,8 +47,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t Map(uint16_t x, uint16_t y) const
|
||||
uint16_t Map(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x >= totalWidth)
|
||||
{
|
||||
x = totalWidth - 1;
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (y >= totalHeight)
|
||||
{
|
||||
y = totalHeight - 1;
|
||||
}
|
||||
else if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
|
||||
@@ -57,8 +78,34 @@ public:
|
||||
return localIndex + tileOffset;
|
||||
}
|
||||
|
||||
NeoTopologyHint TopologyHint(uint16_t x, uint16_t y) const
|
||||
uint16_t MapProbe(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight)
|
||||
{
|
||||
return totalWidth * totalHeight; // count, out of bounds
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
|
||||
calculate(x, y, &localIndex, &tileOffset);
|
||||
|
||||
return localIndex + tileOffset;
|
||||
}
|
||||
|
||||
NeoTopologyHint TopologyHint(int16_t x, int16_t y) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight)
|
||||
{
|
||||
return NeoTopologyHint_OutOfBounds;
|
||||
}
|
||||
|
||||
uint16_t localIndex;
|
||||
uint16_t tileOffset;
|
||||
NeoTopologyHint result;
|
||||
@@ -98,19 +145,6 @@ private:
|
||||
|
||||
void calculate(uint16_t x, uint16_t y, uint16_t* pLocalIndex, uint16_t* pTileOffset) const
|
||||
{
|
||||
uint16_t totalWidth = getWidth();
|
||||
uint16_t totalHeight = getHeight();
|
||||
|
||||
if (x >= totalWidth)
|
||||
{
|
||||
x = totalWidth - 1;
|
||||
}
|
||||
|
||||
if (y >= totalHeight)
|
||||
{
|
||||
y = totalHeight - 1;
|
||||
}
|
||||
|
||||
uint16_t tileX = x / _topo.getWidth();
|
||||
uint16_t topoX = x % _topo.getWidth();
|
||||
|
||||
|
@@ -32,6 +32,7 @@ enum NeoTopologyHint
|
||||
NeoTopologyHint_FirstOnPanel,
|
||||
NeoTopologyHint_InPanel,
|
||||
NeoTopologyHint_LastOnPanel,
|
||||
NeoTopologyHint_OutOfBounds
|
||||
};
|
||||
|
||||
template <typename T_LAYOUT> class NeoTopology
|
||||
@@ -44,16 +45,33 @@ public:
|
||||
|
||||
}
|
||||
|
||||
uint16_t Map(uint16_t x, uint16_t y) const
|
||||
uint16_t Map(int16_t x, int16_t y) const
|
||||
{
|
||||
if (x >= _width)
|
||||
{
|
||||
x = _width - 1;
|
||||
}
|
||||
else if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
if (y >= _height)
|
||||
{
|
||||
y = _height - 1;
|
||||
}
|
||||
else if (y < 0)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
return T_LAYOUT::Map(_width, _height, x, y);
|
||||
}
|
||||
|
||||
uint16_t MapProbe(int16_t x, int16_t y) const
|
||||
{
|
||||
if (x < 0 || x >= _width || y < 0 || y >= _height)
|
||||
{
|
||||
return _width * _height; // count, out of bounds
|
||||
}
|
||||
return T_LAYOUT::Map(_width, _height, x, y);
|
||||
}
|
||||
|
||||
|
@@ -48,10 +48,16 @@ static float _CalcColor(float p, float q, float t)
|
||||
return p;
|
||||
}
|
||||
|
||||
RgbColor::RgbColor(const HtmlColor& color) :
|
||||
R((color.Color >> 16) & 0xff), G((color.Color >> 8) & 0xff), B(color.Color & 0xff)
|
||||
RgbColor::RgbColor(const HtmlColor& color)
|
||||
{
|
||||
}
|
||||
uint32_t temp = color.Color;
|
||||
|
||||
B = (temp & 0xff);
|
||||
temp = temp >> 8;
|
||||
G = (temp & 0xff);
|
||||
temp = temp >> 8;
|
||||
R = (temp & 0xff);
|
||||
};
|
||||
|
||||
RgbColor::RgbColor(const HslColor& color)
|
||||
{
|
||||
|
@@ -28,6 +28,19 @@ License along with NeoPixel. If not, see
|
||||
#include "HslColor.h"
|
||||
#include "HsbColor.h"
|
||||
#include "RgbwColor.h"
|
||||
#include "HtmlColor.h"
|
||||
|
||||
RgbwColor::RgbwColor(const HtmlColor& color)
|
||||
{
|
||||
uint32_t temp = color.Color;
|
||||
B = (temp & 0xff);
|
||||
temp = temp >> 8;
|
||||
G = (temp & 0xff);
|
||||
temp = temp >> 8;
|
||||
R = (temp & 0xff);
|
||||
temp = temp >> 8;
|
||||
W = (temp & 0xff);
|
||||
};
|
||||
|
||||
RgbwColor::RgbwColor(const HslColor& color)
|
||||
{
|
||||
|
@@ -65,8 +65,12 @@ struct RgbwColor
|
||||
B(color.B),
|
||||
W(0)
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
// Construct a RgbwColor using HtmlColor
|
||||
// ------------------------------------------------------------------------
|
||||
RgbwColor(const HtmlColor& color);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Construct a RgbwColor using HslColor
|
||||
|
Reference in New Issue
Block a user