//Display the properties of the attached phidget to the screen. We will be displaying the name, serial number and version of the attached device. int display_properties(CPhidgetTextLCDHandle phid) { int serialNo, version, numRows, numColumns, backlight, cursor, contrast, cursor_blink, numScreens; const char* ptr; CPhidget_DeviceID id; CPhidget_getDeviceType((CPhidgetHandle)phid, &ptr); CPhidget_getSerialNumber((CPhidgetHandle)phid, &serialNo); CPhidget_getDeviceVersion((CPhidgetHandle)phid, &version); CPhidget_getDeviceID((CPhidgetHandle)phid, &id); CPhidgetTextLCD_getRowCount (phid, &numRows); CPhidgetTextLCD_getColumnCount (phid, &numColumns); CPhidgetTextLCD_getBacklight (phid, &backlight); CPhidgetTextLCD_getContrast (phid, &contrast); CPhidgetTextLCD_getCursorOn (phid, &cursor); CPhidgetTextLCD_getCursorBlink (phid, &cursor_blink); printf("%s\n", ptr); printf("Serial Number: %10d\nVersion: %8d\n", serialNo, version); if(id == PHIDID_TEXTLCD_ADAPTER){ CPhidgetTextLCD_getScreenCount (phid, &numScreens); printf("# Screens: %d\n", numScreens); CPhidgetTextLCD_setScreen(phid, 0); CPhidgetTextLCD_setScreenSize(phid, PHIDGET_TEXTLCD_SCREEN_2x16); CPhidgetTextLCD_initialize(phid); } printf("# Rows: %d\n# Columns: %d\n", numRows, numColumns); printf("Current Contrast Level: %d\nBacklight Status: %d\n", contrast, backlight); printf("Cursor Status: %d\nCursor Blink Status: %d\n", cursor, cursor_blink); return 0; }
JNIEXPORT jint JNICALL Java_com_phidgets_Phidget_getDeviceID(JNIEnv *env, jobject obj) { CPhidgetHandle h = (CPhidgetHandle)(uintptr_t)(*env)->GetLongField(env, obj, handle_fid); int error; CPhidget_DeviceID id; if ((error = CPhidget_getDeviceID(h, &id))) PH_THROW(error); return (int)id; }
int AttachHandler(CPhidgetHandle phid, void *userPtr) { int serialNo; const char *name; CPhidget_DeviceID id; CPhidget_DeviceClass cls; CPhidget_getDeviceName (phid, &name); CPhidget_getSerialNumber(phid, &serialNo); CPhidget_getDeviceClass(phid, &cls); CPhidget_getDeviceID(phid, &id); printf("%s %10d attached! (%d, %d) \n", name, serialNo, cls, id); display_devices((CPhidgetManagerHandle)userPtr); return 0; }
int CCONV AttachHandler(CPhidgetHandle ENC, void *userptr) { int serialNo; CPhidget_DeviceID deviceID; int i, inputcount; CPhidget_getSerialNumber(ENC, &serialNo); //Retrieve the device ID and number of encoders so that we can set the enables if needed CPhidget_getDeviceID(ENC, &deviceID); CPhidgetEncoder_getEncoderCount((CPhidgetEncoderHandle)ENC, &inputcount); printf("Encoder %10d attached! \n", serialNo); //the 1047 requires enabling of the encoder inputs, so enable them if this is a 1047 if (deviceID == PHIDID_ENCODER_HS_4ENCODER_4INPUT) { printf("Encoder requires Enable. Enabling inputs....\n"); for (i = 0 ; i < inputcount ; i++) CPhidgetEncoder_setEnabled((CPhidgetEncoderHandle)ENC, i, 1); } return 0; }