-`cb_fn` optional callback function, see [Framebuffer callback](#framebuffer-callback)
#### Returns
#### Returns
u8g2 display object
u8g2 display object
...
@@ -205,6 +207,31 @@ bus = spi.master(spi.HSPI, {sclk=sclk, mosi=mosi})
...
@@ -205,6 +207,31 @@ bus = spi.master(spi.HSPI, {sclk=sclk, mosi=mosi})
disp=u8g2.ssd1306_128x64_noname(bus,cs,dc,res)
disp=u8g2.ssd1306_128x64_noname(bus,cs,dc,res)
```
```
## Framebuffer callback
Each display type can be initialized to provide the framebuffer contents in run-length encoded format to a Lua callback. This mode is enabled when a callback function is specified for the setup function. Hardware display and framebuffer callback can be operated in parallel. If the callback function is the only parameter then no signals for a hardware display are generated, leaving a virtual display.
The callback function can be used to process the framebuffer line by line. It's called with either `nil` as parameter to indicate the start of a new frame or with a string containing a line of the framebuffer with run-length encoding. First byte in the string specifies how many pairs of (x, len) follow, while each pair defines the start (leftmost x-coordinate) and length of a sequence of lit pixels. All other pixels in the line are dark.