https://github.com/edwardoid/libfb
Simple library to render on linux framebuffer
https://github.com/edwardoid/libfb
framebuffer internet-of-things iot linux orangepi raspberry-pi
Last synced: 9 months ago
JSON representation
Simple library to render on linux framebuffer
- Host: GitHub
- URL: https://github.com/edwardoid/libfb
- Owner: edwardoid
- License: gpl-3.0
- Created: 2019-05-13T14:00:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-09T12:05:09.000Z (over 4 years ago)
- Last Synced: 2025-02-03T17:48:00.719Z (11 months ago)
- Topics: framebuffer, internet-of-things, iot, linux, orangepi, raspberry-pi
- Language: C++
- Size: 937 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libfb
**libfb** is a simple library to draw on linux framebuffer.
Following functionality is implemented
- Draw single pixels
- Draw png images (libpng)
- Draw QR codes (libqrencode)
- Draw text (libfreetype2)
- Fill/clear
Color interface is RGB888
# Important
This library is designed to be used without X11.
# Test environment
- Orange PI Zero (any other device like Rapsberry PI should work as well)
- 160*128 LCD SPI Display based on ST7735 16bit-depth color (should work on any other display)
- Armbian Linux (shoudl work on any linux distro, no specific libs were used)
# Installation
Close the repo:
```sh
git clone https://github.com/edwardoid/libfb.git
cd libfb
mkdir tests
cd tests
cmake $PWD/..
make
make install
```
Now you can link fo libfb ```libfb.a``` and ```libfb.so```
To build examples:
```sh
cmake $PWD/.. -DBUILD_TEST=YES
make
```
# Example
```c++
// File: main.cpp
#include
#include
#include "framebuffer.h"
#include "pngprovider.h"
#include "pngimage.h"
#include "sprite.h"
#include "log.h"
int main()
{
IoT::FrameBuffer fb("/dev/fb0");
IoT::PNGProvider provider;
fb.open();
fb.clear(0xFFFFFF);
bg = provider.get("./bg_blue.png");
auto sourceImg = provider.get("./normal_sprite.png");
auto sp = std::make_shared(std::dynamic_pointer_cast(sourceImpl),
/* frame width: */ 160,
/* frame height */ 128,
/* frmaes count */ 166);
while(1) {
sp->jump(i % sp->framesCount());
++i;
fb.flush();
std::this_thread::sleep_for(std::chrono::milliseconds(20));
}
return 0;
}
```
Compile with
```sh
g++ main.cpp -I -L -lfb -lqrencode -lfreetype -I/usr/include/freetype2 -o testApp
```
Run:
```1sh
./testApp
```