-
• #2
I don't believe the module was copied from anywhere else (apart from perhaps the initialisation codes, but they have since been tweaked). I'm not sure the screen itself does much fancy stuff either - it's down to the graphics library in Espruino to do stuff before sending to the screen.
Clear an area is just
fillRect(..)
with the colour set to 0, but scrolling is something I've wanted to do in the Graphics lib for a while - it'd be good if someone would add it (but it'd need doing in C code).If you don't want to touch C, you can do some stuff in JavaScript by accessing the buffer - the only gotcha is that the pixels are stored in 8 pixel vertical strips.
The VT100 terminal module already does some simple scrolling with
new Uint8Array(this.g.buffer).set(new Uint8Array(this.g.buffer, stride), 0);
Making
stride = g.getWidth()
will scroll 8 pixels vertically, and making it 1 will scroll by 1 pixel horizontally. To scroll vertically by less than 8 pixels will require some fun with shifting, which will be pretty slow if done in JS. -
• #3
With most of these displays scrolling (back) is a challenge: the display buffer memory is exactly the size of the display's pixels, which means that all is display memory to MC memory and back operations... doing so over serial and in js put's you to sleep. Furthermore, writing to an area that is not in display does not work (it would work if display buffer would be memory mapped). Of course, you can always just write to a memory buffer, but then you have to update the display... For a small Nokia 5110 BW LCD display (84x48) it is not that an issue - just 500 bytes - but for a serially connected 262K color display it get's really snaily... see Performance live in .mp4 for 20x20 px.
Now that I have my SSD1306 working nicely I was looking for information if it is possible to use fancy stuff like scroll, clear an area instead of the whole display, etc...
I noticed that the module is based on code from Sam Sykes. Could it be that it is this: https://github.com/squix78/esp8266-oled-ssd1306? It seems to be do a lot more than currently is possible with the SSD1306 module.
Module code here: http://www.espruino.com/modules/SSD1306.js
Any pointers on how to extend the current functionality?