From d7c905a3398adbf7fc8f37fabdc56dd69b1219d8 Mon Sep 17 00:00:00 2001 From: Neythen Date: Sat, 1 May 2021 11:39:20 +0100 Subject: [PATCH] communication between server and matrix process working --- __pycache__/stockTicker.cpython-37.pyc | Bin 8701 -> 9339 bytes final.ppm | Bin 793167 -> 793167 bytes server.py | 35 +++++++-- stockTicker.py | 97 ++++++++++++++++++------- stockTicker.pyc | Bin 10218 -> 10207 bytes test.py | 30 ++++++-- 6 files changed, 123 insertions(+), 39 deletions(-) diff --git a/__pycache__/stockTicker.cpython-37.pyc b/__pycache__/stockTicker.cpython-37.pyc index 6964c220a45e62b6dd54a171bcc9b0e05bc181db..0cd579e585b54cf520f8073e7637f50fb3ff7812 100644 GIT binary patch delta 3732 zcma)8>u(g-6`wn=oqc%yzzgPSLjrgqCDbIC0JQ;wjd{hj9Y{t=m+{W^dhFSm<<2Z# zqjk0tv`Sm@feh`3wo>f0Nehb92T4Cysv@=j!mZRVeMoMls*U<7Rhpi2XTi?4mAb3> z-E+^Kd*-^=!phxhjHY7kd36S<(-33QOo}mOreIXubU9;Y%57#_^S!K@wbQm{>vxFRJ|@`-+qfgy#%P-K!FjZrr^FADoi%nS0+o+ZZhp)D?a* zJUToh@B}9T>Qb;TlvbpW%*!QGl1i{`Rb8LWDj@ecoUbUhyh@gdr`pOgsiSc93PZtb z2ppzd52#CvAyfNMc$J04eAj#_qJHnlUZUtHiyIVe4lST?fNBfTXWj(e4A*p2!a z020|pvWiMr2hhcPow&4fSj=)=>hg{`i`k17qlL0nsW@JVM?LD(#EibA_U_t-QnOE>9Vl)T z3XbQ5g+gz%qP}%zH}Voi-@8d!m{-{II8Qlct3(U4j!U^F=vFC7ze2rnd}}xgwF6`{ zdRyB}K8}8&T_Ep8MBhZ-igNmH&098VbI}QXH#r-oCyApy+?b-_gj1s~I|$5tn^2VIDBli-*WrP;Xr>Ba{cU_@?4eQbUZ9F%kQ}2Er!GT3xdVMEH(6 zmm=IDe3E*Mg!FtLzgD+D;O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#iz2r*(Pp z80z3;m{ULpMs ztdNf9xm1&w7bhLl-m)-ff^PejHQkk>RV%IVb6~^lcYQNGGIpA8tk#qD+LZaezxI~L z&~&%ZdY;nnTldM>5Z^a6Irle~(3XWv+0o$pM;w64CklSSKTp#Xd7>|REswMn;|=jG z(d6kbTQ>{-d;yADtMwM@xY2A?e`NMeYm&zuj{R(eMu&#_w()luW1J>SlKr1_wo;dg zAHhU&&y_w8EN01yYklX#VsYP2{^gq*WhVG-%5C$jrq-lv`KE8Y11Z$9)z?LVCBAp~ z&hr(R$fei$t{2WVZ*z-Z9=8AmK_=HU8}a$Bly9 zeM^LMP1zmXaCJyS4PF;lN%+v&p2Db?DHj>i?;^cCYKtaI0)Gk`p6!uQuYa_L^aQGE z>%Fxy_kr(TWs*sneB-dsugOS-{~V3FuJIpW+{SJMiGUV>e=k3}%Om4|@cdAd%@h3z z!8hPuG|e?}RO}SI5>NWtoPVjn-%}*!JD1W4A5zq}_@~PB2>6Uc+SYz0vOsG!&lNRNR} z@V`nrk*!Ew=U*#x<@$pdWjpXc`a2DW1eccyivJ90p6F}-a*B*D3(NGK{@<&qCxMgJ z3fTTK|F1llX1*pn=IL1$rAgVlB;m2^aE^!V`4328f2C{`fBZuJBUJrsP2QUEZ|MAQ Dq0a%0 diff --git a/server.py b/server.py index b6ac441..bc87d4e 100644 --- a/server.py +++ b/server.py @@ -12,9 +12,10 @@ import os import datetime import threading import csv - - -stock_ticker = StockTicker() +import pexpect +from multiprocessing import Process +from subprocess import Popen, PIPE +#stock_ticker = StockTicker() command = 300 tickerList = 0 @@ -26,6 +27,13 @@ LOGO_FOLDER = 'logos/' CSV_FOLDER = 'csv/new/' ALLOWED_EXTENSIONS = {'csv', 'png'} +#ticker.stdin.write(b'from server') +#print(ticker.stdout.readlines()) +#(output, errs) +child = pexpect.spawn("sudo -E python3 stockTicker.py") + +#stock_ticker = StockTicker() + def allowed_file(filename): return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS @@ -38,7 +46,7 @@ def process_file(path, filename): def ShutdownPI(): print('SHUTTING DOWN') - os.system("sudo shutdown --poweroff") + os.system("sudo shutdown now") app = Flask(__name__) @app.route("/", methods=['GET', 'POST']) @@ -128,14 +136,27 @@ def matrix(): global LastCommand if "Run Display" in request.form: pass + print('run display') #stock_ticker.runStockTicker(command, DelayTime, speedTime) - stock_ticker.displayMatrix() + #stock_ticker.displayMatrix() + #os.system("sudo -E python3 test.py") + # + #child.sendline('sent from server') + + #process = Popen(["sudo", "-E", "python3", "stockTicker.py"], stdin=PIPE, stdout=PIPE, stderr=PIPE) + child.sendline('R') + + print('back in flask') + + LastCommand = 'Run display' elif "Stop Display (at next refresh)" in request.form: pass + #ticker.kill() try: - stock_ticker.stopStockTicker() + #stock_ticker.stopStockTicker() LastCommand = 'Stop display at next checkpoint' + child.sendline('K') except: print("none running") elif "Shutdown the pi" in request.form: @@ -148,6 +169,6 @@ def matrix(): return hello() if __name__ == "__main__": - app.run(host='0.0.0.0', port=1024, debug=True) + app.run(host='0.0.0.0', port=1024, debug=False) # the debuggger causes flickering #sudo ./demo -D1 final.ppm -t 50 -m 25 --led-gpio-mapping=adafruit-hat --led-rows=32 --led-cols=256 --led-slowdown-gpio=4 diff --git a/stockTicker.py b/stockTicker.py index e3baaa6..c6791ae 100644 --- a/stockTicker.py +++ b/stockTicker.py @@ -6,7 +6,7 @@ # permission of Daniel Richardson -import sys +import sys, select import os import threading from PIL import Image, ImageDraw, ImageFont @@ -17,6 +17,16 @@ import requests from rgbmatrix import RGBMatrix, RGBMatrixOptions import finnhub +def getInput(Block=False): + if Block or select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): + msg = sys.stdin.read(1) + #sys.stdin.flush() + else: + msg = '' + return msg + + + class StockTicker(): def __init__(self): #Define global resources @@ -59,14 +69,14 @@ class StockTicker(): return image - def SetImage(self, image, offset_x = 0, offset_y = 0, unsafe=True): + def SetImage(self, image, offset_x = 0, offset_y = 0, unsafe=False): if (image.mode != "RGB"): raise Exception("Currently, only RGB mode is supported for SetImage(). Please create images with mode 'RGB' or convert first with image = image.convert('RGB'). Pull requests to support more modes natively are also welcome :)") if unsafe: - #In unsafe mode we directly access the underlying PIL image array + #In unsafe mode we directly acceshow to send commands to running python processs the underlying PIL image array #in cython, which is considered unsafe pointer accecss, #however it's super fast and seems to work fine #https://groups.google.com/forum/#!topic/cython-users/Dc1ft5W6KM4 @@ -84,7 +94,7 @@ class StockTicker(): for y in range(max(0, -offset_y), min(img_height, self.matrix.height - offset_y)): (r, g, b) = pixels[x, y] - self.matrix.SetPixel(x + offset_x, y + offset_y, r*brightness, g*brightness, b*brightness) + self.matrix.SetPixel(x + offset_x, y + offset_y, r*self.brightness, g*self.brightness, b*self.brightness) def ScrollImage(self, image_file, offset_x = 0, offset_y = 0, delay = 0.05): @@ -102,32 +112,48 @@ class StockTicker(): def ScrollImageTransition(self, image_files, offset_x = 0, offset_y = 0, delay = 0.05): # use two image files and switch between them with a seemless transition current_img = 1 - while True: - if current_img == 1: - image = self.openImage(image_files[0]) - elif current_img == 2: - image = self.openImage(image_files[2]) + + + #while True: + + - img_width, img_height = image.size + if current_img == 1: + image = self.openImage(image_files[0]) + elif current_img == 2: + image = self.openImage(image_files[1]) - print('hw', img_width, img_height) - - print(offset_x, offset_y) + img_width, img_height = image.size - while offset_x > -img_width: - offset_x -= 1 + while offset_x > -img_width: + + + offset_x -= 1 + + self.SetImage(image, offset_x = offset_x, offset_y = offset_y) + time.sleep(delay) + + + try: + + if getInput() == 'K': + self.resetMatrix() + break + except KeyboardInterrupt: + sys.stdout.flush() + pass + - self.SetImage(image, offset_x = offset_x, offset_y = offset_y) - time.sleep(delay) - if current_img == 1: - current_img = 2 - elif current_img == 2: - current_img = 1 - offset_x = 0 + if current_img == 1: + current_img = 2 + elif current_img == 2: + current_img = 1 + offset_x = 0 + + + + - - - #Get the logo from file that is the same as ticker name def getLogo(self, Ticker): @@ -240,6 +266,12 @@ class StockTicker(): print(e) self.ApiCalledError = True + def resetMatrix(self): + for x in range(self.matrix.width): + for y in range(self.matrix.height): + + + self.matrix.SetPixel(x , y , 0,0,0) #Connect all the pieces togeather creating 1 long final stock image def GetfullStockImage(self): @@ -341,3 +373,18 @@ class StockTicker(): self.keySwapper = 0 self.running = False print('MATRIX DISPLAY STOP CALLED') + + +if __name__ == '__main__': + + #print(sys.stdin.readlines()) + stock_ticker = StockTicker() + + + + while True: + msg = getInput() + if msg == 'R': + stock_ticker.displayMatrix() + + diff --git a/stockTicker.pyc b/stockTicker.pyc index 4961627f596362ff70f003d1ac534b74b10d2aff..981da55aedf5ea23c8d1057a83c62f0dbed721f0 100644 GIT binary patch delta 1352 zcmZ9MZD?C%6oAjU`MAw@4N23bwW)2BUE5CV=5)@Fuw}Cyy0+fdr3_h@EnhdSDZRbg z7E?zlBBCBPYMa6az)zUS-B zorxbOyske({&P33dp$a4DX6Cn3mOPD4PMk>%>!#*D7v8Gfrb|v8Z=l&D0^XajE?Ik z&`odX2bni@JM=T;7q3IU2ry-M=<&86e2yCc3U+0w+2NbUNGEIHieNF{e4hTjBC+TP)liG7T;x3lv3#;a^xStX{O_u`Wc$RJljObnQqlCP22OI$V z4{8fe8$~xXbZE3e*~KxpGAL^-t{hYO=n$B5gZ%}q2jfGWr3OV#)CC);A%|aMlbaR5 z#n&LuW#B93G_b#;Tfx}uue&$a`D(6~28+Jk{B@3I+(M?s3oMP{2&&8GUQULW4Q4{{ zpS(qVMlebTLOp|fUz=lWbOMZvFWYvh?#x;*RsL6uEPWQ*hh@4Q>cnvKmrxGz_2y8d zf_S+}?XMzEQzV+{nURyEpvzUuDXA`9xUjHdKE@{V2p2U=SE32rZhjQ4V&Da~TK|Y^ zn(mKX95^H*FEGytBuO(bkYmlT;5>a0JJS9@IASrl+p?vdPF-f^Rzff?@N%2hy<^`*Q4SJ<#ct7_N9BE9hTBuh_ z=D6t6&RnbN<^;>8NniK8iGR^lYO`NDq`Iu;ShcCLy(Pb$tf8uNn!>$jG1ats4`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