git-svn-id: http://moon:8086/svn/software/trunk/projects/opencv@356 b431acfa-c32f-4a4a-93f1-934dc6c82436
42 lines
1.4 KiB
Python
Executable File
42 lines
1.4 KiB
Python
Executable File
import time
|
|
import struct
|
|
import math
|
|
import ev3 as ev3
|
|
|
|
addr = '/dev/rfcomm0'
|
|
#addr = "127.0.0.1:5555"
|
|
|
|
if ("__main__" == __name__):
|
|
with ev3.EV3(addr) as brick:
|
|
print ("Connection opened (press 'q' to quit).")
|
|
time.sleep(5)
|
|
data = ev3.system_command.list_files(brick, ev3.KnownPaths.PROJECTS_PATH)
|
|
print (data)
|
|
for i in range(0, 200):
|
|
msg = "Count=" + str(i)
|
|
|
|
print ("Send: " + msg)
|
|
ev3.system_command.write_mailbox(brick, 'Text Message', msg)
|
|
data = struct.pack("f", 100*math.sin(2*math.pi*float(i)/100))
|
|
ev3.system_command.write_mailbox(brick, 'Value', data)
|
|
time.sleep(0.1)
|
|
|
|
cmd = ev3.direct_command.DirectCommand()
|
|
cmd.add_output_speed(ev3.direct_command.OutputPort.PORT_D, 50)
|
|
cmd.add_output_start(ev3.direct_command.OutputPort.PORT_D)
|
|
cmd.add_output_ready(ev3.direct_command.OutputPort.PORT_D)
|
|
cmd.add_timer_wait(1000)
|
|
cmd.add_output_stop(ev3.direct_command.OutputPort.PORT_D, ev3.direct_command.StopType.BRAKE)
|
|
cmd.send(brick)
|
|
|
|
for i in range(0, 2):
|
|
cmd = ev3.direct_command.DirectCommand()
|
|
cmd.add_output_ready(ev3.direct_command.OutputPort.PORT_D)
|
|
cmd.add_output_step_speed(ev3.direct_command.OutputPort.PORT_D, 20, 30, 360, 90, ev3.direct_command.StopType.BRAKE)
|
|
cmd.add_output_ready(ev3.direct_command.OutputPort.PORT_D)
|
|
cmd.add_output_step_speed(ev3.direct_command.OutputPort.PORT_D, -20, 30, 360, 90, ev3.direct_command.StopType.BRAKE)
|
|
cmd.send(brick)
|
|
|
|
time.sleep(5.0)
|
|
|