Author | Oliver "Kiste" Seitz, Copyright © 2011, all rights reserved. |
Adapted-by | Rob Hamerling |
Compiler | 2.4o |
. Prints variables to output device, typically an lcd or a serial port Input variables: bit, byte, sbyte, word, sword, dword, sdword Output formats: decimal, hexadecimal, binary and some specials . For decimal output an arbitrary variable size supported. The user may define a constant with a positive value greater than one. const PRINT_MAX_VAR_SIZE before including this library to specify the highest variable size is required for his program. When not specified by the user a default of 4 is used, which means variables upto dword or sdword are supported. . Examples: . var sword bhl = -684 . Print the signed word in decimal notation on an LCD print_sword_dec(lcd, bhl) will send "-684" to device 'lcd' . To send the same signed word to a serial port: print_sword_dec(serial_hw_data, bhl) . Specials: print_crlf(serial_hw_data) will send CR + LF to the device 'serial_hw_data'. . const byte str1[] = "JalLibWorld V1.0" print_string(lcd, str1) will display the string 'str' on an lcd. . . Note - the whole string - that is the length of the array - . is printed. When you use a variable array to construct strings, . you might want to terminate at a termination character like 0x00. . You can set this termination character with: . const byte print_string_terminator = 0x00 . (or use a var if you want to change it at runtime.)
. - This library replaces an older version which had no scalability. It should be compatible with the old library except for: * All procedures for binary output have been renamed to print_xxxx_bin() for name consistency with '_dec' and '_hex'. * print_bit_truefalse() has been renamed to print_bit_logic() * print_bit_highlow() has been renamed to print_bit_level() * print_bit_10() has been renamed to print_bit_bin() * For renamed procedures a procedure issuing a deprecation warning is provided for compatibility. * The procedure print_sword_fp_dec() has been dropped. For output of fixed point numbers use the format library. * Some procedures are added to print signed bytes, words and double words in binary and hexadecimal format (without sign!).
var bit print_prefix = FALSE
const PRINT_MAX_VAR_SIZE = 4
var byte*PRINT_MAX_VAR_SIZE _print_dec_divisor
print_sdword_bin(volatile byte out device, dword in data)
print_maxsvar_dec(volatile byte out device, sbyte*PRINT_MAX_VAR_SIZE in data)
print_nibble_binary(volatile byte out device, bit in data)
print_dword_bin(volatile byte out device, dword in data)
print_bit_bin(volatile byte out device, bit in data)
print_byte_binary(volatile byte out device, byte in data)
print_sbyte_dec(volatile byte out device, sbyte in data)
print_sbyte_bin(volatile byte out device, sbyte in data)
print_sword_dec(volatile byte out device, sword in data)
print_word_dec(volatile byte out device, word in data)
print_byte_bin(volatile byte out device, byte in data)
print_bit_highlow(volatile byte out device, bit in data)
print_sbyte_hex(volatile byte out device, sbyte in data)
print_word_hex(volatile byte out device, word in data)
print_bit_logic(volatile byte out device, bit in data)
print_string(volatile byte out device, byte in str[])
print_byte_dec(volatile byte out device, byte in data)
print_byte_hex(volatile byte out device, byte in data)
print_maxvar_dec(volatile byte out device, byte*PRINT_MAX_VAR_SIZE in data)
print_bit_10(volatile byte out device, bit in data)
print_sdword_hex(volatile byte out device, sdword in data)
print_nibble_bin(volatile byte out device, byte in data)
print_dword_binary(volatile byte out device, dword in data)
print_crlf(volatile byte out device)
print_sdword_dec(volatile byte out device, sdword in data)
print_sword_hex(volatile byte out device, sword in data)
print_sword_bin(volatile byte out device, sword in data)
print_word_binary(volatile byte out device, word in data)
print_dword_hex(volatile byte out device, dword in data)
print_cls_ansi(volatile byte out device)
print_word_bin(volatile byte out device, word in data)
print_dword_dec(volatile byte out device, dword in data)
print_bit_truefalse(volatile byte out device, bit in data)
print_bit_level(volatile byte out device, bit in data)
var bit print_prefix = FALSE
Variable to indicate if formatted variables should have a prefix. When specified 'TRUE' the following prefixes will be part of the output: binary formats will be prefixed with '0b' hexadecimal formats will be prefixed with '0x' (decimal formats never have prefixes)
const PRINT_MAX_VAR_SIZE = 4
Constant to define the maximum supported variable size (in bytes) to be supported by this library.
var byte*PRINT_MAX_VAR_SIZE _print_dec_divisor
Global variable to determine number of decimal digits
print_sdword_bin(volatile byte out device, dword in data)
Title: Print signed double word binary Arguments: - device name sdword (byte*4 variable) Returns: nothing Notes: Sign is ignored for binary format
print_maxsvar_dec(volatile byte out device, sbyte*PRINT_MAX_VAR_SIZE in data)
Title: Print signed decimal value Arguments: - device name decimal variable (byte*PRINT_MAX_VAR_SIZE variable) Returns: nothing
print_nibble_binary(volatile byte out device, bit in data)
Deprecated
print_dword_bin(volatile byte out device, dword in data)
Title: Print unsigned double word binary Arguments: - device name dword (byte*4 variable) Returns: nothing
print_bit_bin(volatile byte out device, bit in data)
Title: Print binary value of a bit Arguments: - device name bit Returns: nothing
print_byte_binary(volatile byte out device, byte in data)
Deprecated
print_sbyte_dec(volatile byte out device, sbyte in data)
Title: Print unsigned byte decimal Arguments: - device name byte Returns: nothing
print_sbyte_bin(volatile byte out device, sbyte in data)
Title: Print signed byte binary Arguments: - device name sbyte Returns: nothing Notes: Sign is ignored for binary format
print_sword_dec(volatile byte out device, sword in data)
Title: Print signed word decimal Arguments: - device name sword (sbyte*2 variable) Returns: nothing
print_word_dec(volatile byte out device, word in data)
Title: Print unsigned word decimal Arguments: - device name word (byte*2 variable) Returns: nothing
print_byte_bin(volatile byte out device, byte in data)
Title: Print unsigned byte binary Arguments: - device name byte Returns: nothing
print_bit_highlow(volatile byte out device, bit in data)
Deprecated
print_sbyte_hex(volatile byte out device, sbyte in data)
Title: Print signed byte hexadecimal Arguments: - device name sbyte Returns: nothing Notes: Sign is ignored for hexadecimal format
print_word_hex(volatile byte out device, word in data)
Title: Print unsigned word hexadecimal Arguments: - device name word (byte*2 variable) Returns: nothing
print_bit_logic(volatile byte out device, bit in data)
Title: Print logical value of a bit Arguments: - device name bit Returns: nothing
print_string(volatile byte out device, byte in str[])
Title: Print string Arguments: - device name string (array of bytes) Returns: nothing
print_byte_dec(volatile byte out device, byte in data)
Title: Print unsigned byte decimal Arguments: - device name byte Returns: nothing
print_byte_hex(volatile byte out device, byte in data)
Title: Print unsigned byte hexadecimal Arguments: - device name byte Returns: nothing
print_maxvar_dec(volatile byte out device, byte*PRINT_MAX_VAR_SIZE in data)
Title: Print unsigned decimal value Arguments: - device name decimal variable (byte*PRINT_MAX_VAR_SIZE variable) Returns: nothing
print_bit_10(volatile byte out device, bit in data)
Deprecated
print_sdword_hex(volatile byte out device, sdword in data)
Title: Print signed double word hexadecimal Arguments: - device name sdword (sbyte*4 variable) Returns: nothing Notes: Sign is ignored for hexadecimal format
print_nibble_bin(volatile byte out device, byte in data)
Title: Print nibble binary Arguments: - device name nibble (bit*4 variable) Returns: nothing
print_dword_binary(volatile byte out device, dword in data)
Deprecated
print_crlf(volatile byte out device)
Title: Print Carriage Return + LineFeed Arguments: - device name Returns: nothing
print_sdword_dec(volatile byte out device, sdword in data)
Title: Print signed double word decimal Arguments: - device name sdword (sbyte*4 variable) Returns: nothing
print_sword_hex(volatile byte out device, sword in data)
Title: Print signed word hexadecimal Arguments: - device name sword (sbyte*2 variable) Returns: nothing Notes: Sign is ignored for hexadecimal format
print_sword_bin(volatile byte out device, sword in data)
Title: Print signed word binary Arguments: - device name sword (byte*2 variable) Returns: nothing Notes: Sign is ignored for binary format
print_word_binary(volatile byte out device, word in data)
Deprecated
print_dword_hex(volatile byte out device, dword in data)
Title: Print unsigned double word hexadecimal Arguments: - device name dword (byte*4 variable) Returns: nothing
print_cls_ansi(volatile byte out device)
Title: Clear screen on ANSI-compatible terminals Arguments: - device name Returns: nothing
print_word_bin(volatile byte out device, word in data)
Title: Print unsigned word binary Arguments: - device name word (byte*2 variable) Returns: nothing
print_dword_dec(volatile byte out device, dword in data)
Title: Print unsigned double word decimal Arguments: - device name dword (byte*4 variable) Returns: nothing
print_bit_truefalse(volatile byte out device, bit in data)
Deprecated
print_bit_level(volatile byte out device, bit in data)
Title: Print voltage level of a bit Arguments: - device name bit Returns: nothing
_make_tenfold_divisor()
Title: Multiply _print_dec_divisor by 10 Arguments: none Returns: nothing Notes: Used to determine the number of decimal digits
nibble2hex(bit*4 in nibble) return byte
Title: Convert nibble to hexadecimal digit (ASCII printable) Arguments: nibble (bit*4 variable) Returns: byte