Example Seven - Unknown Character

examples/qwiic_alphanumeric_ex07_unknown_char.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex8_unknown_char.py
 4#
 5# This example demonstrates what the library does when the user tries to 
 6# print an unknown character.
 7# ----------------------------------------------------------------------
 8#
 9# Written by Priyanka Makin @ SparkFun Electronics, September 2021
10#
11# This python library supports the SparkFun Electronics qwiic sensor/
12# board ecosystem on a Raspberry Pi (and compatable) single board 
13# computers.
14#
15# More information on qwiic is at https://www.sparkfun.com/qwiic
16#
17# Do you like this library? Help support SparkFun by buying a board!
18#
19# ======================================================================
20# Copyright (c) 2021 SparkFun Electronics
21#
22# Permission is hereby granted, free of charge, to any person obtaining 
23# a copy of this software and associated documentation files (the 
24# "Software"), to deal in the Software without restriction, including 
25# without limitation the rights to use, copy, modify, merge, publish, 
26# distribute, sublicense, and/or sell copies of the Software, and to 
27# permit persons to whom the Software is furnished to do so, subject to 
28# the following conditions:
29#
30# The above copyright notice and this permission notice shall be 
31# included in all copies or substantial portions of the Software.
32#
33# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
34# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
35# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
36# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
37# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
38# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
39# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40#=======================================================================
41# Example 8
42
43from __future__ import print_function
44import qwiic_alphanumeric
45import time
46import sys
47
48def run_example():
49
50    print("\nSparkFun Qwiic Alphanumeric - Example 8: Unkown Char")
51    my_display = qwiic_alphanumeric.QwiicAlphanumeric()
52
53    if my_display.begin() == False:
54        print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
55            file=sys.stderr)
56        return
57    
58    print("\nQwiic Alphanumeric ready!")
59    
60    # Because '\t' is a character unkown to the library, expect the display
61    # to turn on all sefments for that unknown digit/character
62    my_display.print("\t\t\t\t")   # Tabs are not printable characters
63
64if __name__ == '__main__':
65    try:
66        run_example()
67    except (KeyboardInterrupt, SystemExit) as exErr:
68        print("\nEnding Example 8")
69        sys.exit(0)