예제 #1
0
        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);
            }
        }
예제 #2
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);
            }
        }