diff options
-rw-r--r-- | Jetris.ino | 13 | ||||
-rw-r--r-- | drawing.h | 1 | ||||
-rw-r--r-- | drawing.ino | 12 |
3 files changed, 12 insertions, 14 deletions
@@ -3,7 +3,7 @@ /* Compile settings */ #define DEBUG_TO_SERIAL 1 -#define RENDER_TO_SERIAL 0 +#define RENDER_TO_SERIAL 1 /* Pin definitions */ #define LEFT_PIN 2 @@ -16,6 +16,7 @@ #define CLICK_TIME 100 #define FALL_TIME 500 #define DIFF 0.98 +#define REDRAW_TIME 250 void setup() { Serial.begin(115200); @@ -251,8 +252,14 @@ void renderAll() { renderToSerial(); #endif - render(0, 0); - render(1, 8); + static unsigned long reRenderLast; + bool reRender = (millis() - reRenderLast ) > REDRAW_TIME; + + render(0, 0, reRender); + render(1, 8, reRender); + + if( reRender ) + reRenderLast = millis(); } /* @@ -4,7 +4,6 @@ /* Display settings */ #define BUFF_HEIGHT 16 -#define REDRAW_TIME 1000 #define NUM_DISPLAY 2 /* Pin difinitions */ diff --git a/drawing.ino b/drawing.ino index 35a8586..12cb9b3 100644 --- a/drawing.ino +++ b/drawing.ino @@ -31,23 +31,19 @@ void clearBuffer(uint8_t layer[] ) { * device: Which screen * where: It render the next 8 bytes from this index */ -void render(int display, unsigned int where) { +void render(int display, unsigned int where, bool clean) { static uint8_t onScreen[BUFF_HEIGHT]; - static unsigned long reRenderLast; int i; uint8_t toWrite; - /* Completely rerender every one second */ - bool reRender = (millis() - reRenderLast ) > REDRAW_TIME; - /* Will draw 8 lines from /where/. */ for(i = where; i < (where + 8); i++) { toWrite = topLayer[i] | buttonLayer[i]; /* Check if whats on screen is the same */ - if(onScreen[i] == toWrite && !reRender) + if(onScreen[i] == toWrite && !clean) continue; writeCommand(display, maxDIGIT_0 + i - where, toWrite); @@ -55,10 +51,6 @@ void render(int display, unsigned int where) { /* Keep track of whats on screen */ onScreen[i] = toWrite; } - - if(reRender) - reRenderLast = millis(); - } /* Renders all 16 bytes to screen */ |