mirror of
https://git.sr.ht/~calebccff/pbsplash
synced 2026-01-12 20:48:40 -09:00
first commit!
very messy implementation of a simple FB splash for postmarketOS.
This commit is contained in:
commit
461937443c
6 changed files with 95 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
build/
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "tfblib"]
|
||||||
|
path = tfblib
|
||||||
|
url = https://github.com/calebccff/tfblib
|
||||||
13
CMakeLists.txt
Normal file
13
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
|
# set the project name
|
||||||
|
project(pbsplash)
|
||||||
|
|
||||||
|
# add the executable
|
||||||
|
add_executable(pbsplash pbsplash.c)
|
||||||
|
|
||||||
|
include_directories(tfblib/include)
|
||||||
|
|
||||||
|
add_subdirectory(tfblib)
|
||||||
|
|
||||||
|
target_link_libraries(pbsplash tfb)
|
||||||
26
logo.h
Normal file
26
logo.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
const float logo[] = {
|
||||||
|
// Top
|
||||||
|
50, 00, 35, 30, // top to left
|
||||||
|
35, 30, 38, 42, // top left point left
|
||||||
|
38, 42, 50, 40, // top left point right
|
||||||
|
50, 40, 67, 75, // top to right inside
|
||||||
|
67, 75, 70, 63,
|
||||||
|
70, 63, 83, 65,
|
||||||
|
83, 65, 50, 00, // top to right
|
||||||
|
// Bottom left
|
||||||
|
32, 35, 0, 100,
|
||||||
|
0, 100, 30, 100,
|
||||||
|
30, 100, 35, 90,
|
||||||
|
35, 90, 30, 80,
|
||||||
|
30, 80, 45, 45,
|
||||||
|
45, 45, 35, 47,
|
||||||
|
35, 47, 32, 35,
|
||||||
|
// Bottom right
|
||||||
|
35, 80, 40, 90,
|
||||||
|
40, 90, 35, 100,
|
||||||
|
35, 100, 100, 100,
|
||||||
|
100, 100, 85, 70,
|
||||||
|
85, 70, 73, 68,
|
||||||
|
73, 68, 70, 80,
|
||||||
|
70, 80, 35, 80,
|
||||||
|
};
|
||||||
51
pbsplash.c
Normal file
51
pbsplash.c
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <tfblib/tfblib.h>
|
||||||
|
#include <tfblib/tfb_colors.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "logo.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
if ((rc = tfb_acquire_fb(TFB_FL_USE_DOUBLE_BUFFER, "/dev/fb0", "/dev/tty1")) != TFB_SUCCESS) {
|
||||||
|
fprintf(stderr, "tfb_acquire_fb() failed with error code: %d\n", rc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = (int) tfb_screen_width();
|
||||||
|
int h = (int) tfb_screen_height();
|
||||||
|
int sz = (float)(w < h ? w : h) * 0.5;
|
||||||
|
fprintf(stdout, "w=%du, h=%du\n", w, h);
|
||||||
|
float x = (float)w / 2 - sz / 2;
|
||||||
|
float y = (float)h / 2 - sz / 2 - 300;
|
||||||
|
float textX = x;
|
||||||
|
float textY = y;
|
||||||
|
|
||||||
|
while(true) {
|
||||||
|
/* Paint the whole screen in black */
|
||||||
|
tfb_clear_screen(tfb_black);
|
||||||
|
/* Draw a red rectangle at the center of the screen */
|
||||||
|
/* Draw some text on-screen */
|
||||||
|
tfb_draw_string_scaled(x + 75, y + sz + 40, tfb_white, tfb_black, 4, 4, "postmarketOS");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(logo) / sizeof(logo[0]); i+=4)
|
||||||
|
{
|
||||||
|
int x1 = (int) (logo[i] / 100 * sz) + (int)x;
|
||||||
|
int y1 = (int) (logo[i+1] / 100 * sz) + (int)y;
|
||||||
|
int x2 = (int) (logo[i+2] / 100 * sz) + (int)x;
|
||||||
|
int y2 = (int) (logo[i+3] / 100 * sz) + (int)y;
|
||||||
|
//printf("%f == ", logo[i] / 100 * w);
|
||||||
|
printf("x1: %d, y1: %d, x2: %d, y2: %d\n", x1, y1, x1, y2);
|
||||||
|
tfb_draw_line(x1, y1, x2, y2, tfb_green);
|
||||||
|
}
|
||||||
|
|
||||||
|
tfb_flush_window();
|
||||||
|
tfb_flush_fb();
|
||||||
|
usleep(50000);
|
||||||
|
}
|
||||||
|
|
||||||
|
getchar();
|
||||||
|
tfb_release_fb();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
1
tfblib
Submodule
1
tfblib
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 69389193fcf1c4d632febcfa0d3bdd99eb1ae2b7
|
||||||
Loading…
Reference in a new issue