1#!/usr/bin/env python
2#-------------------------------------------------------------------------------
3# qwiic_buzzer_ex9_firmware_version.py
4#
5# This example shows how to read the firmware version from the Qwiic Buzzer
6#
7#-------------------------------------------------------------------------------
8# Written by SparkFun Electronics, January 2024
9#
10# This python library supports the SparkFun Electroncis Qwiic ecosystem
11#
12# More information on Qwiic is at https://www.sparkfun.com/qwiic
13#
14# Do you like this library? Help support SparkFun. Buy a board!
15#
16# https://www.sparkfun.com/products/24474
17#
18#===============================================================================
19# Copyright (c) 2023 SparkFun Electronics
20#
21# Permission is hereby granted, free of charge, to any person obtaining a copy
22# of this software and associated documentation files (the "Software"), to deal
23# in the Software without restriction, including without limitation the rights
24# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25# copies of the Software, and to permit persons to whom the Software is
26# furnished to do so, subject to the following conditions:
27#
28# The above copyright notice and this permission notice shall be included in all
29# copies or substantial portions of the Software.
30#
31# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37# SOFTWARE.
38#===============================================================================
39
40import qwiic_buzzer
41import sys
42import time
43
44def runExample():
45 print("\nQwiic Buzzer Example 9 - Firmware Version\n")
46
47 # Create instance of device
48 my_buzzer = qwiic_buzzer.QwiicBuzzer()
49
50 # Initialize the device
51 if my_buzzer.begin() == False:
52 print("The device isn't connected to the system. Please check your connection", \
53 file=sys.stderr)
54 return
55
56 print("\nQwiic Buzzer ready!\n")
57
58 print("Firmware Version Major: ")
59 print(my_buzzer.firware_version_major())
60 print("\nFirmware Version Minor: ")
61 print(my_buzzer.firware_version_minor())
62
63if __name__ == '__main__':
64 try:
65 runExample()
66 except (KeyboardInterrupt, SystemExit) as exErr:
67 print("\nEnding Example")
68 sys.exit(0)