upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
p9813.hpp
1 /*
2  * Author: Sergey Kiselev <sergey.kiselev@intel.com>
3  * Copyright (c) 2017 Sergey Kiselev
4  * Based on the apa102 driver writen by Yannick Adam <yannick.adam@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #pragma once
26 
27 #include <mraa/gpio.hpp>
28 #include <vector>
29 
30 namespace upm
31 {
38 typedef struct {
39  uint8_t red, green, blue;
40 } RgbColor;
41 
59 class P9813
60 {
61  public:
71  P9813(uint16_t ledCount, uint16_t clkPin, uint16_t dataPin, bool batchMode = false);
72 
76  virtual ~P9813() {};
77 
86  void setLed(uint16_t ledIdx, uint8_t r, uint8_t g, uint8_t b);
87 
95  void setAllLeds(uint8_t r, uint8_t g, uint8_t b);
96 
106  void
107  setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t r, uint8_t g, uint8_t b);
108 
118  void setLeds(uint16_t startIdx, uint16_t endIdx, std::vector<RgbColor> colors);
119 
125  void pushState();
126 
127  private:
128  std::vector<RgbColor> m_leds;
129  mraa::Gpio m_clkGpio;
130  mraa::Gpio m_dataGpio;
131  bool m_batchMode;
132 
133  void sendByte(uint8_t data);
134 };
135 }
void setLed(uint16_t ledIdx, uint8_t r, uint8_t g, uint8_t b)
Definition: p9813.cxx:55
void pushState()
Definition: p9813.cxx:95
virtual ~P9813()
Definition: p9813.hpp:76
void setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t r, uint8_t g, uint8_t b)
Definition: p9813.cxx:67
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
Definition: p9813.hpp:38
P9813(uint16_t ledCount, uint16_t clkPin, uint16_t dataPin, bool batchMode=false)
Definition: p9813.cxx:36
API for controlling P9813/Chainable RGB LEDs.
Definition: p9813.hpp:59
void setAllLeds(uint8_t r, uint8_t g, uint8_t b)
Definition: p9813.cxx:61