Florian Wesch

info-beamer pi 0.9.2 released

Posted Aug 27 2015 by Florian Wesch

info-beamer 0.9.2 improves smoothness for visualizations that are running for a long time and provides a new way to safe energy.

If you're not interested in all the technical details you can freely ignore the following blog post and just download the latest version. Updating is recommended.

Floating point and loss of precision

If you are a programmer and used floating point values before, you are probably aware of the fact that you can't store arbitrary numbers without losing precision (see also: 1 and 2 ). There are two different types of floating point types: float and double. float uses 4 bytes to store a value while double uses 8 bytes.

In your info-beamer visualization you might have used sys.now. Calling that function returns the number of seconds since info-beamer was started. You can use that value to, for example, animated things like this:

function node.render()
    local x = 400 + math.sin(sys.now()) * 300
    font:write(x, 100, "Hello", 40, 1,1,1,1)
end

Since node.render is called for every frame the value returned by sys.now changes every time. As a result math.sin returns a different value between -1 and 1 resulting in the "Hello" text slowly swinging horizontally.

Due to an oversight the type float used to store the number of seconds since info-beamer was started. While values stored in a float variables have a good enough precision in a big area around 0, they lose precision if values get too big (or small).

Normally visualizations are rendered at 60 frames per second. So each frame takes around 1 / 60 = 0.01666 seconds. So normally you'd expect the value of sys.now to increment by that value each frame. Since float was used instead of double this wasn't always the case. When info-beamer was running for a day this effect started to be noticable: Sometimes the difference between frames was reported to be 0.0234 seconds, sometimes it was 0.0156. If you try to animate based on those values the animation might look jittery. This effect gets worse over time.

Initially I thought the reason for that behaviour might be resource leaks or some other problem with the PI firmware. Luckily the fix is a lot easier. By using the double type instead of float all realistically expected values for sys.now can now be represented without problematic loss of precision.

This is probably the most stupid bug in info-beamer since I started the project. And hopefully the last one of that kind.

Saving power by turning of the screen

On the PI you can turn of the video signal using

$ tvservice -o

A lot of screens go into standby once you execute this command thereby reducing power consumption.

To turn it back on to the preferred video mode (which is determined by information provided by the connected screen, see EDID) you can call

$ tvservice -p

In earlier versions of info-beamer this would result in a black screen, since powering off destroys the logical surface info-beamer is using. Starting with version 0.9.2 info-beamer now detects when a screen is turned back on an will try to restore video output. If it fails to restore, which might happen if you change the native video resolution, info-beamer will exit. At that point you can safely restart info-beamer to give your node code the chance to handle the updated resolution.

Together with the fixed bug this should result in visualizations that run for a long time while having the ability to power of the screen during the night.


Read more...


info-beamer.com offers the most advanced digital signage platform for the Raspberry Pi. Fully hosted, programmable and easy to use. Learn more...


Get started for free!

Trying out the best digital signage solution for the Raspberry Pi is totally free: Use one device and 1GB of storage completely free of charge. No credit card required.


Follow @infobeamer on twitter to get notified of new blog posts and other related info-beamer news. It's very low traffic so just give it a try.

You can also subscribe to the RSS Feed RSS feed.


Share this post:

Share using Twitter


Questions or comments?
Get in contact!