first commit
This commit is contained in:
35
include/drivers/PhotoresistorController.h
Normal file
35
include/drivers/PhotoresistorController.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef PHOTORESISTOR_CONTROLLER_H
|
||||
#define PHOTORESISTOR_CONTROLLER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define DEFAULT_MIN_READ_INTERVAL 50
|
||||
#define DEFAULT_SAMPLES 3
|
||||
|
||||
class PhotoresistorController {
|
||||
private:
|
||||
uint8_t _pin;
|
||||
unsigned long _lastReadTime;
|
||||
unsigned long _minReadInterval;
|
||||
int _lastRawValue;
|
||||
int _lastPercentValue;
|
||||
bool _lastReadSuccess;
|
||||
uint8_t _numSamples;
|
||||
int _maxValue;
|
||||
int _minValue;
|
||||
|
||||
public:
|
||||
PhotoresistorController(uint8_t pin, int minValue = 0, int maxValue = 1023);
|
||||
void begin();
|
||||
bool read();
|
||||
int getRawValue();
|
||||
int getPercentValue();
|
||||
void calibrate(int minValue, int maxValue);
|
||||
void autoCalibrateDark();
|
||||
void autoCalibrateBright();
|
||||
bool isLastReadSuccessful() const;
|
||||
void setMinReadInterval(unsigned long interval);
|
||||
void setNumSamples(uint8_t samples);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user