Beispiel #1
0
        public Sensordata readBluetooth()
        {
            String[] values = arduinoPort.ReadLine().Split('~');
            //string totalInput = "";
            //string actualValue = "";

            String[] firstValue = values[0].Split(',');

            #region New Code

            int sensorFront = getActualValue(firstValue[0], "#F");
            int sensorLeft = getActualValue(firstValue[1], "L");
            int sensorRight = getActualValue(firstValue[2], "R");

            Sensordata value = new Sensordata(sensorValues.Count, sensorFront, sensorLeft, sensorRight);

            #endregion

            #region Old Code
            /*
            if (values[0].StartsWith("#F"))
            {
                for (int i = 2; i < values[0].Length; i++)
                {
                    totalInput += values[0][i];
                }
            }

            for (int i = 0; i < totalInput.Length - 2; i++)
            {
                actualValue += totalInput[i];
            }
            int frontValue = Convert.ToInt32(actualValue);
            */
            #endregion

            return value;
        }
Beispiel #2
0
        public List<Sensordata> updateList(List<Sensordata> list, Sensordata value)
        {
            List<Sensordata> temp = new List<Sensordata>();

            if (list.Count < 10)
            {
                temp = list;
                temp.Add(value);
            }
            else
            {
                for (int i = 1; i < sensorValues.Count; i++)
                {
                    temp.Add(sensorValues[i]);
                }
                temp.Add(value);
            }

            return temp;
        }