Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
osie
Commits
9f09b5c2
Commit
9f09b5c2
authored
Jul 15, 2020
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap communication over IC2.
parent
663790fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
examples/lime2-mod-io-relay-on_off.py
examples/lime2-mod-io-relay-on_off.py
+8
-6
No files found.
examples/lime2-mod-io-relay-on_off.py
View file @
9f09b5c2
...
@@ -86,18 +86,20 @@ RELAY_MAP = {0: 0x00,
...
@@ -86,18 +86,20 @@ RELAY_MAP = {0: 0x00,
4
:
0x128
}
4
:
0x128
}
def
sendI2Ccommand
(
code
):
def
sendI2Ccommand
(
code
):
# init I2C
i2c
.
init
(
"/dev/i2c-1"
)
i2c
.
open
(
0x58
)
try
:
try
:
i2c
.
write
([
0x10
,
code
])
i2c
.
write
([
0x10
,
code
])
except
:
except
:
print
(
"Failed co sent command."
)
print
(
"Failed co sent command."
)
i2c
.
close
()
motor_on
=
False
motor_on
=
False
valve_on
=
False
valve_on
=
False
# init I2C
i2c
.
init
(
"/dev/i2c-1"
)
i2c
.
open
(
0x58
)
# stop all
# stop all
sendI2Ccommand
(
0x00
)
sendI2Ccommand
(
0x00
)
...
@@ -113,8 +115,8 @@ while 1:
...
@@ -113,8 +115,8 @@ while 1:
print
(
"Invalid input"
)
print
(
"Invalid input"
)
if
command
==
1
:
if
command
==
1
:
# startmotor relay
# start
motor relay
sendI2Ccommand
(
0x0
00
1
)
sendI2Ccommand
(
0x01
)
elif
command
==
2
:
elif
command
==
2
:
# toggle air valve relay
# toggle air valve relay
...
...
Write
Preview
Markdown
is supported
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