Thread: [Libphidget-cvs-commits] CVS: libphidget/src/libphidget phidget.c,1.17,1.18 phidget.h,1.12,1.13
Status: Alpha
Brought to you by:
jstrohm
From: Jack S. <js...@us...> - 2002-12-14 04:34:40
|
Update of /cvsroot/libphidget/libphidget/src/libphidget In directory sc8-pr-cvs1:/tmp/cvs-serv6412/libphidget Modified Files: phidget.c phidget.h Log Message: Initial support for the Text LCD phidget. Made the C example program work with all supported phidgets. Index: phidget.c =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** phidget.c 13 Dec 2002 22:57:23 -0000 1.17 --- phidget.c 14 Dec 2002 04:34:35 -0000 1.18 *************** *** 552,556 **** DBG("_addDevice"); ! printf(" Called %s\n",ptd->name); temp->type = ptd; --- 552,556 ---- DBG("_addDevice"); ! //printf(" Called %s\n",ptd->name); temp->type = ptd; *************** *** 794,798 **** if (wasFound==0) { ! printf("Bus:0x0%x Dev:0x0%x\n",bus,dev); /* if (_isSoftPhidget(pdt)) --- 794,798 ---- if (wasFound==0) { ! //printf("Bus:0x0%x Dev:0x0%x\n",bus,dev); /* if (_isSoftPhidget(pdt)) *************** *** 804,808 **** serial=_getSerial(dev,pdt); ! printf(" Serial:%d\n",serial); // have we seen this phidget before --- 804,808 ---- serial=_getSerial(dev,pdt); ! //printf(" Serial:%d\n",serial); // have we seen this phidget before *************** *** 904,907 **** --- 904,909 ---- _registerDeviceType("Interface Kit 4/8/8", 0x06C2, 0x0040, LP_INTERFACE_KIT_488); _registerDeviceType("Interface Kit 8/8/0", 0x06C2, 0x0041, LP_INTERFACE_KIT_880); + _registerDeviceType("Phidget LCD", 0x06C2, 0x0041, LP_INTERFACE_KIT_880); + _registerDeviceType("PhidgetTextLCD ECMA1010 Ver 1.0", 0x06C2, 0x0050,LP_TEXT_LCD); //_registerDeviceType("RFID VID/PID", 0x06C2, 0x0030, LP_OTHER); //_registerDeviceType("8-AdvancedServo", 0x06C2, 0x003B, LP_SERVO_CONTROLLER); *************** *** 912,916 **** //_registerDeviceType("PhidgetEncoder Ver 1.0", 0x06C2, 0x004B, LP_OTHER); //_registerDeviceType("PhidgetPower Ver 1.01", 0x06C2, 0x004E, LP_OTHER); - //_registerDeviceType("PhidgetTextLCD ECMA1010 Ver 1.0", 0x06C2, 0x0050, LP_OTHER); //_registerDeviceType("PhidgetGraphicLCD Ver 1.0", 0x06C2, 0x0058, LP_OTHER); //_registerDeviceType("SoftPhidget", 0x06C2, 0x0060, LP_OTHER); --- 914,917 ---- *************** *** 1448,1451 **** --- 1449,1588 ---- analog[0]=((unsigned char)buffer[6]+((unsigned char)buffer[5] & 0xf0) * 16); } + } + + return (_error(LPE_NONE)); + } + + /** + * Helper function to send data to a Text LCD + */ + #include <stdio.h> + enum ELPError phidgetTextLCDWrite(struct phidget *phidgetDevice, int row, int col, const char *str) + { + { + int t,i,j, len, buf_ptr; + unsigned char form_buffer[30]; + unsigned char buffer[10];//={0,0,0,0,0,0,0,0,0,0}; + + /* 0000 - 0 + * 0001 - 1 + * 0010 - 2 + * 0011 - 3 + * 0100 - 4 + * 0101 - 5 + * 0110 - 6 + * 0111 - 7 + * 1000 - 8 + * 1001 - 9 + * 1010 - A + * 1011 - B + * 1100 - C + * 1101 - D + * 1110 - E + * 1111 - F + */ + + { + // Initialize command mode + buffer[0] = 0x69; // 0: 0 1 1 0 1 0 0 1 <- System Set, 4 lines, Use CGRAM + buffer[1] = 0x31; // 0: 0 0 1 1 0 0 0 1 <- Display ON/OFF, Display ON + buffer[2] = 0x42;//66; // 0: 0 1 0 0 0 0 1 0 <- Power Save, Oscillator Circuit ON + buffer[3] = 0x57;//87; // 0: 0 1 0 1 0 1 1 1 <- RAM Address set to 010111 (23) + buffer[4] = 0xB0; // Set the address pointer + buffer[5] = 0x30 + (row - 1) * 0x10 + 0x80+col; + buffer[6] = 0; // testing + buffer[7] = 8; // testing - this makes it work, not sure why + buffer[8] = 5; + phidgetWrite(phidgetDevice,buffer,9); + + // Seems to be needed to flush data + //for (i=0;i<10;i++) buffer[i]=0; + buffer[0]=0x02; + buffer[1]=str[0]; + buffer[2]=str[1]; + buffer[3]=str[2]; + buffer[4]=str[3]; + buffer[5]=str[4]; + + //buffer[6]='5'; + //buffer[7]='1'; + + buffer[6]=1; // go back into command mode + buffer[7]=8; // this works but not sure why + + buffer[8]=6; + phidgetWrite(phidgetDevice,buffer,9); + + for (i=0;i<10;i++) buffer[i]=0; + buffer[0]=0x01; + buffer[8]=1; + phidgetWrite(phidgetDevice,buffer,9); + + } + + /* + { + // Initialize command mode + buffer[0] = 0; // buffer[0] is a windows thing + buffer[1] = 0x69; // 0: 0 1 1 0 1 0 0 1 <- System Set, 4 lines, Use CGRAM + buffer[2] = 0x31; // 0: 0 0 1 1 0 0 0 1 <- Display ON/OFF, Display ON + buffer[3] = 0x42;//66; // 0: 0 1 0 0 0 0 1 0 <- Power Save, Oscillator Circuit ON + buffer[4] = 0x57;//87; // 0: 0 1 0 1 0 1 1 1 <- RAM Address set to 010111 (23) + buffer[5] = 0xB0; // Set the address pointer + + buffer[8] = 0x05; + + phidgetWrite(phidgetDevice,buffer,9); + + //buffer[0]=0x02; + //buffer[8]=1; + //phidgetWrite(phidgetDevice,buffer,9); + } + */ + + /* + printf("1\n");fflush(stdout); + len=strlen(str)/2; + + // Always + buffer[0] = 0; + + // Set the address 0 0 1 1 0 0 0 0 + form_buffer[0] = 0x30 + (row - 1) * 0x10 + 0x80; + + // Switch to data mode + form_buffer[1] = 0x02; + buf_ptr = 2; + for (i = 0; i<len; i++) + { + form_buffer[buf_ptr++] = (unsigned char)str[i]; + } + for (i = 0; i < (12 - len); i++) + { + form_buffer[buf_ptr++] = 0x20; + } + // Back into command mode + form_buffer[buf_ptr++] = 0x01; + + printf("2\n");fflush(stdout); + for (i = 0; i<buf_ptr; i+=7) + { + printf(">> %d of %d\n",i,buf_ptr); + if ((buf_ptr - i) > 7) + len = 7; + else + len = (buf_ptr - i); + + for (j = 0; j < len; j++) + buffer[j + 1] = form_buffer[i + j]; + + buffer[8] = len; + + phidgetWrite(phidgetDevice, buffer, 9); + + } + + printf("3\n");fflush(stdout); + */ } Index: phidget.h =================================================================== RCS file: /cvsroot/libphidget/libphidget/src/libphidget/phidget.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** phidget.h 13 Dec 2002 22:53:56 -0000 1.12 --- phidget.h 14 Dec 2002 04:34:36 -0000 1.13 *************** *** 71,75 **** LP_RFID = 600, /**< Currently unsupported */ LP_LED = 700, /**< Currently unsupported */ ! LP_TEXTLCD = 800, /**< Currently unsupported */ // Phidget devices, a phidget device is something a phidget controls --- 71,75 ---- LP_RFID = 600, /**< Currently unsupported */ LP_LED = 700, /**< Currently unsupported */ ! LP_TEXT_LCD = 800, /**< Currently unsupported */ // Phidget devices, a phidget device is something a phidget controls *************** *** 214,217 **** --- 214,218 ---- enum ELPError phidgetInterfaceKit488(struct phidget *phidgetDevice, float analog[4], int digital[8]); enum ELPError phidgetInterfaceKit880(struct phidget *phidgetDevice, float analog[8], int digital[8]); + enum ELPError phidgetTextLCDWrite(struct phidget *phidgetDevice, int row, int col, const char *str); /** |