Update of /cvsroot/libphidget/libphidget/src/examples
In directory usw-pr-cvs1:/tmp/cvs-serv29451
Modified Files:
servo_example.cc
Log Message:
First example added
Index: servo_example.cc
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/examples/servo_example.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** servo_example.cc 12 Sep 2002 02:02:45 -0000 1.1
--- servo_example.cc 12 Sep 2002 02:06:44 -0000 1.2
***************
*** 1,3 ****
--- 1,5 ----
#include <CPhidgetManager.h>
+ #include <CServo.h>
+ #include <unistd.h>
***************
*** 6,11 ****
static const char *revision="$Revision$";
! /*
* Find the first servo controller we can
*/
--- 8,20 ----
static const char *revision="$Revision$";
+ /**
+ * Releases the phidget manager, makes it look like the program has finished.
+ */
+ void cleanup()
+ {
+ CPhidgetManager::release();
+ }
! /**
* Find the first servo controller we can
*/
***************
*** 21,24 ****
--- 30,52 ----
printf("Servo Controller found: %s\n",servoPhidgetID.asString().c_str());
+
+ cleanup();
+ }
+
+ /**
+ * The easiest way to control a servo
+ */
+ void example1()
+ {
+ // Request servo #0 from the servo controller we previously found
+ CServo servo(CUID(servoPhidgetID.serial(),0));
+
+ // Center it
+ servo.position(.5);
+
+ // Wait for it to move
+ sleep(1);
+
+ cleanup();
}
***************
*** 41,44 ****
--- 69,74 ----
findUsableServoPhidget();
+
+ example1();
}
catch(const exception &e)
|