upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
light.hpp
1 /*
2  * Authors: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Mihai Tudor Panu <mihai.tudor.panu@intel.com>
4  * Sarah Knepper <sarah.knepper@intel.com>
5  * Jon Trulson <jtrulson@ics.com>
6  * Copyright (c) 2014 - 2017 Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 #pragma once
29 
30 #include <string>
31 
32 #include "light.h"
33 
34 namespace upm {
61  class Light {
62  public:
69  Light(unsigned int pin);
70 
74  ~Light();
75 
84  float raw_value();
85 
92  int value();
93 
99  void setAref(float aref);
100 
107  void setScale(float scale);
108 
116  void setOffset(float offset);
117 
124  float getAref();
125 
132  float getScale();
133 
140  float getOffset();
141 
150  float getNormalized();
151 
160  float getRawVolts();
161 
162  /* Sensor name
163  *
164  * @return Sensor name
165  */
166  std::string name()
167  {
168  return std::string("Light Sensor");
169  }
170 
171  protected:
172  light_context m_light;
173 
174  private:
175  /* Disable implicit copy and assignment operators */
176  Light(const Light&) = delete;
177  Light &operator=(const Light&) = delete;
178  };
179 }
void setOffset(float offset)
Definition: light.cxx:81
void setAref(float aref)
Definition: light.cxx:71
float raw_value()
Definition: light.cxx:60
float getScale()
Definition: light.cxx:91
C API for Analog Light (Photocell) Sensors.
Definition: light.h:45
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
int value()
Definition: light.cxx:49
float getOffset()
Definition: light.cxx:96
void setScale(float scale)
Definition: light.cxx:76
Light(unsigned int pin)
Definition: light.cxx:36
~Light()
Definition: light.cxx:44
API for the Light Sensor.
Definition: light.hpp:61
float getNormalized()
Definition: light.cxx:101
float getAref()
Definition: light.cxx:86
float getRawVolts()
Definition: light.cxx:111