From 35efd6942476869ebd42edd8b52694c3987585b8 Mon Sep 17 00:00:00 2001 From: Josef Date: Fri, 15 Mar 2019 15:03:18 +0800 Subject: [PATCH] added webserver and ui for editable toml config --- .gitignore | 0 notiframe/NotiFrame.py | 28 ++--- notiframe/config.toml | 9 +- notiframe/drivers/__init__.py | 0 notiframe/drivers/epd7in5b.py | 0 notiframe/drivers/epdif.py | 0 notiframe/test/card_image.bmp | Bin notiframe/test/greyscale.bmp | Bin notiframe/test/imgBlack.bmp | Bin 30782 -> 30782 bytes notiframe/test/imgBlackWidget.bmp | Bin notiframe/test/imgYellow.bmp | Bin notiframe/test/imgYellowWidget.bmp | Bin notiframe/test/mask.bmp | Bin notiframe/webserver/templates/home.html | 33 ++++++ notiframe/webserver/templates/style.css | 0 notiframe/webserver/webserver.py | 97 ++++++++++++++++++ notiframe/widgets/__init__.py | 0 .../widgets/resources/fonts/DejaVuSans.ttf | Bin .../resources/fonts/DejaVuSansMono.ttf | Bin .../widgets/resources/fonts/FreeMonoBold.ttf | Bin notiframe/widgets/resources/images/calvin.jpg | Bin notiframe/widgets/resources/images/folk.png | Bin notiframe/widgets/resources/images/forest.jpg | Bin notiframe/widgets/resources/images/leaves.jpg | Bin .../widgets/resources/images/onyxbook.jpg | Bin notiframe/widgets/resources/images/staff.png | Bin notiframe/widgets/resources/images/steps.jpg | Bin notiframe/widgets/widget.py | 0 readme.md | 0 29 files changed, 149 insertions(+), 18 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 notiframe/NotiFrame.py mode change 100644 => 100755 notiframe/config.toml mode change 100644 => 100755 notiframe/drivers/__init__.py mode change 100644 => 100755 notiframe/drivers/epd7in5b.py mode change 100644 => 100755 notiframe/drivers/epdif.py mode change 100644 => 100755 notiframe/test/card_image.bmp mode change 100644 => 100755 notiframe/test/greyscale.bmp mode change 100644 => 100755 notiframe/test/imgBlackWidget.bmp mode change 100644 => 100755 notiframe/test/imgYellow.bmp mode change 100644 => 100755 notiframe/test/imgYellowWidget.bmp mode change 100644 => 100755 notiframe/test/mask.bmp create mode 100644 notiframe/webserver/templates/home.html create mode 100644 notiframe/webserver/templates/style.css create mode 100644 notiframe/webserver/webserver.py mode change 100644 => 100755 notiframe/widgets/__init__.py mode change 100644 => 100755 notiframe/widgets/resources/fonts/DejaVuSans.ttf mode change 100644 => 100755 notiframe/widgets/resources/fonts/DejaVuSansMono.ttf mode change 100644 => 100755 notiframe/widgets/resources/fonts/FreeMonoBold.ttf mode change 100644 => 100755 notiframe/widgets/resources/images/calvin.jpg mode change 100644 => 100755 notiframe/widgets/resources/images/folk.png mode change 100644 => 100755 notiframe/widgets/resources/images/forest.jpg mode change 100644 => 100755 notiframe/widgets/resources/images/leaves.jpg mode change 100644 => 100755 notiframe/widgets/resources/images/onyxbook.jpg mode change 100644 => 100755 notiframe/widgets/resources/images/staff.png mode change 100644 => 100755 notiframe/widgets/resources/images/steps.jpg mode change 100644 => 100755 notiframe/widgets/widget.py mode change 100644 => 100755 readme.md diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/notiframe/NotiFrame.py b/notiframe/NotiFrame.py old mode 100644 new mode 100755 index c2def83..f2246b7 --- a/notiframe/NotiFrame.py +++ b/notiframe/NotiFrame.py @@ -45,11 +45,11 @@ config2 = {'resWidth': 640, 'resHeight': 384, 'cellsWidth': 3, 'cellsHeight': 3 ]} #print(toml.dumps(config)) -print(config) -print(config2) +#print(config) +#print(config2) -cwidth = int(round(config['resWidth']/config['cellsWidth'])) -cheight = int(round(config['resHeight']/config['cellsHeight'])) +cwidth = int(round(int(config['resWidth'])/int(config['cellsWidth']))) +cheight = int(round(int(config['resHeight'])/int(config['cellsHeight']))) image_yellow = Image.new('1', (config['resWidth'], config['resHeight']), 255) # 255: clear the frame draw_yellow = ImageDraw.Draw(image_yellow) @@ -91,18 +91,18 @@ def drawWidget(w): image_yellow.paste(w.image_yellow, (coordX, coordY)) def render(index): - if index is not 0: + if index is not 0: for widg in widgetList: widg.updateWidget() - draw_black.rectangle(xy=((0,0), image_black.size), fill=255) - draw_yellow.rectangle(xy=((0,0), image_yellow.size), fill=255) - for widg in widgetList: - drawWidget(widg) - if not testMode: - epd.display_frame(epd.get_frame_buffer(image_black),epd.get_frame_buffer(image_yellow)) - else: - image_black.save(os.path.join(mydir, 'test/imgBlack.bmp')) - image_yellow.save(os.path.join(mydir, 'test/imgYellow.bmp')) + draw_black.rectangle(xy=((0,0), image_black.size), fill=255) + draw_yellow.rectangle(xy=((0,0), image_yellow.size), fill=255) + for widg in widgetList: + drawWidget(widg) + if not testMode: + epd.display_frame(epd.get_frame_buffer(image_black),epd.get_frame_buffer(image_yellow)) + else: + image_black.save(os.path.join(mydir, 'test/imgBlack.bmp')) + image_yellow.save(os.path.join(mydir, 'test/imgYellow.bmp')) widgetList = initWidgets() i = 0 diff --git a/notiframe/config.toml b/notiframe/config.toml old mode 100644 new mode 100755 index 0a8c057..ee9157b --- a/notiframe/config.toml +++ b/notiframe/config.toml @@ -1,16 +1,16 @@ -cellsHeight = 3 resHeight = 384 +cellsHeight = 3 resWidth = 640 cellsWidth = 3 [[widgets]] +bwStyle = "mono" +filename = "forest.jpg" width = 3 posX = 0 posY = 0 scaleMode = "fill" -bwStyle = "mono" -type = "image" -filename = "forest.jpg" height = 3 +type = "image" [[widgets]] list = "Plans" @@ -38,3 +38,4 @@ board = "Organisation" posX = 1 posY = 2 type = "trello" + diff --git a/notiframe/drivers/__init__.py b/notiframe/drivers/__init__.py old mode 100644 new mode 100755 diff --git a/notiframe/drivers/epd7in5b.py b/notiframe/drivers/epd7in5b.py old mode 100644 new mode 100755 diff --git a/notiframe/drivers/epdif.py b/notiframe/drivers/epdif.py old mode 100644 new mode 100755 diff --git a/notiframe/test/card_image.bmp b/notiframe/test/card_image.bmp old mode 100644 new mode 100755 diff --git a/notiframe/test/greyscale.bmp b/notiframe/test/greyscale.bmp old mode 100644 new mode 100755 diff --git a/notiframe/test/imgBlack.bmp b/notiframe/test/imgBlack.bmp index afb7a945b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>C5-E& z?FCFuG{0tjpoBcbpwlZ17S2T~lTeYCG^GaR=rdDaz%133N;HLqs8D=asFeU6+ znoSFoYT5UXROnfXA05U=B>0-hS!RSKORZ49EQ=pKLgY)fcbN{_7L`KUavhvnR2h3> z;|(|BUOyT0rcq=W0W*=#DLdcmMam)+nAd6Ht@H#uv~oGA_3yL_%kp9Nq>|k{{-j|% z!5}85(R%9EX`6qZfEEIXPwFRNIBGoT7a}~Q>Af&Yn)V6wrj^=?d4;~hBj4Q>*>9|)-U$@-QjJ2y3|^}wUM^BlQYbY$4uZoOC&dO}lW@T7eypEk6VlP^< zV?)}Dm-jdvh-wKYtkjvBWGm?h#`LP+&5XU$4m5^=MR__!kHQ;@Ju>q=YW zoj#Ad@r~UpPS!e;!(v_Cx^t#a9gT7Y>|t8|l))#ry=Zx_-M6Xx za$C{$ZjZZYyW?om3kc5eI)d1bWohv>-rKY+);g0%FBk=A<9o~5vpwZ;;w1s5~b$iBkC zHOklSixE0`?OfoW&4h-vW$-W0X5pQu6y8OuuPTMRNVgze_*@p8LJH4if~LAmrq3WP z`q!-1_p5hP_;gJMSl7*!>A$bDK+ReMe7mj~K3=PbDL*a&TBU=XKej++l^)I`|0|@1 z^~DfGI%T_$b>~NY4gIe6hDB;K|*HOa*@*j%l*;_ zxLzt4HB@GmsbYq5CCu=`OAi;kvH#Bc!|wLgj==DzgGRr*VQ+~uDc5-Akm=L2zQD-9 zJb#xj=k(d~hFVn)Os>r<*gk7;t=H{7>bSnWci>Nc_x6sv^EY(gy4)_F`oz~gaM&LN<2m$=^RZr3`*7iB=*d;|<62HI0RXA#hEV1RuL@O?69>+%YQcZt|I~woIW#O zhr?73n)- + + + + + + + +
+ +
+ {% for n in range(widgLists| length) %} +

Widget {{n}}

+ {% for key, value in widgLists[n].iteritems() %} + {{key}}: +
+ {% endfor %} +
+ {% endfor %} + +

System Settings

+ {% for key, value in sysList.iteritems() %} + {{key}}: +
+ {% endfor %} +
+ + +
+ +
+ + \ No newline at end of file diff --git a/notiframe/webserver/templates/style.css b/notiframe/webserver/templates/style.css new file mode 100644 index 0000000..e69de29 diff --git a/notiframe/webserver/webserver.py b/notiframe/webserver/webserver.py new file mode 100644 index 0000000..ab29276 --- /dev/null +++ b/notiframe/webserver/webserver.py @@ -0,0 +1,97 @@ +from flask import Flask, render_template, request, redirect, url_for +import toml +import os + +app = Flask(__name__) + +mydir = os.path.dirname(os.path.abspath(__file__)) +#print(mydir) +mydir = os.path.join(mydir, '../') +#print(mydir) + +essentials = {'type': None, 'height': None, 'width': None, 'posX': None, 'posY': None} +trello_options = {'board': None, 'list': None} +image_options = {'filename': None, 'scaleMode': None, 'bwStyle': None} + +def convert(input): + if isinstance(input, dict): + return dict((convert(key), convert(value)) for key, value in input.iteritems()) + elif isinstance(input, list): + return [convert(element) for element in input] + elif isinstance(input, unicode): + return input.encode('utf-8') + else: + return input + +#HOMEPAGE +@app.route('/home', methods=['GET', 'POST']) +def home(): + config = read_config() + widgLists, sysList = prep_dict_for_web(config) + if request.method == 'POST': + #update system variables + for key in sysList: + if request.form[key]: + if isInt(request.form[key]): + #print(request.form[key] + " is int") + sysList[key] = int(request.form[key]) + else: + sysList[key] = request.form[key] + #update widget variables + #for i in range(len(widgLists)): + # for key in widgLists[i]: + # if request.form[key+str(i)]: + # widgLists[i][key] = request.form[key+str(i)] + for i in range(len(widgLists)): + for key in widgLists[i]: + #print(request.form[key+str(i)]) + if isInt(request.form[key+str(i)]): + #print(request.form[key+str(i)] + " is int") + widgLists[i][key] = int(request.form[key+str(i)]) + else: + widgLists[i][key] = request.form[key+str(i)] + + #print(widgLists) + #print(sysList) + + update_config(widgLists, sysList) + + return render_template('home.html', title='Overview', widgLists=widgLists, sysList=sysList) + +def isInt(s): + try: + int(s) + return True + except ValueError: + return False + +def prep_dict_for_web(config): + widgLists = config['widgets'] #list of dicts + sysList = {} #dict + for key in config: + if key != 'widgets': + sysList[key] = config[key] + return widgLists, sysList + +def read_config(): + uni_config = toml.load(os.path.join(mydir, 'config.toml')) + config = convert(uni_config) + #print(config) + #config = {'widgets': [ + #{'width': 3, 'posX': 0, 'posY': 0, 'scaleMode': 'fill', 'bwStyle': 'mono', 'type': 'image', 'filename': 'forest.jpg', 'height': 3}, + #{'list': 'Plans', 'height': 3, 'width': 1, 'board': 'Organisation', 'posX': 0, 'posY': 0, 'type': 'trello'}, + #{'list': 'To Do:', 'height': 3, 'width': 2, 'board': 'E-paper', 'posX': 1, 'posY': 0, 'type': 'trello'} + #], 'cellsHeight': 3, 'resHeight': 384, 'resWidth': 640, 'cellsWidth': 3} + return config + +def update_config(widgLists, sysList): + config = {'widgets': widgLists} + for key in sysList: + config[key] = sysList[key] + convert(config) + path = os.path.join(mydir, 'config.toml') + with open(path, "w+") as config_file: + config_file.write(toml.dumps(config)) + +if __name__ == '__main__': + app.run(debug=True,host='0.0.0.0') \ No newline at end of file diff --git a/notiframe/widgets/__init__.py b/notiframe/widgets/__init__.py old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/fonts/DejaVuSans.ttf b/notiframe/widgets/resources/fonts/DejaVuSans.ttf old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/fonts/DejaVuSansMono.ttf b/notiframe/widgets/resources/fonts/DejaVuSansMono.ttf old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/fonts/FreeMonoBold.ttf b/notiframe/widgets/resources/fonts/FreeMonoBold.ttf old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/calvin.jpg b/notiframe/widgets/resources/images/calvin.jpg old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/folk.png b/notiframe/widgets/resources/images/folk.png old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/forest.jpg b/notiframe/widgets/resources/images/forest.jpg old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/leaves.jpg b/notiframe/widgets/resources/images/leaves.jpg old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/onyxbook.jpg b/notiframe/widgets/resources/images/onyxbook.jpg old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/staff.png b/notiframe/widgets/resources/images/staff.png old mode 100644 new mode 100755 diff --git a/notiframe/widgets/resources/images/steps.jpg b/notiframe/widgets/resources/images/steps.jpg old mode 100644 new mode 100755 diff --git a/notiframe/widgets/widget.py b/notiframe/widgets/widget.py old mode 100644 new mode 100755 diff --git a/readme.md b/readme.md old mode 100644 new mode 100755