Update analog input support

This commit is contained in:
ShikyC 2024-01-04 20:47:25 -08:00
parent 89b4b0af68
commit 73470d1507
8 changed files with 1191 additions and 2 deletions

31
ESP32-S3-Analog/cache.h Normal file
View file

@ -0,0 +1,31 @@
/***************************************************************
* *
* Taiko Sanro - Arduino *
* Cache data structure *
* *
* Chris *
* wisaly@gmail.com *
* *
***************************************************************/
#ifndef CACHE_H
#define CACHE_H
template <class T, int L>
class Cache {
public:
Cache() { memset(data_, 0, sizeof(data_)); }
inline void put(T value) {
current_ = (current_ + 1) & (L - 1);
data_[current_] = value;
}
inline T get(int offset = 0) const {
return data_[(current_ + offset) & (L - 1)];
}
private:
T data_[L];
int current_ = 0;
};
#endif // CACHE_H