Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
duck
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jp7g21
duck
Commits
e8e21420
Commit
e8e21420
authored
3 years ago
by
jp7g21
Browse files
Options
Downloads
Patches
Plain Diff
Wrote duck cli
parent
bb0a39ec
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
duck/Makefile
+12
-0
12 additions, 0 deletions
duck/Makefile
duck/duck.c
+76
-0
76 additions, 0 deletions
duck/duck.c
duck/udev-rule
+1
-0
1 addition, 0 deletions
duck/udev-rule
with
89 additions
and
0 deletions
duck/Makefile
0 → 100644
+
12
−
0
View file @
e8e21420
duck
:
duck.c ../libduck/libduck.so
cc duck.c
-o
duck
-L
../libduck
-l
duck
.PHONY
:
clean install
clean
:
rm
-f
duck
install
:
duck
install
-T
-D
-m
555 duck /usr/lib/duck/duck
&&
\
install
-T
udev-rule /etc/udev/rules.d/80-duck.rules
&&
\
udevadm control
-R
This diff is collapsed.
Click to expand it.
duck/duck.c
0 → 100644
+
76
−
0
View file @
e8e21420
#include
<stdio.h>
#include
<string.h>
#include
<unistd.h>
#include
<err.h>
#include
<stdlib.h>
#include
"../libduck/libduck.h"
#define SHAKE_ANGLE 45
#define SHAKE_T 300
void
shake
(
int
motor
,
int
number
)
{
for
(
int
j
=
0
;
j
<
number
;
j
++
)
{
duck_set_position
(
motor
,
-
SHAKE_ANGLE
);
duck_delay
(
SHAKE_T
);
duck_set_position
(
motor
,
SHAKE_ANGLE
);
duck_delay
(
2
*
SHAKE_T
);
duck_set_position
(
motor
,
0
);
duck_delay
(
SHAKE_T
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
option
;
const
char
*
fname
=
DEFAULT_DUCK_FNAME
;
char
buf
[
100
];
while
((
option
=
getopt
(
argc
,
argv
,
"t:"
))
!=
-
1
)
{
switch
(
option
)
{
case
't'
:
strncpy
(
buf
,
optarg
,
100
);
fname
=
buf
;
break
;
default:
printf
(
"Usage: duck [-t TTYNAME] command
\n
"
);
exit
(
EXIT_FAILURE
);
break
;
}
}
open_duck
(
fname
);
configure_duck
();
for
(
int
i
=
optind
;
argv
[
i
];
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"set"
)
==
0
)
{
if
(
argv
[
i
+
1
]
&&
argv
[
i
+
2
])
{
int
motor
=
atoi
(
argv
[
i
+
1
]);
int
angle
=
atoi
(
argv
[
i
+
2
]);
duck_set_position
(
motor
,
angle
);
i
+=
2
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"vel"
)
==
0
)
{
if
(
argv
[
i
+
1
]
&&
argv
[
i
+
2
])
{
int
motor
=
atoi
(
argv
[
i
+
1
]);
int
deg_per_sec
=
atoi
(
argv
[
i
+
2
]);
duck_set_velocity
(
motor
,
deg_per_sec
);
i
+=
2
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"headshake"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
int
numshakes
=
atoi
(
argv
[
i
+
1
]);
shake
(
MOTOR_1
,
numshakes
);
i
++
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"nod"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
int
numnods
=
atoi
(
argv
[
i
+
1
]);
shake
(
MOTOR_2
,
numnods
);
i
++
;
}
}
}
return
0
;
}
This diff is collapsed.
Click to expand it.
duck/udev-rule
0 → 100644
+
1
−
0
View file @
e8e21420
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="666"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment