adafruit / Adafruit-SSD1331-OLED-Driver-Library-for-Arduino

For 0.96" OLEDs in the Adafruit shop
http://www.adafruit.com/products/684
Other
100 stars 67 forks source link

Full support for acceleration and rotation. Optional on-device copyBits and fullscreen text scrolling. #30

Open monroewilliams opened 3 years ago

monroewilliams commented 3 years ago

This PR adds full acceleration using the on-chip acceleration commands in the SSD1331. All 4 rotations are supported, and everything is immensely faster.
I've also added a copyBits() function that does an on-device bitblit (copies a rectangle of pixels within the screen buffer), and an optional setTextScroll() method that, when set to true, will cause the screen to scroll when printed text goes below the bottom of the screen so that further printing is visible. These additions are behind #ifdef SSD1331_EXTRAS, which is defined in the Adafruit_SSD1331.h header.

Before/after test timings from the modified test.ino and LCDGFXDemo.ino included in the PR (taken with the code running on a QT Py M0, with display.begin(MAX_SPI);:

test.ino before:

Test pattern took 675ms
Print test took 214ms
Lines test took 1024ms
Optimized Lines test took 31ms
Drawrects test took 28ms
Fillrects test took 80ms
Circles test took 173ms
Round rects test took 231ms
Triangles test took 142ms

test.ino after:

Test pattern took 118ms
Print test took 45ms
Lines test took 10ms
Optimized Lines test took 2ms
Drawrects test took 2ms
Fillrects test took 7ms
Circles test took 28ms
Round rects test took 35ms
Triangles test took 3ms

LCDGFXDemo.ino before:

Speed test number of ms: 787
FPS: 50.83
bounce 32 bitmap
Scroll test number of ms: 27027
FPS: 7
bounce 32 bitmap no clear
Scroll test number of ms: 23111
FPS: 8
pan/bounce 24 bitmap
Scroll test number of ms: 16920
FPS: 11
pan/bounce 24 bitmap no clear
Scroll test number of ms: 13003
FPS: 15
pan/bounce 8 bitmap
Scroll test number of ms: 4053
FPS: 49
pan/bounce 8 bitmap
Scroll test number of ms: 136
FPS: 1470

Count pixels
Speed test number of ms: 7951
FPS: 1.26
Count pixels done

Count_writePixels
Speed test number of ms: 244
FPS: 40.98
Count_writePixels done

LCDGFXDemo.ino after:

Speed test number of ms: 64
FPS: 625.00
bounce 32 bitmap
Scroll test number of ms: 4246
FPS: 47
bounce 32 bitmap no clear
Scroll test number of ms: 3932
FPS: 50
pan/bounce 24 bitmap
Scroll test number of ms: 2528
FPS: 79
pan/bounce 24 bitmap no clear
Scroll test number of ms: 2214
FPS: 90
pan/bounce 8 bitmap
Scroll test number of ms: 431
FPS: 464
pan/bounce 8 bitmap
Scroll test number of ms: 117
FPS: 1709

Count pixels
Speed test number of ms: 2037
FPS: 4.91
Count pixels done

Count_writePixels
Speed test number of ms: 247
FPS: 40.49
Count_writePixels done
monroewilliams commented 3 years ago

@robouden, why thumbs-down?

robouden commented 3 years ago

OOps.Sorry, should have been thumbs up. Greet work!!!