Skip to content

Light Sensor

Location

devices

Type

Interface

Background

Light sensors typically use photo-detectors to measure the amount of light in a environment. The SI unit used is lux.

Overview

The interface should be inherited by light sensing drivers.

Detailed Design

API

namespace sjsu
{
class LightSensor
{
 public:
  virtual Status Initialize() const                           = 0;
  virtual units::illuminance::lux_t GetIlluminance() const    = 0;
  virtual float GetPercentageBrightness() const               = 0;
  units::illuminance::lux_t GetMaxIlluminance() const = 0;
};
}  // namespace sjsu

Initialization

virtual Status Initialize() const
Performs the necessary initialization sequence to initializes the driver for use and returns the initialization status.

Obtaining Sensor Readings

virtual units::illuminance::lux_t GetIlluminance() const
Returns the sensor reading in units of lux.

virtual units::illuminance::lux_t GetMaxIlluminance() const
Returns the maximum illuminance that can be detected by the device.

float GetPercentageBrightness() const
Returns the detected brightness as a percentage ranging from 0.0f to 1.0f. The percentage is determined with the following equation:

percentage = value ÷ (max illuminance)

Caveats

N/A

Future Advancements

N/A