You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					28 lines
				
				653 B
			
		
		
			
		
	
	
					28 lines
				
				653 B
			| 
											5 years ago
										 | #include "light_sensor.h"
 | ||
|  | 
 | ||
| 
											5 years ago
										 | #include <string>
 | ||
|  | 
 | ||
| 
											4 years ago
										 | #include "common/timing.h"
 | ||
| 
											3 years ago
										 | #include "system/sensord/sensors/constants.h"
 | ||
| 
											5 years ago
										 | 
 | ||
| 
											3 years ago
										 | LightSensor::LightSensor(std::string filename) : FileSensor(filename) {}
 | ||
|  | 
 | ||
|  | bool LightSensor::get_event(MessageBuilder &msg, uint64_t ts) {
 | ||
| 
											5 years ago
										 |   uint64_t start_time = nanos_since_boot();
 | ||
|  |   file.clear();
 | ||
|  |   file.seekg(0);
 | ||
|  | 
 | ||
|  |   int value;
 | ||
|  |   file >> value;
 | ||
|  | 
 | ||
| 
											3 years ago
										 |   auto event = msg.initEvent().initLightSensor();
 | ||
| 
											5 years ago
										 |   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);
 | ||
| 
											3 years ago
										 | 
 | ||
|  |   return true;
 | ||
| 
											5 years ago
										 | }
 |