Add real mode (bar)
This commit is contained in:
@ -3,6 +3,7 @@ using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using static DroneSimulator.Drone;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
||||
|
||||
namespace DroneSimulator
|
||||
@ -35,11 +36,15 @@ namespace DroneSimulator
|
||||
|
||||
private Random MainRandom = new Random();
|
||||
|
||||
RealMode.Accelerometer RealAcc = new RealMode.Accelerometer();
|
||||
RealMode.Gyroscope RealGyr = new RealMode.Gyroscope();
|
||||
RealMode.Position RealPos = new RealMode.Position();
|
||||
RealMode.Barometer RealBar = new RealMode.Barometer();
|
||||
RealMode.Range RealRange = new RealMode.Range();
|
||||
|
||||
public struct DataBarometer
|
||||
{
|
||||
public int Value, Pressure; // Значение давления в Паскальях
|
||||
public float Accuracy;
|
||||
public int Frequency;
|
||||
public float Pressure; // Значение давления в Паскальях
|
||||
public uint Time;
|
||||
}
|
||||
|
||||
@ -252,13 +257,10 @@ namespace DroneSimulator
|
||||
else LaserRange = float.MaxValue;
|
||||
}
|
||||
|
||||
if ((dataBarometer.Time + 1000 / dataBarometer.Frequency) < DataTimer)
|
||||
{
|
||||
float bar = dataBarometer.Pressure - PosXYZ.Z * 11;
|
||||
int rnd = MainRandom.Next(-(int)dataBarometer.Accuracy * 10, (int)dataBarometer.Accuracy * 10) / 10;
|
||||
dataBarometer.Value = (int)(bar + rnd);
|
||||
dataBarometer.Time = DataTimer;
|
||||
}
|
||||
float v_bar = PosXYZ.Z * 11;
|
||||
uint t_bar = (uint)tick;
|
||||
RealBar.Update(ref v_bar, ref t_bar);
|
||||
dataBarometer.Pressure = v_bar;
|
||||
|
||||
DataTimer = (uint)tick;
|
||||
}
|
||||
@ -373,7 +375,7 @@ namespace DroneSimulator
|
||||
bar.Head.Type = DroneData.DataType.DataBar;
|
||||
bar.Head.Time = (uint)Environment.TickCount;
|
||||
|
||||
bar.Pressure = dataBarometer.Value;
|
||||
bar.Pressure = dataBarometer.Pressure;
|
||||
bar.Time = dataBarometer.Time;
|
||||
|
||||
return getBytes(bar);
|
||||
|
Reference in New Issue
Block a user