本文整理汇总了Python中framebuf.FrameBuffer方法的典型用法代码示例。如果您正苦于以下问题:Python framebuf.FrameBuffer方法的具体用法?Python framebuf.FrameBuffer怎么用?Python framebuf.FrameBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framebuf
的用法示例。
在下文中一共展示了framebuf.FrameBuffer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def __init__(self, width, height, external_vcc):
self.width = width
self.height = height
self.external_vcc = external_vcc
self.pages = self.height // 8
self.buffer = bytearray(self.pages * self.width)
fb = framebuf.FrameBuffer(self.buffer, self.width, self.height, framebuf.MONO_VLSB)
self.framebuf = fb
# Provide methods for accessing FrameBuffer graphics primitives. This is a
# workround because inheritance from a native class is currently unsupported.
# http://docs.micropython.org/en/latest/pyboard/library/framebuf.html
self.fill = fb.fill
self.pixel = fb.pixel
self.hline = fb.hline
self.vline = fb.vline
self.line = fb.line
self.rect = fb.rect
self.fill_rect = fb.fill_rect
self.text = fb.text
self.scroll = fb.scroll
self.blit = fb.blit
self.poweron()
self.init_display()
示例2: _printchar
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def _printchar(self, char, invert=False):
if char == '\n':
self._newline()
return
glyph, char_height, char_width = self.font.get_ch(char)
if Writer.text_row + char_height > self.screenheight:
if Writer.row_clip:
return
self._newline()
if Writer.text_col + char_width > self.screenwidth:
if Writer.col_clip:
return
else:
self._newline()
buf = bytearray(glyph)
if invert:
for i, v in enumerate(buf):
buf[i] = 0xFF & ~ v
fbc = framebuf.FrameBuffer(buf, char_width, char_height, self.map)
self.device.blit(fbc, Writer.text_col, Writer.text_row)
Writer.text_col += char_width
示例3: _printchar
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def _printchar(self, char, invert=False, recurse=False):
s = self._getstate()
self._get_char(char, recurse)
if self.glyph is None:
return # All done
buf = bytearray(self.glyph)
if invert:
for i, v in enumerate(buf):
buf[i] = 0xFF & ~ v
fbc = framebuf.FrameBuffer(buf, self.char_width, self.char_height, self.map)
self.device.blit(fbc, s.text_col, s.text_row)
s.text_col += self.char_width
self.cpos += 1
示例4: refresh
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def refresh(device, clear=False):
if not isinstance(device, framebuf.FrameBuffer):
raise ValueError('Device must be derived from FrameBuffer.')
if device not in DObject.devices:
DObject.devices[device] = set()
device.fill(0)
else:
if clear:
DObject.devices[device].clear() # Clear the pending set
device.fill(0)
else:
for obj in DObject.devices[device]:
obj.show()
DObject.devices[device].clear()
device.show()
# Displayable object: effectively an ABC for all GUI objects.
示例5: text
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def text(display, text, x=0, y=0, color=0xffff, background=0x0000):
x = min(display.width - 1, max(0, x))
y = min(display.height - 1, max(0, y))
w = display.width - x
h = min(display.height - y, 8)
buffer = bytearray(display.width * h * 2)
fb = framebuf.FrameBuffer(buffer, w, h, framebuf.RGB565)
for line in text.split('\n'):
fb.fill(background)
fb.text(line, 0, 0, color)
display.blit_buffer(buffer, x, y, w, h)
y += 8;
if y >= display.height:
break
示例6: chars
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def chars(self, str, x, y):
str_w = self._font.get_width(str)
div, rem = divmod(self._font.height(),8)
nbytes = div+1 if rem else div
buf = bytearray(str_w * nbytes)
pos = 0
for ch in str:
glyph, char_w = self._font.get_ch(ch)
for row in range(nbytes):
index = row*str_w + pos
for i in range(char_w):
buf[index+i] = glyph[nbytes*i+row]
pos += char_w
fb = framebuf.FrameBuffer(buf,str_w, self._font.height(), framebuf.MONO_VLSB)
self.blit(fb,x,y,str_w,self._font.height())
return x+str_w
示例7: __init__
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def __init__(self, spi, cs, num):
"""
Driver for cascading MAX7219 8x8 LED matrices.
>>> import max7219
>>> from machine import Pin, SPI
>>> spi = SPI(1)
>>> display = max7219.Matrix8x8(spi, Pin('X5'), 4)
>>> display.text('1234',0,0,1)
>>> display.show()
"""
self.spi = spi
self.cs = cs
self.cs.init(cs.OUT, True)
self.buffer = bytearray(8 * num)
self.num = num
fb = framebuf.FrameBuffer(self.buffer, 8 * num, 8, framebuf.MONO_HLSB)
self.framebuf = fb
# Provide methods for accessing FrameBuffer graphics primitives. This is a workround
# because inheritance from a native class is currently unsupported.
# http://docs.micropython.org/en/latest/pyboard/library/framebuf.html
self.fill = fb.fill # (col)
self.pixel = fb.pixel # (x, y[, c])
self.hline = fb.hline # (x, y, w, col)
self.vline = fb.vline # (x, y, h, col)
self.line = fb.line # (x1, y1, x2, y2, col)
self.rect = fb.rect # (x, y, w, h, col)
self.fill_rect = fb.fill_rect # (x, y, w, h, col)
self.text = fb.text # (string, x, y, col=1)
self.scroll = fb.scroll # (dx, dy)
self.blit = fb.blit # (fbuf, x, y[, key])
self.init()
示例8: __init__
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def __init__(self, i2c, address=0x70):
super().__init__(i2c, address)
self._fb_buffer = bytearray(self.WIDTH * self.HEIGHT
* self.FB_BPP // 8)
self.framebuffer = framebuf.FrameBuffer(
self._fb_buffer, self.WIDTH, self.HEIGHT, self.FORMAT)
self.framebuffer.fill(0)
self.pixel = self.framebuffer.pixel
self.fill = self.framebuffer.fill
示例9: _get_id
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def _get_id(device):
if not isinstance(device, framebuf.FrameBuffer):
raise ValueError('Device must be derived from FrameBuffer.')
return id(device)
# Basic Writer class for monochrome displays
示例10: __init__
# 需要导入模块: import framebuf [as 别名]
# 或者: from framebuf import FrameBuffer [as 别名]
def __init__(self, spi, cs, dc, rst=None):
super().__init__(spi, cs, dc, rst)
self.buf = bytearray((HEIGHT // 8) * WIDTH)
self.fbuf = framebuf.FrameBuffer(self.buf, WIDTH, HEIGHT, framebuf.MONO_VLSB)