Merge branch 'master' of matelight:matelight

Conflicts:
	host/server.py
This commit is contained in:
jaseg 2014-12-10 21:19:41 +01:00
commit 3c329decfa
3 changed files with 37 additions and 21 deletions

View file

@ -40,24 +40,24 @@
#define CRATE_SIZE (CRATE_WIDTH*CRATE_HEIGHT) #define CRATE_SIZE (CRATE_WIDTH*CRATE_HEIGHT)
#define BUS_SIZE (CRATES_PER_BUS*CRATE_SIZE*BYTES_PER_PIXEL) #define BUS_SIZE (CRATES_PER_BUS*CRATE_SIZE*BYTES_PER_PIXEL)
unsigned const char const BOTTLE_MAP[CRATE_SIZE] = { unsigned const char const BOTTLE_MAP[CRATE_SIZE] = {
17, 16, 15, 14, 13, 4, 3, 2, 1, 0,
18, 9, 10, 11, 12, 5, 6, 7, 8,19,
19, 8, 7, 6, 5, 12, 11, 10, 9,18,
0, 1, 2, 3, 4 13, 14, 15,16,17
}; };
unsigned const char const FUCKED_UP_BOTTLE_MAP[CRATE_SIZE] = { unsigned const char const FUCKED_UP_BOTTLE_MAP[CRATE_SIZE] = {
3, 4, 5, 6, 7, 16,17, 18,19, 0,
2, 11, 10, 9, 8, 15,14, 13,12, 1,
1, 12, 13, 14, 15, 8, 9, 10,11, 2,
0, 19, 18, 17, 16 7, 6, 5, 4, 3
}; };
unsigned const char const CRATE_MAP[CRATE_COUNT] = { unsigned const char const CRATE_MAP[CRATE_COUNT] = {
0x07, 0x05, 0x03, 0x01, 0x10, 0x12, 0x14, 0x16, 0x36, 0x34, 0x32, 0x30, 0x11, 0x13, 0x15, 0x17,
0x06, 0x04, 0x02, 0x00, 0x11, 0x13, 0x15, 0x17, 0x37, 0x35, 0x33, 0x31, 0x10, 0x12, 0x14, 0x16,
0x26, 0x24, 0x22, 0x20, 0x31, 0x33, 0x35, 0x37, 0x27, 0x25, 0x23, 0x21, 0x01, 0x03, 0x05, 0x07,
0x27, 0x25, 0x23, 0x21, 0x30, 0x32, 0x34, 0x36 0x26, 0x24, 0x22, 0x20, 0x00, 0x02, 0x04, 0x06
}; };
#define SYSTICKS_PER_SECOND 100 #define SYSTICKS_PER_SECOND 100

View file

@ -1,3 +1,4 @@
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mabstraction is a type of decadence \x1B[38;5;214mabstraction is a type of decadence
\x1B[38;5;214mit's important to stay clean on all levels \x1B[38;5;214mit's important to stay clean on all levels
\x1B[38;5;214mexpiring for love is beautiful but stupid \x1B[38;5;214mexpiring for love is beautiful but stupid
@ -37,6 +38,7 @@
\x1B[38;5;214moccasionally principles are more valuable than people \x1B[38;5;214moccasionally principles are more valuable than people
\x1B[38;5;214ma sense of timing is the mark of genius \x1B[38;5;214ma sense of timing is the mark of genius
\x1B[38;5;214mexpressing anger is necessary \x1B[38;5;214mexpressing anger is necessary
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mroutine is a link with the past \x1B[38;5;214mroutine is a link with the past
\x1B[38;5;214mtorture is barbaric \x1B[38;5;214mtorture is barbaric
\x1B[38;5;214melaboration is a form of pollution \x1B[38;5;214melaboration is a form of pollution
@ -66,6 +68,7 @@
\x1B[38;5;214mideals are replaced by conventional goals at a certain age \x1B[38;5;214mideals are replaced by conventional goals at a certain age
\x1B[38;5;214mmost people are not fit to rule themselves \x1B[38;5;214mmost people are not fit to rule themselves
\x1B[38;5;214mguilt and self-laceration are indulgences \x1B[38;5;214mguilt and self-laceration are indulgences
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mit's better to be lonely than to be with inferior people \x1B[38;5;214mit's better to be lonely than to be with inferior people
\x1B[38;5;214mdying and coming back gives you considerable perspective \x1B[38;5;214mdying and coming back gives you considerable perspective
\x1B[38;5;214mabsolute submission can be a form of freedom \x1B[38;5;214mabsolute submission can be a form of freedom
@ -95,6 +98,7 @@
\x1B[38;5;214mchildren are the most cruel of all \x1B[38;5;214mchildren are the most cruel of all
\x1B[38;5;214mthe cruelest disappointment is when you let yourself down \x1B[38;5;214mthe cruelest disappointment is when you let yourself down
\x1B[38;5;214mgo all out in romance and let the chips fall where they may \x1B[38;5;214mgo all out in romance and let the chips fall where they may
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mthe only way to be pure is to stay by yourself \x1B[38;5;214mthe only way to be pure is to stay by yourself
\x1B[38;5;214mspending too much time on self-improvement is antisocial \x1B[38;5;214mspending too much time on self-improvement is antisocial
\x1B[38;5;214mknowing yourself lets you understand others \x1B[38;5;214mknowing yourself lets you understand others
@ -124,6 +128,7 @@
\x1B[38;5;214mat times inactivity is preferable to mindless functioning \x1B[38;5;214mat times inactivity is preferable to mindless functioning
\x1B[38;5;214mmostly you should mind your own business \x1B[38;5;214mmostly you should mind your own business
\x1B[38;5;214mthe mundane is to be cherished \x1B[38;5;214mthe mundane is to be cherished
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mselfishness is the most basic motivation \x1B[38;5;214mselfishness is the most basic motivation
\x1B[38;5;214msloppy thinking gets worse over time \x1B[38;5;214msloppy thinking gets worse over time
\x1B[38;5;214myou can't expect people to be something they're not \x1B[38;5;214myou can't expect people to be something they're not
@ -214,6 +219,7 @@
\x1B[38;5;214mpeople are boring unless they are extremists \x1B[38;5;214mpeople are boring unless they are extremists
\x1B[38;5;214mconfusing yourself is a way to stay honest \x1B[38;5;214mconfusing yourself is a way to stay honest
\x1B[38;5;214mstarvation is nature's way \x1B[38;5;214mstarvation is nature's way
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mhumor is a release \x1B[38;5;214mhumor is a release
\x1B[38;5;214mcrime against property is relatively unimportant \x1B[38;5;214mcrime against property is relatively unimportant
\x1B[38;5;214mat times your unconsciousness is truer than your conscious mind \x1B[38;5;214mat times your unconsciousness is truer than your conscious mind
@ -244,6 +250,7 @@
\x1B[38;5;214mthe idea of transcendence is used to obscure oppression \x1B[38;5;214mthe idea of transcendence is used to obscure oppression
\x1B[38;5;214mpolitics is used for personal gain \x1B[38;5;214mpolitics is used for personal gain
\x1B[38;5;214meating too much is criminal \x1B[38;5;214meating too much is criminal
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥
\x1B[38;5;214mimposing order is man's vocation for chaos is hell \x1B[38;5;214mimposing order is man's vocation for chaos is hell
\x1B[38;5;214myou don't know what's what until you support yourself \x1B[38;5;214myou don't know what's what until you support yourself
\x1B[38;5;214mif you can't leave your mark give up \x1B[38;5;214mif you can't leave your mark give up
@ -257,3 +264,4 @@
\x1B[38;5;214mfaithfulness is a social not a biological law \x1B[38;5;214mfaithfulness is a social not a biological law
\x1B[38;5;214mrelativity is no boon to mankind \x1B[38;5;214mrelativity is no boon to mankind
\x1B[38;5;214mmoderation kills the spirit \x1B[38;5;214mmoderation kills the spirit
\x1B[92mMate Light\x1B[93m@\x1B[92mPlay store or \x1B[94;101mtcp://ml.jaseg.net:1337\x1B[0;91m ♥

View file

@ -10,6 +10,7 @@ import itertools
import threading import threading
import random import random
import os import os
import sys
from ctypes import * from ctypes import *
@ -64,6 +65,7 @@ def printframe(fb):
def log(*args): def log(*args):
printlock.acquire() printlock.acquire()
print(strftime('\x1B[93m[%m-%d %H:%M:%S]\x1B[0m'), ' '.join(str(arg) for arg in args), '\x1B[0m') print(strftime('\x1B[93m[%m-%d %H:%M:%S]\x1B[0m'), ' '.join(str(arg) for arg in args), '\x1B[0m')
sys.stdout.flush()
printlock.release() printlock.release()
class TextRenderer: class TextRenderer:
@ -73,6 +75,7 @@ class TextRenderer:
def __iter__(self): def __iter__(self):
for i in range(-DISPLAY_WIDTH, self.width): for i in range(-DISPLAY_WIDTH, self.width):
#print('Rendering text @ pos {}'.format(i))
yield render_text(self.text, i) yield render_text(self.text, i)
class MateLightUDPServer: class MateLightUDPServer:
@ -134,7 +137,7 @@ class MateLightTCPTextHandler(BaseRequestHandler):
data = str(self.request.recv(1024).strip(), 'UTF-8') data = str(self.request.recv(1024).strip(), 'UTF-8')
addr = self.client_address[0] addr = self.client_address[0]
if len(data) > 140: if len(data) > 140:
self.request.sendall('TOO MUCH INFORMATION!\n') self.request.sendall(b'TOO MUCH INFORMATION!\n')
return return
log('\x1B[95mText from\x1B[0m {}: {}\x1B[0m'.format(addr, data)) log('\x1B[95mText from\x1B[0m {}: {}\x1B[0m'.format(addr, data))
renderqueue.append(TextRenderer(data)) renderqueue.append(TextRenderer(data))
@ -150,11 +153,11 @@ userver = MateLightUDPServer()
userver.start() userver.start()
defaultlines = [ TextRenderer(l[:-1].replace('\\x1B', '\x1B')) for l in open('default.lines').readlines() ] defaultlines = [ TextRenderer(l[:-1].replace('\\x1B', '\x1B')) for l in open('default.lines').readlines() ]
random.shuffle(defaultlines) #random.shuffle(defaultlines)
defaulttexts = itertools.cycle(itertools.chain(*defaultlines)) defaulttexts = itertools.chain(*defaultlines)
if __name__ == '__main__': if __name__ == '__main__':
#print('\033[?1049h'+'\n'*9) print('\033[?1049h'+'\n'*9)
while True: while True:
if renderqueue: if renderqueue:
renderer = renderqueue.popleft() renderer = renderqueue.popleft()
@ -167,13 +170,18 @@ if __name__ == '__main__':
frame = bytes([v for c in zip(list(foo), list(foo), list(foo)) for v in c ]) frame = bytes([v for c in zip(list(foo), list(foo), list(foo)) for v in c ])
sleep(0.05) sleep(0.05)
else: else:
frame = next(defaulttexts) try:
sleep(0.05) frame = next(defaulttexts)
except StopIteration:
defaultlines = [ TextRenderer(l[:-1].replace('\\x1B', '\x1B')) for l in open('default.lines').readlines() ]
#random.shuffle(defaultlines)
defaulttexts = itertools.chain(*defaultlines)
sendframe(frame) sendframe(frame)
#printframe(next(defaulttexts)) # printframe(frame)
continue continue
# sleep(0.1)
for frame in renderer: for frame in renderer:
sendframe(frame) sendframe(frame)
sleep(0.05) # printframe(frame)
#printframe(frame) # sleep(0.1)