Esempio n. 1
0
        public static void Example_FixCRC()
        {
            Device MyReader = new Device("COM3", 0x52, SpdSize.DDR4);

            // Read first 126 bytes
            byte[] spdHeader = Eeprom.ReadByte(MyReader, 0, 126);

            // Calculate CRC
            ushort crc = Spd.Crc16(spdHeader);

            // Get LSB (byte 127) and MSB (byte 128)
            byte CrcLsb = (byte)(crc & 0xff);   // CRC LSB at 0x7e for 0-125 range or @ 0xfe for 128-253 range
            byte CrcMsb = (byte)(crc >> 8);     // CRC MSB at 0x7f for 0-125 range or @ 0xff for 128-253 range

            // Compare calculated CRC against SPD data
            if (Eeprom.ReadByte(MyReader, 0x7e, 1)[0] == CrcLsb && Eeprom.ReadByte(MyReader, 0x7f, 1)[0] == CrcMsb)
            {
                // The checksum is correct, do nothing
                return;
            }
            else
            {
                // Write correct values to SPD
                Eeprom.UpdateByte(MyReader, 0x7e, CrcLsb);
                Eeprom.UpdateByte(MyReader, 0x7f, CrcMsb);
            }
            // Note: you'll have to do the same for 128-253 range, checksum bytes are 0xfe and 0xff
        }
Esempio n. 2
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     if (Spd.Length() > 2)
     {
         Rot = (float)Atan2(Spd.Y, Spd.X);
     }
 }
Esempio n. 3
0
 public override void update()
 {
     Pow.update();
     Skl.update();
     Spd.update();
     Lck.update();
     Def.update();
     Res.update();
     Mov.update();
     Con.update();
     Aid.update();
 }
Esempio n. 4
0
        public override void draw(SpriteBatch sprite_batch, Vector2 draw_offset = default(Vector2))
        {
            Vector2 loc = this.loc + draw_vector();

            sprite_batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, Scissor_State);
            Pow.draw(sprite_batch, draw_offset - loc);
            Skl.draw(sprite_batch, draw_offset - loc);
            Spd.draw(sprite_batch, draw_offset - loc);
            Lck.draw(sprite_batch, draw_offset - loc);
            Def.draw(sprite_batch, draw_offset - loc);
            Res.draw(sprite_batch, draw_offset - loc);
            Mov.draw(sprite_batch, draw_offset - loc);
            Con.draw(sprite_batch, draw_offset - loc);
            Aid.draw(sprite_batch, draw_offset - loc);
            sprite_batch.End();
        }
Esempio n. 5
0
        void ReleaseDesignerOutlets()
        {
            if (Acc != null)
            {
                Acc.Dispose();
                Acc = null;
            }

            if (AccLbl != null)
            {
                AccLbl.Dispose();
                AccLbl = null;
            }

            if (Alt != null)
            {
                Alt.Dispose();
                Alt = null;
            }

            if (AltAcc != null)
            {
                AltAcc.Dispose();
                AltAcc = null;
            }

            if (AltAccLbl != null)
            {
                AltAccLbl.Dispose();
                AltAccLbl = null;
            }

            if (AltLbl != null)
            {
                AltLbl.Dispose();
                AltLbl = null;
            }

            if (Error != null)
            {
                Error.Dispose();
                Error = null;
            }

            if (ErrorLbl != null)
            {
                ErrorLbl.Dispose();
                ErrorLbl = null;
            }

            if (Hdg != null)
            {
                Hdg.Dispose();
                Hdg = null;
            }

            if (HdgAcc != null)
            {
                HdgAcc.Dispose();
                HdgAcc = null;
            }

            if (HdgAccLbl != null)
            {
                HdgAccLbl.Dispose();
                HdgAccLbl = null;
            }

            if (HdgLbl != null)
            {
                HdgLbl.Dispose();
                HdgLbl = null;
            }

            if (Lat != null)
            {
                Lat.Dispose();
                Lat = null;
            }

            if (LatLbl != null)
            {
                LatLbl.Dispose();
                LatLbl = null;
            }

            if (Lon != null)
            {
                Lon.Dispose();
                Lon = null;
            }

            if (LonLbl != null)
            {
                LonLbl.Dispose();
                LonLbl = null;
            }

            if (Spd != null)
            {
                Spd.Dispose();
                Spd = null;
            }

            if (SpdLbl != null)
            {
                SpdLbl.Dispose();
                SpdLbl = null;
            }

            if (Updated != null)
            {
                Updated.Dispose();
                Updated = null;
            }

            if (UpdatedLbl != null)
            {
                UpdatedLbl.Dispose();
                UpdatedLbl = null;
            }
        }