summaryrefslogtreecommitdiff
path: root/lpd8806/src/LPD8806.h
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2013-05-16 21:02:19 +0300
committerYuval Adam <yuv.adm@gmail.com>2013-05-16 21:02:19 +0300
commit2ff68176a3fa5b4390abcf2ae28276c4510f95f5 (patch)
treeaa778f7f16996fedc9aa73a90a2d8c5ca8e45b69 /lpd8806/src/LPD8806.h
parent8111ed7c07a31dd99a323a0a29f9e99dd54c6d80 (diff)
Funky LPD8806 stuff
Diffstat (limited to 'lpd8806/src/LPD8806.h')
-rw-r--r--lpd8806/src/LPD8806.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/lpd8806/src/LPD8806.h b/lpd8806/src/LPD8806.h
new file mode 100644
index 0000000..126ef1c
--- /dev/null
+++ b/lpd8806/src/LPD8806.h
@@ -0,0 +1,46 @@
+#if (ARDUINO >= 100)
+ #include <Arduino.h>
+#else
+ #include <WProgram.h>
+ #include <pins_arduino.h>
+#endif
+
+class LPD8806 {
+
+ public:
+
+ LPD8806(uint16_t n, uint8_t dpin, uint8_t cpin); // Configurable pins
+ LPD8806(uint16_t n); // Use SPI hardware; specific pins only
+ LPD8806(void); // Empty constructor; init pins & strip length later
+ void
+ begin(void),
+ show(void),
+ setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b),
+ setPixelColor(uint16_t n, uint32_t c),
+ updatePins(uint8_t dpin, uint8_t cpin), // Change pins, configurable
+ updatePins(void), // Change pins, hardware SPI
+ updateLength(uint16_t n); // Change strip length
+ uint16_t
+ numPixels(void);
+ uint32_t
+ Color(byte, byte, byte),
+ getPixelColor(uint16_t n);
+
+ private:
+
+ uint16_t
+ numLEDs, // Number of RGB LEDs in strip
+ numBytes; // Size of 'pixels' buffer below
+ uint8_t
+ *pixels, // Holds LED color values (3 bytes each) + latch
+ clkpin , datapin, // Clock & data pin numbers
+ clkpinmask, datapinmask; // Clock & data PORT bitmasks
+ volatile uint8_t
+ *clkport , *dataport; // Clock & data PORT registers
+ void
+ startBitbang(void),
+ startSPI(void);
+ boolean
+ hardwareSPI, // If 'true', using hardware SPI
+ begun; // If 'true', begin() method was previously invoked
+};