频率改为间隔

This commit is contained in:
xu 2020-05-04 11:08:35 +08:00
parent dc07d2d560
commit 26b3e573f8
2 changed files with 8 additions and 8 deletions

View File

@ -203,10 +203,10 @@ namespace Plane.CommunicationManagement
}
private byte[] DoTaskLEDCommandAsync(int ledmode, float ledrate, int ledtimes, byte cR,byte cG,Byte cB)
private byte[] DoTaskLEDCommandAsync(int ledmode, float ledInterval, int ledtimes, byte cR,byte cG,Byte cB)
{
//频率转为间隔单位100ms
byte LEDInterval = (byte)(10 / ledrate);
//ledInterval间隔单位秒改为单位100ms
byte LEDInterval = (byte)(ledInterval*10); //(byte)(10 / ledInterval);
MAVLink.mavlink_msg_id_led_control led = new MAVLink.mavlink_msg_id_led_control();
led.target_system = 1;
@ -564,20 +564,20 @@ namespace Plane.CommunicationManagement
/*
private int ledmode = 0; //灯光模式 0常亮 1闪烁 2随机闪烁(RGB无意义)
private float ledrate = 0; //频率 最小0.1
private float ledInterval = 0; //间隔 单位秒 最小0.1
private int ledtimes = 0; //次数 (预留、暂取消其意义)
private string ledRGB = "FFFFFF"; //灯光颜色
*/
public void LED_TaskAsync( int ledmode, float ledrate, int ledtimes, string ledRGB, ICopter copter )
public void LED_TaskAsync( int ledmode, float ledInterval, int ledtimes, string ledRGB, ICopter copter )
{
if (UseTransModule)
{
Task.Run(async () =>
{
Color rightColor = (Color)ColorConverter.ConvertFromString("#" + ledRGB);
byte[] packet = DoTaskLEDCommandAsync(ledmode, ledrate, ledtimes, (byte)rightColor.R, (byte)rightColor.G, (byte)rightColor.B);
byte[] packet = DoTaskLEDCommandAsync(ledmode, ledInterval, ledtimes, (byte)rightColor.R, (byte)rightColor.G, (byte)rightColor.B);
await WriteCommPacketAsync(short.Parse(copter.Id), MavComm.COMM_DOWNLOAD_COMM, packet).ConfigureAwait(false);
});
}

View File

@ -187,12 +187,12 @@ namespace Plane.Copters
Altitude = alt
};
public static IMission CreateLEDControlMission(int delay, int ledmode, float ledrate, int ledtimes, byte red, byte green, byte blue) => new Mission
public static IMission CreateLEDControlMission(int delay, int ledmode, float ledInterval, int ledtimes, byte red, byte green, byte blue) => new Mission
{
Command = FlightCommand.LEDControl,
Param1 = delay, //灯光延时 单位:100ms
Param2 = ledmode, //灯光模式 0.常亮 1.闪烁 2.随机闪烁(RGB无意义)
Param3 = ledrate, //闪烁延时 单位:100ms
Param3 = ledInterval, //闪烁延时 单位:100ms
Param4 = ledtimes, //次数 (暂无意义)
R = red, //Red
G = green, //Green