using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Tinkerforge; namespace WindowsFormsApplication1 { class Program { private static string HOST = "localhost"; private static int PORT = 4223; private static string UID = "8Ad"; private static string UID2 = "9r7"; private static string UID3 = "9so"; private delegate void SetPosDel(double val); private SetPosDel SetValues; void PositionCB(short val) { try { object[] p = { (val / 100.0) }; this.Invoke(SetValues, p); } catch { } } private void Invoke(SetPosDel SetValues, object[] p) { throw new NotImplementedException(); } private void InvokeSetter(double val) { DateTime now = DateTime.Now; txt_log.Text = "Temperatur um " + now.ToString("yyyy-MM-dd HH:mm:ss:ff") + ": " + val.ToString("0#.##") + "°C" + Environment.NewLine + txt_log.Text; txt_ExcelLog.Text += now.ToString("HH:mm:ss") + "\t" + val + Environment.NewLine; } static void Main() { Tinkerforge.IPConnection ipcon = new Tinkerforge.IPConnection(HOST, PORT); Tinkerforge.BrickletRotaryPoti poti = new Tinkerforge.BrickletRotaryPoti(UID); Tinkerforge.BrickletLCD20x4 lcd = new Tinkerforge.BrickletLCD20x4(UID2); Tinkerforge.BrickletDistanceIR dir = new Tinkerforge.BrickletDistanceIR(UID3); ipcon.AddDevice(dir); ipcon.AddDevice(lcd); ipcon.AddDevice(poti); poti.RegisterCallback(new BrickletRotaryPoti.Position(PositionCB)); SetValues = new SetPosDel(InvokeSetter); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); lcd.BacklightOff(); ipcon.Destroy(); } } }