forked from in4lio/ev3dev-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.py
39 lines (31 loc) · 936 Bytes
/
io.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
import sys
from ev3dev import *
if ev3_init() < 1: sys.exit( 1 )
ok, ls = ev3_listdir( '/sys/class/leds', 256 )
if ok:
print 'leds folder:', ls
else:
print 'ERROR: ev3_listdir( leds )'
ok, state = ev3_read_int( '/sys/class/leds/ev3:left:red:ev3dev/brightness' )
if ok:
if not ev3_write_int( '/sys/class/leds/ev3:left:red:ev3dev/brightness', 0 if state else 255 ):
print 'ERROR: ev3_write_int( brightness )'
else:
print 'ERROR: ev3_read_int( brightness )'
ok, ls = ev3_listdir( '/sys/class/lego-port', 256 )
if ok:
print 'lego-port folder:', ls
else:
print 'ERROR: ev3_listdir( lego-port )'
ok, ls = ev3_listdir( '/sys/class/lego-sensor', 256 )
if ok:
print 'lego-sensor folder:', ls
else:
print 'ERROR: ev3_listdir( lego-sensor )'
ok, ls = ev3_listdir( '/sys/class/tacho-motor', 256 )
if ok:
print 'tacho-motor folder:', ls
else:
print 'ERROR: ev3_listdir( tacho-motor )'
ev3_uninit()