DUDS
Distributed Update of Data from Something
ISL29125.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
10 #ifndef ISL29125_HPP
11 #define ISL29125_HPP
12 
15 
16 namespace duds { namespace hardware { namespace devices { namespace instruments {
17 
24 class ISL29125 : boost::noncopyable {
28  std::unique_ptr<duds::hardware::interface::I2c> com;
40  std::uint16_t r;
44  std::uint16_t g;
48  std::uint16_t b;
49 public:
55  ISL29125(std::unique_ptr<duds::hardware::interface::I2c> &c);
59  ~ISL29125();
65  void init(bool wide = true);
69  void suspend();
74  void resume();
79  void sample();
80 
81  // Not sure what the units are; may change with lux range and ADC sample
82  // size. With the narrow, 375lux, range and 16-bit samples:
83  // red may be (20/65536) uW/cm^2
84  // green may be (18/65536) uW/cm^2
85  // blue may be (30/65536) uW/cm^2
86 
87  std::uint16_t red() const {
88  return r;
89  }
90  std::uint16_t green() const {
91  return g;
92  }
93  std::uint16_t blue() const {
94  return b;
95  }
96 };
97 
98 } } } }
99 
100 #endif // #ifndef ISL29125_HPP
void init(bool wide=true)
Configures for continuous 16-bit sampling of all colors.
Definition: ISL29125.cpp:29
std::unique_ptr< duds::hardware::interface::I2c > com
The I2C communication interface.
Definition: ISL29125.hpp:28
ISL29125(std::unique_ptr< duds::hardware::interface::I2c > &c)
Prepares to communicate with the device, but does not initalize the device.
Definition: ISL29125.cpp:16
duds::hardware::interface::Conversation initialize
Output used to initialize the device.
Definition: ISL29125.hpp:32
A quick try at supporting ISL29125 RGB sensor; will change significantly in the future.
Definition: ISL29125.hpp:24
void suspend()
Suspends operation by putting the device into a low-power mode.
Definition: ISL29125.cpp:40
std::uint16_t b
Blue brightness.
Definition: ISL29125.hpp:48
std::uint16_t g
Green brightness.
Definition: ISL29125.hpp:44
Header for Conversarion; includes ConversationVector.hpp and ConversationExternal.hpp.
void sample()
The device takes about 101ms to produce a 16-bit sample per color.
Definition: ISL29125.cpp:57
std::uint16_t r
Red brightness.
Definition: ISL29125.hpp:40
void resume()
Resumes operation after a call to suspend().
Definition: ISL29125.cpp:50
duds::hardware::interface::Conversation input
Used to read in the sampled data.
Definition: ISL29125.hpp:36
Represents a two-way conversation with a device.