Esempio n. 1
0
 private void connect_Click(object sender, EventArgs e)
 {
     if (port.IsOpen)
     {
         port.Close();
         connect.Text = "Connect";
     }
     else
     {
         try
         {
             int    baudRate = Convert.ToInt32(this.baudBox.Text);
             string portName = comboBox1.Text;
             port.Open(portName, baudRate);
             connect.Text = "Disconnect";
         }
         catch (NullReferenceException)
         {
             MessageBox.Show("Error Opening Com Port: No Port Name Selected!");
         }
         catch (FormatException)
         {
             MessageBox.Show("Error Opening Com Port: Invalid Baud Rate!");
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error Opening Com Port: " + ex.Message);
         }
     }
 }
Esempio n. 2
0
        public static void Scan(string portName)
        {
            var port = new SerialPortWrapper(portName);

            if (!port.Open())
            {
                Console.WriteLine("Failed to open specified port. Exiting.");
                return;
            }

            port.WriteByte(I2CCommands.SCAN);
            var devicesCount = port.ReadByte();

            if (devicesCount == 0)
            {
                Console.WriteLine("No devices found.");
                return;
            }

            var devices = port.ReadBytes(devicesCount);

            Console.WriteLine($"Found {devicesCount} devices:");
            foreach (byte d in devices)
            {
                if (d > 127)
                {
                    Console.WriteLine($"{d - 128:X2} [ERROR]");
                }
                else
                {
                    Console.WriteLine($"{d:X2}");
                }
            }
        }
Esempio n. 3
0
        public static void IdentifyInteface(string portName)
        {
            var port = new SerialPortWrapper(portName);

            if (!port.Open())
            {
                Console.WriteLine("Failed to open specified port. Exiting.");
                return;
            }

            port.WriteByte(I2CCommands.IDENT);
            var size = port.ReadByte();

            Console.WriteLine(port.ReadString(size));
        }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     if ((sound_1) && (!source.isPlaying))
     {
         source.clip = audioo[0];
         source.Play();
         sound_1 = false;
         girl.GetComponent <Animator>().Play("speak");
     }
     if ((sound_2) && (!source.isPlaying))
     {
         source.clip = audioo[1];
         source.Play();
         sound_2 = false;
         girl.GetComponent <Animator>().Play("speak 3");
         backs[0].SetActive(false);
         backs[1].SetActive(true);
     }
     if ((sound_3) && (!source.isPlaying))
     {
         source.clip = audioo[2];
         source.Play();
         sound_3 = false;
         girl.GetComponent <Animator>().Play("speak 4");
     }
     if ((sound_4) && (!source.isPlaying))
     {
         source.clip = audioo[3];
         source.Play();
         sound_4 = false;
         girl.GetComponent <Animator>().Play("speak 5");
         backs[0].SetActive(true);
         backs[1].SetActive(false);
         backs[2].SetActive(true);
         backs[3].SetActive(true);
     }
     if (start)
     {
         girl.GetComponent <Animator>().Play("idle 1");
         sp.Open();
         sp.ReadTimeout = 1;
         InvokeRepeating("Resolocation", 0.1f, 0.132f);
         Invoke("stopi", 15f);
         start = false;
     }
 }
Esempio n. 5
0
    void Update()
    {
        for (int i = 0; i < 21; i++)
        {
            if (lamp1[i].activeSelf == true)
            {
                int j = (i + 1) / 5;
                for (int k = 0; k < j; k++)
                {
                    gg[k].SetActive(true);
                }
            }
            if (i < 21)
            {
                int a = i + 1 / 5;
                for (int e = a; e < 4; e++)
                {
                    gg[e].SetActive(false);
                }
            }
        }

        if ((sound_1) && (!source.isPlaying))
        {
            source.clip = audioo[0];
            source.Play();
            sound_1 = false;
            girl.GetComponent <Animator>().Play("speak");
        }
        if ((sound_2) && (!source.isPlaying))
        {
            source.clip = audioo[1];
            source.Play();
            sound_2 = false;
            girl.GetComponent <Animator>().Play("speak 1");
        }
        if ((sound_3) && (!source.isPlaying))
        {
            source.clip = audioo[2];
            source.Play();
            sound_3 = false;
            girl.GetComponent <Animator>().Play("speak 2");
        }
        if ((sound_4) && (!source.isPlaying))
        {
            source.clip = audioo[3];
            source.Play();
            sound_4 = false;
            girl.GetComponent <Animator>().Play("speak 5");
        }
        if ((sound_5) && (!source.isPlaying))
        {
            source.clip = audioo[4];
            source.Play();
            sound_5 = false;
            girl.GetComponent <Animator>().Play("speak 6");
        }
        if ((sound_6) && (!source.isPlaying))
        {
            source.clip = audioo[5];
            source.Play();
            sound_6 = false;
            girl.GetComponent <Animator>().Play("speak 7");
        }
        if ((sound_7) && (!source.isPlaying))
        {
            source.clip = audioo[6];
            source.Play();
            sound_7 = false;
            girl.GetComponent <Animator>().Play("speak 8");
        }
        if ((sound_8) && (!source.isPlaying))
        {
            source.clip = audioo[7];
            source.Play();
            sound_8 = false;
            girl.GetComponent <Animator>().Play("speak 9");
        }

        if (start)
        {
            sp.Open();
            sp.ReadTimeout = 1;
            girl.GetComponent <Animator>().Play("idle 0");
            InvokeRepeating("Resolocation", 0.01f, 0.1f);
            Invoke("stopi", 15f);
            start = false;
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if ((sound_1) && (!source.isPlaying))
        {
            source.clip = audioo[0];
            source.Play();
            sound_1 = false;
            girl.GetComponent <Animator>().Play("speak");
        }
        if (hotfree)
        {
            girl.GetComponent <Animator>().Play("idle");
            Fish.GetComponent <Animator>().Play("freezing");
            Invoke("frost", 1f);
            hotfree = false;
        }
        if ((sound_2) && (!source.isPlaying))
        {
            source.clip = audioo[1];
            source.Play();
            sound_2 = false;
            girl.GetComponent <Animator>().Play("speak 3");
        }
        if ((sound_3) && (!source.isPlaying))
        {
            source.clip = audioo[2];
            source.Play();
            sound_3 = false;
            girl.GetComponent <Animator>().Play("speak 6");
        }
        if ((sound_6) && (!source.isPlaying))
        {
            source.clip = audioo[7];
            source.Play();
            sound_6 = false;
            girl.GetComponent <Animator>().Play("speak 12");
        }
        if ((sound_7) && (!source.isPlaying))
        {
            source.clip = audioo[9];
            source.Play();
            sound_7 = false;
            girl.GetComponent <Animator>().Play("speak 16");
            Fish.GetComponent <Animator>().Play("idle");
        }
        if ((sound_8) && (!source.isPlaying))
        {
            source.clip = audioo[10];
            source.Play();
            sound_8 = false;
            girl.GetComponent <Animator>().Play("speak 18");
        }
        if ((sound_9) && (!source.isPlaying))
        {
            source.clip = audioo[12];
            source.Play();
            sound_9 = false;
            girl.GetComponent <Animator>().Play("speak 20");
        }
        if ((sound_10) && (!source.isPlaying))
        {
            source.clip = audioo[13];
            source.Play();
            sound_10 = false;
            girl.GetComponent <Animator>().Play("speak 24");
        }

        /*   if ((sound_4) && (!source.isPlaying))
         * {
         *     source.clip = audioo[3];
         *     source.Play();
         *     sound_4 = false;
         * }*/

        if (start)
        {
            girl.GetComponent <Animator>().Play("idle 0");
            if (!sp.IsOpen)
            {
                k++;
                if (k < 10)
                {
                    sp.Open();
                    sp.ReadTimeout = 1;
                    start          = false;
                    InvokeRepeating("Resolocation", 0.1f, 0.1f);//если меньше 10 фпс ставьте повторения на 0.132f
                }
            }
            if (k == 10)
            {
                if (!source.isPlaying)
                {
                    source.clip = audioo[17];
                    source.Play();
                }
                girl.GetComponent <Animator>().Play("speak 34");
            }
        }
    }