本文整理汇总了Python中writer.Writer.printstring方法的典型用法代码示例。如果您正苦于以下问题:Python Writer.printstring方法的具体用法?Python Writer.printstring怎么用?Python Writer.printstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writer.Writer
的用法示例。
在下文中一共展示了Writer.printstring方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def wrap(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
Writer.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = Writer(ssd, freesans20, verbose=False)
wri.set_clip(False, False, True) # Word wrap
wri.printstring('the quick brown fox jumps over')
ssd.show()
示例2: inverse
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def inverse(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
rhs = WIDTH -1
ssd.line(rhs - 20, 0, rhs, 20, 1)
square_side = 10
ssd.fill_rect(rhs - square_side, 0, square_side, square_side, 1)
Writer.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = Writer(ssd, freesans20, verbose=False)
wri.set_clip(False, False, False) # Char wrap
wri.printstring('Sunday\n')
wri.printstring('12 Aug 2018\n')
wri.printstring('10.30am', True) # Inverse text
ssd.show()
示例3: scroll
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def scroll(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
rhs = WIDTH -1
ssd.line(rhs - 20, 0, rhs, 20, 1)
square_side = 10
ssd.fill_rect(rhs - square_side, 0, square_side, square_side, 1)
Writer.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = Writer(ssd, freesans20, verbose=False)
wri.set_clip(False, False, False) # Char wrap
wri.printstring('Sunday\n')
wri.printstring('12 Aug 2018\n')
wri.printstring('10.30am')
for x in range(5):
ssd.show()
utime.sleep(2)
wri.printstring('\nCount = {:2d}'.format(x))
ssd.show()
utime.sleep(2)
wri.printstring('\nDone.')
ssd.show()
示例4: tabs
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def tabs(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
Writer.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = Writer(ssd, fixed, verbose=False)
wri.set_clip(False, False, False) # Char wrap
wri.printstring('1\t2\n')
wri.printstring('111\t22\n')
wri.printstring('1111\t1')
ssd.show()
示例5: fonts
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def fonts(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
Writer.set_textpos(ssd, 0, 0) # In case previous tests have altered it
wri = Writer(ssd, freesans20, verbose=False)
wri.set_clip(False, False, False) # Char wrap
wri_f = Writer(ssd, small, verbose=False)
wri_f.set_clip(False, False, False) # Char wrap
wri_f.printstring('Sunday\n')
wri.printstring('12 Aug 2018\n')
wri.printstring('10.30am')
ssd.show()
示例6: test
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def test(use_spi=False):
ssd = setup(use_spi) # Create a display instance
rhs = WIDTH -1
ssd.line(rhs - 20, 0, rhs, 20, 1)
square_side = 10
ssd.fill_rect(rhs - square_side, 0, square_side, square_side, 1)
wri = Writer(ssd, freesans20)
Writer.set_textpos(ssd, 0, 0) # verbose = False to suppress console output
wri.printstring('Sunday\n')
wri.printstring('12 Aug 2018\n')
wri.printstring('10.30am')
ssd.show()
示例7: rjust
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
def rjust(use_spi=False, soft=True):
ssd = setup(use_spi, soft) # Create a display instance
Writer.set_textpos(ssd, 0, 0) # Previous tests may have altered it
wri = Writer(ssd, freesans20, verbose=False)
wri.set_clip(False, False, False) # Char wrap
my_str = 'Sunday\n'
l = wri.stringlen(my_str)
Writer.set_textpos(ssd, col = WIDTH - l)
wri.printstring(my_str)
my_str = '12 Aug 2018\n'
l = wri.stringlen(my_str)
Writer.set_textpos(ssd, col = WIDTH - l)
wri.printstring(my_str)
my_str = '10.30am'
l = wri.stringlen(my_str)
Writer.set_textpos(ssd, col = WIDTH - l)
wri.printstring(my_str)
ssd.show()
示例8: Writer
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
import pyb, machine
import limi
from writer import Writer
import myfont
limi.powerup()
display = limi.init_oled()
w = Writer(display.framebuf,myfont,width=160,height=128)
w.printstring("HEEYY")
#
# display.pixel(1,1,1)
# display.pixel(140,1,1)
# display.pixel(140,127,1)
# def color_oled(r,g,b):
for r in range(0,255):
display.framebuf.fill_rect(60,1,160,100, r << 13 )
# display.fill_rect(60,1,160,100,r << 3 )
# display.fill_rect(60,1,160,100,r << 8)
w.printstring(str(r)+"\n")
display.show()
pyb.delay(100)
示例9: SSD1306_SPI
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
# X3 Rst
# X6 CLK
# X8 DATA
HEIGHT = 32
pdc = machine.Pin('X1', machine.Pin.OUT_PP)
pcs = machine.Pin('X2', machine.Pin.OUT_PP)
prst = machine.Pin('X3', machine.Pin.OUT_PP)
spi = machine.SPI(1)
ssd = SSD1306_SPI(WIDTH, HEIGHT, spi, pdc, prst, pcs)
else: # I2C
# Pyb SSD
# 3v3 Vin
# Gnd Gnd
# Y9 CLK
# Y10 DATA
HEIGHT = 64
pscl = machine.Pin('Y9', machine.Pin.OUT_PP)
psda = machine.Pin('Y10', machine.Pin.OUT_PP)
i2c = machine.I2C(scl=pscl, sda=psda)
ssd = SSD1306_I2C(WIDTH, HEIGHT, i2c)
#wri = Writer(ssd, freeserif19)
wri2 = Writer(ssd, freesans20)
Writer.set_clip(True, True)
wri2.printstring('Tuesday\n')
wri2.printstring('8 Nov 2016\n')
wri2.printstring('10.30am')
ssd.show()
示例10: callback
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import printstring [as 别名]
# Font
import freesans20
import bme280
import time
valt=False
def callback(p):
global valt
valt=not valt
p_fel=machine.Pin(12,machine.Pin.IN, machine.Pin.PULL_UP)
p_fel.irq(trigger=machine.Pin.IRQ_RISING, handler=callback)
i2c = machine.I2C(-1, machine.Pin(4), machine.Pin(5))
ssd = setup(False) # Create a display instance
wri = Writer(ssd, freesans20)
while(1):
Writer.set_textpos(ssd, 0, 0) # verbose = False to suppress console output
strr=bme280.BME280(i2c=i2c).values[0]+' \n'
wri.printstring(strr)
#if 0:
if valt==False:
strr=bme280.BME280(i2c=i2c).values[1]+' \n'
else:
altitude=((1-((float(bme280.BME280(i2c=i2c).values[1].split('h')[0])/1013.25)**0.190284))*145366.45)*0.3048
strr=str(altitude)+'m \n'
wri.printstring(strr)
strr=bme280.BME280(i2c=i2c).values[2]+' '
wri.printstring(strr)
ssd.show()
time.sleep(0.5)