many updates..
new sensors.. display.. led.. drawing.. stuff..
This commit is contained in:
17
data/Color.h
17
data/Color.h
@@ -1,3 +1,9 @@
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
struct Color {
|
||||
|
||||
uint8_t r;
|
||||
@@ -40,6 +46,15 @@ public:
|
||||
Color c; c.setHSV(h,s,v); return c;
|
||||
}
|
||||
|
||||
/** get color with new brightness (0..255) */
|
||||
Color brightness(const uint8_t brightness) const {
|
||||
return Color(
|
||||
((uint16_t)r)*brightness/255,
|
||||
((uint16_t)g)*brightness/255,
|
||||
((uint16_t)b)*brightness/255
|
||||
);
|
||||
}
|
||||
|
||||
void setHSV(const uint8_t h, const uint8_t s, const uint8_t v) {
|
||||
|
||||
uint8_t region, remainder, p, q, t;
|
||||
@@ -97,3 +112,5 @@ public:
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // COLOR_H
|
||||
|
||||
35
data/Vector.h
Normal file
35
data/Vector.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef DATA_VECTOR_H
|
||||
#define DATA_VECTOR_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
template <typename T> class Vector {
|
||||
|
||||
private:
|
||||
|
||||
T* data = nullptr;
|
||||
size_t nextIdx = 0;
|
||||
size_t total = 8;
|
||||
|
||||
public:
|
||||
|
||||
Vector() {
|
||||
data = (T*) malloc(total*sizeof(T));
|
||||
}
|
||||
|
||||
void push_back(T elem) {
|
||||
data[nextIdx] = elem;
|
||||
++nextIdx;
|
||||
}
|
||||
|
||||
T& operator[] (const size_t idx) {
|
||||
return data[idx];
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return nextIdx;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // DATA_VECTOR_H
|
||||
Reference in New Issue
Block a user