Yoctopuce Yocto-MaxiDisplay Mode D'emploi page 53

Module électronique
Table des Matières

Publicité

import os,
sys
from
yocto_api
import
from
yocto_display
def
usage():
scriptname
= os.path.basename(sys.argv[0])
print("Usage:")
print(scriptname +
print(scriptname +
print(scriptname +
sys.exit()
def
die(msg):
sys.exit(msg +
errmsg
= YRefParam()
if len(sys.argv) <
usage()
target
= sys.argv[1]
# Setup the API to use local USB devices
if YAPI.RegisterHub("usb", errmsg) !=
sys.exit("init error"
if
target
==
'any':
# retreive any RGB led
disp
= YDisplay.FirstDisplay()
if
disp
is
None:
die('No module
else:
disp
=
YDisplay.FindDisplay(target +
if not
disp.isOnline():
die("Module not connected
# display clean up
disp.resetAll()
# retreive the display size
w
= disp.get_displayWidth()
h
= disp.get_displayHeight()
# retreive the first layer
l0
= disp.get_displayLayer(0)
l0.clear()
# display a text in the middle of the screen
l0.drawText(w /
2,
# visualize each corner
l0.moveTo(0, 5)
l0.lineTo(0, 0)
l0.lineTo(5, 0)
l0.moveTo(0,
h -
6)
l0.lineTo(0,
h -
1)
l0.lineTo(5,
h -
1)
l0.moveTo(w -
1,
h -
l0.lineTo(w -
1,
h -
l0.lineTo(w -
6,
h -
l0.moveTo(w -
1, 5)
l0.lineTo(w -
1, 0)
l0.lineTo(w -
6, 0)
# draw a circle in the top left corner of layer 1
l1
= disp.get_displayLayer(1)
l1.clear()
l1.drawCircle(h /
# and animate the layer
print("Use Ctrl-C to
x
=
0
y
=
0
www.yoctopuce.com
*
import
*
'
<serial_number>')
'
<logical_name>')
' any
')
' (check USB
cable)')
2:
YAPI.SUCCESS:
+
errmsg.value)
connected')
")
h /
2, YDisplayLayer.ALIGN.CENTER,
6)
1)
1)
8,
h /
8,
h /
8)
stop")
9. Utilisation du Yocto-MaxiDisplay en Python
".display")
"Hello
world!")
47

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Yocto-displayYocto-color-v2

Table des Matières