[Libphidget-cvs-commits] CVS: libphidget/src/examples phidget_c.c,1.19,1.20
Status: Alpha
Brought to you by:
jstrohm
|
From: Jack S. <js...@us...> - 2003-06-23 22:37:37
|
Update of /cvsroot/libphidget/libphidget/src/examples
In directory sc8-pr-cvs1:/tmp/cvs-serv24449/src/examples
Modified Files:
phidget_c.c
Log Message:
Added support for the Power phidget along with initial support for the AdvancedServo soft phidget. Currently regular phidgets don't work though.
Index: phidget_c.c
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/examples/phidget_c.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** phidget_c.c 23 Dec 2002 04:38:39 -0000 1.19
--- phidget_c.c 23 Jun 2003 22:37:34 -0000 1.20
***************
*** 28,31 ****
--- 28,32 ----
int IK880=0;
int TEXTLCD=0;
+ int POWER=0;
// Initialize libphiget, here is where the devices are actually retrieved by the library
***************
*** 58,62 ****
printf("Phidget Name ID ID Serial#\n");
printf("-------------------------------- ------ ------- -------\n");
! printf ("%32s 0x0%x 0x0%x %06d\n",
phidgetTypeName (phidgetType (dev)),
phidgetTypeVendorID (phidgetType (dev)),
--- 59,63 ----
printf("Phidget Name ID ID Serial#\n");
printf("-------------------------------- ------ ------- -------\n");
! printf ("%32s 0x0%x 0x0%x %06d\n",
phidgetTypeName (phidgetType (dev)),
phidgetTypeVendorID (phidgetType (dev)),
***************
*** 72,75 ****
--- 73,77 ----
printf(" IKDIGITALWRITE - write data to the 488 or 880 interface kit\n");
printf(" TEXTLCD - test text lcd\n");
+ printf(" POWER - test power phidget\n");
***************
*** 90,93 ****
--- 92,96 ----
if (strcmp(argv[1],"IKDIGITALWRITE")==0) IKDIGITALWRITE=1;
if (strcmp(argv[1],"TEXTLCD")==0) TEXTLCD=1;
+ if (strcmp(argv[1],"POWER")==0) POWER=1;
}
***************
*** 97,100 ****
--- 100,104 ----
unsigned char buffer[6];
float k;
+
struct phidget *dev = phidgetOpen (phidgets[t]); // Open the phidget #t
***************
*** 135,139 ****
if (
(SERVO1 && phidgetTypeDeviceClass (phidgetType (dev)) == LP_UNI_SERVO) ||
! (SERVO4 && phidgetTypeDeviceClass (phidgetType (dev)) == LP_QUAD_SERVO)
)
{
--- 139,144 ----
if (
(SERVO1 && phidgetTypeDeviceClass (phidgetType (dev)) == LP_UNI_SERVO) ||
! (SERVO4 && phidgetTypeDeviceClass (phidgetType (dev)) == LP_QUAD_SERVO) ||
! (SERVO8 && phidgetTypeDeviceClass (phidgetType (dev)) == LP_8WAY_SERVO)
)
{
***************
*** 159,163 ****
{
printf("error - %s\n",phidgetErrorString(phidgetLastError()));
! return(5);
}
}
--- 164,178 ----
{
printf("error - %s\n",phidgetErrorString(phidgetLastError()));
! return(6);
! }
! }
!
! if (SERVO8)
! {
! for (i=0;i<8;i++)
! if (phidget8Servo (dev, i,k,.1,.1)<0)
! {
! printf("error - %s\n",phidgetErrorString(phidgetLastError()));
! return(7);
}
}
***************
*** 263,266 ****
--- 278,296 ----
}
}
+ if (POWER)
+ if (phidgetTypeDeviceClass (phidgetType (dev)) == LP_POWER)
+ {
+ char temp[1024];
+ phidgetPower(dev,0,1,0);
+ phidgetPower(dev,1,50000,50000);
+
+ printf("Setting power phidget at holding, press enter to turn off\n");
+ getchar();
+
+ phidgetPower(dev,0,0,1);
+ phidgetPower(dev,1,0,1);
+ }
+ else
+ printf("Not a power phidget\n");
// Close the phidget
***************
*** 268,272 ****
{
printf("error - %s\n",phidgetErrorString(phidgetLastError()));
! return(6);
}
--- 298,302 ----
{
printf("error - %s\n",phidgetErrorString(phidgetLastError()));
! return(8);
}
|