Created
April 27, 2013 06:54
-
-
Save lutoma/5472151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import base64 | |
import json | |
import bitarray | |
import time | |
import sys | |
# 152 x 16 | |
COLS = 152 | |
ROWS = 16 | |
def send_frame(data): | |
data = base64.b64encode(data.tobytes()) | |
payload = json.dumps({'pixmap': data.decode('ascii')}) | |
req = requests.post('http://pingiepie.rzl:8000', data = payload) | |
print(req) | |
def main(): | |
with open(sys.argv[1]) as pbm: | |
# Skip first three lines. Kind of a hack, but hey | |
[next(pbm) for Pass in range(3)] | |
pbm = filter(lambda char: char in ('1', '0'), pbm.read()) | |
pbm = ''.join(pbm) | |
image_array = bitarray.bitarray(pbm) | |
send_frame(image_array) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment