summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschodet2004-05-09 21:37:23 +0000
committerschodet2004-05-09 21:37:23 +0000
commitc8229b467e828f0f28c98a8fdca2eadc3a6a148e (patch)
tree682c6112fcb9365906b9e8caf8b4db70deecac97
parent36ead8cdaae97b3bb3647998582d29800b54155f (diff)
Ajout du support servo.
-rw-r--r--2004/i/nono/src/io/io_cmd.cc27
-rw-r--r--2004/i/nono/src/io/io_cmd.h3
-rw-r--r--2004/i/nono/src/io/test_io.cc2
-rw-r--r--2004/i/nono/src/qdai/test_robot.cc3
4 files changed, 30 insertions, 5 deletions
diff --git a/2004/i/nono/src/io/io_cmd.cc b/2004/i/nono/src/io/io_cmd.cc
index d64928f..1177f8b 100644
--- a/2004/i/nono/src/io/io_cmd.cc
+++ b/2004/i/nono/src/io/io_cmd.cc
@@ -24,6 +24,7 @@
// }}}
#include "io_cmd.h"
#include "gpio.h"
+#include "servo.h"
#include <iostream>
#include <cstdlib>
@@ -31,10 +32,12 @@
const char ioHelp[] =
" o <n> <bits> <nb> set des sorties.\n"
" i <n> <nb> get des entrées.\n"
- " d <n> <bits> <nb> dir des entrées/sorties.\n";
+ " d <n> <bits> <nb> dir des entrées/sorties.\n"
+ " m <n> <diff> déplace le servo n de diff.\n"
+ " M <n> <pos> déplace le servo n en pos.\n";
bool
-ioCmd (int argc, char **argv, int &i, Gpio &io)
+ioCmd (int argc, char **argv, int &i, Gpio &io, Servo &servo)
{
int n, bits, nb;
switch (argv[i][0])
@@ -74,6 +77,26 @@ ioCmd (int argc, char **argv, int &i, Gpio &io)
std::dec << ' ' << nb << std::endl;
io.dir (n, bits, nb);
break;
+ case 'm':
+ i++;
+ int diff;
+ if (i >= argc) break;
+ n = atoi (argv[i++]);
+ if (i >= argc) break;
+ diff = atoi (argv[i++]);
+ std::cout << "test: servo move " << n << ' ' << diff << std::endl;
+ servo.move (n, diff);
+ break;
+ case 'M':
+ i++;
+ int pos;
+ if (i >= argc) break;
+ n = atoi (argv[i++]);
+ if (i >= argc) break;
+ pos = atoi (argv[i++]);
+ std::cout << "test: servo moveTo " << n << ' ' << pos << std::endl;
+ servo.moveTo (n, pos);
+ break;
default:
return false;
}
diff --git a/2004/i/nono/src/io/io_cmd.h b/2004/i/nono/src/io/io_cmd.h
index a7d6e8a..b199a9f 100644
--- a/2004/i/nono/src/io/io_cmd.h
+++ b/2004/i/nono/src/io/io_cmd.h
@@ -26,10 +26,11 @@
// }}}
class Gpio;
+class Servo;
extern const char ioHelp[];
bool
-ioCmd (int argc, char **argv, int &i, Gpio &io);
+ioCmd (int argc, char **argv, int &i, Gpio &io, Servo &servo);
#endif // io_cmd_h
diff --git a/2004/i/nono/src/io/test_io.cc b/2004/i/nono/src/io/test_io.cc
index 5af38bf..11c86e8 100644
--- a/2004/i/nono/src/io/test_io.cc
+++ b/2004/i/nono/src/io/test_io.cc
@@ -57,7 +57,7 @@ main (int argc, char **argv)
int i = 1;
while (i < argc)
{
- if (!ioCmd (argc, argv, i, gc))
+ if (!ioCmd (argc, argv, i, gc, gspp))
{
switch (argv[i][0])
{
diff --git a/2004/i/nono/src/qdai/test_robot.cc b/2004/i/nono/src/qdai/test_robot.cc
index 4356a7f..69ed5b8 100644
--- a/2004/i/nono/src/qdai/test_robot.cc
+++ b/2004/i/nono/src/qdai/test_robot.cc
@@ -59,7 +59,8 @@ main (int argc, char **argv)
int i = 1;
while (i < argc)
{
- if (!ioCmd (argc, argv, i, gc) && !motorCmd (argc, argv, i, m))
+ if (!ioCmd (argc, argv, i, gc, gspp)
+ && !motorCmd (argc, argv, i, m))
{
switch (argv[i][0])
{