misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
10a3500d27
commit
0b07bf3621
@ -1,21 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import argparse
|
||||
from http.server import HTTPServer
|
||||
import shutil
|
||||
import logging
|
||||
import yaml
|
||||
|
||||
sys.path.insert(0,
|
||||
os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
'../sdcard/rootfs/root/pwnagotchi/scripts/'))
|
||||
'../pwnagotchi/'))
|
||||
|
||||
from pwnagotchi.ui.display import Display, VideoHandler
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class CustomDisplay(Display):
|
||||
|
||||
def __init__(self, config, state):
|
||||
@ -41,6 +37,7 @@ class DummyPeer:
|
||||
def name():
|
||||
return "beta"
|
||||
|
||||
|
||||
def append_images(images, horizontal=True, xmargin=0, ymargin=0):
|
||||
w, h = zip(*(i.size for i in images))
|
||||
|
||||
@ -57,14 +54,15 @@ def append_images(images, horizontal=True, xmargin=0, ymargin=0):
|
||||
y_offset = 0
|
||||
|
||||
for im in images:
|
||||
result.paste(im, (x_offset,y_offset))
|
||||
if horizontal:
|
||||
x_offset += im.size[0] + xmargin
|
||||
else:
|
||||
y_offset += im.size[1] + ymargin
|
||||
result.paste(im, (x_offset, y_offset))
|
||||
if horizontal:
|
||||
x_offset += im.size[0] + xmargin
|
||||
else:
|
||||
y_offset += im.size[1] + ymargin
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="This program emulates\
|
||||
the pwnagotchi display")
|
||||
@ -97,11 +95,10 @@ def main():
|
||||
list_of_displays = list()
|
||||
for display_type in args.displays:
|
||||
config = yaml.safe_load(config_template.format(display=display_type,
|
||||
lang=args.lang))
|
||||
lang=args.lang))
|
||||
display = CustomDisplay(config=config, state={'name': f"{display_type}>"})
|
||||
list_of_displays.append(display)
|
||||
|
||||
|
||||
columns = list()
|
||||
|
||||
for display in list_of_displays:
|
||||
@ -162,10 +159,10 @@ def main():
|
||||
# append them all together (vertical)
|
||||
columns.append(append_images(emotions, horizontal=False, xmargin=args.xmargin, ymargin=args.ymargin))
|
||||
|
||||
|
||||
# append columns side by side
|
||||
final_image = append_images(columns, horizontal=True, xmargin=args.xmargin, ymargin=args.ymargin)
|
||||
final_image.save(args.output, 'PNG')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
SystemExit(main())
|
||||
|
Loading…
x
Reference in New Issue
Block a user