From a5466dbd858232c1591e792b822e5bc1c50442b8 Mon Sep 17 00:00:00 2001 From: Andrew Kay Date: Tue, 26 May 2020 16:58:01 -0500 Subject: [PATCH] Improve pycoax character map example --- pycoax/examples/20_char_map.py | 48 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/pycoax/examples/20_char_map.py b/pycoax/examples/20_char_map.py index 83bde17..cf435ca 100755 --- a/pycoax/examples/20_char_map.py +++ b/pycoax/examples/20_char_map.py @@ -2,40 +2,62 @@ from common import create_serial, create_interface -from coax import read_address_counter_hi, read_address_counter_lo, load_address_counter_hi, load_address_counter_lo, write_data +from coax import Control, read_address_counter_hi, read_address_counter_lo, load_address_counter_hi, load_address_counter_lo, write_data, load_control_register DIGIT_MAP = [0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85] with create_serial() as serial: interface = create_interface(serial) - print('LOAD_ADDRESS_COUNTER_HI...') + load_control_register(interface, Control(cursor_inhibit=True)) load_address_counter_hi(interface, 0) - - print('LOAD_ADDRESS_COUNTER_LO...') - load_address_counter_lo(interface, 80) - print('WRITE_DATA...') - - buffer = b'\x00' * 3 + buffer = b'\x00' * 4 # Header Row for lo in range(16): - buffer += bytes([DIGIT_MAP[lo]]) + (b'\x00' * 3) + buffer += bytes([0x2f, DIGIT_MAP[lo]]) + (b'\x00' * 2) - buffer += b'\x00' * 13 + buffer += b'\x00' * 12 # Rows for hi in range(16): - buffer += bytes([DIGIT_MAP[hi]]) + (b'\x00' * 2) + buffer += bytes([DIGIT_MAP[hi], 0x2f]) + (b'\x00' * 2) for lo in range(16): - buffer += bytes([(hi << 4) | lo]) + b'\x32\xc0\x00' + if hi < 12: + buffer += bytes([0x00, (hi << 4) | lo, 0xc0, 0x00]) + else: + buffer += bytes([(hi << 4) | lo, 0x32, 0xc0, 0x00]) - buffer += b'\x00' * 13 + buffer += b'\x00' * 12 buffer += b'\x00' * 560 write_data(interface, buffer) + + # Status Line + load_address_counter_hi(interface, 7) + load_address_counter_lo(interface, 48) + + buffer = b'' + + for hi in range(12, 16): + buffer += bytes([DIGIT_MAP[hi]]) + (b'\x00' * 15) + + buffer += b'\x00' * 16 + + for hi in range(12, 16): + for lo in range(0, 16): + buffer += bytes([DIGIT_MAP[lo]]) + + write_data(interface, buffer) + + load_address_counter_hi(interface, 0) + load_address_counter_lo(interface, 0) + + buffer = bytes(range(0xc0, 0xff + 1)) + + write_data(interface, buffer)