本文整理汇总了Python中writer.Writer.set_textpos方法的典型用法代码示例。如果您正苦于以下问题:Python Writer.set_textpos方法的具体用法?Python Writer.set_textpos怎么用?Python Writer.set_textpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writer.Writer
的用法示例。
在下文中一共展示了Writer.set_textpos方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dual
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [as 别名]
def dual(use_spi=False, soft=True):
ssd0 = setup(False, soft) # I2C display
ssd1 = setup(True, False) # SPI instance
Writer.set_textpos(ssd0, 0, 0) # In case previous tests have altered it
wri0 = Writer(ssd0, small, verbose=False)
wri0.set_clip(False, False, False)
Writer.set_textpos(ssd1, 0, 0) # In case previous tests have altered it
wri1 = Writer(ssd1, small, verbose=False)
wri1.set_clip(False, False, False)
nfields = []
dy = small.height() + 6
col = 15
for n, wri in enumerate((wri0, wri1)):
nfields.append([])
y = 2
for txt in ('X:', 'Y:', 'Z:'):
Label(wri, y, 0, txt)
nfields[n].append(Label(wri, y, col, wri.stringlen('99.99'), True))
y += dy
for _ in range(10):
for n, wri in enumerate((wri0, wri1)):
for field in nfields[n]:
value = int.from_bytes(uos.urandom(3),'little')/167772
field.value('{:5.2f}'.format(value))
wri.device.show()
utime.sleep(1)
for wri in (wri0, wri1):
Label(wri, 0, 64, ' DONE ', True)
wri.device.show()
示例2: wrap
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例3: tabs
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例4: fonts
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例5: test
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例6: inverse
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例7: scroll
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例8: rjust
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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()
示例9: setup
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [as 别名]
def setup():
device.fill(0)
Writer.set_textpos(0,0)
示例10: callback
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import set_textpos [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)