upm  1.5.0
Sensor/Actuator repository for libmraa (v1.8.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 {
35 
56  class Light {
57  public:
64  Light(unsigned int pin);
65 
69  ~Light();
70 
79  float raw_value();
80 
87  int value();
88 
94  void setAref(float aref);
95 
102  void setScale(float scale);
103 
111  void setOffset(float offset);
112 
119  float getAref();
120 
127  float getScale();
128 
135  float getOffset();
136 
145  float getNormalized();
146 
155  float getRawVolts();
156 
157  /* Sensor name
158  *
159  * @return Sensor name
160  */
161  std::string name()
162  {
163  return std::string("Light Sensor");
164  }
165 
166  protected:
167  light_context m_light;
168 
169  private:
170  /* Disable implicit copy and assignment operators */
171  Light(const Light&) = delete;
172  Light &operator=(const Light&) = delete;
173  };
174 }
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
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:56
float getNormalized()
Definition: light.cxx:101
float getAref()
Definition: light.cxx:86
float getRawVolts()
Definition: light.cxx:111