Пример #1
0
        /// <summary>
        /// Initialize the Finch robot
        /// </summary>
        private static void InitializeFinch(Finch myFinch)
        {
            Console.Clear();

            Console.WriteLine();
            Console.WriteLine("Attempting to connect to the Finch robot.");
            Console.WriteLine();

            myFinch.connect();

            //
            // Audio/visual feedback to user
            //
            for (int increment = 0; increment < 255; increment += 10)
            {
                myFinch.setLED(0, increment, 0);
                //myFinch.noteOn(increment * 100);
                myFinch.wait(200);
            }
            myFinch.setLED(0, 0, 0);
            myFinch.noteOff();

            Console.Clear();

            Console.WriteLine();
            Console.WriteLine("The Finch robot is now connected.");
            Console.WriteLine();

            DisplayContinuePrompt();
        }
Пример #2
0
        //
        // display connect finch robot
        //
        static bool DisplayConnectFinchRobot(Finch finchRobot)
        {
            bool finchRobotConnected = false;

            DisplayScreenHeader("Connect Finch Robot");

            Console.WriteLine("Ready to connect to the Finch Robot. Please be sure to connect the USB cable to the robot and the computer.");
            DisplayContinuePrompt();
            Console.Clear();
            Console.WriteLine();

            finchRobotConnected = finchRobot.connect();

            if (finchRobotConnected)
            {
                finchRobot.setLED(0, 255, 0);
                finchRobot.noteOn(15000);
                finchRobot.wait(250);
                finchRobot.noteOff();
                finchRobot.setLED(0, 0, 0);

                Console.WriteLine();
                Console.WriteLine("Finch robot is now connected.");
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine("Unable to connect to the Finch robot.");
            }

            DisplayContinuePrompt();

            return(finchRobotConnected);
        }
Пример #3
0
        /// <summary>
        /// *****************************************************************
        /// *                  Connect the Finch Robot                      *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>
        /// <returns>notify if the robot is connected</returns>
        static bool DisplayConnectFinchRobot(Finch myFinch)
        {
            Console.CursorVisible = false;

            bool robotConnected;

            DisplayScreenHeader("Connect Finch Robot");

            Console.WriteLine("\tAbout to connect to Finch robot. Please be sure the USB cable is connected to the robot and computer now.");
            DisplayContinuePrompt();

            robotConnected = myFinch.connect();

            // TODO test connection and provide user feedback - text, lights, sounds

            DisplayMenuPrompt("Main Menu");

            //
            // reset finch robot
            //
            myFinch.setLED(0, 0, 0);
            myFinch.noteOff();

            return(robotConnected);
        }
Пример #4
0
        /// <summary>
        ///                   Connect the Finch Robot
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>
        /// <returns>notify if the robot is connected</returns>
        static bool DisplayConnectFinchRobot(Finch finchRobot)
        {
            Console.CursorVisible = false;

            bool robotConnected;

            DisplayScreenHeader("Connecting to Finch Robot");

            Console.WriteLine("\tYou're about to connect to a Finch robot, please be sure the USB cable is connected to");
            Console.WriteLine();
            Console.WriteLine("\tthe robot and computer now.");
            Console.WriteLine();
            DisplayContinuePrompt();

            robotConnected = finchRobot.connect();

            // TODO test connection and provide user feedback - text, lights, sounds
            Console.WriteLine("\tYou're now connected.");
            Console.WriteLine();
            DisplayMenuPrompt("Main");

            //
            // reset finch robot
            //
            finchRobot.setLED(0, 0, 0);
            finchRobot.noteOff();

            return(robotConnected);
        }
Пример #5
0
        static Finch InstantiateTim()
        {
            Finch tim = new Finch();

            tim.connect();
            return(tim);
        }
Пример #6
0
        /// <summary>
        /// Connect the finch and test to see if it has a connection and pull the temperature.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frm_FinchConnect_Click_Click(object sender, EventArgs e)
        {
            bool robotConnected;

            robotConnected = finchRobot.connect();
            if (robotConnected)
            {
                finchRobot.noteOn(880);
                finchRobot.setLED(255, 0, 0);
                finchRobot.wait(100);
                finchRobot.noteOn(988);
                finchRobot.setLED(0, 255, 0);
                finchRobot.wait(100);
                finchRobot.noteOn(1047);
                finchRobot.setLED(0, 0, 255);
                finchRobot.wait(100);
                finchRobot.noteOff();
                finchRobot.setLED(0, 0, 0);

                MessageBox.Show("Your Finch robot is now connected!",
                                "Finch Connected");
            }
            else
            {
                MessageBox.Show("Your Finch could not be connectd, please check to see if it is plugged in and try again", "Connection Error");
            }

            txb_Temp.Text = finchRobot.getTemperature().ToString();
        }
        /// <summary>
        /// *****************************************************************
        /// *               Disconnect the Finch Robot                      *
        /// *****************************************************************
        /// </summary>
        /// <param name="myFinch">finch robot object</param>
        static void DisplayDisconnectFinchRobot(Finch myFinch)
        {

            Console.CursorVisible = false;

            bool robotConnected;

            DisplayScreenHeader("Disconnect Finch Robot");

            Console.WriteLine("\tAbout to disconnect from the Finch robot.");
            DisplayContinuePrompt();

            robotConnected = myFinch.connect();

            if (robotConnected)
            { 
                myFinch.disConnect();
                Console.WriteLine("\tThe Finch robot is disconnected.");
            }
            else
            {
                Console.WriteLine("\tThe Finch robot is already disconnected.");
            }

            DisplayMenuPrompt("Main Menu");
        }
Пример #8
0
        // *************************************************************
        // Application:     Finch Control

        // Author:          Hailey McGuire
        // Description:     Finch Starter - Data Recorder
        // Application Type: Console
        // Date Created:    02/09/2021
        // Date Revised:    02/28/2021
        // *************************************************************

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

            myFinch = new Finch();

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

            //
            // begin your code
            //

            MainAppTheme();

            DisplayWelcomeScreen();

            MainMenu();

            DisplayClosingScreen();

            //
            // call the disconnect method
            //
            myFinch.disConnect();
        }
Пример #9
0
        static void Main(string[] args)
        {
            Sam.connect();
            DisplayWelcomeScreen();
            FinchShields shieldLevel = GetUserShieldLevel();
            int          speed       = 0;

            ambientTemperature = GetTempature();

            switch (shieldLevel)
            {
            case FinchShields.HIGH:
                speed = 100;
                break;

            case FinchShields.MEDIUM:
                speed = 75;
                break;

            case FinchShields.LOW:
                speed = 50;
                break;

            default:
                break;
            }

            DisplayContinuePrompt();
            Console.Clear();
            MoveSamForward(speed);
            Console.WriteLine("Super Finch is marching forward into battle!");

            do
            {
                switch (shieldLevel)
                {
                case FinchShields.HIGH:
                    Sam.setLED(0, 255, 0);
                    break;

                case FinchShields.MEDIUM:
                    Sam.setLED(0, 0, 255);
                    break;

                case FinchShields.LOW:
                    Sam.setLED(255, 0, 0);
                    break;

                default:
                    break;
                }

                shieldLevel = HitDetection(shieldLevel);
            } while (shieldLevel != FinchShields.FAILED);

            Sam.setMotors(0, 0);
            Console.WriteLine("Game Over!");
            DisplayContinuePrompt();
        }
Пример #10
0
        /// <summary>
        /// Instantiate a new finch named tim
        /// </summary>
        /// <returns>tim the finch</returns>
        static Finch InstantiateFinch()
        {
            PrintHeader("Connect Tim Robot");
            Finch tim = new Finch();

            Console.WriteLine($"Tim connected: {tim.connect()}");
            DisplayAnyKey();
            return(tim);
        }
Пример #11
0
        //**************************************************************
        //
        // TALENT SHOW DANCE
        //
        //***************************************************************
        static void DisplayDance(Finch myFinch)
        {
            myFinch = new Finch();
            string speedOfLeft;
            string speedOfRight;


            Console.CursorVisible = false;

            DisplayScreenHeader("Dance");


            Console.WriteLine("Your finch robot will begin moving in a square.");



            int noOfTimes = 2;

            for (int movement = 0; movement < Convert.ToInt32(noOfTimes); movement++)
            {
                myFinch.setMotors(150, 150);
                myFinch.wait(500);
                myFinch.setMotors(-35, 35);
                myFinch.wait(500);
                myFinch.setMotors(150, 150);
                myFinch.wait(500);
                myFinch.setMotors(-35, 35);
                myFinch.wait(500);
                myFinch.setMotors(150, 150);
                myFinch.wait(500);
                myFinch.setMotors(-35, 35);
                myFinch.wait(500);
                myFinch.setMotors(150, 150);
                myFinch.wait(500);
                myFinch.setMotors(-35, 35);
            }
            Console.WriteLine("Press any key to continue and be able to put in your own pattern for the Finch robot.");
            Console.ReadKey();
            Console.Clear();

            Console.Write("Please enter speed of left motor (-255 to 255):");
            speedOfLeft = Console.ReadLine();

            Console.Write("Please enter speed of right motor (-255 to 255):");
            speedOfRight = Console.ReadLine();

            Console.WriteLine("\tThe Finch robot will now move according to your input!");
            DisplayContinuePrompt();

            myFinch.connect();

            myFinch.setMotors(Convert.ToInt32(speedOfLeft), Convert.ToInt32(speedOfRight));

            DisplayContinuePrompt();
            DisplayMenuPrompt("Talent Show Menu");
        }
Пример #12
0
        // Displaying menu
        static void DisplayMenu()
        {
            string decision;

            Console.WriteLine();
            Console.WriteLine("MENU");
            Console.WriteLine();
            Console.WriteLine("Type USA for a patriotic light and movement show");
            Console.WriteLine("Type RAINBOW for a rainbow light and movement show");
            Console.WriteLine("Type SURPRISE for a surprise light and movement show");
            Console.WriteLine("Type 'QUIT' to quit");
            Console.WriteLine();
            decision = Console.ReadLine().ToUpper();

            // users type the show they want or quit
            // once the users type this, the switch statement will call the required method

            Finch cappy = new Finch();

            cappy.connect();

            switch (decision)
            {
            case "USA":

                DisplayPatrioticShow(cappy);

                break;

            case "RAINBOW":

                DisplayRainbowShow(cappy);

                break;

            case "SURPRISE":

                DisplaySurpriseShow(cappy);

                break;

            case "QUIT":

                DisplayClosingScreen();
                cappy.disConnect();
                break;

            default:
                Console.Clear();
                Console.WriteLine("Please enter a correct value.");
                DisplayMenu();
                break;

                // if the users type something the code will not accept, it will clear the screen and tell the user to enter a correct value
            }
        }
Пример #13
0
        private static void DisplayAlarmSystem(Finch fn)
        {
            Console.CursorVisible = true;

            fn.connect();
            bool quitAlarm = false;

            string sensorsToMonitor     = "";
            string rangeType            = "";
            int    minMaxThresholdValue = 0;
            int    timeToMonitor        = 0;

            do
            {
                DisplayHeader("\n\tAlarm System");
                Console.WriteLine("\n\tWhat would you like to do?");
                Console.WriteLine("\ta) Set sensors to monitor");
                Console.WriteLine("\tb) Set range type");
                Console.WriteLine("\tc) Set minumum/maximum threshold");
                Console.WriteLine("\td) Set time to monitor");
                Console.WriteLine("\te) Set alarm");
                Console.WriteLine("\tf) Return to main menu");
                DisplayChooseAnOption();
                string MenuChoice = Console.ReadLine().ToLower();
                switch (MenuChoice)
                {
                case "a":
                    sensorsToMonitor = LightAlarmDisplaySetSensorstoMonitor();
                    break;

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

                case "c":
                    minMaxThresholdValue = LightAlarmDisplaySetMinMaxThresholdValue(fn, rangeType);
                    break;

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

                case "e":
                    LightAlarmDisplaySetAlarm(fn, timeToMonitor, rangeType, minMaxThresholdValue, sensorsToMonitor);
                    break;

                case "f":
                    quitAlarm = true;
                    break;

                default:
                    DisplayIncorrectInput();
                    break;
                }
            } while (!quitAlarm);
        }
Пример #14
0
        /// <summary>
        /// Screen that runs the gameplay:
        /// </summary>
        /// <param name="myFinch"></param>
        /// <param name="myFinchOperator"></param>
        /// <param name="difficulty"></param>
        static void DisplayGameInProgress(Finch myFinch, FinchOperator myFinchOperator)
        {
            // Instantiates a new hit tracker:
            Monitor hitTracker = new Monitor();
            int     timeInLoop = 0;

            //Variables:
            myFinchOperator.isDefeated = false;

            // Resets Finch Operator to default hitpoints.
            myFinchOperator.HitsSuffered = 0;


            DisplayHeader("DARTH FINCH");
            Console.WriteLine();

            Console.WriteLine("\t\tInitializing...");

            // Just in case the user attempts to run the game without a Finch - it doesn't crash, but it doesn't make sense either.
            if (!myFinch.connect())
            {
                DisplayHeader("DARTH FINCH");
                Console.WriteLine("\tNo finch detected. Please connect a Finch before proceeding!");
                DisplayContinuePrompt();
                FinchOperator.EstablishFinchConnection(myFinch);
            }

            // Little indicator that the game has begun:
            FinchOperator.PlayImpMarchShort(myFinch);

            // Main Gameplay Loop:
            while (!myFinchOperator.isDefeated && timeInLoop <= myFinchOperator.TimeAvailable)
            {
                DisplayHeader("DARTH FINCH:");

                Console.WriteLine("\tDarth Finch is active!");
                Console.WriteLine("\tTime Remaining:" + $"[{myFinchOperator.TimeAvailable - timeInLoop}]");
                DisplayHealthStatus(myFinchOperator);

                //hitTracker.IsFrozen = Monitor.FreezeDetection(myFinch);
                //hitTracker.IsHit = Monitor.HitDetection(myFinch);

                DisplayVulnerbilityStatus(myFinch, hitTracker, myFinchOperator);
                myFinch.wait(500);

                myFinchOperator.isDefeated = CheckHealth(myFinchOperator);

                FinchOperator.LEDSettings(myFinch, myFinchOperator);
                // FinchOperator.MotorSettings(myFinch, myFinchOperator); Disabling this for the time being.
                myFinch.wait(500);
                timeInLoop++;
            }
        }
Пример #15
0
 static void DisplayInitializeFinch(Finch edi)
 {
     if (edi.connect())
     {
         Console.WriteLine("Finch is connected. Press any key to begin.");
         Console.ReadKey();
     }
     else
     {
         Console.WriteLine("Finch is not connected, you won't get the full experience unfortunately. You can still continue anyway.");
         Console.ReadKey();
     }
 }
Пример #16
0
        static void DisplayConnectToFinch(Finch finch)
        {
            int note = 300;

            finch.connect();
            for (int i = 0; i < 10; i++)
            {
                finch.noteOn(note);
                finch.wait(5);
                finch.noteOff();
                note = note + 100;
            }
        }
Пример #17
0
        private static void DisplayUserProgramming(Finch fn)
        {
            fn.connect();
            bool quitUP = false;

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

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

            do
            {
                DisplayHeader("User Programming");
                Console.WriteLine("\n\tWhat would you like to do?");
                Console.WriteLine("\ta) Set command parameters");
                Console.WriteLine("\tb) Add commands");
                Console.WriteLine("\tc) View commands");
                Console.WriteLine("\td) Execute commands");
                Console.WriteLine("\te) Return to main menu");
                DisplayChooseAnOption();
                string MenuChoice = Console.ReadLine().ToLower();
                switch (MenuChoice)
                {
                case "a":
                    commandParameters = DisplayUserProgrammingGetCommandsParamter();
                    break;

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

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

                case "d":
                    DisplayUserProgrammingExecuteFinchCommands(fn, commands, commandParameters);
                    break;

                case "e":
                    quitUP = true;
                    break;

                default:
                    DisplayIncorrectInput();
                    break;
                }
            } while (!quitUP);
        }
Пример #18
0
        private static void AdvoidLightAndObsticales(Finch alma)
        {
            alma.connect();
            int light;
            int lightThreshold = 8;



            DisplayHeader("Finch flees before the spotlight");
            Console.WriteLine("Finch will Avoid the spotlight (flashlight) for 10 seconds. The Finch will also Avoid  Obsitacls");

            light = alma.getRightLightSensor();

            for (int i = 0; i < 17; i++)
            {
                alma.setMotors(100, 100);
                alma.setLED(0, 255, 0);
                alma.wait(500);

                //
                //avoid light
                //
                if ((lightThreshold + light) < alma.getRightLightSensor())
                {
                    alma.setMotors(255, 0);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                    alma.setMotors(255, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(1500);
                    alma.setMotors(0, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }
                if (alma.isObstacleLeftSide())
                {
                    alma.setMotors(0, 255);
                    alma.setLED(255, 0, 0);
                    alma.wait(500);
                }

                else if (alma.isObstacleRightSide())
                {
                    alma.setMotors(255, 0);
                    alma.setLED(255, 0, 0);
                }
            }
            alma.disConnect();
            DisplayContinuePrompt();
        }
Пример #19
0
        private static void DisplayDataRecorder(Finch fn)
        {
            Console.CursorVisible = true;
            int    numberOfDataPoints = 0;
            double dataPointFrequency = 0;

            double[] temperatures = null;

            fn.connect();
            bool quitData = false;

            do
            {
                DisplayHeader("\n\tData Recorder");
                Console.WriteLine("\n\tWhat would you like to see?");
                Console.WriteLine("\ta) Number of Data Points");
                Console.WriteLine("\tb) Frequency of Data Points");
                Console.WriteLine("\tc) Get Data");
                Console.WriteLine("\td) Show Data");
                Console.WriteLine("\te) Return to main menu");
                DisplayChooseAnOption();
                string MenuChoice = Console.ReadLine().ToLower();
                switch (MenuChoice)
                {
                case "a":
                    numberOfDataPoints = DataRecorderDisplayGetNumberOfDataPoints();
                    break;

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

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

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

                case "e":
                    quitData = true;
                    break;

                default:
                    DisplayIncorrectInput();
                    break;
                }
            } while (!quitData);
        }
Пример #20
0
 private static void TestFinchConnection(Finch myFinch)
 {
     do
     {
         Console.WriteLine("Wait a minute...");
         Thread.Sleep(2000);
         Console.WriteLine("Why am I not awake?");
         Console.WriteLine("Please check connection plz then hit any key to continue my boot up.");
         Console.ReadKey();
     } while (!myFinch.connect());
     if (myFinch.connect() == true)
     {
         Console.WriteLine("Wait....that was meant for later.");
         for (int i = 0; i < 5; i++)
         {
             Console.WriteLine(".");
             Thread.Sleep(1000);
         }
         Console.WriteLine("Sorry lets continue to main menu.");
         Thread.Sleep(5000);
         Console.Clear();
     }
 }
Пример #21
0
        static void DisplayMenu()
        {
            string menuChoice;
            bool   exiting = false;
            Finch  myfinch = new Finch();

            myfinch.connect();
            double lowerTempThreshold  = 0;
            double lowerLightThreshold = 0;


            while (!exiting)
            {
                DisplayHeader("Main Menu");

                Console.WriteLine("1)Setup");
                Console.WriteLine("2)Activate Sentry Bot");
                Console.WriteLine("3) Light Threshold");
                Console.WriteLine("E) Exit");
                Console.WriteLine();
                Console.WriteLine("Enter Menu Choice");
                menuChoice = Console.ReadLine();

                switch (menuChoice)
                {
                case "1":
                    lowerTempThreshold = DisplaySetup(myfinch, out lowerLightThreshold);
                    break;

                case "2":
                    DisplayActivateSentrybot(lowerTempThreshold, myfinch, lowerLightThreshold);
                    break;

                case "3":

                    break;

                case "E":
                case "e":
                    exiting = true;
                    myfinch.disConnect();
                    break;

                default:
                    Console.WriteLine("Please enter a valid menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            }
        }
        /// <summary>
        /// connect to Finch Robot
        /// </summary>
        static void DisplayConnectToFinch(Finch freddy)
        {
            DisplayHeader("Connect to Finch");

            if (freddy.connect())
            {
                Console.WriteLine("Finch Robot is connected and ready.");
            }
            else
            {
                Console.WriteLine("Finch Robot is not connect. Please check the wires.");
            }

            DisplayContinuePrompt();
        }
Пример #23
0
        /// <summary>
        /// instantiate and assign SuperTina the Finch
        /// </summary>
        /// <returns>Finch SuperTina</returns>
        static Finch InstantiateFinch()
        {
            Finch SuperTina = new Finch();

            if (SuperTina.connect())
            {
                Console.WriteLine("Super Tina is here.");
            }
            else
            {
                Console.WriteLine("Super Tina didn't show up.");
            }

            return(SuperTina);
        }
Пример #24
0
        public Form1()
        {
            InitializeComponent();

            if (tina.connect())
            {
                txtConnected.Text = "True";
            }
            else
            {
                txtConnected.Text = "False";
            }

            nudSpeed.Value = speed;
        }
Пример #25
0
        static void DisplayMenu()
        {
            bool  exiting   = false;
            Finch sentryBot = new Finch();

            sentryBot.connect();
            double lowerTempThreshold  = 0;
            int    upperLightThreshold = 0;

            while (!exiting)
            {
                Console.Clear();

                DisplayHeader("Main Menu");
                Console.WriteLine("1) Display Setup");
                Console.WriteLine("2) Activate Sentry Bot");
                Console.WriteLine("E) Exit");
                Console.WriteLine();
                Console.WriteLine("Enter Menu Choice: ");

                switch (Console.ReadLine())
                {
                case "1":
                    Console.Clear();
                    lowerTempThreshold  = DisplayTempSetup(sentryBot);
                    upperLightThreshold = DisplayLightSetup(sentryBot);
                    break;

                case "2":
                    Console.Clear();
                    DisplayActivateSentryBot(lowerTempThreshold, upperLightThreshold, sentryBot);
                    break;

                case "e":
                case "E":
                    Console.Clear();
                    exiting = true;
                    sentryBot.disConnect();
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("Please enter a valid menu choice.");
                    DisplayContinue();
                    break;
                }
            }
        }
Пример #26
0
        /// <summary>
        /// connect to Finch Robot
        /// </summary>
        static void DisplayConnectToFinch()
        {
            DisplayHeader("Connect to Finch");

            if (tim.connect())
            {
                Console.WriteLine("Finch Robot is connected and ready.");
                tim.setLED(100, 100, 100);
            }
            else
            {
                Console.WriteLine("Finch Robot is not connect. Please check the wires.");
            }

            DisplayContinuePrompt();
        }
Пример #27
0
        /// <summary>
        /// display initialize screen
        /// </summary>
        static void DisplayInitializeFinch()
        {
            DisplayScreen("Initialize Finch");
            finchActive = tim.connect();

            Console.WriteLine($"Finch connected: {finchActive}");
            if (finchActive)
            {
                tim.noteOn(500);
                tim.setLED(255, 255, 255);
                tim.wait(500);
                tim.setLED(0, 0, 0);
                tim.noteOff();
            }

            DisplayAnyKey();
        }
Пример #28
0
        static void DisplayMenu()
        {
            //
            // variables
            //
            string karaokeSong;

            gloria.connect();
            double paparazziLightThreshold = 0;


            //
            // Display instructions message
            //
            Console.WriteLine("Gloria, a Finch robot, is a terrible singer but she loves karaoke!");
            Console.WriteLine();
            Console.WriteLine("Also when the song is over, flashing lights or 'paparazzi' flash photography make her dance!");
            Console.WriteLine("Have fun!");
            Console.WriteLine();

            //
            // Get song choice from user
            //
            Console.WriteLine("Please enter 1, 2 or 3 for your song choice for Karaoke legend Gloria:");
            karaokeSong = Console.ReadLine();

            switch (karaokeSong)
            {
            case "1":
                KaraokeSongOne(paparazziLightThreshold);
                break;

            case "2":
                KaraokeSongTwo(paparazziLightThreshold);
                break;

            case "3":
                KaraokeSongThree(paparazziLightThreshold);
                break;

            default:
                Console.WriteLine("Sorry, invalid song choice. Unable to continue.");
                Console.WriteLine("Music time is over!");
                break;
            }
        }
        /// <summary>
        /// *****************************************************************
        /// *                  Connect the Finch Robot                      *
        /// *****************************************************************
        /// </summary>
        /// <param name="finchRobot">finch robot object</param>
        /// <returns>notify if the robot is connected</returns>
        static bool DisplayConnectFinchRobot(Finch finchRobot)
        {
            Console.CursorVisible = false;

            bool robotConnected;

            DisplayScreenHeader("Connect Finch Robot");

            Console.WriteLine("\tAbout to connect to Finch robot. Please be sure the USB cable is connected to the robot and computer now.");
            DisplayContinuePrompt();

            robotConnected = finchRobot.connect();

            // Test connection and provide user feedback - text, lights, sounds

            if (robotConnected == true)
            {
                Console.WriteLine("\tFinch robot successfully connected");
                finchRobot.setLED(0, 255, 0);
                finchRobot.noteOn(500);
                finchRobot.wait(500);
                finchRobot.noteOn(1000);
                finchRobot.wait(500);
                finchRobot.noteOff();
                finchRobot.setLED(0, 0, 0);
            }
            else
            {
                Console.WriteLine("\tFailed to connect. Please try again");
                finchRobot.setLED(255, 0, 0);
                finchRobot.noteOn(100);
                finchRobot.wait(1000);
                finchRobot.noteOff();
            }

            DisplayMenuPrompt("Main Menu");

            //
            // reset finch robot
            //
            finchRobot.setLED(0, 0, 0);
            finchRobot.noteOff();

            return(robotConnected);
        }
Пример #30
0
        static void DisplayMenu()
        {
            bool   exiting = false;
            string menuChoice;
            Finch  steve = new Finch();

            steve.connect();
            double lowerTempThreshold  = 0;
            double upperLightThreshold = 0;

            while (!exiting)
            {
                DisplayHeader("Main Menu");
                Console.WriteLine("1) Setup");
                Console.WriteLine("2) Activate Sentry Bot");
                Console.WriteLine("E) Exit");
                Console.WriteLine();
                Console.Write("Enter Menu Choice:");
                menuChoice = Console.ReadLine();

                switch (menuChoice)
                {
                case "1":
                    lowerTempThreshold  = SetupTemp(steve);
                    upperLightThreshold = SetupLight(steve);
                    break;

                case "2":
                    ActivateSentryBot(lowerTempThreshold, upperLightThreshold, steve);
                    break;

                case "E":
                case "e":
                    exiting = true;
                    steve.disConnect();
                    break;

                default:
                    Console.WriteLine("Please enter a proper menu choice.");
                    DisplayContinuePrompt();
                    break;
                }
            }
        }
Пример #31
0
        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();
        }