projects
/
Arduino
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added double buffering to prevent tearning
[Arduino]
/
Hub08_LedMatrix
/
LEDMatrix.cpp
diff --git
a/Hub08_LedMatrix/LEDMatrix.cpp
b/Hub08_LedMatrix/LEDMatrix.cpp
index
133cfb2
..
8cae64e
100644
(file)
--- a/
Hub08_LedMatrix/LEDMatrix.cpp
+++ b/
Hub08_LedMatrix/LEDMatrix.cpp
@@
-47,6
+47,7
@@
LEDMatrix::LEDMatrix(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t oe, uin
#if USE_SPI
SPI.begin();
#endif
#if USE_SPI
SPI.begin();
#endif
+ buffer = 0;
}
void LEDMatrix::begin(uint8_t *displaybuf, uint16_t width, uint16_t height)
}
void LEDMatrix::begin(uint8_t *displaybuf, uint16_t width, uint16_t height)
@@
-135,6
+136,9
@@
void LEDMatrix::scan()
}
uint8_t *head = displaybuf + row * (width / 8);
}
uint8_t *head = displaybuf + row * (width / 8);
+
+ if ( buffer ) head += (width/8) * height;
+
for (uint8_t line = 0; line < (height / 16); line++) {
uint8_t *ptr = head;
head += width * 2; // width * 16 / 8
for (uint8_t line = 0; line < (height / 16); line++) {
uint8_t *ptr = head;
head += width * 2; // width * 16 / 8
@@
-173,6
+177,18
@@
void LEDMatrix::scan()
row = (row + 1) & 0x0F;
}
row = (row + 1) & 0x0F;
}
+uint8_t *LEDMatrix::offscreen_buffer()
+{
+ uint8_t *buff = displaybuf;
+ if ( ! buffer ) buff += (width/8) * height;
+ return buff;
+}
+
+void LEDMatrix::swap()
+{
+ buffer = ! buffer;
+}
+
void LEDMatrix::on()
{
state = 1;
void LEDMatrix::on()
{
state = 1;