Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6145,6 +6145,7 @@ public class SignalUnits
public static readonly String Local_DefaultCal = "local*";
public static readonly String KiloOhms = "kOhms";
public static readonly String MicroSiemens = "uSiemens";
public static readonly String NanoAmpere = "nA";
}
}

Expand Down
37 changes: 37 additions & 0 deletions ShimmerAPI/ShimmerAPI/Utilities/ProgrammerUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ShimmerAPI.Utilities
{
public static class ProgrammerUtilities
{
//Note there is a method Calculatetwoscomplement in ShimmerBluetooth class that would be more suited to be in this class as well
public static int ByteArrayToInt(byte[] data, bool lsbOrder, bool isSigned)
{
var number = 0;
int i = 0;
foreach (byte b in data)
{
if (lsbOrder)
{
number += (b << i * 8);
} else
{
number = (number << 8) + b;
}
i++;
}

if (isSigned)
{
var bitLength = data.Length * 8;
if (number >= (1 << (bitLength - 1)))
{
number = -((number ^ (int)(Math.Pow(2, bitLength) - 1)) + 1);
}
}
return number;
}
}
}