Example 1 - Bitmap Example

examples/ex1_splash_screen.py
 1#!/usr/bin/env python
 2#-----------------------------------------------------------------------------
 3# ex1_splash_screen.py
 4#
 5# Simple Example for the Qwiic OLED Display
 6#------------------------------------------------------------------------
 7#
 8# Written by  SparkFun Electronics, May 2021
 9#
10# This python library supports the SparkFun Electroncis qwiic
11# qwiic sensor/board ecosystem on a Raspberry Pi (and compatable) single
12# board computers.
13#
14# More information on qwiic is at https:# www.sparkfun.com/qwiic
15#
16# Do you like this library? Help support SparkFun. Buy a board!
17#
18#==================================================================================
19# Copyright (c) 2021 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# Example 1 - Simple example to display the splash screen bitmap on the Qwiic OLED Display.
40#
41
42from __future__ import print_function
43import qwiic_oled_display
44from qwiic_oled_base import oled_logos as disp_logo
45import time
46import sys
47
48def runExample():
49
50  #  These three lines of code are all you need to initialize the
51  #  OLED and print the splash screen.
52
53  #  Before you can start using the OLED, call begin() to init
54  #  all of the pins and configure the OLED.
55
56
57  print("\nSparkFun Qwiic OLED Display - Splash screen example\n")
58  myOLED = qwiic_oled_display.QwiicOledDisplay()
59
60  if not myOLED.connected:
61    print("The Qwiic OLED Display isn't connected to the system. Please check your connection", \
62      file=sys.stderr)
63    return
64
65  myOLED.begin()
66
67  #  clear(ALL) will clear out the OLED's graphic memory.
68  myOLED.clear(myOLED.ALL) #  Clear the display's memory (gets rid of artifacts)
69  
70  #  To actually draw anything on the display, you must call the display() function.
71  myOLED.display()  #  Display buffer contents
72  time.sleep(3)
73
74  #  clear(PAGE) will clear the Arduino's display buffer.
75  myOLED.clear(myOLED.PAGE)  #  Clear the display's buffer
76
77  #  Display buffer contents
78  myOLED.display()
79  time.sleep(3)
80
81  disp_logo.add_logo(myOLED._screenbuffer)
82  myOLED.display()
83
84if __name__ == '__main__':
85  try:
86    runExample()
87  except (KeyboardInterrupt, SystemExit) as exErr:
88    print("\nEnding OLED bitmap Example")
89    sys.exit(0)