The fbpy module is a API for drawing in the framebuffer on linux machines. It was conceived as part of an audioplayer project based on the raspberry pi computer and wolfson pi audio interface. I needed a low-level graphics library for visualising audio data (scope, phase,...). I also wanted to gain some programming skills, like writing c libs for python and some kernel stuff. So this module is by no means an attempt to make a better graphics lib with fancy harware acceleration or anythin or making something original. I think it is useable though and by examining the source, it might serve as a form of documentation if you want to make something like this yourself. That is why I publish it. Oh, and ofcourse because I support open source hardware and software, the ‘firmware’ of my audioplayer should be available as source :)
This is the main class, it generates a drawing surface. On first invokation, it will generate a surface which encompasses the entire screen automaticaly and it will open the framebuffer device. The classmethod close will close it. Subsequent instances will need arguments defining size and position.
>>> import fbpy.fb as fb
>>> main = fb.Surface()
The framebuffer device was opened successfully.
Original 1366x768, 32bpp
screensize 4196352
size of tmp buf: 8
1366
768
will make blackscreen
returns an raw bitmap array of the current window, use set_raw to put the bitmap back.
>>> sprite = main.get_raw()
>>> main.set_raw(sprite)
grabs current frame into file <filename>.png
grabs current frame into file with filename <filename#>
where # is an automatich counter. the output will be e.g.: screenshot0001.png, screenshot0002.png, ...
you can use e.g.
nerd@wonka: ~/tmp$ avconv -i <filename>%04d.png -c:v huffyuv <yourmoviename>.avi
to convert the sequence to a movie. You can also use ofcourse somehtin like
$ avconv -f fbdev -r 10 -i /dev/fb0 -c:v huffyuv /dev/shm/movi.avi 2> /dev/null
draws scope-like graticule @ first tuple of size second tuple (width/height). color = subs, color2 main
returns 0
pass relevant class info to fbutils driver, this is how one ‘instance’ of the driver can serve multiple Surface instances
>>> main.line((0,0),(100,100))
or
>>> main.line((0.0),(1.0,1.0))
x, y will be the points, have to be the same length and type
style = 0, 1, 2 0: solid line 1: dashed line 2: dotted line
>>> import numpy as np
>>> x = np.arange(0,1,0.1)
>>> y = x**2
>>> main.poly(x,y)
Will print text in string at position defined by tuple (x, y).
Size can be 1 or 2, where 2 prints triple sized LCD-like format
>>> main.printxy((10,10), "Hello world!", 2)
returns 0
Will draw a rectangle @ first tuple, width and height as in second tuple
>>> main.rect((0,0), (100,100))
dotstyle 0 : fast plot dotstyle 1 : plot with soft alpha dotstyle 2 : plot with blur + soft alpha
blur radius: well, 2 sigma ^2 it is
puts the bitmap array into the buffer, see get_raw.
draws the buffered geometries. So, you need this before you actualy see anything
>>> main.update()
The Uniton is a special case of the Vulgion and ensures inheritance of certain properties of the primeordial instance for all consecutive instances.