def get_erika_for_given_args(args, is_character_based=False): is_dry_run = args.dry_run com_port = args.serial_port if is_dry_run: if is_character_based or not 'file' in args: # using low size just so it fits on the screen well - does not reflect the paper dimensions that Erika supports erika = CharacterBasedErikaMock( DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY, exception_if_overprinted=False) else: # a bit hacky, as I'm mirroring behavior from ErikaImageRenderer - this kindof goes against the now-beautiful architecture :( try: # hacky: use exception to determine image type image_for_provoking_exception = WrappedImage(args.file) erika = MicrostepBasedErikaMock( DRY_RUN_WIDTH, DRY_RUN_HEIGHT, output_after_each_step=True, delay_after_each_step=DRY_RUN_DELAY, exception_if_overprinted=False) except NotAnImageException: erika = CharacterBasedErikaMock( DRY_RUN_WIDTH, DRY_RUN_HEIGHT, delay_after_each_step=DRY_RUN_DELAY, exception_if_overprinted=False) else: erika = Erika(com_port) return erika
def test_movement(self): """simple test to test cursor movement - validation is manual check of cursor movement""" delay = 0 with Erika(COM_PORT) as my_erika: for i in range(10): my_erika.move_right() time.sleep(delay) for i in range(10): my_erika.move_up() time.sleep(delay) for i in range(10): my_erika.move_left() time.sleep(delay) for i in range(10): my_erika.move_down() time.sleep(delay)
def get_erika_for_given_args(args): is_dry_run = args.dry_run com_port = args.serial_port if is_dry_run: # using 60x40 just so it fits on the screen well - does not reflect the paper dimensions that Erika supports erika = ErikaMock(60, 40, output_after_each_step=True, delay_after_each_step=0.005) # slower, but output will not flicker as much # erika = ErikaMock(60, 40, output_after_each_step=True, delay_after_each_step=0.05) else: erika = Erika(com_port) return erika
tweet_as_string = "{}: {}".format(username, tweet) # print(tweet) q.put(tweet_as_string) def on_error(self, status_code, data): print(status_code) # Want to stop trying to get data because of the error? # Uncomment the next line! # self.disconnect() q = Queue() # TODO bad style, use "with" statement instead for clean closing... erika = Erika(ERIKA_PORT) # For local tests # erika = ErikaMock(output_after_each_step=True) def twitter_worker(): stream = MyStreamer(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET) stream.statuses.filter(track=COMMA_SEPARATED_HASH_TAGS_TO_LISTEN_FOR) def erika_worker(): while True: tweet_as_string = q.get(block=True) erika.crlf() print("### DEBUG (tweet):" + tweet_as_string)
def test_write(self): """simple test that there is no exception when connecting""" with Erika(COM_PORT) as my_erika: my_erika.crlf() my_erika.print_ascii("Hello, World!") my_erika.crlf()
def test_connect(self): """simple test that there is no exception when connecting""" with Erika(COM_PORT) as ignored: pass
#! /usr/bin/python3 from erika.erika import Erika from sys import stdin import time e = Erika("/dev/ttyAMA0") with e: e.print_string("\n") e.print_string("Test Single Diacritics") e.print_string("\n") e.print_string("----------------------") e.print_string("\n") e.print_string("^^^") e.print_string("\n") e.print_string("```") e.print_string("\n") e.print_string("´´´") e.print_string("\n") e.print_string("¨¨¨") e.print_string("\n") e.print_string("°°°") e.print_string("\n") e.print_string("²²²") e.print_string("\n") e.print_string("³³³") e.print_string("\n") e.print_string("\n") e.print_string("Test Combined Diacritics") e.print_string("\n") e.print_string("------------------------") e.print_string("\n")
#!/usr/bin/env python3 import socket import string import time from erika.erika import Erika from erika.local_settings import ERIKA_MAX_LINE_LENGTH from erika.local_settings import ERIKA_PORT from erika.local_settings import TCP_IP, TCP_PORT, BUFFER_SIZE ALLOWED_CHARACTERS = string.digits + string.ascii_letters + "@.,;:# ()_/?!\"§+%&=*-'äöüÄÖÜßéè°|$£µ^²³\n" # TODO bad style, use "with" statement instead for clean closing... erika = Erika(ERIKA_PORT) erika.set_keyboard_echo(False) s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((TCP_IP, TCP_PORT)) s.listen(1) def print_to_erika(sanitized_tweet): erika.crlf() xpos = 0 for i in range(0, len(sanitized_tweet)): erika.print_ascii(sanitized_tweet[i]) xpos += 1