Ejemplo n.º 1
0
        byte[] getBytes(Wobbler2_Params wob)
        {
            int size = Marshal.SizeOf(wob);

            byte[] arr = new byte[size];

            IntPtr ptr = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(wob, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);
            return(arr);
        }
Ejemplo n.º 2
0
        private void EepromSave_Click(object sender, EventArgs e)
        {
            Wobbler2_Params P = new Wobbler2_Params();

            P.T           = 0xff;
            P.CalibNormal = levelNormal - 2048;
            P.CalibPhased = levelPhased - 2048;

            //#define VERSIONBYTE 0x10
            WriteEepromByte(0, 0x10);
            System.Threading.Thread.Sleep(200);
            var B = getBytes(P);

            for (int i = 0; i < B.Length; i++)
            {
                WriteEepromByte((ushort)(i + 1), B[i]);
                System.Threading.Thread.Sleep(500);
            }
            for (int i = 0; i < B.Length; i++)
            {
                byte b = B[i];
                Console.WriteLine("writing {0:X}:{1:X}", i, b);
            }
        }