Simple neopixel (WS2812) library, tuned for stm32 (L432) at 80 MHz Should be compatible with any stm32, different clock speed may require timing adjustments in neopixel.c
Dependents: Nucleo_neopixel_ovgu Nucleo_neopixel_ovgu1 Nucleo_neopixel_ovgu3
Fork of NeoPixel by
neopixel.h@1:037882a8e193, 2017-12-11 (annotated)
- Committer:
- Hinz
- Date:
- Mon Dec 11 12:54:00 2017 +0000
- Revision:
- 1:037882a8e193
- Parent:
- 0:a81364d9a67b
ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MightyPork | 0:a81364d9a67b | 1 | #ifndef NEOPIXEL_H |
MightyPork | 0:a81364d9a67b | 2 | #define NEOPIXEL_H |
MightyPork | 0:a81364d9a67b | 3 | #include "mbed.h" |
MightyPork | 0:a81364d9a67b | 4 | |
MightyPork | 0:a81364d9a67b | 5 | union Pixel { |
MightyPork | 0:a81364d9a67b | 6 | struct __attribute__((packed)) { |
MightyPork | 0:a81364d9a67b | 7 | uint8_t b; |
MightyPork | 0:a81364d9a67b | 8 | uint8_t g; |
MightyPork | 0:a81364d9a67b | 9 | uint8_t r; |
MightyPork | 0:a81364d9a67b | 10 | uint8_t a; // unused |
MightyPork | 0:a81364d9a67b | 11 | }; |
Hinz | 1:037882a8e193 | 12 | uint32_t hex; |
Hinz | 1:037882a8e193 | 13 | }; |
MightyPork | 0:a81364d9a67b | 14 | |
Hinz | 1:037882a8e193 | 15 | class NeoPixel : DigitalOut { |
Hinz | 1:037882a8e193 | 16 | private: |
Hinz | 1:037882a8e193 | 17 | void byte(uint32_t b); |
Hinz | 1:037882a8e193 | 18 | int _npixels; |
Hinz | 1:037882a8e193 | 19 | Pixel *_pixels; |
Hinz | 1:037882a8e193 | 20 | public: |
Hinz | 1:037882a8e193 | 21 | NeoPixel(PinName, int ); |
Hinz | 1:037882a8e193 | 22 | void show(void); |
Hinz | 1:037882a8e193 | 23 | void setColor(int, uint32_t); |
Hinz | 1:037882a8e193 | 24 | void clear(void); |
MightyPork | 0:a81364d9a67b | 25 | }; |
MightyPork | 0:a81364d9a67b | 26 | |
MightyPork | 0:a81364d9a67b | 27 | |
Hinz | 1:037882a8e193 | 28 | #endif /* NEOPIXEL_H */ |