Qwiic_Alphanumeric_Py

follow on Twitter

SparkFun Qwiic Alphanumeric - Pink

Python module for the [SparkFun Qwiic Alphanumeric Display].

It is compatible with the following products:

This python package is a port of the existing SparkFun Qwiic Alphanumeric Arduino Library

This package can be used in conjunction with the overall SparkFun qwiic Python Package

New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.

Contents

Supported Platforms

The Qwiic LED Stick Python package currently supports the following platforms:

Dependencies

This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py

Documentation

The SparkFun Qwiic LED Stick module documentation is hosted at ReadTheDocs

Installation

PyPi Installation

This repository is hosted on PyPi as the sparkfun-qwiic-alphanumeric package. On systems that support PyPi installation via pip, this library is installed using the following commands

For all users (note: the user must have sudo privileges):

sudo pip install sparkfun-qwiic-alphanumeric

For the current user:

pip install sparkfun-qwiic-alphanumeric

To install, make sure the setuptools package is installed on the system.

Direct installation at the command line:

python setup.py install

To build a package for use with pip:

python setup.py sdist

A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.

cd dist
pip install sparkfun-qwiic-alphanumeric-<version>.tar.gz

Example Use

See the examples directory for more detailed use examples.

from __future__ import print_function
import qwiic_alphanumeric
import time
import sys

def run_example():

    print("\nSparkFun Qwiic Alphanumeric - Example 4: Print String")
    my_display = qwiic_alphanumeric.QwiicAlphanumeric()

    if my_display.begin() == False:
        print("\nThe Qwiic Alphanumeric isn't connected to the system. Please check your connection.", \
            file=sys.stderr)
        return

    print("\nQwiic Alphanumeric ready!")

    my_display.print("Milk")

if __name__ == '__main__':
    try:
        run_example()
    except (KeyboardInterrupt, SystemExit) as exErr:
        print("\nEnding Example 4")
        sys.exit(0)

SparkFun - Start Something

Table of Contents

API Reference

qwiic_alphanumeric

Python module for the SparkFun Qwiic Alphanumeric displays.

This package is a port of the existing [SparkFun Alphanumeric Display Arduino Library](https://github.com/sparkfun/SparkFun_Alphanumeric_Display_Arduino_Library).

This package can be used in conjunction with the overall [SparkFun Qwiic Python Package](https://github.com/sparkfun/Qwiic_Py).

New to qwiic? Take a look at the entire [SparkFun Qwiic Ecosystem](https://www.sparkfun.com/qwiic).

class qwiic_alphanumeric.QwiicAlphanumeric(address=None, i2c_driver=None)[source]
Parameters
  • address – The I2C address to use for the device. If not provided, the default address is used.

  • i2c_driver – An existing i2c driver object. If not provided a a driver is created.

Returns

The QwiicAlphanumeric device object.

Return type

Object

begin(address_display_one=112, address_display_two=255, address_display_three=255, address_display_four=255)[source]

Initialize the operation of the Qwiic Alphanumeric. Assign addresses to displays and determine the number of displays connected to the bus. Run is_connected(). Initialize and clear displays.

Parameters
  • address_display_one – I2C address of first display

  • address_display_two – I2C address of the second display

  • address_dispplay_three – I2C address of the third display

  • address_display_four – I2C address of the fourth display

Returns

Returns true if a Qwiic Alphanumeric is connected to the system. False otherwise.

Return type

bool

clear()[source]

Turn off all segments of all displays connected to bus

Returns

True if display was updated correctly, false otherwise

Return type

bool

colon_off()[source]

Turn the colon off for all displays on the bus

Returns

true if all displays are successfully updated, false otherwise.

Return type

bool

colon_off_single(display_number)[source]

Turn the colon off for a single display

Parameters

display_number – number of display to update.

Returns

true if display updated successfully, false otherwise.

Return type

bool

colon_on()[source]

Turn the colon on for all displays on the bus

Returns

true if displays successfully updated, false otherwise.

Return type

bool

colon_on_single(display_number)[source]

Turn the colon on for a single display

Parameters

display_number – number of display to update.

Returns

true if display updated successfully, false otherwise.

Return type

bool

decimal_off()[source]

Turn the decimal point off for all displays on the bus

Returns

true if displays are updated successfully, false otherwise.

Return type

bool

decimal_off_single(display_number)[source]

Turn the decimal point off for a single display

Parameters

display_number – the number of display to turn the decimal point off for.

Returns

true if decimal is successfully turned off, false otherwise.

Return type

bool

decimal_on()[source]

Turn the decimal on for all displays on the bus

Returns

true if displays are updated successfully, false otherwise.

Return type

bool

decimal_on_single(display_number)[source]

Turn the decimal point on for a single display

Parameters

display_number – the number of display to turn the decimal on for.

Returns

true if decimal is successfully turned on, false otherwise.

Return type

bool

disable_system_clock()[source]

Turn off the system oscillator for all displays on the bus

Returns

True if all clocks successfully disabled, false otherwise.

Return type

bool

disable_system_clock_single(display_number)[source]

Turn off the system oscillator for standby mode

Parameters

display_number – number of display on I2C bus to disable the system clock for.

Returns

True if setting updated successfully, false otherwise.

Return type

bool

display_off()[source]

Turn off all displays on the I2C bus

Returns

True if all displays are successfully turned off, false otherwise.

Return type

bool

display_off_single(display_number)[source]

Turn a single alphanumeric display off

Parameters

display_number – the number of display to be updated

Returns

True if display is successfully turned off, false otherwise

Return type

bool

display_on()[source]

Turn on all displays on the I2C bus

Returns

True if displays are successfully turned on, false otherwise.

Return type

bool

display_on_single(display_number)[source]

Turn a single alphanumeric display on

Parameters

display_number – the number of display to be updated

Returns

True if display is successfully turned on, false otherwise

Return type

bool

enable_system_clock()[source]

Turn on the system oscillator for all displays on the I2C bus

Returns

True if all clocks successfully enabled, false otherwise.

Return type

bool

enable_system_clock_single(display_number)[source]

Turn on the system oscillator for normal operation mode

Parameters

display_number – number of display on I2C bus to enable the system clock for.

Returns

True if setting updated successfully, false otherwise.

Return type

bool

illuminate_char(segments_to_turn_on, digit)[source]

Fiven a binary set of segments and a digit, store this data into the RAM array

Parameters
  • segments_to_turn_on – list of segments to illuminate which create an alphanumeric character

  • digit – digit on which to illuminate this char (list of segments)

Returns

nothing

Return type

Void

illuminate_segment(segment, digit)[source]

Given a segment and a digit, set the matching bit within the RAM of the Holtek RAM set

Parameters
  • segment – the segment to illuminate. There are 14 segments available, so A-N

  • digit – the digit on the display to turn the segment on. There are 4 digits per display

Returns

nothing

Return type

Void

initialize()[source]

Run through initialization sequence for each display connected on the I2C bus Enable clocks, set brightness default to full brightness, turn off blinking, and turn all displays on

Returns

True if all function calls passed, False if there’s a failure somewhere

Return type

bool

is_connected(display_number)[source]

Check that dispplays are responding on the I2C bus.

Parameters

display_number – The number of the display on the bus

Returns

True if the device is connected, false otherwise.

Return type

bool

look_up_display_address(display_number)[source]

This function connects the display number to its coressponding address

Parameters

display_number – number of display on I2C bus. The left-most display is zero and display number increments by 1 with each additional display on bus.

Returns

The I2C address of given display. 0 if display_number is not valid

Return type

int

print(print_string)[source]

Print a whole string to the alphanumeric display(s)

Parameters

print_string – string to be printed

Returns

true if update_display() is successful, false otherwise

Return type

bool

print_char(display_char, digit)[source]

Print a character, for a given digit, on display

Parameters
  • display_char – the character to be printed to display

  • digit – the digit position where character should be printed

Returns

nothing

Return type

Void

Set the blink rate of all displays on the bus as defined by the datasheet.

Parameters

rate – Blink frequency in Hz. Valid options are defined by datasheet: 2.0, 1.0, or 0.5 Hz. Any other input to this function will result in steady alphanumeric display (no blink).

Returns

True if blink setting is successfully updated, false otherwise.

Return type

bool

Set the blink rate of a single display on the bus

Parameters
  • display_number – the number of display to be updated

  • rate – Blink frequency in Hz. Valid options are defined by datasheet: 2.0, 1.0, or 0.5 Hz. Any other input to this function will result in steady alphanumeric display (no blink).

Returns

True if blink setting is successfully updated, false otherwise.

Return type

bool

set_brightness(duty)[source]

This function sets the brightness of all displays on the bus. Duty cycle over 16.

Parameters

duty – Valid between 0 (display off) and 15 (full brightness)

Returns

True if brightness is successfully updated, false otherwise.

Return type

bool

set_brightness_single(display_number, duty)[source]

Set the brightness of a single display

Parameters
  • display_number – The number of display on the I2C bus.

  • duty – Over 16. Valid between 0 (display off) and 15 (full brightness)

Returns

True if brightness is successfully updated, false otherwise.

Return type

bool

set_colon_on_off(display_number, turn_on_colon)[source]

Set or clear the colon on/off bit

Parameters
  • display_number – number of display to update.

  • turn_on_colon – boolean variable. If true, colon will turn on. If false, colon will turn off.

:return true if display updated successfully, false otherwise. :rtype: bool

set_decimal_on_off(display_number, turn_on_decimal)[source]

Set or clear the decimal on/off bit

Parameters
  • display_number – the number of display to update.

  • turn_on_decimal – boolean variable. If true, will turn decimal on. If false, will turn decimal off.

Returns

true if the display is updated successfully, false otherwise.

Return type

bool

set_display_on_off(display_number, turn_on_display)[source]

Set or clear the display on/off bit of a given display number

Parameters
  • display_number – the number of display to be updated

  • turn_on_display – boolean variable. If true, will turn display on. If false, will turn display off

Returns

True if display is successfully updated, false otherwise.

Return type

bool

shift_left(shift_amt=1)[source]

Shift the display content to the left a number of digits

Parameters

shift_amt – the number of digits to shift the string

Returns

true if display updates successfully, false otherwise.

Return type

bool

shift_right(shift_amt=1)[source]

Shift the display content to the right a number of digits

Parameters

shift_amt – the number of digits to shift the string

Returns

true if display updates successfully, false otherwise.

Return type

bool

update_display()[source]

Push the contents of display_RAM out on to the various displays in 16 byte chunks

Returns

true if displays are updated successfully, false otherwise.

Return type

bool

write_RAM(address, reg, buff)[source]

Write LED updates to the RAM of the LED driver IC

Parameters
  • address – I2C address of the display

  • reg – the location in RAM to write to

  • buff – the bytes to be written

Returns

true if RAM has been written to successfully, false otherwise.

Return type

bool

Example One - Print String

examples/qwiic_alphanumeric_ex01_print_string.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex4_print_string.py
 4#
 5# This example shows how to use the print() function to illuminate strings
 6# on the alphanumeric display.
 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 4
42
43from __future__ import print_function
44import qwiic_alphanumeric
45import time
46import sys
47
48def run_example():
49
50    print("\nSparkFun Qwiic Alphanumeric - Example 4: Print String")
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.print("Milk")
61
62if __name__ == '__main__':
63    try:
64        run_example()
65    except (KeyboardInterrupt, SystemExit) as exErr:
66        print("\nEnding Example 4")
67        sys.exit(0)

Example Two - Turn on one Segment

examples/qwiic_alphanumeric_ex02_turn_on_one_segment.py
 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)

Example Three - Print Char

examples/qwiic_alphanumeric_ex03_print_char.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex3_print_char.py
 4#
 5# This example tests illuminating a whole character on the 14-segment display.
 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 3
41
42from __future__ import print_function
43import qwiic_alphanumeric
44import time
45import sys
46
47def run_example():
48
49    print("\nSparkFun Qwiic Alphanumeric - Example 3: Print Char")
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 connection.", \
54            file=sys.stderr)
55        return
56    
57    print("\nQwiic Alphanumeric ready!")
58        
59    my_display.print_char('W', 0)
60    my_display.print_char('H', 1)
61    my_display.print_char('A', 2)
62    my_display.print_char('T', 3)
63
64    my_display.update_display()
65    
66    # # Un comment these lines if you want to see all available characters
67    # # Print to every digit of a given display
68    # for digit_num in range(0, 4):
69        # for i in range(ord(' '), ord('~')):
70            # if i is not ord(':') or ord('.'):
71                # my_display.print_char(chr(i), digit_num)
72                # my_display.update_display()
73                # time.sleep(1)
74                # my_display.clear()
75
76if __name__ == '__main__':
77    try:
78        run_example()
79    except (KeyboardInterrupt, SystemExit) as exErr:
80        print("\nEnding Example 3")
81        sys.exit(0)

Example Four - Set Brightness

examples/qwiic_alphanumeric_ex04_set_brightness.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex5_set_brightness.py
 4#
 5# This example sets the brightness of the Qwiic Alphanumeric display.
 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 5
41
42from __future__ import print_function
43import qwiic_alphanumeric
44import time
45import sys
46
47def run_example():
48
49    print("\nSparkFun Qwiic Alphanumeric - Example 5: Set Brightness")
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 wiring.", \
54            file=sys.stderr)
55        return
56
57    print("\nQwiic Alphanumeric Ready!")
58    
59    while True:
60        for i in range(0, 16):
61            # The input to set_brightness() is a duty cycle over 16
62            # So, the acceptable inputs to this function are ints between 0 (display off)
63            # and 15 (full brightness)
64            my_display.set_brightness(i)
65            my_display.display_print("Milk")
66            time.sleep(1)
67    
68if __name__ == '__main__':
69    try:
70        run_example()
71    except (KeyboardInterrupt, SystemExit) as exErr:
72        print("\nEnding Example 5")
73        sys.exit(0)

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)

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)

Example Eight - Multiple Displays

examples/qwiic_alphanumeric_ex08_multi_display.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex9_multi_display.py
 4#
 5# This example demonstrates how to connect multiple displays to the bus
 6# to print longer strings.
 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 9
42
43from __future__ import print_function
44import qwiic_alphanumeric
45import time
46import sys
47
48def run_example():
49
50    print("\nSparkFun Qwiic Alphanumeric - Example 9: Multi Display")
51    my_display = qwiic_alphanumeric.QwiicAlphanumeric()
52
53    if my_display.begin(0x70, 0x71) == False:
54        print("\nThe Qwiic Alhanumerics aren't connected to the system. Please check your connection", \
55            file=sys.stderr)
56        return
57
58    print("\nQwiic Alphanumerics ready!")
59
60    my_display.print("Get Milk")
61
62if __name__ == '__main__':
63    try:
64        run_example()
65    except (KeyboardInterrupt, SystemExit) as exErr:
66        print("\nEnding Example 9")
67        sys.exit(0)

Example Nine - Scrolling String

examples/qwiic_alphanumeric_ex09_scrolling_string.py
 1# !/usr/bin/env python
 2# ----------------------------------------------------------------------
 3# qwiic_alphanumeric_ex10_scrolling_string.py
 4#
 5# This example tests the scrolling functionality of the display.
 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 10
41
42from __future__ import print_function
43import qwiic_alphanumeric
44import time
45import sys
46
47def run_example():
48
49    print("\nSparkFun Qwiic Alphanumeric - Example 10: Scrolling String")
50    my_display = qwiic_alphanumeric.QwiicAlphanumeric()
51
52    if my_display.begin(0x70, 0x71) == False:
53        print("\nThe Qwiic Alhanumerics aren't connected to the system. Please check your connection", \
54            file=sys.stderr)
55        return
56
57    print("\nQwiic Alphanumerics passed begin!")
58    
59    my_display.print("GET MILK")
60
61    while 1:
62        time.sleep(1)
63        my_display.shift_left()
64        # Alternatively - you could also shift the string to the right
65        #my_display.shift_right()
66
67if __name__ == '__main__':
68    try:
69        run_example()
70    except (KeyboardInterrupt, SystemExit) as exErr:
71        print("\nEnding Example 10")
72        sys.exit(0)

Indices and tables