1# !/usr/bin/env python
2# ----------------------------------------------------------------------
3# qwiic_alphanumeric_ex2_turn_on_one_segment.py
4#
5# This example tests illuminating individual segments of the display. Pass
6# in the segment and digit you wish to illuminate into illuminate_segment().
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 2
42
43from __future__ import print_function
44import qwiic_alphanumeric
45import time
46import sys
47
48def run_example():
49
50 print("\nSparkFun Qwiic Alphanumeric - Example 2: Turn On One Segment")
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 my_display.illuminate_segment('A', 0)
61 my_display.illuminate_segment('L', 1)
62 my_display.illuminate_segment('I', 2)
63 my_display.illuminate_segment('G', 3)
64
65 my_display.update_display()
66
67if __name__ == '__main__':
68 try:
69 run_example()
70 except (KeyboardInterrupt, SystemExit) as exErr:
71 print("\nEnding Example 2")
72 sys.exit(0)