Skip to content

Instantly share code, notes, and snippets.

@lutoma
Created April 27, 2013 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lutoma/5472151 to your computer and use it in GitHub Desktop.
Save lutoma/5472151 to your computer and use it in GitHub Desktop.
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