Example Six - Colon and Decimal

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