first commit

This commit is contained in:
lumijiez
2025-04-28 18:30:29 +03:00
commit a4b88564a4
45 changed files with 2188 additions and 0 deletions

View 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