forked from mendhak/waveshare-epaper-display
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·53 lines (41 loc) · 1.58 KB
/
run.sh
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
#!/bin/bash
cd /home/pi/waveshare-epaper-display
(
set -x
. env.sh
function log {
echo "---------------------------------------"
echo ${1^^}
echo "---------------------------------------"
}
log "Get Weather info"
timeout $TIMEOUT python3 screen-weather-get.py || \
timeout $TIMEOUT python3 screen-weather-get.py || \
timeout $TIMEOUT python3 screen-weather-get.py || exit 1
log "Get Calendar info"
timeout $TIMEOUT python3 screen-calendar-get.py || \
timeout $TIMEOUT python3 screen-calendar-get.py || \
timeout $TIMEOUT python3 screen-calendar-get.py || exit 1
log "Export to PNG"
if [ $WAVESHARE_EPD75_VERSION = 1 ]; then
WAVESHARE_WIDTH=640
WAVESHARE_HEIGHT=384
else
WAVESHARE_WIDTH=800
WAVESHARE_HEIGHT=480
fi
inkscape screen-output-weather.svg --without-gui -e screen-output.png -w$WAVESHARE_WIDTH -h$WAVESHARE_HEIGHT --export-dpi=300
log "Separate black/red channels"
convert screen-output.png -channel R -separate only_black.png
pngtopnm screen-output.png > screen-output.pnm
pngtopnm only_black.png > only_black.pnm
ppmtopgm only_black.pnm | pnmsmooth | pgmtopbm -threshold -value 0.9999 | pbmmask > mask.pbm
pnminvert mask.pbm > mask_invert.pbm
pnmcomp -alpha=mask_invert.pbm mask_invert.pbm screen-output.pnm only_red.pnm
pnmtopng only_red.pnm > only_red.png
# Convert to a black and white, 1 bit bitmap
convert -colors 2 +dither -type Bilevel -monochrome only_red.png only_red.bmp
convert -colors 2 +dither -type Bilevel -monochrome only_black.png only_black.bmp
log "Display on epaper"
python3 display.py only_black.bmp only_red.bmp
) 2>&1 | tee -a LOG