static void OtherApiTests(MCP41X1_Base dp) { var quit = false; Console.Clear(); try { var expectedValue = 0; dp.Set(0); for (var i = 0; i <= dp.MaxDigitalValue; i += _demoStep) { expectedValue += _demoStep; if(expectedValue > dp.MaxDigitalValue) expectedValue = dp.MaxDigitalValue; if(DisplayPotentiometerInfoAndCheckForCancel(dp)) { quit = true; break;} dp.Increment(_demoStep); var v = dp.Get(); if(expectedValue != v) Console.WriteLine("Method Get() did not return expected result"); } if(quit) return; dp.Set(dp.MaxDigitalValue); DisplayPotentiometerInfoAndCheckForCancel(dp); expectedValue = dp.MaxDigitalValue; for (var i = dp.MaxDigitalValue; i > 0; i -= _demoStep) { expectedValue -= _demoStep; if(expectedValue < dp.MinDigitalValue) expectedValue = dp.MinDigitalValue; if(DisplayPotentiometerInfoAndCheckForCancel(dp)) { quit = true; break;} dp.Decrement(_demoStep); var v = dp.Get(); if(expectedValue != v) Console.WriteLine("Method Get() did not return expected result"); } } finally { dp.Set(0); } }
static void OtherApiTests(MCP41X1_Base dp) { var quit = false; Console.Clear(); try { dp.Set(0); for (var i = 0; i <= dp.MaxDigitalValue; i += demoStep) { if(DisplayPotentiometerInfoAndCheckForCancel(dp)) { quit = true; break;} dp.Increment(demoStep); } if(quit) return; dp.Set(dp.MaxDigitalValue); DisplayPotentiometerInfoAndCheckForCancel(dp); for (var i = dp.MaxDigitalValue; i > 0; i -= demoStep) { if(DisplayPotentiometerInfoAndCheckForCancel(dp)) { quit = true; break;} dp.Decrement(demoStep); } } finally { dp.Set(0); } }
static void TestDigitalPotRange(MCP41X1_Base dp, bool tryReadValue = false) { Console.Clear(); for (var i = dp.MinDigitalValue; i <= dp.MaxDigitalValue; i += _demoStep) { if (!dp.Set(i).Succeeded) Console.WriteLine("Communication error"); if(DisplayPotentiometerInfoAndCheckForCancel(dp, tryReadValue)) break; } dp.Set(0); }
static void DigitalPotRangeForLed(MCP41X1_Base dp) { Console.Clear(); var quit = false; var ledThreadHold17Volt = 0; dp.Set(0); int wait = 16; while (!quit) { for (var i = ledThreadHold17Volt; i <= dp.MaxDigitalValue; i += 1) { if (!dp.Set(i).Succeeded) Console.WriteLine("Communication error"); if(DisplayPotentiometerInfoAndCheckForCancel(dp, exWaitTime:wait)) { quit = true; break; } } if(DisplayPotentiometerInfoAndCheckForCancel(dp, exWaitTime:wait)) { quit = true; break; } //_mcp4131_10k.Set(dp.MaxDigitalValue); //TimePeriod.Sleep(waitTime * 10); //for (var i = 0; i < 5; i++) { // dp.Set(0); // TimePeriod.Sleep(waitTime*2); // _mcp4131_10k.Set(dp.MaxDigitalValue); // TimePeriod.Sleep(waitTime*3); //} for (var i = dp.MaxDigitalValue; i > ledThreadHold17Volt; i -= 1) { if (!dp.Set(i).Succeeded) Console.WriteLine("Communication error"); if(DisplayPotentiometerInfoAndCheckForCancel(dp, exWaitTime:wait)) { quit = true; break; } } //TimePeriod.Sleep(waitTime*10); if(DisplayPotentiometerInfoAndCheckForCancel(dp, exWaitTime:wait)) { quit = true; break; } } var k = Console.ReadKey(); dp.Set(0); }