[Libphidget-cvs-commits] CVS: libphidget/src/libphidget phidget.c,1.34,1.35
Status: Alpha
Brought to you by:
jstrohm
|
From: Jack S. <js...@us...> - 2003-07-08 02:24:14
|
Update of /cvsroot/libphidget/libphidget/src/libphidget
In directory sc8-pr-cvs1:/tmp/cvs-serv17875/libphidget
Modified Files:
phidget.c
Log Message:
Added some code to support digital output on the 888
Index: phidget.c
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** phidget.c 4 Jul 2003 22:38:46 -0000 1.34
--- phidget.c 8 Jul 2003 02:24:11 -0000 1.35
***************
*** 596,599 ****
--- 596,608 ----
*/
+ // For the 888 let's allocate some space so that we can store it's digital out state
+ if (temp->type->deviceClass == LP_INTERFACE_KIT_888)
+ {
+ temp->extraDataSize = 1;
+ temp->extraData = malloc(temp->extraDataSize);
+ memset(temp->extraData,0,temp->extraDataSize);
+ }
+
+
_usbDeviceList[_phidgetDeviceCount] = temp;
***************
*** 1549,1552 ****
--- 1558,1574 ----
char buffer[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ int ServoPosition=percent*180;
+ int MaxVelocity=maxvelocity*400;
+ int Acceleration=acceleration*2000;
+
+
+ buffer[0] = id;
+ buffer[1] = 0xff;
+ ((int *)(buffer+4))[0] = (int)((ServoPosition + 23) * 8109);
+ ((int *)(buffer+4))[1] = (int)((MaxVelocity / 50) * 8109);
+ ((int *)(buffer+4))[2] = (int)((Acceleration / 2500) * 8109);
+
+ /*
+ // Kinda stopped working
buffer[0]=id; // Which servo to control
***************
*** 1571,1574 ****
--- 1593,1597 ----
// Write the position, this seems to work.
((int *)(buffer+5))[0] = percent*16218;
+ */
***************
*** 1718,1727 ****
char buffer[4];
! // TODO - This doesn't work for the 888 yet, need to rework some internal data structures to get it working.
!
! buffer[0] = index+(value << 3);
buffer[1] = 0;
buffer[2] = 0;
buffer[3] = 0;
return(phidgetWrite(phidgetDevice,buffer,4));
}
--- 1741,1766 ----
char buffer[4];
! // Used by all formats
buffer[1] = 0;
buffer[2] = 0;
buffer[3] = 0;
+
+ if (phidgetDevice->type->deviceClass == LP_INTERFACE_KIT_888)
+ {
+ unsigned char *privateData=(unsigned char *)phidgetDevice->extraData;
+
+ // 888 version, using the extra data buffer
+ if (value)
+ privateData[0] |= 1 << index;
+ else
+ privateData[0] &= ~(1 << index);
+ buffer[0] = privateData[0];
+ }
+ else
+ {
+ // Everyone else
+ buffer[0] = index+(value << 3);
+ }
+
return(phidgetWrite(phidgetDevice,buffer,4));
}
|