HCesp/NTC_10K.h

37 lines
611 B
C++

#ifndef __NTC_H
#define __NTC_H
#ifndef rRef
#define rRef 10000
#endif
#define NTC_COUNT 32
#define NTC_MASK (NTC_COUNT - 1)
#include <esp_adc/adc_oneshot.h>
class NTC_10K {
private:
//lookup table
//float resistance[64];
//int16_t temp_C[64];
int16_t temps[NTC_COUNT];
int16_t temp_sum;
int16_t temp_idx;
float _vRef;
int _RESO;
bool m_bNegativePolarity;
int16_t m_nTemp;
float m_fTemp;
float m_fLastTemp;
adc_oneshot_unit_handle_t adc1_handle;
public:
void setup(bool bNegativePolarity);
void readSensor();
inline int16_t getTemp() { return m_nTemp; };
};
extern NTC_10K ntc;
#endif