Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
strip_impl.h
Go to the documentation of this file.
1
6// do not use pragma once here, has this can be mocked
7#ifndef PLATFORM_STRIPIMPL_H
8#define PLATFORM_STRIPIMPL_H
9
10#include <cstddef>
11#include <cstdint>
12
13#define NEO_RGB ((0 << 6) | (0 << 4) | (1 << 2) | (2))
14#define NEO_RBG ((0 << 6) | (0 << 4) | (2 << 2) | (1))
15#define NEO_KHZ800 0x0000
16
17typedef uint8_t neoPixelType;
18
19namespace lampda {
20namespace platform {
22namespace strip {
23
29template<size_t LedCount, uint8_t ChannelCount> class LampdaStrip
30{
31 static_assert(ChannelCount == 3 || ChannelCount == 4);
32
33public:
34 static constexpr size_t numLEDs = LedCount;
35 static constexpr uint8_t channelCount = ChannelCount;
36
37 LampdaStrip(int16_t p, neoPixelType type = NEO_RGB + NEO_KHZ800) : begun(false), endTime(0)
38 {
39 updateType(type);
40 setPin(p);
41 }
42
43 bool begin(void);
44 void show(void);
45
46 void setPixelColor(uint16_t n, uint32_t c);
47 uint32_t getPixelColor(uint16_t n) const;
48
49 bool canShow(void);
50
51protected:
52 void updateType(neoPixelType t);
53 void setPin(int16_t p);
54
55private:
56 bool begun;
57
58 int16_t pin;
59
60 uint8_t rOffset;
61 uint8_t gOffset;
62 uint8_t bOffset;
63 uint8_t wOffset;
64
65 uint32_t endTime;
66
67 static constexpr uint16_t numBytes = LedCount * ChannelCount;
68
69 static constexpr uint32_t pattern_size = numBytes * 8 + 2;
70 uint16_t pixels_pattern[pattern_size];
71
73 uint8_t pixels[numBytes];
74};
75
76} // namespace strip
77} // namespace platform
78} // namespace lampda
79
80#endif
This class is a lightweight port of the Adafruit_Neopixel library, with compile time buffers to have ...
Definition: strip_impl.h:30
void show(void)
Definition: strip_impl.hpp:134
Program scope.
Definition: control_fixed_modes.hpp:12
uint8_t neoPixelType
3rd arg to Adafruit_NeoPixel constructor
Definition: strip_impl.h:17