31 lines
877 B
C++
31 lines
877 B
C++
#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 |