ardupilot/Tools/ArdupilotMegaPlanner/Delta.cs
Michael Oborne c4433b6944 APM Planner 1.1.96
Fix camera stab reverse boxs
add better param data duplicate handling
add rfd900a
tweak terminal settings
2012-07-06 07:27:42 +08:00

39 lines
895 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArdupilotMega
{
class Delta
{
public static void
delta_encode(ref char[] buffer)
{
int length = buffer.Length;
char delta = (char)0;
char original;
uint i;
for (i = 0; i < length; ++i)
{
original = buffer[i];
buffer[i] = (char)(byte)(buffer[i] - delta);
delta = original;
}
}
public static void
delta_decode(ref char[] buffer)
{
int length = buffer.Length;
char delta = (char)0;
uint i;
for (i = 0; i < length; ++i)
{
buffer[i] = (char)(byte)(buffer[i] + delta);
delta = buffer[i];
}
}
}
}