static void Main(string[] args)
        {
            //
            // declare the Finch variable and create (instantiate) a new Finch object
            //
            Finch myFinch;
            myFinch = new Finch();

            //
            // connect to the Finch robot
            //
            myFinch.connect();

            //
            // pause the console window before exiting
            //
            Console.WriteLine("Press any key to continue.");
            Console.ReadKey();

            //
            // disconnect from the Finch robot
            //
            myFinch.disConnect();
        }
Пример #2
0
        static void Main(string[] args)
        {
            // create Finch
            Finch bot = new Finch();

            bot.connect();

            Console.WriteLine("Start XGamepadApp");
            // Initialize XInput
            var controllers = new[] { new Controller(UserIndex.One), new Controller(UserIndex.Two), new Controller(UserIndex.Three), new Controller(UserIndex.Four) };

            // Get 1st controller available
            Controller controller = null;

            foreach (var selectControler in controllers)
            {
                if (selectControler.IsConnected)
                {
                    controller = selectControler;
                    break;
                }
            }

            if (controller == null)
            {
                Console.WriteLine("No XInput controller installed");
            }
            else
            {
                Console.WriteLine("Found a XInput controller available");

                while (controller.IsConnected)
                {
                    if (IsKeyPressed(ConsoleKey.Escape))
                    {
                        break;
                    }
                    var state    = controller.GetState();
                    var LeftJoyX = state.Gamepad.LeftThumbX;
                    var LeftJoyY = state.Gamepad.LeftThumbY;
                    //Console.WriteLine($"X: {LeftJoyX} Y: {LeftJoyY}");
                    int lmotor = (LeftJoyY / 128) + (LeftJoyX / 128);
                    int rmotor = (LeftJoyY / 128) - (LeftJoyX / 128);
                    bot.setMotors(lmotor, rmotor);
                    if (state.Gamepad.RightThumbY > 0)
                    {
                        bot.noteOn(state.Gamepad.RightThumbY / 20);
                    }
                    if (state.Gamepad.RightThumbY < 0)
                    {
                        bot.noteOn((-(state.Gamepad.RightThumbY)) / 20);
                    }
                    int Red   = 0;
                    int Green = 0;
                    int Blue  = 0;
                    if (state.Gamepad.Buttons == GamepadButtonFlags.B)
                    {
                        Red = Red + 255;
                        Console.WriteLine($"Temperature: {bot.getTemperature()}");
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.A)
                    {
                        Green = Green + 255;
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.X)
                    {
                        Blue = Blue + 255;
                    }
                    if (state.Gamepad.Buttons == GamepadButtonFlags.Y)
                    {
                        Red   = Red + 255;
                        Green = Green + 255;
                        Console.WriteLine($"Light Level: {bot.getLeftLightSensor()}");
                    }
                    bot.setLED(Red, Green, Blue);
                    while (bot.isObstacleLeftSide() || bot.isObstacleRightSide())
                    {
                        bot.setMotors(-255, -255);
                    }
                }
            }
            Console.WriteLine("End XGamepadApp");
            bot.disConnect();
        }
Пример #3
0
 private static void DisplayExecuteFinchCommands(
     Finch finchRobot,
     List <Command> commands,
     (int motorSpeed, int ledBrightness, double waitSeconds) commandParameters)
Пример #4
0
        /// <summary>
        /// finches play tem shop
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            ///
            //COMMENT BLOCK
            //
            // title: finches play tem shop
            // description: two finches plays 'tem shop' by Toby Fox
            // application type: console
            // author: Eric Grant
            // date created: 9/15/2017
            // last modified: 9/17/2017
            //
            //COMMENT BLOCK END
            ///

            ///
            //VARIABLES
            //
            Finch myFinch;

            myFinch = new Finch();

            //length of a normal beat
            //
            int beatLen = 300;

            //length of a normal rest after beat
            //
            int beatRes = 50;

            //notes used in song
            //vars commented out are not used in this song
            //
            //int C3 = 130;
            int D3 = 146;
            //int E3 = 164;
            //int F3 = 174;
            int G3 = 196;
            //int A3 = 220;
            int B3 = 246;

            //int C4 = 261;
            int D4 = 293;
            int E4 = 329;
            int F4 = 349;
            int G4 = 392;
            //int A4 = 440;
            //int B4 = 493;

            //int C5 = 523;
            int D5 = 587;
            int E5 = 659;
            int F5 = 698;
            int G5 = 784;
            int A5 = 880;
            int B5 = 988;

            //int C6 = 1046;
            int D6 = 1174;

            //
            //VARIABLES END
            ///

            ///
            //METHODS
            //

            ///<summary>
            ///sasafsafasfagg
            /// </summary>

            ///<summary>
            ///finch plays note and lights up nose
            ///</summary>
            ///<param name="note">frequencie of note</param>
            ///<param name="play">duration of note</param>
            ///<param name="hold">duration of rest after note</param>
            void FinchNote(int note, int play, int hold)
            {
                myFinch.setLED(255, 255, 255);
                myFinch.noteOn(note);
                myFinch.wait(play);

                myFinch.setLED(0, 0, 0);
                myFinch.noteOff();
                myFinch.wait(hold);
            }

            //background beat parts
            //
            void FinchBeat1()
            {
                FinchNote(G3, beatLen, beatRes);
                FinchNote(B3, beatLen, beatRes);
                FinchNote(D3, beatLen, beatRes);
                FinchNote(B3, beatLen, beatRes);
            }

            void FinchBeat2()
            {
                FinchNote(B3, beatLen, beatRes);
                FinchNote(E4, beatLen, beatRes);
                FinchNote(G3, beatLen, beatRes);
                FinchNote(E4, beatLen, beatRes);
            }

            void FinchBeat3()
            {
                FinchNote(D4, beatLen, beatRes);
                FinchNote(F4, beatLen, beatRes);
                FinchNote(G3, beatLen, beatRes);
                FinchNote(F4, beatLen, beatRes);
            }

            void FinchBeat4()
            {
                FinchNote(B3, beatLen, beatRes);
                FinchNote(E4, beatLen, beatRes);
                FinchNote(D4, beatLen, beatRes);
                FinchNote(F4, beatLen, beatRes);
            }

            void FinchBeat5()
            {
                FinchNote(D4, beatLen, beatRes);
                FinchNote(F4, beatLen, beatRes);
                FinchNote(G4, beatLen, beatRes);
                FinchNote(G3, beatLen, beatRes);
            }

            //
            //METHODS END
            ///

            //connect to the Finch robot
            myFinch.connect();

            //wait to start
            Console.WriteLine("'tem shop'");
            Console.WriteLine("Toby Fox");
            Console.WriteLine("Press any key to begin");
            Console.ReadKey();

            ///
            //FINCH 1 - BEAT
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //the BEAT code should run on FINCH 1 simultaneously with the MELODY code on FINCH 2
            //remove the BEAT code from FINCH 2 and vise versa
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //
            for (int x = 0; x < 2; x++)
            {
                FinchBeat1();
                FinchBeat1();
                FinchBeat2();
                FinchBeat3();
                FinchBeat1();
                FinchBeat1();
                FinchBeat4();
                FinchBeat5();
            }
            //
            //FINCH 1 - BEAT END
            ///

            ///
            //FINCH 2 - MELODY
            //
            for (int x = 0; x < 2; x++)
            {
                myFinch.wait(beatLen + beatRes);
                FinchNote(D6, beatLen + (beatLen / 2), beatRes);
                FinchNote(B5, beatLen + (beatLen / 2), beatRes);
                myFinch.wait(beatRes);

                FinchNote(G5, beatLen, beatRes);
                FinchNote(A5, beatLen / 2, beatRes / 2);
                FinchNote(G5, beatLen, beatRes);
                FinchNote(D5, beatLen / 2, beatRes / 2);
                FinchNote(E5, beatLen / 2, beatRes / 2);
                FinchNote(G5, beatLen / 2, beatRes / 2);

                myFinch.wait(beatLen + beatRes);
                FinchNote(E5, beatLen + (beatLen / 2), beatRes);
                FinchNote(G5, beatLen + (beatLen / 2), beatRes);
                myFinch.wait(beatRes);

                FinchNote(F5, beatLen, beatRes);
                FinchNote(G5, beatLen / 2, beatRes / 2);
                FinchNote(A5, beatLen, beatRes);
                myFinch.wait((beatLen + beatRes) / 2);
                myFinch.wait(beatLen + beatRes);

                myFinch.wait(beatLen + beatRes);
                FinchNote(D6, beatLen + (beatLen / 2), beatRes);
                FinchNote(B5, beatLen + (beatLen / 2), beatRes);
                myFinch.wait(beatRes);

                FinchNote(G5, beatLen, beatRes);
                FinchNote(A5, beatLen / 2, beatRes / 2);
                FinchNote(G5, beatLen, beatRes);
                FinchNote(D5, beatLen / 2, beatRes / 2);
                FinchNote(E5, beatLen / 2, beatRes / 2);
                FinchNote(G5, beatLen / 2, beatRes / 2);

                FinchNote(B5, beatLen / 2, beatRes / 2);
                FinchNote(B5, beatLen / 2, beatRes / 2);
                FinchNote(A5, beatLen, beatRes);
                FinchNote(A5, beatLen / 2, beatRes / 2);
                FinchNote(G5, beatLen / 2, beatRes / 2);
                FinchNote(E5, beatLen, beatRes);

                FinchNote(E5, beatLen, beatRes);
                FinchNote(G5, beatLen, beatRes);
                FinchNote(G5, beatLen, beatRes);
                myFinch.wait(beatLen + beatRes);
            }
            //
            //FINCH 2 - MELODY END
            ///

            //disconnect from the Finch robot
            //
            myFinch.disConnect();

            //pause the console window before exiting
            //
            Console.WriteLine("\nPress any key to exit.");
            Console.ReadKey();
        }
Пример #5
0
        static void DisplayColors(Finch cappy)
        {
            // rainbow

            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
            cappy.setLED(255, 0, 0);
            cappy.wait(50);
            cappy.setLED(0, 255, 0);
            cappy.wait(50);
            cappy.setLED(0, 0, 255);
            cappy.wait(50);
        }
Пример #6
0
        /// <summary>
        /// *****************************************************************
        /// *               Talent Show > Mixing It Up                      *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>

        static void DisplayMixingItUp(Finch finchRobot)
        {
            Console.CursorVisible = false;

            DisplayScreenHeader("Mix it Up");

            Console.WriteLine("\tThe Finch robot will not show off its glowing talent!");
            DisplayContinuePrompt();

            for (int lightSoundLevel = 0; lightSoundLevel < 3; lightSoundLevel++)
            {
                finchRobot.setLED(0, 189, 189);
                finchRobot.noteOn(100);
                finchRobot.wait(1000);
                finchRobot.noteOn(130);
                finchRobot.wait(500);
                finchRobot.noteOn(100);
                finchRobot.wait(500);
                finchRobot.noteOn(160);
                finchRobot.wait(500);
                finchRobot.setLED(255, 0, 0);
                finchRobot.noteOn(140);
                finchRobot.wait(500);
                finchRobot.noteOn(100);
                finchRobot.wait(500);
                finchRobot.noteOn(100);
                finchRobot.wait(500);
                finchRobot.noteOn(130);
                finchRobot.wait(500);
                finchRobot.noteOn(100);
                finchRobot.wait(500);
                finchRobot.noteOn(175);
                finchRobot.wait(500);
                finchRobot.noteOn(160);
                finchRobot.wait(500);
                finchRobot.noteOn(100);
                finchRobot.wait(500);
                finchRobot.noteOn(110);
                finchRobot.wait(500);
                finchRobot.noteOn(210);
                finchRobot.wait(500);
                finchRobot.noteOn(190);
                finchRobot.wait(500);
                finchRobot.noteOn(160);
                finchRobot.wait(500);
                finchRobot.noteOn(140);
                finchRobot.wait(500);
                finchRobot.noteOn(130);
                finchRobot.wait(500);
                finchRobot.noteOn(210);
                finchRobot.wait(250);
                finchRobot.noteOn(210);
                finchRobot.wait(250);
                finchRobot.noteOn(190);
                finchRobot.wait(500);
                finchRobot.noteOn(160);
                finchRobot.wait(500);
                finchRobot.noteOn(175);
                finchRobot.wait(500);
                finchRobot.noteOn(160);
                finchRobot.wait(500);
                finchRobot.setMotors(250, 0);
                finchRobot.wait(1000);
                finchRobot.noteOff();
                finchRobot.setLED(0, 0, 0);
                finchRobot.setMotors(0, 0);
            }

            DisplayMenuPrompt("Talent Show Menu");
        }
Пример #7
0
        static void Main(string[] args)
        {
            //**********************************************
            // Application: CIT 110 Capstone
            // Author: Duane Dodge
            // Date: Dec 6th, 2017
            //**********************************************

            Finch SneakyFinch = new Finch();

            SneakyFinch.connect();



            double ambientLight;
            double currentLight;
            double lightTolerance;
            double maxLightThreshold;


            //
            // set up temp values
            //

            /*temperatureTolerance = 1;
             * ambientTemperature = SneakyFinch.getTemperature();
             * minTemperatureThreshold = ambientTemperature - temperatureTolerance;*/

            //
            // set up light values
            //
            lightTolerance    = 15;
            ambientLight      = SneakyFinch.getLeftLightSensor();
            maxLightThreshold = ambientLight + lightTolerance;

            string menuChoice;
            bool   exiting = false;


            //
            // display menu choices
            //
            DisplayHeader("");

            Console.WriteLine("Welcome to Sneaky Finch!");
            Console.WriteLine("Sneaky Finch will sneak into the lab to collect some code that will help defeat the bad guys!");
            Console.WriteLine("He will be sneaking through the shadows and avoiding the guard's flashlight.");
            Console.Write("Enter Shield Level");
            Console.WriteLine();
            Console.WriteLine("\t1) Enter hallway one");
            Console.WriteLine("\t2) Enter hallway two");
            Console.WriteLine("\t3) Enter stairwell");
            Console.WriteLine("\t4) Enter secret lab");
            menuChoice = Console.ReadLine();

            switch (menuChoice)
            {
            case "1":
                HallwayCrawl(5, SneakyFinch);
                break;

            case "2":
                HallwayCrawlTwo(5, SneakyFinch);
                break;

            case "3":
                StairWell(5, SneakyFinch);
                break;

            case "4":
                break;
                SecretLab(10, SneakyFinch);

            default:
                break;
            }



            //
            // sneaky finch continue
            //
            SneakyFinch.setMotors(0, 0);
            Console.WriteLine("So far so good.");
            Console.WriteLine();
            Console.WriteLine("Press Enter Key to Continue");
            Console.ReadKey();

            //
            // display menu choices
            //
            DisplayHeader("");

            Console.WriteLine("Welcome to Sneaky Finch!");
            Console.WriteLine("Sneaky Finch will sneak into the lab to collect some code that will help defeat the bad guys!");
            Console.WriteLine("He will be sneaking through the shadows and avoiding the guard's flashlight.");
            Console.Write("Enter Shield Level");
            Console.WriteLine();
            Console.WriteLine("\t1) Enter hallway one");
            Console.WriteLine("\t2) Enter hallway two");
            Console.WriteLine("\t3) Enter stairwell");
            Console.WriteLine("\t4) Enter secret lab");
            menuChoice = Console.ReadLine();

            switch (menuChoice)
            {
            case "1":
                HallwayCrawl(5, SneakyFinch);
                break;

            case "2":
                HallwayCrawlTwo(5, SneakyFinch);
                break;

            case "3":
                StairWell(5, SneakyFinch);
                break;

            case "4":
                break;
                SecretLab(10, SneakyFinch);

            default:
                break;
            }

            SneakyFinch.setMotors(0, 0);
            Console.WriteLine("Phew that was close.");
            Console.WriteLine();
            Console.WriteLine("Press Enter Key to Continue");
            Console.ReadKey();

            //
            // display menu choices
            //
            DisplayHeader("");

            Console.WriteLine("Welcome to Sneaky Finch!");
            Console.WriteLine("Sneaky Finch will sneak into the lab to collect some code that will help defeat the bad guys!");
            Console.WriteLine("He will be sneaking through the shadows and avoiding the guard's flashlight.");
            Console.Write("Enter Shield Level");
            Console.WriteLine();
            Console.WriteLine("\t1) Enter hallway one");
            Console.WriteLine("\t2) Enter hallway two");
            Console.WriteLine("\t3) Enter stairwell");
            Console.WriteLine("\t4) Enter secret lab");
            menuChoice = Console.ReadLine();

            switch (menuChoice)
            {
            case "1":
                HallwayCrawl(5, SneakyFinch);
                break;

            case "2":
                HallwayCrawlTwo(5, SneakyFinch);
                break;

            case "3":
                StairWell(5, SneakyFinch);
                break;

            case "4":
                break;
                SecretLab(10, SneakyFinch);

            default:
                break;
            }

            SneakyFinch.setMotors(0, 0);
            Console.WriteLine("That was TOO easy!");
            Console.WriteLine();
            Console.WriteLine("Press Enter Key to Continue");
            Console.ReadKey();

            //
            // display menu choices
            //
            DisplayHeader("");

            Console.WriteLine("Welcome to Sneaky Finch!");
            Console.WriteLine("Sneaky Finch will sneak into the lab to collect some code that will help defeat the bad guys!");
            Console.WriteLine("He will be sneaking through the shadows and avoiding the guard's flashlight.");
            Console.Write("Enter Shield Level");
            Console.WriteLine();
            Console.WriteLine("\t1) Enter hallway one");
            Console.WriteLine("\t2) Enter hallway two");
            Console.WriteLine("\t3) Enter stairwell");
            Console.WriteLine("\t4) Enter secret lab");
            menuChoice = Console.ReadLine();

            switch (menuChoice)
            {
            case "1":
                HallwayCrawl(5, SneakyFinch);
                break;

            case "2":
                HallwayCrawlTwo(5, SneakyFinch);
                break;

            case "3":
                StairWell(5, SneakyFinch);
                break;

            case "4":
                break;
                SecretLab(10, SneakyFinch);

            default:
                break;
            }
            //
            // disconnect finch
            //
            SneakyFinch.setMotors(0, 0);
            Console.WriteLine("I did it, I got the secret code!");
            Console.WriteLine();
            Console.WriteLine("Press Enter Key to exit");
            Console.ReadKey();
            SneakyFinch.disConnect();
        }
Пример #8
0
        private static void LightAlarmSetAlarm
            (Finch finchRobot,
            string sensorsToMonitor,
            string rangeType,
            int lightMinMaxThresholdValue,
            int timeToMonitor)
        {
            int  secondsElapsed          = 0;
            bool thresholdExceeded       = false;
            int  currentLightSensorValue = 0;

            DisplayScreenHeader("Set Light Alarm");

            Console.WriteLine($"\tSensors to monitor {sensorsToMonitor}");
            Console.WriteLine("\tRange Type: {0}", rangeType);
            Console.WriteLine("\tmin/max Threshold value: " + lightMinMaxThresholdValue);
            Console.WriteLine($"\tTime to Monitor: {timeToMonitor}");
            Console.WriteLine();

            Console.WriteLine("Press any key to begin monitoring!");
            DisplayContinuePrompt();

            while ((secondsElapsed < timeToMonitor) && !thresholdExceeded)
            {
                switch (sensorsToMonitor)
                {
                case "left":
                    currentLightSensorValue = finchRobot.getLeftLightSensor();
                    break;

                case "right":
                    currentLightSensorValue = finchRobot.getRightLightSensor();
                    break;

                case "both":
                    currentLightSensorValue = (finchRobot.getRightLightSensor() + finchRobot.getLeftLightSensor()) / 2;
                    break;
                }
                switch (rangeType)
                {
                case "minimum":
                    if (currentLightSensorValue < lightMinMaxThresholdValue)
                    {
                        thresholdExceeded = true;
                    }
                    break;

                case "maximum":
                    if (currentLightSensorValue > lightMinMaxThresholdValue)
                    {
                        thresholdExceeded = true;
                    }
                    break;
                }
                finchRobot.wait(1000);
                secondsElapsed++;
            }

            if (thresholdExceeded)
            {
                finchRobot.noteOn(700);
                Console.WriteLine($"The {rangeType} threshold value of {lightMinMaxThresholdValue} was exceeded by the current light sensor value of {currentLightSensorValue}.");
                DisplayContinuePrompt();
                finchRobot.noteOff();
            }
            else
            {
                Console.WriteLine($"The {rangeType} threshold value of {lightMinMaxThresholdValue} was  not exceeded by the current light sensor value of {currentLightSensorValue}.");
            }
            DisplayMenuPrompt("Light and Temperature Alarm");
        }
Пример #9
0
 private static void dataRecorder(Finch myFinch)
 {
 }
Пример #10
0
        // *************************************************************
        // Application:     Finch Starter Solution
        // Author:          Velis, John E
        // Description:
        // Date Created:    5/20/2016
        // Date Revised:
        // *************************************************************
        //Application Additions Talent Show, Sensors, and a few others
        //Author: Sam G.
        //Description
        //Date Edited addition.10/1/2020
        //***************************************************************
        static void Main(string[] args)
        {
            //
            // create a new Finch object
            //
            Finch myFinch;

            myFinch = new Finch();
            bool   endNow = false;
            string caseSwitch;

            //
            // call the connect method
            //
            TestFinchConnection(myFinch);

            //
            // begin your code
            //

            //color change test
            myFinch.setLED(0, 0, 255);
            myFinch.wait(5000);
            myFinch.setLED(0, 255, 0);
            myFinch.wait(5000);
            myFinch.setLED(255, 0, 0);
            //run set up and explanation functions
            SetUpDisplay();
            DisplayWelcomeMessage();
            do
            {
                DisplayMainMenu();
                caseSwitch = GatherInput();
                Console.WriteLine($"Option {caseSwitch} was selected.");
                Console.ReadKey();
                switch (caseSwitch)
                {
                case "a":
                    Console.Clear();
                    TalentShow(myFinch);
                    break;

                case "b":
                    Console.Clear();
                    AngryFinch(myFinch);
                    Console.Clear();
                    break;

                case "c":
                    Console.Clear();
                    DisplayDataRecorder(myFinch);
                    break;

                case "d":
                    Console.Clear();
                    DisplayLightDataRecorder(myFinch);
                    break;

                case "e":
                    Console.Clear();
                    AlarmSystemAlert(myFinch);
                    break;

                case "quit":
                    Console.WriteLine("Thank you for using our robot!");
                    Thread.Sleep(5000);
                    endNow = true;
                    break;
                }
            } while (!endNow);
            #region testCode

            /**myFinch.setLED(0, 0, 255);
             * myFinch.wait(1000);
             * myFinch.setLED(0, 255, 0);
             * myFinch.wait(1000);*/

            /**for (int i = 0; i<5; i++)
             * {
             *  myFinch.setLED(0, 0, 255);
             *  myFinch.wait(100);
             *  myFinch.setLED(0, 255, 0);
             *  myFinch.wait(100);
             *  myFinch.setLED(255, 0, 0);
             *  myFinch.wait(100);
             * }
             *
             * for (int  i = 0; i<255; i++)
             * {
             *  myFinch.setLED(0, 0, i);
             *  myFinch.wait(100);
             *  myFinch.setLED(i, 0, 0);
             *  myFinch.wait(100);
             * }
             *
             * for (int i = 255; i >0; i--)
             * {
             *  myFinch.setLED(0, 0, i);
             *  myFinch.wait(100);
             *  myFinch.setLED(i, 0, 0);
             *  myFinch.wait(100);
             * }
             *
             * for (int i = 0; i < 5; i++)
             * {
             *  myFinch.noteOn(261);
             *  myFinch.wait(1000);
             *  myFinch.noteOff();
             *  myFinch.wait(100);
             * }
             * myFinch.setMotors(-255, 255);
             * myFinch.wait(10000);
             */
            #endregion
            //
            //end of your code
            //

            //
            // call the disconnect method
            //
            myFinch.disConnect();
        }
Пример #11
0
        private static (int[], int[]) ExecuteSentryMode(int sentrySec, int sentryFrequency, int[] dataAmountSentryTakes, Finch myFinch, int minMax)
        {
            bool finished = false;

            int[] dataAmountSentryTakesRight = new int[dataAmountSentryTakes.Length];
            (int[], int[])sensoryData;

            DisplayHeader("Sentry Mode.");
            Console.WriteLine("sentry mode will begin, press any key to continue.");
            Console.ReadKey();
            do
            {
                int i = 0;
                if (i == sentryFrequency)
                {
                    finished = true;
                }
                else
                {
                    dataAmountSentryTakes[i]      = myFinch.getLeftLightSensor();
                    dataAmountSentryTakesRight[i] = myFinch.getRightLightSensor();
                    myFinch.wait(sentrySec * 1000);
                    i++;
                }
            } while (!finished);
            sensoryData = (dataAmountSentryTakes, dataAmountSentryTakesRight);
            return(sensoryData);
        }
Пример #12
0
        private static void AlarmSystemAlert(Finch myFinch)
        {
            string optionSelect    = null;
            bool   sentryMode      = true;
            int    sentrySec       = 0;
            int    sentryFrequency = 0;
            int    userChoice      = 0;
            int    minMax          = 0;

            int[] dataAmountSentryTakes = new int[userChoice];
            Console.WriteLine("Alarm System being prepped for arming.");
            myFinch.wait(5000);
            do
            {
                Console.Clear();
                DisplayAlarm();
                optionSelect = Console.ReadLine().ToLower();
                switch (optionSelect)
                {
                case "a":
                    sentrySec = SentryTimerSettings();
                    Console.WriteLine($"{sentrySec} of how many seconds there are.");
                    Console.ReadKey();
                    break;

                case "b":
                    sentryFrequency = SentryDataTakenFrequencySettings();
                    Console.WriteLine($"{sentryFrequency} of how many datapoints will be taken there are.");
                    Console.ReadKey();
                    break;

                case "c":
                    userChoice = SentryDataTakenAmount();
                    Console.WriteLine($"{userChoice} how long the list will be.");
                    break;

                case "d":
                    minMax = SentryAlarmAlert();
                    break;

                case "e":
                    if (sentrySec <= 0 || sentryFrequency <= 0 || userChoice <= 0)
                    {
                        Console.WriteLine("Error you have entered in a null amount, sentry mode cannot be zero.");
                    }
                    else
                    {
                        (int[], int[])sensorData = ExecuteSentryMode(sentrySec, sentryFrequency, dataAmountSentryTakes, myFinch, minMax);
                    }
                    break;

                case "quit":
                    Console.WriteLine("Sentry Mode: Disengaging!");
                    myFinch.noteOn(500);
                    myFinch.wait(2000);
                    myFinch.noteOff();
                    sentryMode = false;
                    break;
                }
            } while (sentryMode);
        }
Пример #13
0
        //------------------//
        //Command Parameters//
        //------------------//
        static (int motorSpeed, int ledBrightness, double waitSeconds) DisplayGetCommandParameters(Finch myFinch)
        {
            string userResponse;
            bool   validResponse;

            DisplayHeader("Command Parameters");

            (int motorSpeed, int ledBrightness, double waitSeconds)commandParameters;
            commandParameters.motorSpeed    = 0;
            commandParameters.ledBrightness = 0;
            commandParameters.waitSeconds   = 0;

            //***********//
            //Motor Speed//
            //***********//
            do
            {
                Console.WriteLine("\tEnter Motor Speed[1 - 255]:");
                userResponse = Console.ReadLine();

                validResponse = int.TryParse(userResponse, out commandParameters.motorSpeed);

                if (!validResponse)
                {
                    Console.WriteLine("Incorrect format");
                }
            } while (validResponse == false);
            //**************//
            //LED Brightness//
            //**************//
            do
            {
                Console.WriteLine("\tEnter LED Brightness [1 - 255]:");
                userResponse = Console.ReadLine();

                validResponse = int.TryParse(userResponse, out commandParameters.ledBrightness);

                if (!validResponse)
                {
                    Console.WriteLine("Incorrect format");
                }
            } while (validResponse == false);
            //*********//
            //Wait Time//
            //*********//
            do
            {
                Console.WriteLine("Enter Wait in Seconds;");
                userResponse = Console.ReadLine();

                validResponse = double.TryParse(userResponse, out commandParameters.waitSeconds);

                if (!validResponse)
                {
                    Console.WriteLine("Incorrect format");
                }
            } while (validResponse == false);

            Console.WriteLine();
            Console.WriteLine($"\tMotor Speed: {commandParameters.motorSpeed}");
            Console.WriteLine($"\tLED Brightness: {commandParameters.ledBrightness}");
            Console.WriteLine($"\tWait Command Duration; {commandParameters.waitSeconds}");

            DisplayUserProgram(myFinch);

            return(commandParameters);
        }
Пример #14
0
        //--------//
        //Get Data//
        //--------//
        static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointsFrequency, Finch myFinch)
        {
            double[] temperatures = new double[numberOfDataPoints];
            int      frequencyInSeconds;

            DisplayHeader("Get Data");

            Console.WriteLine($"You have {numberOfDataPoints} data points and a frequency of {dataPointsFrequency}");

            Console.WriteLine("The finch robot is ready to record temperature");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = myFinch.getTemperature();
                Console.WriteLine($"Data #{index + 1}: {temperatures[index]} in celcius. {index + 1}: {(temperatures[index] * 9 / 5) + 32} in fahrenheit");
                frequencyInSeconds = (int)(dataPointsFrequency * 1000);
                myFinch.wait(frequencyInSeconds);
            }

            Console.WriteLine();
            Console.WriteLine("Current Data");
            DataRecorderDisplayTable(temperatures);

            DisplayContinuePrompt();
            DisplayDataRecorder(myFinch);
            return(temperatures);
        }
Пример #15
0
        //-----//
        //MUSIC//
        //-----//
        static void DisplayNotes(Finch myFinch)
        {
            DisplayHeader("Finch Notes");

            for (int soundlevel = 0; soundlevel < 20000; soundlevel = soundlevel + 50)
            {
                myFinch.noteOn(soundlevel);
            }
            for (int soundlevel = 255; soundlevel > 0; soundlevel = soundlevel - 50)
            {
                myFinch.noteOn(soundlevel);
            }

            //-----------------//
            //Hot Cross Buns???//
            //-----------------//

            myFinch.noteOn(587);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(523);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(493);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(587);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(523);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(493);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(493);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(493);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(523);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(523);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(587);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(523);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            myFinch.noteOn(493);
            myFinch.wait(500);
            myFinch.noteOff();
            myFinch.wait(500);

            DisplayContinuePrompt();
            DisplayTalentShow(myFinch);
        }
Пример #16
0
        //
        //          Alarm system Display
        //
        static void AlarmSystemDisplayMenuScreen(Finch finchRobot)
        {
            Console.CursorVisible = true;

            bool   quitMenu = false;
            string menuChoice;

            string sensorsToMonitor                = null;
            string rangeType                       = null;
            int    lightMinMaxThresholdValue       = 0;
            int    temperatureMinMaxThresholdValue = 0;
            int    timeToMonitor                   = 0;

            do
            {
                DisplayScreenHeader("Light  and Temperature Alarm Menu");
                //
                // get user menu choice
                //
                Console.WriteLine("\ta) Set Sensors to Monitor");
                Console.WriteLine("\tb) Set Range Type");
                Console.WriteLine("\tc) Set Light Maximum/Minimum Threshold Value");
                Console.WriteLine("\td) Set Time to Monitor");
                Console.WriteLine("\te) Set Light Alarm");
                Console.WriteLine("\tf) Set temperature Alarm");
                Console.WriteLine("\tg) Set Light and temperature Alarm");
                Console.WriteLine("\th) Set temperature Maximum/Minimum Threshold Value");
                Console.WriteLine("\tq) Main Menu");
                Console.Write("\t\tEnter Choice:");
                menuChoice = Console.ReadLine().ToLower();
                //
                // process user menu choice
                //
                switch (menuChoice)
                {
                case "a":
                    sensorsToMonitor = LightAlarmDisplaySetSensorsToMonitor();
                    break;

                case "b":
                    rangeType = LightAlarmDisplaySetRangeType();
                    break;

                case "c":
                    lightMinMaxThresholdValue = LightAlarmSetMinMaxThresholdValue(rangeType, finchRobot);
                    break;

                case "d":
                    timeToMonitor = LightAlarmSetTimeToMonitor();
                    break;

                case "e":
                    LightAlarmSetAlarm(finchRobot, sensorsToMonitor, rangeType, lightMinMaxThresholdValue, timeToMonitor);
                    break;

                case "f":
                    TemperatureAlarmSetAlarm(finchRobot, rangeType, temperatureMinMaxThresholdValue, timeToMonitor);
                    break;

                case "g":
                    TemperatureAndLightAlarmSetAlarm(finchRobot, sensorsToMonitor, rangeType, lightMinMaxThresholdValue, temperatureMinMaxThresholdValue, timeToMonitor);
                    break;

                case "h":
                    temperatureMinMaxThresholdValue = TemperatureAlarmSetMinMaxThresholdValue(rangeType, finchRobot);
                    break;

                case "q":
                    quitMenu = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("\tPlease enter a letter for the menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            } while (!quitMenu);
        }
Пример #17
0
        private static void DisplayLightDataRecorder(Finch myFinch)
        {
            string caseSwitch;
            bool   endNowData = false;

            double[] leftLightData, rightLightData, averageLightData;
            int      numberOfDataPoints           = 0;
            double   frequencyOfDataPointsSeconds = 0;
            Tuple <double[], double[]> lightData  = null;

            leftLightData    = null;
            rightLightData   = null;
            averageLightData = null;
            do
            {
                DisplayHeader("Data Recorder Menu");


                Console.WriteLine("\ta) Get number of data points.");
                Console.WriteLine("\tb) Get the freuquency of data points");
                Console.WriteLine("\tc) Get Light Measurements of data points.");
                Console.WriteLine("\td) Display Table of Light");
                Console.WriteLine("\te) ");
                Console.WriteLine("\t\tMan Menu");
                Console.WriteLine("Please select an option.");
                caseSwitch = Console.ReadLine();
                switch (caseSwitch)
                {
                case "a":
                    numberOfDataPoints = LightDataRecorderDisplayGetNumberOfDataPoints();
                    break;

                case "b":
                    frequencyOfDataPointsSeconds = LightDataRecorderDisplayGetFrequencyOfDataPoints();
                    break;

                case "c":
                    if (numberOfDataPoints == 0 || frequencyOfDataPointsSeconds == 0)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Please enter the number and frequency");
                    }
                    else
                    {
                        lightData = LightDataRecorderDisplayGetFrequencyOfDataSet(numberOfDataPoints, frequencyOfDataPointsSeconds, myFinch);
                    }
                    leftLightData    = lightData.Item1;
                    rightLightData   = lightData.Item2;
                    averageLightData = null;
                    for (int i = 0; i < leftLightData.Length; i++)
                    {
                        averageLightData[i] = (lightData.Item1[i] + lightData.Item2[i]) / 2;
                    }
                    break;

                case "d":
                    LightDataRecorderDisplayGetFrequencyOfDataSet(leftLightData, rightLightData, averageLightData);
                    break;

                case "quit":
                    Console.WriteLine("Back to main menu.");
                    endNowData = true;
                    break;
                }
            } while (!endNowData);
        }
Пример #18
0
        //
        //
        //
        //          user programming screen
        //
        //
        //

        static void UserProgrammingDisplayMenuScreen(Finch finchRobot)
        {
            Console.CursorVisible = true;
            Console.WriteLine("Sorry this section is still under construction...");
            DisplayContinuePrompt();
        }
Пример #19
0
        /// <summary>
        /// Data Recorder > Get the Data Points
        /// </summary>
        /// <param name="numberOfDataPoints"></param>
        /// <param name="frequencyOfDataPointsSeconds"></param>
        /// <param name="myFinch"></param>
        /// <returns></returns>
        static Tuple <double[], double[]> LightDataRecorderDisplayGetFrequencyOfDataSet(int numberOfDataPoints, double frequencyOfDataPointsSeconds, Finch myFinch)
        {
            double[] lightReadingRight = new double[numberOfDataPoints];
            double[] lightReadingLeft  = new double[numberOfDataPoints];
            DisplayHeader("Get Data Set");

            Console.WriteLine($"\tNumber of Data Points: {numberOfDataPoints}");
            Console.WriteLine($"\tFrequency of Data Points: {frequencyOfDataPointsSeconds}");
            Console.WriteLine();

            Console.WriteLine("\tFinch robot is ready to record light measurement data.");
            Console.WriteLine("\tPress any key to begin.");
            Console.ReadKey();

            double lightLeft, lightRight;
            int    waitVariable;

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                lightLeft  = myFinch.getLeftLightSensor();
                lightRight = myFinch.getRightLightSensor();

                Console.WriteLine($"Left light reading at {index + 1}: {lightLeft}");
                Console.WriteLine($"Right light reading at {index + 1}: {lightRight}");
                lightReadingLeft[index]  = lightLeft;
                lightReadingRight[index] = lightRight;
                waitVariable             = (int)(frequencyOfDataPointsSeconds * 1000);
                myFinch.wait(waitVariable);
            }
            Tuple <double[], double[]> lightReadingVarable = new Tuple <double[], double[]>(lightReadingLeft, lightReadingRight);

            return(lightReadingVarable);
        }
        static void UserProgrammingDisplayMenuScreen(Finch finchRobot)
        {
            string menChoice;
            bool   quitMenu = false;

            //
            // Command Parameter Tuple
            //

            (int motorSpeed, int ledBrightness, double waitSeconds)commandParameters;
            commandParameters.motorSpeed    = 0;
            commandParameters.ledBrightness = 0;
            commandParameters.waitSeconds   = 0;


            List <Command> commands = new List <Command>();

            do
            {
                DisplayScreenHeader("User Programming Menu");

                //
                // User menu Choice
                //

                Console.WriteLine("\tA) Set Command Parameters");
                Console.WriteLine("\tB) Add Commands");
                Console.WriteLine("\tC) View Commands");
                Console.WriteLine("\tD) Execute Commands");
                Console.WriteLine("\tQ) Quit");
                Console.WriteLine("Enter Choice: ");
                menChoice = Console.ReadLine().ToLower();

                switch (menChoice)
                {
                case "a":
                    commandParameters = UserProgrammingDisplayGetCommandParameters();
                    break;

                case "b":
                    UserProgrammingDisplayGetFinchCommands(commands);
                    break;

                case "c":
                    UserProgrammingDisplayFinchCommands(commands);
                    break;

                case "d":
                    UserProgrammingDisplayExecuteFinchCommands(finchRobot, commands, commandParameters);
                    break;

                case "q":
                    quitMenu = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("\tPlease enter a letter for the menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            } while (!quitMenu);
        }
Пример #21
0
        /// <summary>
        /// Data Recorder > Get the Data Points
        /// </summary>
        /// <param name="numberOfDataPoints"></param>
        /// <param name="frequencyOfDataPointsSeconds"></param>
        /// <param name="myFinch"></param>
        /// <returns></returns>
        static double[] DataRecorderDisplayGetFrequencyOfDataSet(int numberOfDataPoints, double frequencyOfDataPointsSeconds, Finch myFinch)
        {
            double[] temperatures = new double[numberOfDataPoints];

            DisplayHeader("Get Data Set");

            Console.WriteLine($"\tNumber of Data Points: {numberOfDataPoints}");
            Console.WriteLine($"\tFrequency of Data Points: {frequencyOfDataPointsSeconds}");
            Console.WriteLine();

            Console.WriteLine("\tFinch robot is ready to record temperature data.");
            Console.WriteLine("\tPress any key to begin.");
            Console.ReadKey();

            double temperature;
            int    waitVariable;

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperature = myFinch.getTemperature();
                Console.WriteLine($"Temperature Reading {index + 1}: {temperature} C");
                temperatures[index] = temperature;
                waitVariable        = (int)(frequencyOfDataPointsSeconds * 1000);
                myFinch.wait(waitVariable);
            }

            return(temperatures);
        }
Пример #22
0
 static void UserProgrammingDisplayExecuteFinchCommands(Finch finchRobot,
                                                        List <Command> commands,
                                                        (int motorSpeed, int ledBrightness, double waitSecounds) comandParameters)
Пример #23
0
        static void DisplayExecuteFinchCommands(Finch myFinch, List <FinchCommand> commands, int motorSpeed, int lEDBrightness, int delayDuration)
        {
            commands = null;

            DisplayHeader("Execute Finch Commands");
            if (commands != null)
            {
                Console.WriteLine("Click any key when ready to execute commands");
                DisplayContinuePrompt();

                for (int index = 0; index < commands.Count; index++)
                {
                    Console.WriteLine($"Command:{commands[index]}");

                    switch (commands[index])
                    {
                    case FinchCommand.DONE:
                        break;

                    case FinchCommand.MOVEFORWARD:
                        myFinch.setMotors(motorSpeed, motorSpeed);
                        break;

                    case FinchCommand.MOVEBACKWARD:
                        myFinch.setMotors(-motorSpeed, -motorSpeed);
                        break;

                    case FinchCommand.STOPMOTORS:
                        myFinch.setMotors(0, 0);
                        break;

                    case FinchCommand.DELAY:
                        myFinch.wait(delayDuration);
                        break;

                    case FinchCommand.TURNRIGHT:
                        myFinch.setMotors(motorSpeed, -motorSpeed);
                        break;

                    case FinchCommand.TURNLEFT:
                        myFinch.setMotors(-motorSpeed, motorSpeed);
                        break;

                    case FinchCommand.LEDON:
                        myFinch.setLED(lEDBrightness, lEDBrightness, lEDBrightness);
                        break;

                    case FinchCommand.LEDOFF:
                        myFinch.setLED(0, 0, 0);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("Please enter Finch Robot commands first.");
            }

            DisplayContinuePrompt();
        }
Пример #24
0
        static void DisplayPatrioticShow(Finch cappy)
        {
            Console.WriteLine("You Chose the Patriotic Show!");

            Console.WriteLine("Press any key to begin the show!");
            Console.ReadKey();

            cappy.noteOn(1500);
            cappy.wait(500);

            // star spangled banner (really bad)

            cappy.noteOn(784);
            cappy.wait(1200);
            cappy.noteOn(659);
            cappy.wait(1000);
            cappy.wait(600);
            cappy.noteOn(523);
            cappy.wait(1200);
            cappy.noteOn(659);
            cappy.wait(1200);
            cappy.noteOn(784);
            cappy.wait(1200);
            cappy.noteOn(523);
            cappy.wait(2400);
            cappy.noteOn(659);
            cappy.wait(1200);
            cappy.noteOn(587);
            cappy.wait(600);
            cappy.noteOn(523);
            cappy.wait(1200);
            cappy.noteOn(659);
            cappy.wait(1200);
            cappy.noteOn(698);
            cappy.wait(1200);
            cappy.noteOn(784);
            cappy.wait(1500);
            cappy.noteOff();
            Console.WriteLine("You no longer have to listen to my sad attempt on the Star Spangled Banner! Yay! Onto the lights... ");
            Console.WriteLine("I'm pretty sure you know what colors they are.");

            // red, white, and blue

            cappy.setLED(255, 0, 0);
            cappy.wait(1000);
            cappy.setLED(255, 255, 255);
            cappy.wait(1000);
            cappy.setLED(0, 0, 255);
            cappy.wait(1000);
            cappy.setLED(255, 0, 0);
            cappy.wait(1000);
            cappy.setLED(255, 255, 255);
            cappy.wait(1000);
            cappy.setLED(0, 0, 255);
            cappy.wait(1000);
            cappy.setLED(255, 0, 0);
            cappy.wait(1000);
            cappy.setLED(255, 255, 255);
            cappy.wait(1000);
            cappy.setLED(0, 0, 255);
            cappy.wait(1000);
            cappy.setLED(0, 0, 0);

            Console.Clear();
            DisplayMenu();
        }
Пример #25
0
        /// <summary>
        /// display the main menu
        /// </summary>
        /// <param name="myFinch">Finch object</param>
        static void DisplayMainMenu(Finch myFinch)
        {
            string menuChoice;
            bool   exiting = false;

            int delayDuration    = 0;
            int numberOfCommands = 0;
            int motorSpeed       = 0;
            int LEDBrightness    = 0;
            //FinchCommand[] commands = null;
            List <FinchCommand> commands = new List <FinchCommand>();

            while (!exiting)
            {
                //
                // display menu
                //
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine("Main Menu");
                Console.WriteLine();

                Console.WriteLine("\t1) Get Command Parameters");
                Console.WriteLine("\t2) Get Finch Robot Commands");
                Console.WriteLine("\t3) Display Finch Robot Commands");
                Console.WriteLine("\t4) Execute Finch Robot Commands");
                Console.WriteLine("\tE) Exit");
                Console.WriteLine();
                Console.Write("Enter Choice:");
                menuChoice = Console.ReadLine();

                //
                // process menu
                //
                switch (menuChoice)
                {
                case "1":
                    numberOfCommands = DisplayGetNumberOfCommands();
                    delayDuration    = DisplayGetDelayDuration();
                    motorSpeed       = DisplayGetMotorSpeed();
                    LEDBrightness    = DisplayGetLEDBrightness();
                    break;

                case "2":
                    DisplayGetFinchCommands(commands, numberOfCommands);
                    break;

                case "3":
                    DisplayFinchCommands(commands);
                    break;

                case "4":
                    DisplayExecuteFinchCommands(myFinch, commands, motorSpeed, LEDBrightness, delayDuration);
                    break;

                case "e":
                case "E":
                    exiting = true;
                    break;

                default:
                    break;
                }
            }
        }
Пример #26
0
        static void UserProgrammingDisplayMenuScreen(Finch finchRobot)
        {
            Console.Clear();

            Console.CursorVisible = true;

            bool   quitMenu = false;
            string menuChoice;

            //
            // tuple
            //
            (int motorSpeed, int ledBrightness, double waitSeconds)commandParameters;
            commandParameters.ledBrightness = 0;
            commandParameters.motorSpeed    = 0;
            commandParameters.waitSeconds   = 0;

            List <Command> commands = new List <Command>();

            do
            {
                DisplayScreenHeader("User Programing Menu");

                //
                // get user menu choice
                //
                Console.WriteLine("\ta) set Command Parameters");
                Console.WriteLine("\tb) Add Commands");
                Console.WriteLine("\tc) View Commands");
                Console.WriteLine("\td) Execute Commands");
                Console.WriteLine("\tq) Return to Main Menu");
                Console.Write("\t\tEnter Choice:");
                menuChoice = Console.ReadLine().ToLower();

                //
                // process user menu choice
                //
                switch (menuChoice)
                {
                case "a":
                    commandParameters = UserProgrammingDisplayGetParameters();
                    break;

                case "b":
                    UserProgramingDisplayGetFinchCommands(commands);
                    break;

                case "c":
                    DisplayFinchCommands(commands);
                    break;

                case "d":
                    DisplayExecuteFinchCommands(finchRobot, commands, commandParameters);
                    break;

                case "q":
                    quitMenu = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("\tPlease enter a letter for the menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            } while (!quitMenu);
        }
Пример #27
0
        //
        //
        //          Data Recorder Menu
        //
        //
        //
        static void DataRecorderDisplayMenuScreen(Finch finchRobot)
        {
            int    numberOfDataPoints = 0;
            double dataPointFrequency = 0;

            double[] temperatures  = null;
            double[] LightReadings = null;

            Console.CursorVisible = true;

            bool   quitMenu = false;
            string menuChoice;

            do
            {
                DisplayScreenHeader("Data Recorder Menu");

                //
                // get user menu choice
                //
                Console.WriteLine("\ta) Number of Data Points");
                Console.WriteLine("\tb) Frequency of Data Points");
                Console.WriteLine("\tc) Get Temperature Data");
                Console.WriteLine("\td) Show Temperature Data");
                Console.WriteLine("\te) Get Light Data");
                Console.WriteLine("\tf) Show Light Sensor Data");
                Console.WriteLine("\tq) Main Menu");
                Console.Write("\t\tEnter Choice:");
                menuChoice = Console.ReadLine().ToLower();

                //
                // process user menu choice
                //
                switch (menuChoice)
                {
                case "a":
                    numberOfDataPoints = DataRecorderDidsplayGetNumberOfDataPoints();
                    break;

                case "b":
                    dataPointFrequency = DataRecorderDidsplayGetDataPointFrequency();
                    break;

                case "c":
                    temperatures = DataRecorderDisplayGetData(numberOfDataPoints, dataPointFrequency, finchRobot);
                    break;

                case "d":
                    DataRecorderDisplayGetData(temperatures);
                    break;

                case "e":
                    LightReadings = DataRecorderDisplayGetDataLights(numberOfDataPoints, dataPointFrequency, finchRobot);
                    break;

                case "f":
                    DataRecorderDisplayGetLightData(LightReadings);
                    break;

                case "q":
                    quitMenu = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("\tPlease enter a letter for the menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            } while (!quitMenu);
        }
Пример #28
0
        ///
        /// *****************************************************************
        /// *                     Main Menu                                 *
        /// *****************************************************************
        ///
        static void DisplayMenuScreen()
        {
            Console.CursorVisible = true;

            bool   quitApplication = false;
            string menuChoice;

            Finch finchRobot = new Finch();

            do
            {
                DisplayScreenHeader("Main Menu");

                //
                // get user menu choice
                //
                Console.WriteLine("\ta) Connect Finch Robot");
                Console.WriteLine("\tb) Talent Show");
                Console.WriteLine("\tc) Data Recorder");
                Console.WriteLine("\td) Alarm System");
                Console.WriteLine("\te) User Programming");
                Console.WriteLine("\tf) Disconnect Finch Robot");
                Console.WriteLine("\tq) Quit");
                Console.Write("\t\tEnter Choice:");
                menuChoice = Console.ReadLine().ToLower();

                //
                // process user menu choice
                //
                switch (menuChoice)
                {
                case "a":
                    DisplayConnectFinchRobot(finchRobot);
                    break;

                case "b":
                    DisplayTalentShowMenuScreen(finchRobot);
                    break;

                case "c":
                    DataRecorderMenuScreen(finchRobot);
                    break;

                case "d":
                    LightAlarmDisplayMenuScreen(finchRobot);
                    break;

                case "e":
                    UserProgrammingDisplayMenuScreen(finchRobot);
                    break;

                case "f":
                    DisplayDisconnectFinchRobot(finchRobot);
                    break;

                case "q":
                    DisplayDisconnectFinchRobot(finchRobot);
                    quitApplication = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("\tPlease enter a letter for the menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            } while (!quitApplication);
        }
Пример #29
0
        private static double[] DataRecorderDisplayGetData(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            //
            //  Temp
            //

            double[] temperatures = new double[numberOfDataPoints];
            DisplayScreenHeader("Get that Data!");

            Console.WriteLine($"Number of data points:{numberOfDataPoints}");

            Console.WriteLine($"The Frequency at which the data is displayed:{dataPointFrequency}");

            Console.WriteLine();
            Console.WriteLine("\tThe Finch Robot is ready to begin Recording your temperature Data!");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                temperatures[index] = ConvertToFarenheit(finchRobot.getTemperature());
                Console.WriteLine($"\tReading{index + 1}: {temperatures[index].ToString("n2")}");
                int waitInSeconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(waitInSeconds);
            }
            DisplayContinuePrompt();
            DisplayScreenHeader("Get Data");

            Console.WriteLine();
            Console.WriteLine("\tTable of Temperatures");
            Console.WriteLine();
            DataRecorderDisplayTable(temperatures);

            Console.WriteLine($"The avedrage of the readings is {temperatures.Average()}");

            DisplayContinuePrompt();

            return(temperatures);
        }
Пример #30
0
        // *************************************************************
        // Application:     Finch lights and temp
        // Author:          Eric Grant
        // Date Created:    9-20-2017
        // Date Revised:    9-20-2017
        // *************************************************************

        static void Main(string[] args)
        {
            // create a new Finch object
            //
            Finch myFinch = new Finch();

            //vars
            //
            double temp;
            double lightL;
            double lightR;
            bool   note = false;

            // call the connect method
            //
            bool isConnected;

            isConnected = myFinch.connect();
            Console.WriteLine($"isConnected = {isConnected}");
            Console.WriteLine("Any Key To Start\n");
            Console.ReadKey();

            // begin your code
            //

            //display temp
            //
            while (true)
            {
                temp   = myFinch.getTemperature();
                lightL = myFinch.getLeftLightSensor();
                lightR = myFinch.getRightLightSensor();
                Console.WriteLine($"temp = {temp}");
                Console.WriteLine($"left light = {lightL}\nright light = {lightR}\n");
                if (lightL > 70 && lightR < 70)
                {
                    myFinch.setLED(255, 0, 0);
                    myFinch.noteOn(750);
                    note = true;
                    Console.WriteLine("left light is lit");
                }
                else if (lightL < 70 && lightR > 70)
                {
                    myFinch.setLED(0, 255, 0);
                    myFinch.noteOn(250);
                    note = true;
                    Console.WriteLine("right light is lit");
                }
                else if (lightL > 70 && lightR > 70)
                {
                    myFinch.setLED(255, 255, 255);
                    myFinch.noteOn(500);
                    note = true;
                    Console.WriteLine("both lights are lit");
                }
                else if (lightL < 70 && lightR < 70)
                {
                    myFinch.setLED(0, 0, 0);
                    if (note == true)
                    {
                        myFinch.noteOff();
                        note = false;
                    }
                    Console.WriteLine("no light is lit");
                }
                myFinch.wait(100);
                Console.Clear();
            }

            //end of your code
            //

            // call the disconnect method
            //
            Console.WriteLine("\nAny Key To End");
            Console.ReadKey();
            myFinch.disConnect();
        }
Пример #31
0
        private static double[] DataRecorderDisplayGetDataLights(int numberOfDataPoints, double dataPointFrequency, Finch finchRobot)
        {
            double[] LightReadings = new double[numberOfDataPoints];
            DisplayScreenHeader("Get that Data!");

            Console.WriteLine($"Number of data points:{numberOfDataPoints}");

            Console.WriteLine($"The Frequency at which the data is displayed:{dataPointFrequency}");

            Console.WriteLine();
            Console.WriteLine("\tThe Finch Robot is ready to begin Recording your Light Sensor Data!");
            DisplayContinuePrompt();

            for (int index = 0; index < numberOfDataPoints; index++)
            {
                LightReadings[index] = finchRobot.getRightLightSensor();
                Console.WriteLine($"\tReading{index + 1}: {LightReadings[index].ToString("n2")}");
                int waitInSeconds = (int)(dataPointFrequency * 1000);
                finchRobot.wait(waitInSeconds);
            }
            DisplayContinuePrompt();
            DisplayScreenHeader("Get Data");

            Console.WriteLine();
            Console.WriteLine("\tTable of Light Sensor Data");
            Console.WriteLine();
            DataRecorderDisplayTable(LightReadings);

            Console.WriteLine($"The avedrage of the readings is {LightReadings.Average()}");

            DisplayContinuePrompt();

            return(LightReadings);
        }