Commit cd5086cc authored by jp7g21's avatar jp7g21
Browse files

stuff

parent 7713ca81
......@@ -5,9 +5,9 @@ res=$?
if [ $res != 0 ]
then
/usr/lib/duck/duck headshake 3
/usr/lib/duck/duck headshake 4
else
/usr/lib/duck/duck nod 1
/usr/lib/duck/duck nod 2
fi
exit $res
......
......@@ -27,17 +27,22 @@ void shake(int motor, int number, int min, int max, int delay)
duck_delay(delay2);
}
int read_mode = 0;
int main(int argc, char **argv)
{
int option;
const char *fname = DEFAULT_DUCK_FNAME;
char buf[100];
while ((option=getopt(argc, argv, "t:d")) != -1) {
while ((option=getopt(argc, argv, "+t:dr")) != -1) {
switch (option) {
case 'd':
duck_debug_mode = 1;
break;
case 'r':
read_mode = 1;
break;
case 't':
strncpy(buf, optarg, 100);
fname = buf;
......@@ -61,11 +66,12 @@ int main(int argc, char **argv)
i += 2;
}
} else if (strcmp(argv[i], "vel") == 0) {
if (argv[i+1] && argv[i+2]) {
if (argv[i+1] && argv[i+2] && argv[i+3]) {
int motor = atoi(argv[i+1]);
int deg_per_sec = atoi(argv[i+2]);
duck_set_velocity(motor, deg_per_sec);
i += 2;
int ms = atoi(argv[i+3]);
duck_set_velocity(motor, deg_per_sec, ms);
i += 3;
}
} else if (strcmp(argv[i], "headshake") == 0) {
if (argv[i+1]) {
......@@ -87,6 +93,11 @@ int main(int argc, char **argv)
}
}
}
if (read_mode) {
while (1) {
char c;
if (read(duckfd, &c, 1) != 1) err(
close_duck();
return 0;
}
......@@ -80,11 +80,12 @@ int duck_delay(int ms)
return duck_printf("d %d\n", ms);
}
int duck_set_velocity(int motor, int deg_per_sec)
/* Final position will be (deg_per_sec * ms / 1000), rounded down to nearest degree */
int duck_set_velocity(int motor, int deg_per_sec, int ms)
{
if (!validate_motor(motor)) return -1;
if (abs(deg_per_sec) > 1000) return -1;
return duck_printf("v %d %d\n", motor, deg_per_sec);
return duck_printf("v %d %d %d\n", motor, deg_per_sec, ms);
}
void close_duck(void)
......
......@@ -15,7 +15,7 @@ void open_duck(const char *fname);
void configure_duck(void);
int duck_set_position(int motor, int angle);
int duck_delay(int ms);
int duck_set_velocity(int motor, int deg_per_sec);
int duck_set_velocity(int motor, int deg_per_sec, int ms);
void close_duck(void);
#endif /* _LIBDUCK_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment