本文整理汇总了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)