int main(int argc, char* argv[])
{
	int res;
	int i;

	// Initialize the hidapi library
	printf("Starting to initialize HID library...\n");
	res = hid_init();
	printf("Initialized HID library.\n");

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	printf("Trying to open device...\n");
	handle = hid_open(0x04d8, 0x003f, NULL);
	if(handle != NULL) {
		printf("Opened device successfully.\n");
	} else {
		printf("Could not open device.\n");
		exit(EXIT_FAILURE);
	}
	read_device_info();

	toggle_led1();

	printf("Button is %spressed.\n", get_push1_state() ? "" : "not ");

	printf("The decimal result is %d\n", get_pot1_val());

	// Register signal handler
	if (signal(SIGINT, sig_handler) == SIG_ERR) {
        printf("\nCan't catch SIGINT\n");
        exit(EXIT_FAILURE);
	}

	// Enter ncurses mode
	initialize_display();

	// Main loop
	while(1) {
		int a;
		a = (int)((100 / 1023.0) * get_pot1_val()); 
		print_percent_bar(2, a);
		refresh();
		sleep(0.1);
	}

	// Leave ncurses mode
	end_display();

	// Unregister signal handler
	signal(SIGINT, SIG_DFL);

	// Finalize the hidapi library
	res = hid_exit();

	return 0;
}
int main()
{
	//set LCD_PORT to OUTPUT and then ...
	DDRB = 0xFF;	

	//.. do fancy stuff with the lcd
	initialize_display();
		
	set_cursor(0, 0);
	write_string("Hello World!");
	
	set_cursor(1,0);
	write_string("Code written by:");
	
	set_cursor(2,0);
	write_string("Dave the Brave");
		
	while(1)
	{
		asm volatile ("nop");	//do nothing (in a very explicit way)
	}

	return 0;
}