From e801773dd590e5a20d028c8d7635732306608331 Mon Sep 17 00:00:00 2001 From: Jong Chern Date: Fri, 6 Aug 2021 17:43:58 +0800 Subject: [PATCH 1/2] bitarraytointmethod --- .../Utilities/ProgrammerUtilities.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ShimmerAPI/ShimmerAPI/Utilities/ProgrammerUtilities.cs diff --git a/ShimmerAPI/ShimmerAPI/Utilities/ProgrammerUtilities.cs b/ShimmerAPI/ShimmerAPI/Utilities/ProgrammerUtilities.cs new file mode 100644 index 00000000..cd55eb7b --- /dev/null +++ b/ShimmerAPI/ShimmerAPI/Utilities/ProgrammerUtilities.cs @@ -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; + } + } +} From 1b4c88fe8f2d9c30a263843f8f962faad0e2b057 Mon Sep 17 00:00:00 2001 From: Jong Chern Date: Fri, 6 Aug 2021 21:52:02 +0800 Subject: [PATCH 2/2] add nano ampere --- ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs b/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs index e54ddada..2ffa48fe 100644 --- a/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs +++ b/ShimmerAPI/ShimmerAPI/ShimmerBluetooth.cs @@ -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"; } }