本文整理匯總了Python中Adafruit_SSD1306.SSD1306_128_64屬性的典型用法代碼示例。如果您正苦於以下問題:Python Adafruit_SSD1306.SSD1306_128_64屬性的具體用法?Python Adafruit_SSD1306.SSD1306_128_64怎麽用?Python Adafruit_SSD1306.SSD1306_128_64使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類Adafruit_SSD1306
的用法示例。
在下文中一共展示了Adafruit_SSD1306.SSD1306_128_64屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import Adafruit_SSD1306 [as 別名]
# 或者: from Adafruit_SSD1306 import SSD1306_128_64 [as 別名]
def __init__(self):
self.ser = serial.Serial(port='/dev/ttyAMA0',baudrate=9600, timeout = 0.2)
# Raspberry Pi pin configuration:
RST = 24
# Note the following are only used with SPI:
DC = 23
SPI_PORT = 0
SPI_DEVICE = 0
# 128x32 display with hardware I2C:
#self.disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)
# 128x64 display with hardware I2C:
self.disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)
# Initialize library.
self.disp.begin()
# Clear display.
self.disp.clear()
self.disp.display()
# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = self.disp.width
height = self.disp.height
self.image = Image.new('1', (width, height))
# Get drawing object to draw on image.
self.draw = ImageDraw.Draw(self.image)
padding = 2
shape_width = 20
top = padding
bottom = height-padding
x = padding
x += shape_width+padding
# Load default font.
#self.font = ImageFont.load_default()
self.font = ImageFont.truetype('Minecraftia-Regular.ttf', 8)