Permalink
Browse files

A few updates: "python -i microprinter.py {serial device}" will now s…

…tart an interactive terminal with 'm', an instance of the class all ready to work.
  • Loading branch information...
1 parent 84c1bd2 commit 4d6c6d3eb9cb2a8717386eaed1db54678175b924 @benosteen committed Apr 27, 2012
Showing with 59 additions and 8 deletions.
  1. +17 −4 microprinter.py
  2. +0 −2 print_image.py
  3. +0 −2 print_image_hires.py
  4. +42 −0 reader.py
View
@@ -108,8 +108,8 @@ def x(*args, **kwargs):
CBM1000 = {
"FULLCUT" : [0x1D,0x56,0x01,0x49],
- "PARTIALCUT" : [0x1D,0x56,0x66,0x10],
- "FEED" : 0x64 }
+ "PARTIALCUT" : [0x1D,0x56,0x66,0x10], # CBM1000 specific codes as necessary
+ "FEED" : 0x64}
CBM231 = {
} # CBM231 specific codes as necessary
@@ -200,8 +200,8 @@ def CBMfeed(self, lines=1):
self.write("\n\n")
self.flush()
else:
- self.write("\n\n")
- self.flush()
+ self.write("\n\n")
+ self.flush()
@check_serial_init
def setPrintMode(self, mode):
@@ -416,3 +416,16 @@ def setLineFeedRate(self, feedlength):
}
"""
+
+if __name__=="__main__":
+ print "You should run this as 'python -i microprinter.py {PORT DEVICE}"
+ import sys
+ serdev = "/dev/ttyAMA0"
+ make = "CBM1000"
+ if len(sys.argv) > 1:
+ serdev = sys.argv[1]
+ if len(sys.argv) > 2:
+ make = sys.argv[2]
+ m = Microprinter(serdev, make)
+ m.feed()
+
View
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
import sys, os
import Image
View
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
import sys, os
import Image
View
@@ -0,0 +1,42 @@
+from xml.dom import minidom
+import sys, time, urllib
+
+from microprinter import Microprinter
+
+m=Microprinter("/dev/ttyAMA0", "CBM1000")
+
+if len(sys.argv) != 2:
+ print "Please enter a search"
+ raise SystemExit
+
+search = sys.argv[1]
+
+m.CBM1000_printMarkup("Search Term: *%s*" % search)
+
+id = 0
+
+while True:
+
+ url = "http://search.twitter.com/search.atom?rpp=50&q=%s&since_id=%s" % (search, id)
+
+ xml = urllib.urlopen(url)
+
+ doc = minidom.parse(xml)
+
+ entries = doc.getElementsByTagName("entry")
+
+ if len(entries) > 0:
+
+ entries.reverse()
+
+ for e in entries:
+
+ title = e.getElementsByTagName("title")[0].firstChild.data
+ pub = e.getElementsByTagName("published")[0].firstChild.data
+ id = e.getElementsByTagName("id")[0].firstChild.data.split(":")[2]
+ name = e.getElementsByTagName("name")[0].firstChild.data.split(" ")[0]
+
+ print "> " + name + ": " + title + " [" + pub + "]"
+ m.CBM1000_printMarkup("[%s] *%s* %s" % (pub.encode("ascii", 'ignore'), name.encode("ascii", 'ignore'), title.encode("ascii", 'ignore')))
+
+ time.sleep(360)

0 comments on commit 4d6c6d3

Please sign in to comment.