Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SD600A by
SD600A.h@26:98163818a82e, 2012-10-13 (annotated)
- Committer:
- heroic
- Date:
- Sat Oct 13 04:49:47 2012 +0000
- Revision:
- 26:98163818a82e
- Parent:
- 24:d8d960a7124e
- Child:
- 27:6667543f3b28
Change SD600A SPI to use a single SD600ASupervisor for SPI. This substantially reduces interrupt load.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
heroic | 26:98163818a82e | 1 | // Mbed library to control SD600A-based RGB LED Strips |
heroic | 26:98163818a82e | 2 | // (c) 2011 Jelmer Tiete |
heroic | 26:98163818a82e | 3 | // This library is ported from the Arduino implementation of Adafruit Industries |
heroic | 26:98163818a82e | 4 | // found at: http://github.com/adafruit/LPD8806 |
heroic | 26:98163818a82e | 5 | // and their strips: http://www.adafruit.com/products/306 |
heroic | 26:98163818a82e | 6 | // Released under the MIT License: http://mbed.org/license/mit |
heroic | 26:98163818a82e | 7 | // |
heroic | 26:98163818a82e | 8 | /*****************************************************************************/ |
heroic | 26:98163818a82e | 9 | |
heroic | 26:98163818a82e | 10 | // Heavily modified by Jas Strong, 2012-10-04 |
heroic | 26:98163818a82e | 11 | // Changed to use a virtual base class, drive the SD600A, and to use software SPI. |
heroic | 26:98163818a82e | 12 | |
heroic | 26:98163818a82e | 13 | #include "mbed.h" |
heroic | 26:98163818a82e | 14 | #include "rtos.h" |
heroic | 26:98163818a82e | 15 | #include "LedStrip.h" |
heroic | 26:98163818a82e | 16 | #ifndef MBED_SD600A_H |
heroic | 26:98163818a82e | 17 | #define MBED_SD600A_H |
heroic | 26:98163818a82e | 18 | |
heroic | 26:98163818a82e | 19 | #define INTERRUPT_INTERVAL (60) |
heroic | 26:98163818a82e | 20 | |
heroic | 26:98163818a82e | 21 | class SD600A : public LedStrip { |
heroic | 26:98163818a82e | 22 | public: |
heroic | 26:98163818a82e | 23 | SD600A(PinName dataPin, PinName clockPin, int n); |
heroic | 26:98163818a82e | 24 | virtual void begin(void); |
heroic | 26:98163818a82e | 25 | virtual void show(void); |
heroic | 26:98163818a82e | 26 | virtual void blank(void); |
heroic | 26:98163818a82e | 27 | virtual void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b); |
heroic | 26:98163818a82e | 28 | virtual void setPixelB(uint16_t n, uint8_t b); |
heroic | 26:98163818a82e | 29 | virtual void setPixelG(uint16_t n, uint8_t g); |
heroic | 26:98163818a82e | 30 | virtual void setPixelR(uint16_t n, uint8_t r); |
heroic | 26:98163818a82e | 31 | virtual void setPixelColor(uint16_t n, uint32_t c); |
heroic | 26:98163818a82e | 32 | virtual uint16_t numPixels(void); |
heroic | 26:98163818a82e | 33 | virtual uint32_t Color(uint8_t, uint8_t, uint8_t); |
heroic | 26:98163818a82e | 34 | virtual uint32_t total_luminance(void); |
heroic | 26:98163818a82e | 35 | friend class SD600ASupervisor; |
heroic | 26:98163818a82e | 36 | |
heroic | 26:98163818a82e | 37 | private: |
heroic | 26:98163818a82e | 38 | void write(uint8_t byte); |
heroic | 26:98163818a82e | 39 | uint8_t *pixels; // Holds LED color values; also, SPI buffer. |
heroic | 26:98163818a82e | 40 | uint32_t data_length; // used by SPI ISR |
heroic | 26:98163818a82e | 41 | uint32_t bit_index; // used by SPI ISR |
heroic | 26:98163818a82e | 42 | uint32_t byte_index; |
heroic | 26:98163818a82e | 43 | uint16_t numLEDs; // Number of RGB LEDs in strand |
heroic | 26:98163818a82e | 44 | DigitalOut dat; |
heroic | 26:98163818a82e | 45 | DigitalOut clk; |
heroic | 26:98163818a82e | 46 | |
heroic | 26:98163818a82e | 47 | }; |
heroic | 26:98163818a82e | 48 | |
heroic | 26:98163818a82e | 49 | class SD600ASupervisor { |
heroic | 26:98163818a82e | 50 | public: |
heroic | 26:98163818a82e | 51 | SD600ASupervisor(void); |
heroic | 26:98163818a82e | 52 | virtual void add(SD600A *strip); |
heroic | 26:98163818a82e | 53 | private: |
heroic | 26:98163818a82e | 54 | uint32_t data_length; // used by SPI ISR |
heroic | 26:98163818a82e | 55 | uint32_t bit_index; // used by SPI ISR |
heroic | 26:98163818a82e | 56 | uint32_t byte_index; |
heroic | 26:98163818a82e | 57 | |
heroic | 26:98163818a82e | 58 | uint32_t numstrips; |
heroic | 26:98163818a82e | 59 | SD600A *strips[8]; |
heroic | 26:98163818a82e | 60 | Ticker idletoggle; |
heroic | 26:98163818a82e | 61 | void spi_isr(void); |
heroic | 26:98163818a82e | 62 | }; |
ehbmbed2 | 0:12e734116fea | 63 | #endif |