-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit_scr
executable file
·57 lines (47 loc) · 1.89 KB
/
init_scr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
# -*- coding:utf-8 -*-
from PIL import Image, ImageDraw, ImageFont # Font handeling
from waveshare_epd import epd2in13_V2
import os
import configparser #to handle the config file.
from ser2bt_lib import line_pos, center_text
#import configuration file:
#Read ser2bt_config.ini file
config_obj = configparser.ConfigParser()
config_obj.read("/etc/ser2bt_config.ini")
screen = config_obj["screen"]
init_screen = config_obj["init_screen"]
# parameters to use the keys from the ser2bt_config.ini
screen_rotate = int(screen["screen_rotate"])
foreground = int(screen["foreground"])
background = int(screen["background"])
# Variable decleration
epd = epd2in13_V2.EPD()
tmp_dir = "/tmp/"
shut_file = "shut"
title_msg = 'Loading:'
msg = 'Serial to bluetooth bridge'
np = True #New Page, True or False
roboto_font_dir='/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/'
f_title_font18 = ImageFont.truetype(roboto_font_dir+'Roboto-Bold.ttf', 18)
f_title_font24 = ImageFont.truetype(roboto_font_dir+'Roboto-Bold.ttf', 24)
#Check if battery file exists, create if it does not:
if not os.path.exists(tmp_dir+shut_file):
os.mknod(tmp_dir+shut_file)
#Then, change the rights on the file.
os.chmod(tmp_dir+shut_file, 0o664)
#Clear the Screen:
epd.init(epd.FULL_UPDATE)
epd.Clear(background)
#Draw out the boot screen
boot_image = Image.new('1', (epd.height, epd.width), background) #clear the frame
boot_draw = ImageDraw.Draw(boot_image)
#Plot the text:
boot_draw.text((center_text(boot_draw, title_msg, f_title_font24), line_pos(np,boot_draw, title_msg, f_title_font24)), title_msg, font=f_title_font24, fill = foreground)
np = False
boot_draw.text((center_text(boot_draw, msg, f_title_font18), line_pos(np,boot_draw, msg, f_title_font18)), msg, font=f_title_font18, fill = foreground)
#Display the screen
epd.display(epd.getbuffer(boot_image.rotate(screen_rotate)))
#Exit:
epd2in13_V2.epdconfig.module_exit()
exit()