Exemple #1
0
int Create_Text_LCD()
	/*-----------------
		creation du handler pour le display du kit LCD
		------------------*/
{
	int err2;
	const char *errStr;

	CPhidgetTextLCD_create(&txt_lcd);

	CPhidget_set_OnAttach_Handler((CPhidgetHandle)txt_lcd,
			LCD_AttachHandler, NULL);
	CPhidget_set_OnDetach_Handler((CPhidgetHandle)txt_lcd,
			LCD_DetachHandler, NULL);
	CPhidget_set_OnError_Handler((CPhidgetHandle)txt_lcd,
			LCD_ErrorHandler, NULL);
	//open the TextLCD for device connections
	CPhidget_open((CPhidgetHandle)txt_lcd,lcd_display_number);

	//get the program to wait for an TextLCD device to be attached
	if((err2 = CPhidget_waitForAttachment((CPhidgetHandle)txt_lcd,
					10000)))
	{
		CPhidget_getErrorDescription(err2, &errStr);
		printf("Problem waiting for attachment Texte LCD: %s\n", errStr);
		return 0;
	}
	return 1;
}
Exemple #2
0
LCD::LCD()
{
    txt_lcd = 0;
    brightness = 255;
    contrast = 110;
    backlight = 1;
    
    CPhidgetTextLCD_create(&txt_lcd);
    CPhidget_open((CPhidgetHandle)txt_lcd, -1); //PLEASE COMMENT THIS
    if(CPhidget_waitForAttachment((CPhidgetHandle)txt_lcd, 1000)) {
        std::cout << "Error attaching Phidget Text LCD." << std::endl;
    }
    
    CPhidgetTextLCD_setBacklight(txt_lcd, backlight);
    CPhidgetTextLCD_setContrast(txt_lcd, contrast);
    CPhidgetTextLCD_setBrightness(txt_lcd, brightness);
}
Exemple #3
0
int textlcd_simple()
{
	int result;
	const char *err;

	//Declare an TextLCD handle
	CPhidgetTextLCDHandle txt_lcd = 0;

	//create the TextLCD object
	CPhidgetTextLCD_create(&txt_lcd);

	//Set the handlers to be run when the device is plugged in or opened from software, unplugged or closed from software, or generates an error.
	CPhidget_set_OnAttach_Handler((CPhidgetHandle)txt_lcd, AttachHandler, NULL);
	CPhidget_set_OnDetach_Handler((CPhidgetHandle)txt_lcd, DetachHandler, NULL);
	CPhidget_set_OnError_Handler((CPhidgetHandle)txt_lcd, ErrorHandler, NULL);

	//open the TextLCD for device connections
	CPhidget_open((CPhidgetHandle)txt_lcd, -1);

	//get the program to wait for an TextLCD device to be attached
	printf("Waiting for TextLCD to be attached....\n");
	if((result = CPhidget_waitForAttachment((CPhidgetHandle)txt_lcd, 10000)))
	{
		CPhidget_getErrorDescription(result, &err);
		printf("Problem waiting for attachment: %s\n", err);
		return 0;
	}

	//Display the properties of the attached textlcd device
	display_properties(txt_lcd);

	//read TextLCD event data
	printf("Reading.....\n");

	//Begin simulation of capabilities

	//Step 1: Write a simple message to the first row
	printf("Writing to first row. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setDisplayString (txt_lcd, 0, "Row 1");

	//Step 2: write a simple message to the second row
	printf("Writing to second row. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setDisplayString (txt_lcd, 1, "Row 2");

	//Step 3: turn up, turn down, and set back to default the contrast
	printf("Adjusting contrast up. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setContrast (txt_lcd, 255); //valid range is 0 - 255, default is 0 normal viewable seems to be around 100

	printf("Restoring default contrast. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setContrast (txt_lcd, 110);

	//Step 4: Turn on the cursor
	printf("Turn on cursor. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setCursorOn (txt_lcd, 1);

	//Step 5: turn on the cursor blink
	printf("Turn on cursor blink. Press any key to continue\n");
	getchar();

	CPhidgetTextLCD_setCursorOn (txt_lcd, 0);

	CPhidgetTextLCD_setCursorBlink (txt_lcd, 1);

	//End simulation
	printf("Press any key to end\n");
	getchar();

	CPhidgetTextLCD_setCursorBlink (txt_lcd, 0);
	CPhidgetTextLCD_setDisplayString (txt_lcd, 0, "");
	CPhidgetTextLCD_setDisplayString (txt_lcd, 1, "");

	//since user input has been read, this is a signal to terminate the program so we will close the phidget and delete the object we created
	printf("Closing...\n");
	CPhidget_close((CPhidgetHandle)txt_lcd);
	CPhidget_delete((CPhidgetHandle)txt_lcd);

	//all done, exit
	return 0;
}