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
06e86402
Commit
06e86402
authored
Jul 15, 2020
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple python app to control machine.
parent
4e35ae4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
14 deletions
+39
-14
examples/lime2-mod-io-relay-on_off.py
examples/lime2-mod-io-relay-on_off.py
+39
-14
No files found.
examples/lime2-mod-io-relay-on_off.py
View file @
06e86402
...
...
@@ -79,20 +79,45 @@ III. Integration with Nexedi's toolset for Wendelin
from
pyA20Lime2
import
i2c
import
time
i2c
.
init
(
"/dev/i2c-1"
)
i2c
.
open
(
0x58
)
# switch ON RELAY1
i2c
.
write
([
0x10
,
0x0F
])
for
i
in
range
(
0
,
30
*
60
*
24
):
# switch OFF RELAY1
i2c
.
write
([
0x10
,
0x00
])
time
.
sleep
(
2
)
# switch ON RELAY1
i2c
.
write
([
0x10
,
0x0F
])
time
.
sleep
(
1
)
RELAY_MAP
=
{
0
:
0x00
,
1
:
0x01
,
2
:
0x32
,
3
:
0x64
,
4
:
0x128
}
motor_on
=
False
valve_on
=
False
# init I2C
i2c
.
init
(
"/dev/i2c-1"
)
i2c
.
open
(
0x58
)
# stop al
i2c
.
write
([
0x10
,
0x00
])
while
1
:
command
=
input
(
"Enter 1 to start motor and 2 to toggle (on/off) air valve. Enter 'q' to quit: "
)
if
command
==
"q"
:
break
try
:
command
=
int
(
command
)
except
:
print
(
"Invalid input"
)
if
command
==
1
:
# startmotor relay
i2c
.
write
([
0x10
,
0x0001
])
elif
command
==
2
:
# toggle air valve relay
if
valve_on
:
i2c
.
write
([
0x10
,
0x01
])
valve_on
=
False
else
:
i2c
.
write
([
0x10
,
0x03
])
valve_on
=
True
# stop all
i2c
.
write
([
0x10
,
0x00
])
print
(
"Bye!"
)
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