-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathEVs_PiLight.cpp
62 lines (50 loc) · 1.92 KB
/
EVs_PiLight.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// AbsoluteIMU.cpp
//
// This is a class for controlling the PiLight device made by OpenElectrons.com
// See http://www.openelectrons.com/pages/19
// Initial version: 2014-03-17 by Michael Giles
// Large parts of the code is ported from the Raspberry Pi library for the device,
// written by Nitin Patil.
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "EVs_PiLight.h"
EVs_PiLight::EVs_PiLight(uint8_t i2c_address)
: EVShieldI2C(i2c_address)
{
}
void EVs_PiLight::readPiLight(color &currcolor)
{
char *b;
char str[200];
b = readString(PILIGHT_RED, 3);
currcolor.r = readIntFromBuffer((uint8_t *)&b[0]);
currcolor.g = readIntFromBuffer((uint8_t *)&b[1]);
currcolor.b = readIntFromBuffer((uint8_t *)&b[2]);
}
void EVs_PiLight::setTimeout1(uint8_t timeoutValue)
{
uint8_t null = 0;
writeByteToBuffer(_buffer + 0, null);
writeByteToBuffer(_buffer + 1, null);
writeByteToBuffer(_buffer + 2, null);
writeByteToBuffer(_buffer + 3, timeoutValue);
writeRegisters(PILIGHT_RED, 4, _buffer);
}
void EVs_PiLight::createPiLight(uint8_t red, uint8_t green, uint8_t blue)
{
writeByteToBuffer(_buffer + 0, red);
writeByteToBuffer(_buffer + 1, green);
writeByteToBuffer(_buffer + 2, blue);
writeRegisters(PILIGHT_RED, 3, _buffer);
}