private static void Ads1115(I2cBus i2c) { var ads1115 = new ADS1115(i2c, 0x4A); char keyChar = ' '; do { if (Console.KeyAvailable) { keyChar = Console.ReadKey().KeyChar; } var ch0 = ads1115.ReadAdcSingleEnded(0); Thread.Sleep(10); var ch1 = ads1115.ReadAdcSingleEnded(1); Thread.Sleep(10); var v0 = ads1115.ConvertToVoltage(ch0); var v1 = ads1115.ConvertToVoltage(ch1); Console.WriteLine($"v0 {v0:F3} {ch0} v1 {v1:F3} {ch1}"); Thread.Sleep(300); } while (keyChar != 'x'); }
private static void Roboter(I2cBus i2c) { var pca9685 = new Pca9685.Pca9685(i2c, 0x40, 50); var axis1 = new ServoAxis(0, pca9685, 158, 529); // Savöx var axis2 = new ServoAxis(1, pca9685, 172, 519); // Spektrum var axis3 = new ServoAxis(2, pca9685, 126, 528); // Tower // var axis4 = new ServoAxis(3, pca9685, 150, 650); // var axis5 = new ServoAxis(4, pca9685, 150, 650); // var axis6 = new ServoAxis(5, pca9685, 150, 650); var ads1115 = new ADS1115(i2c, 0x4A); var ctrl = new XInputController(UserIndex.One); if (!ctrl.IsConnected) { Console.WriteLine("No Controller Conected"); Console.ReadKey(); return; } ctrl.StartAutoUpdate(); ctrl.ButtonPressed += axis3.OnButtonPressed; ctrl.Updated += axis1.OnUpdate; char keyChar = ' '; do { if (Console.KeyAvailable) { keyChar = Console.ReadKey().KeyChar; } Console.Clear(); if (ctrl.A) { axis1.MoveAbsolute(ctrl.LeftThumbX); axis2.MoveAbsolute(ctrl.LeftThumbY); } else { var ch0 = ads1115.ReadAdcSingleEnded(0); var ch1 = ads1115.ReadAdcSingleEnded(1); var pot0 = ads1115.Normalize(ch0); var pot1 = ads1115.Normalize(ch1); axis1.MoveAbsolute(pot0); axis2.MoveAbsolute(pot1); } //axis2.MoveAbsolute(ctrl.LeftThumbY); axis3.MoveAbsolute(ctrl.RightThumbY); // axis4.MoveAbsolute(ctrl.RightThumbX); // axis5.MoveAbsolute(ctrl.LeftTrigger); // axis6.MoveAbsolute(ctrl.RightTrigger); } while (!ctrl.Start && keyChar != 'x'); }
private static void Mcp4725(I2cBus i2c) { var mcp = new Mcp4725.Mcp4725(i2c); var ads1115 = new ADS1115(i2c, 0x4A); char keyChar = ' '; UInt16 outVar = 0; do { if (Console.KeyAvailable) { keyChar = Console.ReadKey().KeyChar; if (keyChar == '+') { outVar += 10; } if (keyChar == '-') { outVar -= 10; } } mcp.SetVoltage(outVar, false); var ch0 = ads1115.ReadAdcSingleEnded(0); Thread.Sleep(10); var v0 = ads1115.ConvertToVoltage(ch0); Console.WriteLine($"OutVar {outVar} In {v0}"); Thread.Sleep(300); } while (keyChar != 'x'); }