Skip to content

Commit

Permalink
Added RTL-Mode, invert now by method, updated PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
soundstorm committed Oct 24, 2017
1 parent 5caec11 commit 5966683
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Binary file modified 5x7FlipDotController2-5.pdf
Binary file not shown.
24 changes: 20 additions & 4 deletions FlipDot_5x7.cpp
Expand Up @@ -39,7 +39,15 @@ void FlipDot_5x7_Slave::receiveEvent(int n) {
}
#endif //ESP8266


FlipDot_5x7::FlipDot_5x7(uint8_t xModules, uint8_t yModules) :
// +2 is a dirty hack to allow displaying chars on last display.
Adafruit_GFX(xModules*FLIPDOT_MODULE_WIDTH+2, yModules*FLIPDOT_MODULE_HEIGHT),
_xModules(xModules),
_yModules(yModules),
_invert(false) {
imageBuffer = (boolean*) calloc(width()*height(), sizeof(boolean));
oldImageBuffer = (boolean*) calloc(FLIPDOT_MODULE_WIDTH*height(), sizeof(boolean));
}

FlipDot_5x7::FlipDot_5x7(uint8_t xModules, uint8_t yModules, boolean invert) :
// +2 is a dirty hack to allow displaying chars on last display.
Expand Down Expand Up @@ -152,15 +160,23 @@ void FlipDot_5x7::setPixelDelay(uint8_t pixelDelay) {
_pixelDelay = pixelDelay;
}

void FlipDot_5x7::setRtl(boolean rtl) {
_rtl = rtl;
}

void FlipDot_5x7::invert(boolean invert) {
_invert = invert;
}

void FlipDot_5x7::display(void) {
if (_serialMode) {
for (uint8_t x = 0; x < FLIPDOT_MODULE_WIDTH; x++) {
for (uint8_t y = 0; y < FLIPDOT_MODULE_HEIGHT; y++) {
//uint8_t dnc = 0;
for (int8_t yModule = _yModules-1; yModule > -1; yModule--) {
for (int8_t xModule = (yModule%2)?(_xModules-1):0;
((yModule%2)?-1:xModule) < ((yModule%2)?xModule:_xModules);
xModule += (yModule%2)?-1:1) {
for (int8_t xModule = (yModule%2 != _rtl)?(_xModules-1):0;
((yModule%2 != _rtl)?-1:xModule) < ((yModule%2 != _rtl)?xModule:_xModules);
xModule += (yModule%2 != _rtl)?-1:1) {
uint8_t _x = xModule*FLIPDOT_MODULE_WIDTH+x;
uint8_t _y = yModule*FLIPDOT_MODULE_HEIGHT+y;
//if (oldImageBuffer[y*width()+x] == imageBuffer[y*width()+x]) dnc++;
Expand Down
4 changes: 4 additions & 0 deletions FlipDot_5x7.h
Expand Up @@ -37,6 +37,7 @@ class FlipDot_5x7 : public Adafruit_GFX {
boolean *oldImageBuffer = NULL;
boolean _invert;
boolean _serialMode = false;
boolean _rtl = false;
uint8_t _xModules, _yModules,
_pixelDelay = 0;

Expand All @@ -52,7 +53,10 @@ class FlipDot_5x7 : public Adafruit_GFX {
void drawPixel(int16_t, int16_t, uint16_t);
void display(void);
void setPixelDelay(uint8_t);
void setRtl(boolean);
void invert(boolean);
int16_t width(void) const;
FlipDot_5x7(uint8_t, uint8_t);
FlipDot_5x7(uint8_t, uint8_t, boolean);
};

Expand Down

0 comments on commit 5966683

Please sign in to comment.