openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.

23 lines
523 B

#include "light_sensor.h"
#include <string>
#include "common/timing.h"
#include "selfdrive/sensord/sensors/constants.h"
void LightSensor::get_event(cereal::SensorEventData::Builder &event) {
uint64_t start_time = nanos_since_boot();
file.clear();
file.seekg(0);
int value;
file >> value;
event.setSource(cereal::SensorEventData::SensorSource::RPR0521);
event.setVersion(1);
event.setSensor(SENSOR_LIGHT);
event.setType(SENSOR_TYPE_LIGHT);
event.setTimestamp(start_time);
event.setLight(value);
}