Example #1
0
        private void GatherCounts()
        {
            Thread.Sleep(_sleepTime);
            Debug.Print("Gathering Geiger counts data, resetting. " + Debug.GC(true));

            var dataIndex = 0;

            var time = RTC.CurrentTime();

            _newData[dataIndex++ + _offset] = time[0];
            _newData[dataIndex++ + _offset] = time[1];
            _newData[dataIndex++ + _offset] = time[2];

            _geigerData.shielded_geigerCount = ShieldedCounts;
            _newData[dataIndex++ + _offset]  = (byte)((_geigerData.shielded_geigerCount >> 8) & 0xFF);
            _newData[dataIndex++ + _offset]  = (byte)(_geigerData.shielded_geigerCount & 0xFF);

            _geigerData.unshielded_geigerCount = UnshieldedCounts;
            _newData[dataIndex++ + _offset]    = (byte)((_geigerData.unshielded_geigerCount >> 8) & 0xFF);
            _newData[dataIndex++ + _offset]    = (byte)(_geigerData.unshielded_geigerCount & 0xFF);

            time = RTC.CurrentTime();
            _newData[dataIndex++ + _offset] = time[0];
            _newData[dataIndex++ + _offset] = time[1];
            _newData[dataIndex++ + _offset] = time[2];

            ShieldedCounts   = 0;
            UnshieldedCounts = 0;
        }
Example #2
0
        private void GyroUpdater()
        {
            var dataIndex = 0;

            var time = RTC.CurrentTime();

            _newData[dataIndex++ + _offset] = time[0];
            _newData[dataIndex++ + _offset] = time[1];
            _newData[dataIndex++ + _offset] = time[2];

            var gyro_vec = _bnoSensor.read_vector(SerialBNO.Bno055VectorType.Vector_Gyroscope);

            _bnoData.gyro_x = (short)(gyro_vec.X * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.gyro_x >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.gyro_x & 0xFF);

            _bnoData.gyro_y = (short)(gyro_vec.Y * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.gyro_y >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.gyro_y & 0xFF);

            _bnoData.gyro_z = (short)(gyro_vec.Z * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.gyro_z >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.gyro_z & 0xFF);

            var accel_vec = _bnoSensor.read_vector(SerialBNO.Bno055VectorType.Vector_Accelerometer);

            _bnoData.accel_x = (short)(accel_vec.X * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.accel_x >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.accel_x & 0xFF);

            _bnoData.accel_y = (short)(accel_vec.Y * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.accel_y >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.accel_y & 0xFF);

            _bnoData.accel_z = (short)(accel_vec.Z * _precision);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.accel_z >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.accel_z & 0xFF);

            _bnoData.temp = _bnoSensor.read_signed_byte(SerialBNO.Bno055Registers.Bno055_Temp_Addr);
            _newData[dataIndex++ + _offset] = (byte)((_bnoData.temp >> 8) & 0xFF);
            _newData[dataIndex++ + _offset] = (byte)(_bnoData.temp & 0xFF);


            time = RTC.CurrentTime();
            _newData[dataIndex++ + _offset] = time[0];
            _newData[dataIndex++ + _offset] = time[1];
            _newData[dataIndex++ + _offset] = time[2];

            //Debug.Print("Gyro - <" + _bnoData.gyro_x.ToString("F2") + ", "
            //            + _bnoData.gyro_y.ToString("F2") + ", "
            //            + _bnoData.gyro_z.ToString("F2") + ">\n" +
            //            "Accel - <" + _bnoData.accel_x.ToString("F2") + ", "
            //            + _bnoData.accel_y.ToString("F2") + ", "
            //            + _bnoData.accel_z.ToString("F2") + ">\n" +
            //            "Temp: " + _bnoData.temp);
            Debug.Print("BNO Sensor update complete.");
        }
        private void DumpAccelData()
        {
            short x = 0;


            _dataArray[0 + _offset] = RTC.Hours();
            _dataArray[1 + _offset] = RTC.Minutes();
            _dataArray[2 + _offset] = RTC.Seconds();

            for (var i = 0; i < _arraySize; i += 2)
            {
                short raw = 0;
                switch (x++ % 3)
                {
                case 0: raw = (short)(XPin.Read() * 1000);
                    break;

                case 2: raw = (short)(YPin.Read() * 1000);
                    break;

                case 1: raw = (short)(ZPin.Read() * 1000);
                    break;
                }

                _dataArray[i + _offset + 3]  = (byte)(raw & 0xFF);
                _dataArray[i + +_offset + 4] = (byte)((raw >> 8) & 0xFF);
                //var period = 1000*(1/_frequency);
                //if (period < 1) period = 1;
                //Thread.Sleep(period);
            }

            var time = RTC.CurrentTime();

            _dataArray[_arraySize + _offset + 3] = time[0]; //hours
            _dataArray[_arraySize + _offset + 4] = time[1]; //minutes
            _dataArray[_arraySize + _offset + 5] = time[2]; //seconds

            Debug.Print("Accel data dump complete - free mem: " + Debug.GC(true));
        }