Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (85 sloc) 2.588 kb
06b29773 »
2010-06-26 First commit for the sign writer
1 import serial
2 import tweetstream
3 import time
4
5 #signfile = serial.Serial('/dev/ttyUSB0',baudrate=9600,stopbits=1,xonxoff=1,rtscts=0,timeout=0,parity='N',dsrdtr=0)
6
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
7 styles = {
1eedb693 »
2010-06-27 generic function is generic
8 "instant" : "<FB>",
9 "scroll_bottom" : "<FC>",
10 "in_place_right" : "<FD",
11 "from_center_h" : "<FE>",
12 "from_center_v" : "<FF>",
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
13 "scroll_always" : "<FH>",
1eedb693 »
2010-06-27 generic function is generic
14 "invisible" : "<FM>",
15 "" : "",
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
16 }
17
1eedb693 »
2010-06-27 generic function is generic
18 def textToSign(id, top_style, top_note, bottom_style, bottom_note, page):
19 signfile.write("<ID" + str(id) + ">")
20 signfile.write("<P"+page+">")
21 signfile.write(styles.get(top_style))
22 if bottom_note:
23 signfile.write("<L1>")
24 signfile.write(top_note)
25 if bottom_note:
26 signfile.write("<L2>")
27 signfile.write(styles.get(bottom_style))
28 signfile.write(bottom_note)
29 signfile.write("\r\n")
30 signfile.write("<ID" + str(id) + ">")
31 signfile.write("<RP" + page + ">")
32 time.sleep(1)
33 signfile.write("\x0C")
34
35
36
37 ''' signfile.write("\x0D\x0A\x0A")
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
38 signfile.write(" <ID"+str(id)+"><PZ>")
208e4fb8 »
2010-06-27 Fail reduced
39 signfile.write(styles.get(top_style))
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
40 signfile.write("<L1>")
208e4fb8 »
2010-06-27 Fail reduced
41 signfile.write(top_note)
42 signfile.write("<L2>"+bottom_note)
43 signfile.write(styles.get(bottom_style))
06b29773 »
2010-06-26 First commit for the sign writer
44 signfile.write("\x0D\x0A")
45 signfile.write(" ")
46 signfile.write("<ID"+str(id)+"><RPZ>")
47 signfile.write("\x0D\x0A")
48 time.sleep(1)
49 signfile.write("\x0C")
1eedb693 »
2010-06-27 generic function is generic
50 '''
208e4fb8 »
2010-06-27 Fail reduced
51 def formTweet(sign, tweet):
9dc8c46c »
2010-06-26 Now we can control the various strings via a fancy dictionary:q
52 tosign(sign, "center", '@'+tweet['user']['screen_name'].upper(), "scroll_always", tweet['text'])
dbf2c80a »
2010-06-26 Refactoring for less fail, also currently responds to oil
53
06b29773 »
2010-06-26 First commit for the sign writer
54 signfile = serial.Serial('/dev/ttyUSB0',baudrate=9600)
1eedb693 »
2010-06-27 generic function is generic
55 #tosign(30, "center", "", "center", "Please tweet at me!")
56 #tosign(40,"center", "", "center", "")
57 #tosign(73,"center", "", "center", "")
58 '''words = ["oil","dojosign","hackerdojo","hacker dojo","#dojosign"]
06b29773 »
2010-06-26 First commit for the sign writer
59 p = ""
60 pp = ""
61 with tweetstream.TrackStream("dojosign", "dojo77", words) as stream:
62 for tweet in stream:
63 if type(tweet['text']) is str:
64 print tweet['user']['screen_name']+": "+tweet['text']
65 print "\n"
dbf2c80a »
2010-06-26 Refactoring for less fail, also currently responds to oil
66 if "oil" in tweet['text']:
208e4fb8 »
2010-06-27 Fail reduced
67 formTweet(30, tweet)
06b29773 »
2010-06-26 First commit for the sign writer
68 if p:
208e4fb8 »
2010-06-27 Fail reduced
69 formTweet(40, p)
06b29773 »
2010-06-26 First commit for the sign writer
70 if pp:
ad8cce0a »
2010-06-27 Crap, failed again
71 formTweet(73, pp)
06b29773 »
2010-06-26 First commit for the sign writer
72 if p:
73 pp = p
74 p = tweet
1eedb693 »
2010-06-27 generic function is generic
75 time.sleep(10)'''
76 '''
77 #signfile.write("<ID73><GY>11111111111111111111111111111111111111111111")
78 #signfile.write("\x0D\x0A")
79 signfile.write("<ID73>")
80 signfile.write("<V>")
81 #signfile.write("\r\n<ID73><RPZ>")
82 signfile.write("\x0D\x0A")
83 print signfile.readline()
84 time.sleep(1)
85 signfile.write("\x0C")
86 '''
87
88 textToSign(73, "", "\x7F", "", "", "A")
06b29773 »
2010-06-26 First commit for the sign writer
89
90 signfile.close()
91
92
93
94 #signfile.write("\n\n<ID40><PZ><FB><L1>BBB<FP5><L2>AAA<FH>\n")
95 #signfile.write("<ID40><RPZ>")
96 #signfile.write("\x0C")
97 #signfile.close()
Something went wrong with that request. Please try again.