Skip to content

Instantly share code, notes, and snippets.

@jwoschitz
Created November 28, 2013 19:42
Show Gist options
  • Save jwoschitz/7697185 to your computer and use it in GitHub Desktop.
Save jwoschitz/7697185 to your computer and use it in GitHub Desktop.
rasperry pi message emitter for xmas
import requests
url = 'http://192.168.178.134:8080'
chars = {
" ": [
'0',
'0',
'0',
'0'
],
"C": [
'1111',
'1000',
'1000',
'1111'
],
"D": [
'1111',
'1000',
'1000',
'1111'
]
}
input = "CDE CE CD"
def sendPattern(delay, patterns):
requests.post(url, '\n'.join(map(lambda x: str(delay) + "-" + str(x), patterns)))
lines = [
'',
'',
'',
''
]
for char in list(input):
#print(char)
char = char.upper()
if not char in chars:
continue
lines[0] += chars[char][0] + '0'
lines[1] += chars[char][1] + '0'
lines[2] += chars[char][2] + '0'
lines[3] += chars[char][3] + '0'
messages = []
for index in range(0, len(lines[0]) - 4):
message = lines[0][index:index+4]
message += lines[1][index:index+4]
message += lines[2][index:index+4]
message += lines[3][index:index+4]
messages.append(message)
print(messages)
sendPattern(300, messages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment