summaryrefslogtreecommitdiff
path: root/2003/i/buzz/src/motor/test_motor.cc
diff options
context:
space:
mode:
Diffstat (limited to '2003/i/buzz/src/motor/test_motor.cc')
-rw-r--r--2003/i/buzz/src/motor/test_motor.cc59
1 files changed, 50 insertions, 9 deletions
diff --git a/2003/i/buzz/src/motor/test_motor.cc b/2003/i/buzz/src/motor/test_motor.cc
index 636d743..b9e5066 100644
--- a/2003/i/buzz/src/motor/test_motor.cc
+++ b/2003/i/buzz/src/motor/test_motor.cc
@@ -4,24 +4,65 @@
//
#include "motor.h"
#include "erreur/erreur.h"
+#include "date/date.h"
#include <iostream>
#include <unistd.h>
+#include <stdlib.h>
int
-main (void)
+main (int argc, char **argv)
{
+ cout << "hello" << endl;
try
{
Motor m;
- m.goDistance (2000);
- while (!m.finnish ()) sleep (1);
- m.turnAngle (180);
- while (!m.finnish ()) sleep (1);
- m.goDistance (2000);
- while (!m.finnish ()) sleep (1);
- m.turnAngle (-180);
- while (!m.finnish ()) sleep (1);
+ cout << "world" << endl;
+ int i = 1;
+ int c;
+ while (i < argc)
+ {
+ switch (argv[i][0])
+ {
+ case 'j':
+ cout << "jack" << endl;
+ i++;
+ m.waitRound ();
+ break;
+ case 'h':
+ i++;
+ cout << "capteurs ";
+ c = m.getCapteurs ();
+ for (int j = 1; j < 0x100; j <<= 1)
+ {
+ cout << (c & j ? '#' : '_') << ' ';
+ }
+ cout << endl;
+ break;
+ case 't':
+ cout << "turn" << endl;
+ i++;
+ if (i >= argc) return 1;
+ m.turnAngle (atoi (argv[i++]));
+ break;
+ case 'z':
+ cout << "rezet" << endl;
+ i++;
+ m.reset ();
+ break;
+ case 'H':
+ i++;
+ if (i >= argc) return 1;
+ cout << "servo " << atoi (argv[i]);
+ m.setServo (atoi (argv[i++]));
+ break;
+ default:
+ cout << "go" << endl;
+ m.goDistance (atoi (argv[i++]));
+ break;
+ }
+ while (!m.finnish ()) Date::wait (50);
+ }
return 0;
}
catch (Erreur &e)