[Libphidget-cvs-commits] CVS: libphidget/src/examples Makefile.am,1.3,1.4 phidget_cpp.cc,1.12,1.13
Status: Alpha
Brought to you by:
jstrohm
|
From: Jack S. <js...@us...> - 2002-12-17 03:10:14
|
Update of /cvsroot/libphidget/libphidget/src/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv29565/examples
Modified Files:
Makefile.am phidget_cpp.cc
Log Message:
Bug fixes and code modifications to support the new example ik2lcd. Also the start of the rebuild of the device query system in phidget++
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/examples/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.am 16 Dec 2002 22:37:08 -0000 1.3
--- Makefile.am 17 Dec 2002 03:10:10 -0000 1.4
***************
*** 1,3 ****
! bin_PROGRAMS = phidget_c phidget_cpp servo_example ik_example
phidget_c_SOURCES = phidget_c.c
--- 1,3 ----
! bin_PROGRAMS = phidget_c phidget_cpp servo_example ik_example ik2lcd
phidget_c_SOURCES = phidget_c.c
***************
*** 17,20 ****
--- 17,24 ----
ik_example_LDADD = ../libphidget/libphidget.la ../phidget++/libphidget++.la
ik_example_DEPENDENCIES = ../libphidget/libphidget.la ../phidget++/libphidget++.la
+
+ ik2lcd_SOURCES = ik2lcd.cc
+ ik2lcd_LDADD = ../libphidget/libphidget.la ../phidget++/libphidget++.la
+ ik2lcd_DEPENDENCIES = ../libphidget/libphidget.la ../phidget++/libphidget++.la
CFLAGS = -I../libphidget -L../libphidget
Index: phidget_cpp.cc
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/examples/phidget_cpp.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** phidget_cpp.cc 16 Dec 2002 04:54:56 -0000 1.12
--- phidget_cpp.cc 17 Dec 2002 03:10:10 -0000 1.13
***************
*** 24,205 ****
static const char *revision="$Revision$";
- /*
- class CMyServoController : public CServoController
- {
- public:
- CMyServoController(const CUID &uid) :
- CServoController(uid)
- {
- printf("Initializing My Servo Controller\n");
- }
- ~CMyServoController()
- {
- printf("Destroying My Servo Controller\n");
- }
- void onAttach()
- {
- printf("My Servo Controller: Attach\n");
- }
- void onDetach()
- {
- printf("My Servo Controller: Detach\n");
- }
- };
-
- class CMyServo : public CServo
- {
- public:
- CMyServo(const CUID &uid) :
- CServo(uid)
- {
- printf("Construction of my servo class.\n");
- }
- ~CMyServo()
- {
- printf("Destruction of my servo class.\n");
- }
- void position(float f)
- {
- CServo::position(f);
- printf("Rotating servo to %f\n",f);
- }
- };
-
-
- // Discovery of available phidgets, creation of phidget objects, and discovery of all devices afterwards.
- void example1()
- {
- printf("example 1 - Discovery of phidgets\n");
-
- {
- // See what the system has available
- CPhidgetManager *manager=CPhidgetManager::getInstance();
- CPhidgetManager::getInstance()->checkForEvents();
-
- // This queries for any devices that are phidgets
- vector< CUID > devices=manager->query(LP_ALL);
- printf("All:%d\n",devices.size());
- CPhidgetManager::getInstance()->checkForEvents();
-
- // Print out how many we found
- devices=manager->query(LP_PHIDGET);
- printf("Phidgets:%d\n",devices.size());
- CPhidgetManager::getInstance()->checkForEvents();
-
- // Get the phidgets, this forces the manager to create them
- // since they haven't already been created by the user.
- for (int t=0;t<devices.size();t++)
- {
- CPhidget *phidg=dynamic_cast<CPhidget *>(manager->find(devices[t],true));
- }
- CPhidgetManager::getInstance()->checkForEvents();
-
- // Now let's see how many devices are available
- devices=manager->query(LP_ALL);
- printf("All:%d\n",devices.size());
- CPhidgetManager::getInstance()->checkForEvents();
- }
-
- // This makes the next example run like it's the first.
- CPhidgetManager::release();
- printf("Done\n");
- }
-
-
- // Just attacheding to a servo, don't have to worry about anything else
- void example2()
- {
- printf("example 2 - Manipulating a servo\n");
-
- {
- // Create a servo
- CServo servo(CUID(741,0));
-
- servo.position(.5);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- }
-
- // This makes the next example run like it's the first.
- CPhidgetManager::release();
- printf("Done\n");
- }
-
- void example3()
- {
-
- printf("example 3 - Custom servo device\n");
-
- {
- // Create a servo
- CMyServo servo(CUID(741,0));
-
- servo.position(.2);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.5);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.8);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- }
-
- // This makes the next example run like it's the first.
- CPhidgetManager::release();
- printf("Done\n");
-
- }
-
- void example4()
- {
- printf("example 4 - Custom servo device\n");
-
- {
- CMyServoController controller(CUID(741));
- CServo servo(CUID(741,0));
-
- servo.position(.2);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.5);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.8);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- }
-
- // This makes the next example run like it's the first.
- CPhidgetManager::release();
- printf("Done\n");
- }
-
- void example5()
- {
- printf("example 5 - Custom servo device\n");
-
- {
- CMyServoController controller(CUID(741));
- CMyServo servo(CUID(741,0));
-
- servo.position(.2);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.5);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- servo.position(.8);
- sleep(1);
- CPhidgetManager::getInstance()->checkForEvents();
- }
-
- // This makes the next example run like it's the first.
- CPhidgetManager::release();
- printf("Done\n");
- }
-
- */
-
void phidgets_ls()
{
--- 24,27 ----
|