Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
Adding a inverted color logo, updated the ini to reflect init screen, shutdown screen, and main screen rotation/color options;
updated the init_scr file to read and accept input from the ini file;
added logic to the shutdown_scr file to use the regular or inverted color graghic, based on the setting of the text(forground);
All this exposed 2 bugs in the upgrade file:
  was not putting the graphic files in the correct subdirectory;
  noted that the upgrade utility was overwriting the config (ini) file.  added logic to check for existance as apposed to match the file with the default.
  • Loading branch information
lgbrownjr committed Jan 3, 2023
1 parent 01c2253 commit 725f52f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
16 changes: 12 additions & 4 deletions init_scr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
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
#user-changable settings.
screen_rotate = 180
foreground = 0
background = 255
#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()
Expand Down
5 changes: 5 additions & 0 deletions ser2bt_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ screen_rotate=0
foreground=0
background=255

[init_screen]
screen_rotate=0
foreground=0
background=255

[shutdown_screen]
screen_rotate=0
foreground=0
Expand Down
5 changes: 4 additions & 1 deletion shutdown_scr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ f_top_line_font16 = ImageFont.truetype(roboto_font_dir+'Roboto-Medium.ttf', 16)
f_title_font18 = ImageFont.truetype(roboto_font_dir+'Roboto-Bold.ttf', 18)
f_title_font24 = ImageFont.truetype(roboto_font_dir+'Roboto-Bold.ttf', 24)

bmp = Image.open(os.path.join(picdir, 'logo.bmp'))
if foreground == 0:
bmp = Image.open(os.path.join(picdir, 'logo.bmp'))
else:
bmp = Image.open(os.path.join(picdir, 'logo_inverted.bmp'))
exit_image = Image.new('1', (epd.height, epd.width), int(background)) #clear the frame
exit_draw = ImageDraw.Draw(exit_image)
left_margin = 1 #Left margin.
Expand Down
37 changes: 19 additions & 18 deletions upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ wavesh_bin_files=(ser2bt_status init_scr shutdown_scr ser2bt_lib.py)
full_bin_files=( "${base_bin_files[@]}")
pisugar2_bin_files=(button_detect bat_mon)
ups_lite_bin_files=(bat_mon)
base_lib_files=(format.sh)
ser2bt_lib_files=(logo.bmp)
full_lib_files=( "${base_lib_files[@]}")
base_lib_files=("format.sh")
ser2bt_lib_files=("logo.bmp" "logo_inverted.bmp")
full_lib_files=( "${base_lib_files[@]}") #The script will determine what should get added to base_lib_files later on:
etc_files=(ser2bt_bridge.screenrc)
wavesh_etc_files=(ser2bt_config.ini)
base_service_files=(rfcomm.service)
Expand Down Expand Up @@ -292,7 +292,7 @@ fi

if [ "${upgrade_path}" = "enhanced" ] ; then
bin_files=(${base_bin_files[@]})
lib_files=(${enhanc_lib_files[@]})
lib_files=(${base_lib_files[@]}) #The script will determine what should get added to base_lib_files later on:
service_files=(${enhanc_service_files[@]})
service_assoc=(${enhanc_service_assoc[@]})
config_txt_addons=(${enhanc_config_txt_addons[@]})
Expand All @@ -304,7 +304,7 @@ fi

if [ "${upgrade_path}" = "full" ] ; then
bin_files=(${full_bin_files[@]})
lib_files=(${base_lib_files[@]})
lib_files=(${base_lib_files[@]}) #The script will determine what should get added to base_lib_files later on:
service_files=(${full_service_files[@]})
service_assoc=(${full_service_assoc[@]})
config_txt_addons=(${full_config_txt_addons[@]})
Expand Down Expand Up @@ -373,7 +373,7 @@ if [ "${e_ink}" = "True" ] && [ "${upgrade_path}" = "full" ] ; then
config_txt_values=("${config_txt_values[@]}" "${wavesh_config_txt_values[@]}")
boot_search=("${boot_search[@]}" "${wavesh_boot_search[@]}")
bin_files=("${bin_files[@]}" "${wavesh_bin_files[@]}")
lib_files=("${lib_files[@]}" "${ser21bt_lib_files[@]}")
# lib_files=("${lib_files[@]}" "${ser2bt_lib_files[@]}")
etc_files=("${etc_files[@]}" "${wavesh_etc_files[@]}")
service_files=("${service_files[@]}" "${wavesh_service_files[@]}")
service_assoc=("${service_assoc[@]}" "${wavesh_service_assoc[@]}")
Expand Down Expand Up @@ -651,21 +651,22 @@ done
fi
done
if [ "${e_ink}" = "True" ] && [ "${upgrade_path}" = "Full" ] ; then
printf "\nCopying files to the ${cyn}${ser2bt_lib_folder} ${nor}directory:\n"
for file in "${ser2bt_lib_files[@]}" ; do
if cmp --silent "${ser2bt_lib_folder}${file}" "${project_folder}${file}" ; then
printf " ${nor}Both versions of ${yel}${file} ${nor}are the same, Skipping...\n"
else
cp ${project_folder}${file} ${ser2bt_lib_folder} && printf " ${yel}${file} ${nor}copied.\n" || break
fi
done
fi
if [ "${e_ink}" = "True" ] && [ "${upgrade_path}" = "full" ] ; then
printf "\nCopying files to the ${cyn}${ser2bt_lib_folder} ${nor}directory:\n"
for file in "${ser2bt_lib_files[@]}" ; do
if cmp --silent "${ser2bt_lib_folder}${file}" "${project_folder}${file}" ; then
printf " ${nor}Both versions of ${yel}${file} ${nor}are the same, Skipping...\n"
else
cp ${project_folder}${file} ${ser2bt_lib_folder} && printf " ${yel}${file} ${nor}copied.\n" || break
fi
done
fi
printf "\nCopying files to the ${cyn}${etc_folder} ${nor}directory:\n"
for file in "${etc_files[@]}" ; do
if cmp --silent "${etc_folder}${file}" "${project_folder}${file}" ; then
printf " ${nor}Both versions of ${yel}${file} ${nor}are the same, Skipping...\n"
if [ -e "${etc_folder}${file}" ]; then
# if cmp --silent "${etc_folder}${file}" "${project_folder}${file}" ; then
printf " ${yel}${file}${nor} already exists, Skipping...\n"
else
cp ${project_folder}${file} ${etc_folder} && printf "${yel}${file} ${nor}copied.\n" || break
fi
Expand Down

0 comments on commit 725f52f

Please sign in to comment.