The beginnings of a rework
This commit is contained in:
31
include/SerpentineArrangement.h
Normal file
31
include/SerpentineArrangement.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef SERPENTINEARRANGEMENT_H
|
||||
#define SERPENTINEARRANGEMENT_H
|
||||
|
||||
#include "ILEDArrangement.h"
|
||||
|
||||
class SerpentineArrangement : public ILEDArrangement {
|
||||
public:
|
||||
SerpentineArrangement(bool _isColumnSerpentine) : isColumnSerpentine(_isColumnSerpentine) {}
|
||||
virtual ~SerpentineArrangement() {}
|
||||
|
||||
int16_t XY(int16_t x, int16_t y, int16_t width, int16_t height) {
|
||||
if(isColumnSerpentine) {
|
||||
if(x & 0x1) {
|
||||
return x * height + (height - 1 - y);
|
||||
} else {
|
||||
return x * height + y;
|
||||
}
|
||||
} else {
|
||||
if(y & 0x1) {
|
||||
return y * width + (width - 1 - x);
|
||||
} else {
|
||||
return y * width + x;
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
bool
|
||||
isColumnSerpentine;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user