diff --git a/protosign.py b/protosign.py index e69de29..a976abf 100644 --- a/protosign.py +++ b/protosign.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from vestactrl import setup_digits, board_init_uart +import textwrap + +def send_sign(text): + """ + Wraps and sends text to the Vestaboard. + """ + COLS = 22 + ROWS = 6 + + # Wrap text to fit the board's width. + lines = textwrap.wrap(text, width=COLS) + + # Truncate if the message is too long for the board's height. + if len(lines) > ROWS: + lines = lines[:ROWS] + + # The board controller expects spaces to be replaced with `0 for a blank character. + board_lines = [line.replace(' ', '`0') for line in lines] + + # setup_digits handles displaying the lines on the board. + # It will also vertically center the block of text. + setup_digits(board_lines, left_to_right_swap=False, real_hw=True) + + +if __name__ == '__main__': + # Initialize communication with the board. + board_init_uart() + message = "This is a test of the protosign script. This message should wrap across multiple lines and be truncated if it is too long to fit on the display." + send_sign(message)