Raspberry pi 3B自定义开机动画

树莓派自定义开机动画

1.获取bannerd工具:

在命令行中输入下列命令:

git clone https://github.com/alukichev/bannerd.git

cd bannerd

make

将生成的bannerd二进制文件拷贝到容易查找的目录:如/usr/local/bin/

以下是bannerd指令的参数列表以及解释:

 bannerd [options] [interval[fps]] frame.bmp ...

    -D, --no-daemon       Do not fork into the background, log

                          to stdout

    -v, --verbose         Do not suppress debug messages in the

                          log (may also be suppressed by syslog configuration)

    -c [],

    --run-count[=]   Display the sequence of frames

                          times, then exit. If is omitted,

                          repeat only once. If it is less than

                          1, ignore the option

    -p, --preserve-mode   Do not restore framebuffer mode on exit

                          which usually means leaving last frame displayed

    -i ,

    --command-pipe= Open a named pipe and wait for

                          commands. The pipe should exist. If -c

                          is specified, it is ignored. See bannerd(1)

                          man page for command syntax.

    interval              Interval in milliseconds between frames.

                          If 'fps' suffix is present then it is in

                          frames per second. Default:  41 (24fps)

    frame.bmp ...         list of filenames of frames in BMP format

 

2. 在windows下使用gif分解器将gif动画分解为.bmp文件,拷贝到树莓派上容易找到的目录下,如/opt/frames/目录下。
在linux下可以使用ffmpeg工具:若你的gif带alpha通道,使用以下命令得到.bmp文件:

ffmpeg -i original_animation.gif %04d.png

mogrify -background black -flatten -format bmp *.png

 

3.创建splashscreen.service文件:

在/etc/systemd/system/目录下创建splashscreen.service文件,输入内容如下:

[Unit]

Description=Splashscreen

DefaultDependencies=no

After=local-fs.target

[Service]

ExecStart=/bin/sh -c /usr/local/bin/bannerd -D /opt/frames/*.bmp

StandardInput=tty

StandardOutput=tty

[Install]

WantedBy=sysinit.target

4.编辑完之后,在命令行开启splashscreen服务

systemctl enable splashscreen

或者使用以下命令进行测试:

systemctl start splashscreen

5.去掉系统自带logo及输出内容:

1)屏蔽彩色测试图片(彩虹图片):

在/boot/config.txt文件末尾加入一行:disable_splash=1

2)屏蔽左上角的四个树莓派logo:
在/boot/cmdline.txt文件中加入:logo.nologo

3)屏蔽Linux内核输出的内容:
在/boot/cmdline.txt中加入:consoleblank=0 loglevel=1 quiet

4)屏蔽登录提示:
在命令行中输入:sudo system disable getty@tty1

5)使用plymouth:
在/boot/cmdline.txt中加入:splash plymouth.ignore-serial-consoles
6.修改plymouth工具的显示图片及输出信息的代码:
完成以上步骤后重启会出现自定义动画和splashscreen图片交替显示的情况,这是由于在使用plymouth时会显示一张系统自带图片,该图片的目录为/usr/share/plymouth/themes/pix/splash.png,显示代码在同目录下的pix.script.而如果我们不使用plymouth工具,就会在显示开机动画的时候显示文字。所以需要修改它的显示代码,即屏蔽其中的显示函数即可。
在pix.script中注释掉以下几行代码:

Sprite = Sprite(resized_image);

Sprite.SetPosition(image_x,image_y,-100);

 

Message_sprite = Sprite();

Message_sprite.SetPosition(screen_width*0.1,screen_height*0.9,10000);

 

My_image=Image.Text(text,1,1,1)

Message_sprite.SetImage(my_image);

Sprite.SetImage(resized_image);

7.sudo reboot重启树莓派

你可能感兴趣的:(树莓派)