int main(void) {
	// Create IP connection
	IPConnection ipcon;
	ipcon_create(&ipcon);

	// Create device object
	LCD20x4 lcd;
	lcd_20x4_create(&lcd, UID, &ipcon);

	// Connect to brickd
	if(ipcon_connect(&ipcon, HOST, PORT) < 0) {
		fprintf(stderr, "Could not connect\n");
		return 1;
	}
	// Don't use device before ipcon is connected

	// Turn backlight on
	lcd_20x4_backlight_on(&lcd);

	// Write "Hello World"
	lcd_20x4_write_line(&lcd, 0, 0, "Hello World");

	printf("Press key to exit\n");
	getchar();
	lcd_20x4_destroy(&lcd);
	ipcon_destroy(&ipcon); // Calls ipcon_disconnect internally
	return 0;
}
示例#2
0
static int tinker_lcd20x4_backlight_on(lua_State* L) {
  struct tinker_lcd20x4 *tlcd = luaL_checkudata(L, 1, TINKER_LCD20x4_META);
  lcd_20x4_backlight_on(&tlcd->lcd);
  return 0;
}