Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Hacksaar
Sphinx
Commits
f17468e6
Commit
f17468e6
authored
Mar 08, 2015
by
Ralf
Browse files
testblinker test input pins
parent
11c74940
Changes
2
Hide whitespace changes
Inline
Side-by-side
busfahrer.py
View file @
f17468e6
...
...
@@ -49,16 +49,19 @@ class I2C:
# now we know what to set
self
.
setPins
(
pin
.
addr
,
byte
)
def
getPin
(
self
,
pin
):
def
getPin
s
(
self
,
addr
):
with
self
.
_lock
:
if
not
self
.
_active
:
return
None
# read the current value
byte
=
self
.
_bus
.
read_byte
(
pin
.
addr
)
# now we need to get the bit
mask
=
(
1
<<
pin
.
bit
)
return
bool
(
byte
&
mask
)
return
self
.
_bus
.
read_byte
(
addr
)
def
getPin
(
self
,
pin
):
# read the current value
byte
=
self
.
getPins
(
pin
.
addr
)
if
byte
is
None
:
return
None
# now we need to get the bit
mask
=
(
1
<<
pin
.
bit
)
return
bool
(
byte
&
mask
)
# kate: space-indent off; tab-width 4; indent-width 4;
\ No newline at end of file
testblinker
.py
→
testblinker
100644 → 100755
View file @
f17468e6
#!/usr/bin/python3
from
busfahrer
import
I2C
,
Pin
import
time
b
=
I2C
(
1
)
b
.
setPins
(
0x20
,
0xFF
)
b
.
activate
()
i
=
0
while
True
:
...
...
@@ -11,5 +13,6 @@ while True:
b
.
setPin
(
Pin
(
0x21
,
5
),
(
i
//
2
)
%
2
==
0
)
b
.
setPin
(
Pin
(
0x21
,
6
),
(
i
//
4
)
%
2
==
0
)
b
.
setPin
(
Pin
(
0x21
,
7
),
(
i
//
8
)
%
2
==
0
)
time
.
sleep
(
0.2
)
print
(
"{:08b}"
.
format
(
b
.
getPins
(
0x20
)))
time
.
sleep
(
0.02
)
i
+=
1
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment