本文整理汇总了Python中Adafruit_Thermal.boldOn方法的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_Thermal.boldOn方法的具体用法?Python Adafruit_Thermal.boldOn怎么用?Python Adafruit_Thermal.boldOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Adafruit_Thermal
的用法示例。
在下文中一共展示了Adafruit_Thermal.boldOn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_post
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import boldOn [as 别名]
def generate_post():
with open('/home/yuri/mashbotv2/cleaned.txt') as f:
text = f.read()
text_model = markovify.Text(text, state_size=2)
mash_text = text_model.make_short_sentence(129) # was 140
wrapped_text = textwrap.fill(mash_text, 32)
output_text = "@acoluthon " + mash_text
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
printer.setDefault()
printer.justify('L')
printer.feed(3)
printer.boldOn()
printer.setSize('M')
printer.println("Mash Note")
printer.setSize('S')
printer.boldOff()
printer.println(wrapped_text)
printer.feed(2)
# Write the status to a file, for debugging
with open('/home/yuri/mashbotv2/history.txt', 'a') as f:
f.write('mashed: ' + mash_text + ' | tweeted: ' + output_text + '\n')
return output_text
示例2: justification
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import boldOn [as 别名]
# Test character double-width on & off
printer.doubleWidthOn()
printer.println("Double Width ON")
printer.doubleWidthOff()
# Set justification (right, center, left) -- accepts 'L', 'C', 'R'
printer.justify('R')
printer.println("Right justified")
printer.justify('C')
printer.println("Center justified")
printer.justify('L')
printer.println("Left justified")
# Test more styles
printer.boldOn()
printer.println("Bold text")
printer.boldOff()
printer.underlineOn()
printer.println("Regular underlined text")
printer.underlineOff()
printer.underlineOn(2)
printer.println("Heavy underlined text")
printer.underlineOff()
printer.strikeOn()
printer.println("Strike through text")
printer.strikeOff()
示例3: main
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import boldOn [as 别名]
def main():
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
deg = chr(0xf8) # Degree symbol on thermal printer
events = get_events()
# Print heading
printer.setSize('M')
printer.justify('C')
printer.println( datetime.datetime.today().date().strftime("%A, %B %-d, %Y") )
printer.justify('L')
printer.setSize('S')
# Print schedule
printer.boldOn()
printer.underlineOn()
printer.justify('C')
printer.println("Today's Schedule")
printer.justify('L')
printer.underlineOff()
printer.boldOff()
printer.feed(1)
if not events:
printer.println('No scheduled events today.')
printer.feed(1)
for event in events:
start = dateutil.parser.parse(event['start'].get('dateTime', event['start'].get('date'))).strftime("%-I:%M%p")
end = dateutil.parser.parse(event['end'].get('dateTime', event['end'].get('date'))).strftime("%-I:%M%p")
location = event.get('location', '')
printer.println(event['summary'])
if start == end:
if location:
printer.println(start + ", " + location)
else:
printer.println(start)
else:
if location == "":
printer.println(start + " - " + end)
else:
printer.println(start + " - " + end + ", " + location)
printer.feed(1)
printer.feed(1)
# Print weather
weather = get_weather()
printer.boldOn()
printer.underlineOn()
printer.justify('C')
printer.println("Today's Weather")
printer.justify('L')
printer.underlineOff()
printer.boldOff()
printer.feed(1)
printer.println("Temperature: " + str(weather.temp_now) + ". Feels like " + str(weather.feels_like_now))
printer.feed(1)
printer.println("Today: " + weather.weather_today)
printer.feed(1)
printer.println("Tonight: " + weather.weather_tonight)
printer.feed(1)
downcase_first = lambda s: s[:1].lower() + s[1:] if s else ''
printer.println("Tomorrow: " + weather.weather_tomorrow + " Tomorrow night, " + downcase_first(weather.weather_tomorrow_night))
printer.feed(1)
printer.feed(2)
示例4: Adafruit_Thermal
# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import boldOn [as 别名]
return gray
if __name__ == '__main__':
# new videocapture object
cap = cv2.VideoCapture(0)
# Create a Adafruit_Thermal object that we can use for printing
printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
# python-tesseract initialization
api = tesseract.TessBaseAPI()
api.SetOutputName("hacker_u")
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)
printer.boldOn() # Make text bold
printer.setSize('L') # Set type size, accepts 'S', 'M', 'L'
printer.justify('C') # Center the text to leave lots of whitespace
while(True):
''' Prompt the user to enter some text to be recognized by python-tesseract '''
text_to_print = raw_input("Enter text: ")
# Alert user that we are printing
print("Printing...")
''' Print the user's text out '''
printer.println(text_to_print)
time.sleep(1)