Skip to content

Instantly share code, notes, and snippets.

@lutoma
Created April 27, 2013 04:30
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/5471888 to your computer and use it in GitHub Desktop.
Save lutoma/5471888 to your computer and use it in GitHub Desktop.
import requests
import base64
import json
import bitarray
import time
# 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)
print(req.text)
def main():
image_array = bitarray.bitarray(COLS * ROWS)
image_array.setall(False)
for y in range(ROWS):
for x in range(COLS):
if ((x % 2) and not (y % 2)) or (not (x % 2) and (y % 2)):
image_array[y * COLS + x] = True
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