public static SByte ToSByte(string valueToParse, SByte defaultValue) { SByte returnValue; if (!SByte.TryParse(valueToParse, out returnValue)) returnValue = defaultValue; return returnValue; }
private void WorkOnInstanceAndLocal() { int localInt, i, j; for ( i = 0; i < 100; i++ ) { int index = randomNumGen.Next(0, ValueArraySize); instanceInt_1 = ValueArray[index]; Thread.Sleep(index); localInt = instanceInt_1; for ( j = 0; j < ValueArraySize; j++ ) if ( ValueArray[j] == localInt ) break; if (j == ValueArraySize ) throw new Exception("WorkOnInstanceAndLocal: Atomicity of Read/Write violated - " + localInt); } SByte localInt_1; localInt_1 = 1 + 1; if(localInt_1 != 2) throw new Exception("Loc_7453fg! Major Error here"); localInt_1 = SByte.MaxValue + SByte.MinValue; if(localInt_1 != -1) throw new Exception("Loc_98745sg! Major Error here"); localInt_1 = 50 * 2; if(localInt_1 != 100) throw new Exception("Loc_3975sg! Major Error here, " + localInt_1); localInt_1 = SByte.Parse("32"); if(localInt_1 != 32) throw new Exception("Loc_975esg! Major Error here, " + localInt_1); localInt_1 = SByte.MaxValue; if(localInt_1.GetHashCode() != 32639) throw new Exception("Loc_07245sg! Major Error here, " + localInt_1.GetHashCode()); if(localInt_1.ToString() != "127") throw new Exception("Loc_834sgd! Major Error here, " + localInt_1.ToString()); }
private static void Test_SetDataTypesFromValue() { CUBRIDParameter param = new CUBRIDParameter(); param.ParameterName = "?p"; Boolean b = true; param.Value = b; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT); SByte sb = new SByte(); param.Value = sb; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT); Byte by = new Byte(); param.Value = by; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT); Int16 i16 = 0; param.Value = i16; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT); UInt16 ui16 = 0; param.Value = ui16; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_SHORT); UInt32 ui32 = 0; param.Value = ui32; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_INT); Int64 i64 = 0; param.Value = i64; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_BIGINT); UInt64 ui64 = 0; param.Value = ui64; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_BIGINT); param.Value = DateTime.Now; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_DATETIME); string str = "cubrid"; param.Value = str; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_STRING); Single sin = 0; param.Value = sin; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_FLOAT); Double dou = 0; param.Value = dou; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_DOUBLE); Decimal dec = 0; param.Value = dec; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_NUMERIC); DBNull n=null; param.Value = n; Debug.Assert(param.CUBRIDDataType == CUBRIDDataType.CCI_U_TYPE_NULL); }
public GarminFitnessSByteRange(SByte value, SByte min, SByte max) { m_MinimumValue = Math.Min(min, max); m_MaximumValue = Math.Max(min, max); Value = value; }
void Update() { if (connected) { // When connected to Arduino if (_txUINT8 != (UINT8)txUINT8) { _txUINT8 = (UINT8)txUINT8; SetDirty(); // It must call to run OnPush } if (_txINT8 != (INT8)txINT8) { _txINT8 = (INT8)txINT8; SetDirty(); // It must call to run OnPush } if (_txUINT16 != (UINT16)txUINT16) { _txUINT16 = (UINT16)txUINT16; SetDirty(); // It must call to run OnPush } if (_txINT16 != (INT16)txINT16) { _txINT16 = (INT16)txINT16; SetDirty(); // It must call to run OnPush } if (_txUINT32 != (UINT32)txUINT32) { _txUINT32 = (UINT32)txUINT32; SetDirty(); // It must call to run OnPush } if (_txINT32 != (INT32)txINT32) { _txINT32 = (INT32)txINT32; SetDirty(); // It must call to run OnPush } if (_txFLOAT32 != (FLOAT32)txFLOAT32) { _txFLOAT32 = (FLOAT32)txFLOAT32; SetDirty(); // It must call to run OnPush } if (txSTRING.Equals(_txSTRING) == false) { _txSTRING = (STRING)txSTRING; SetDirty(); // It must call to run OnPush } rxUINT8 = _rxUINT8; rxINT8 = _rxINT8; rxUINT16 = _rxUINT16; rxINT16 = _rxINT16; rxUINT32 = _rxUINT32; rxINT32 = _rxINT32; rxFLOAT32 = _rxFLOAT32; rxSTRING = _rxSTRING; } else { // When disconnected to Arduino } }
private static void TestSByte( SByte value ) { var output = new MemoryStream(); Packer.Create( output ).Pack( value ); Assert.AreEqual( value, Unpacking.UnpackSByte( new MemoryStream( output.ToArray() ) ) ); Assert.AreEqual( value, Unpacking.UnpackSByte( output.ToArray() ).Value ); }
public void Deserialize_V0(Stream stream, DataVersion version) { Byte[] buffer = new Byte[1]; stream.Read(buffer, 0, 1); Value = (SByte)buffer[0]; }
public String encBytes(SByte[] barr) { StringBuilder licKey = new StringBuilder(); for (int i = 0; i <= 15; i++) { SByte i1 = barr[i]; int j = 0; j |= i1 & 0xFF; j %= 32; if (i > 0 && i % 4 == 0) { licKey.Append("-" ); } // licKey = licKey.Append(Convert.ToChar(validChars.Substring(j, 1))); } // String licKey = Base64Utils.base64Encode(hash); return licKey.ToString(); }
private void CreatePawn(Player player, Pawn pawn, int i, int j) { Pawn down = Board.Down(pawn); bool upgrade = Board.IsUpgrade(pawn); GameObject cell = IndexToCell(i, j); float x = cell.transform.position.x; float z = cell.transform.position.z; float yangle = 0.0f; float zangle = 0.0f; if (player == PlayerDef.SECOND) { yangle = 180.0f; } if (upgrade) { zangle = 180.0f; } Quaternion angle = Quaternion.identity; angle.eulerAngles = new Vector3(0, yangle, zangle); GameObject pawnObject = Instantiate(Pawns[down], new Vector3(x, 0.025f, z), angle) as GameObject;; pawnObject.transform.parent = PawnsParent.transform; }
public static SByte[] ReadSByteArray(this ObjectReader reader) { var length = reader.ReadInt32(); SByte[] value = new SByte[length]; for(int i = 0; i < length; i++) value[i] = (SByte)reader.Stream.ReadByte(); return value; }
public MFTestResults ParseSByte_Test_1() { Log.Comment("SByte MinValue = " + SByte.MinValue.ToString()); Log.Comment("SByte MaxValue = " + SByte.MaxValue.ToString()); String[] strArr = GetRandomStringArray(SByte.MaxValue, true); SByte[] _sByte = new SByte[intArr.Length]; for (int i = 0; i < _sByte.Length; i++) { _sByte[i] = (SByte)intArr[i]; } int counter = 0; SByte temp = 0; for (int i = 0; i < strArr.Length; i++) { try { temp = SByte.Parse(strArr[i]); } catch (Exception ex) { Log.Comment(i.ToString() + " Caught : " + ex.Message + " when SByte.Parse('" + strArr[i] + "')"); counter++; } if (temp != _sByte[i]) { Log.Comment(i.ToString() + " Expecting " + _sByte[i] + " but got " + temp); counter++; } } return (counter == 0) ? MFTestResults.Pass : MFTestResults.Fail; }
public override SByte[] Serialize(String data) { if (String.IsNullOrEmpty(data)) return null; var totalLength = buildHead(data.Length, data); encodeData = new SByte[totalLength]; var startX = 0; for (int i = 0; i < data.Length / 3; i++) { var value = Convert.ToString(Int32.Parse(data.Substring(startX, 3)), 2); value = Converter.SupplyZero(10, value); fillData(startX + headLength, value); startX += 3; } startX /= 3; var remainer = totalLength - startX * 10; if (remainer > 0) { var value = Convert.ToString(Int32.Parse(data.Substring(startX)), 2); value = Converter.SupplyZero(remainer, value); fillData(startX + headLength, value); } return encodeData; }
public static void TestCtor() { SByte i = new SByte(); Assert.True(i == 0); i = 41; Assert.True(i == 41); }
private static void TestSByte( SByte value ) { var output = new MemoryStream(); Packer.Create( output ).Pack( value ); var mpo = UnpackOne( output ); Assert.AreEqual( value, ( SByte )mpo ); Assert.AreEqual( value, mpo.AsSByte() ); }
public override void Init(MapMemberInfo mapMemberInfo) { if (mapMemberInfo == null) throw new ArgumentNullException("mapMemberInfo"); _nullValue = Convert.ToSByte(mapMemberInfo.NullValue); base.Init(mapMemberInfo); }
private void SetReserveCount(Player player, Pawn pawn, int count) { GameObject reservesCount = GetReserveCount(player, pawn); GameObject text = reservesCount.transform.Find("Text").gameObject; TextMesh textMesh = text.GetComponent <TextMesh>(); textMesh.text = count.ToString(); }
public static object Abs(SByte x) { if (x < 0) { if (x == SByte.MinValue) return -(Int16)SByte.MinValue; else return (SByte)(-x); } else { return x; } }
public void FillData(SByte[] data) { var end = false; //for (int i = 0; i < data.Length; i += 2) //{ //} }
public ScanResponseEventArgs (SByte rssi, Byte packet_type, Byte[] sender, Byte address_type, Byte bond, Byte[] data) { this.rssi = rssi; this.packet_type = packet_type; this.sender = sender; this.address_type = address_type; this.bond = bond; this.data = data; }
public static void WriteSByteArray(this ObjectWriter writer, SByte[] value) { writer.WriteTag(FormatterTag.SByteArray); writer.InnerWrite(value.Length); foreach(var item in value) { writer.Stream.WriteByte((Byte)item); } }
public static float int82angle(SByte angle, bool half) { float halfv = 128f; if(half == true) halfv = 254f; halfv = ((float)angle) * ((float)System.Math.PI / halfv); return halfv; }
private void CellToReserve(GameObject cell, out Player player, out Pawn pawn) { string name = cell.name; name = name.Replace("Reserve(", ""); name = name.Replace(")", ""); string[] splited = name.Split(','); player = (Player)int.Parse(splited[0]); pawn = (Pawn)int.Parse(splited[1]); }
public static void TestSByteOverflow (SByte a, SByte b) { try { checked { SByte sum = (SByte)(a + b); Console.WriteLine(sum); } } catch (OverflowException) { Console.WriteLine("Overflow detected"); } }
public SByte Abs_Ok(SByte l) { if (l >= 0) return l; if (l == SByte.MinValue) throw new Exception(); return (sbyte)-l; }
public static Byte[] ReadByteArray(this DataInputStream input) { if (input == null) throw new ArgumentNullException("input"); var length = input.ReadInt32(); SByte[] result = new SByte[length]; for (var i = 0; i < length; i++) result[i] = (SByte)input.ReadByte(); _byte2SByteMap.SByteArray = result; return _byte2SByteMap.ByteArray; }
public void read() { EID = socket.readInt(); socket.readString(); levelType = socket.readString(); mode = socket.readInt(); atmosphere = socket.readInt(); difficulty = socket.readByte(); socket.readByte(); maxPlayers = (byte) socket.readByte(); }
public int AddNew(Guid TemplateGuid, string Title, string TemplatePath, SByte TemplateType, SByte ArticleType) { DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERTTemplate",CommandType.StoredProcedure); oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TemplateGuid",DbType.Guid,TemplateGuid)); oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Title",DbType.String,Title)); oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TemplatePath",DbType.String,TemplatePath)); oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TemplateType", DbType.Byte, TemplateType)); oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ArticleType", DbType.Byte, ArticleType)); return Convert.ToInt32(DbProviderHelper.ExecuteScalar(oDbCommand)); }
/// <summary> /// Initializes a new instance of the <see cref="libtr.RoomSector"/> struct. /// </summary> /// <param name="floordataid">The index into FloorData [].</param> /// <param name="boxid">The index into Boxes [] / Zones [].</param> /// <param name="roombelow">The id of the room below this one.</param> /// <param name="floorheight">The absolute height of the floor.</param> /// <param name="roomabove">The id of the room above this one.</param> /// <param name="ceilingheight">The absolute height of the ceiling.</param> public RoomSector ( UInt16 floordataid, Int16 boxid, Byte roombelow, SByte floorheight, Byte roomabove, SByte ceilingheight) : this () { FloorDataIndex = floordataid; BoxIndex = boxid; RoomBelow = roombelow; Floor = floorheight; RoomAbove = roomabove; Ceiling = ceilingheight; }
public unsafe void Update(SByte message) { if((AllowUnalignedRead || (_remainder & (sizeof(SByte) - 1)) == 0) && _remainder + sizeof(SByte) < BufSize) { fixed(ulong* uptr = _data) *(SByte*)((byte*)uptr + _remainder) = message; _length += sizeof(SByte); _remainder += sizeof(SByte); } else Update(&message, sizeof(SByte)); }
/// <summary> /// Get the name of the active CUDA device. /// </summary> /// <returns>Name string of the active graphics-card/compute device in a system.</returns> public static String nppGetGpuName() { string deviceName = String.Empty; int bufferSize = 255; SByte[] devName = new SByte[bufferSize]; IntPtr namePtr = NativeMethods.nppGetGpuName(); deviceName = Marshal.PtrToStringAnsi(namePtr, bufferSize).TrimEnd('\0'); return deviceName; }
public virtual void resetProperties() { TV_CHAR_0 = '\0'; TV_BYTE_0 = 0; TV_SBYTE_0 = 0; TV_STR_0 = String.Empty; TV_AGENT_0 = null; TV_KEMPLOYEE_0.resetProperties(); STV_KEMPLOYEE_0.resetProperties(); STV_LIST_SBYTE_0.Clear(); TV_LIST_KEMPLOYEE_0.Clear(); STV_LIST_KEMPLOYEE_0.Clear(); }
public void execMethod_all ( ref String st, ref Boolean bo, ref SByte sb, ref Byte by, ref char c, ref double d, ref float f, ref long l, ref short sh, ref int i ) { value_String = const_String; value_Boolean = const_Boolean; value_SByte = const_SByte; value_Byte = const_Byte; value_char = const_char; value_double = const_double; value_float = const_float; value_long = const_long; value_short = const_short; value_int = const_int; }
public static ulong GetUTC (ulong localTimestamp, SByte tz) { SByte posTz = tz; if (tz < 0) posTz = (SByte) (0 - tz); ulong offset = (ulong)posTz * Timestamp.HourUnit; if (tz < 0) return localTimestamp + offset; else return localTimestamp - offset; }
public static ulong Localize (ulong utcTimestamp, SByte tz) { SByte posTz = tz; if (tz < 0) posTz = (SByte) (0 - tz); ulong offset = (ulong)posTz * Timestamp.HourUnit; if (tz < 0) return utcTimestamp - offset; else return utcTimestamp + offset; }
private void SelectReserve(Player player, Pawn pawn) { if (step == "idle") { if (player != board.GetPlayer()) { return; } board.GetMoveList(moveListTmp); List <Move> moveList = new List <Move>(); while (0 < moveListTmp.size()) { Move move = moveListTmp.front(); if (move.reserve == pawn) { moveList.Add(move); } moveListTmp.pop_front(); } if (moveList.Count == 0) { return; } selectMove.reserve = pawn; foreach (Move moveTmp in moveList) { GameObject highlight = IndexToCell(moveTmp.to.x, moveTmp.to.y); highlight.GetComponent <MeshRenderer>().material.color = new Color(1.0f, 1.0f, 1.0f, 0.5f); } step = "select"; } else if (step == "select") { selectMove = new Move(GlobalMembers.MOVE_ZERO); ResetHighlight(); step = "idle"; } }
private void BoardMove(Move move) { if (move.from.pawn != PawnDef.NONE) { GameObject cell = IndexToCell(move.from.x, move.from.y); GameObject pawn = CellToPawn(cell); Destroy(pawn); } if (move.to.pawn != PawnDef.NONE) { GameObject cell = IndexToCell(move.to.x, move.to.y); GameObject pawn = CellToPawn(cell); Destroy(pawn); } if (move.reserve != PawnDef.NONE) { CreatePawn(board.GetPlayer(), move.reserve, move.to.x, move.to.y); } else { Pawn pawnTmp = move.from.pawn; if (move.upgrade == true) { Board.Upgrade(ref pawnTmp); } CreatePawn(board.GetPlayer(), pawnTmp, move.to.x, move.to.y); } board.Forward(move); for (int i = 0; i < PawnDef.CAPTURE_MAX; i++) { SetReserveCount(PlayerDef.FIRST, (Pawn)i, board.GetReserve(PlayerDef.FIRST, (Pawn)i)); SetReserveCount(PlayerDef.SECOND, (Pawn)i, board.GetReserve(PlayerDef.SECOND, (Pawn)i)); } Debug.Log(board.GetPlayer()); board.GetMoveList(moveListTmp); if (moveListTmp.size() == 0) { Debug.Log("gameset"); } }
private void CreateReserve(Player player, Pawn pawn) { Pawn down = Board.Down(pawn); GameObject cell = GetReserve(player, pawn); float x = cell.transform.position.x; float z = cell.transform.position.z; float yangle = 0.0f; float zangle = 0.0f; if (player == PlayerDef.SECOND) { yangle = 180.0f; } Quaternion angle = Quaternion.identity; angle.eulerAngles = new Vector3(0, yangle, zangle); GameObject pawnObject = Instantiate(Pawns[down], new Vector3(x, 0.025f, z), angle) as GameObject;; pawnObject.transform.parent = PawnsParent.transform; }
public void AppendLine(System.SByte value, string format) { Append(value, format); AppendLine(); }
public static bool TryParse(String s, out SByte result) { return(TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result)); }
public static bool IsUpgrade(Pawn type) { return((type & 0x08) != 0); }
public static Pawn Down(Pawn type) { return((Pawn)(type & 0x07)); }
public JSONObject AddField(string name, System.SByte val) { return(AddField(name, Create(val))); }
public static bool IsGyokuKinUpgrade(Pawn type) { return(PawnDef.KIN <= type); }
public void AppendLine(System.SByte value) { Append(value); AppendLine(); }
public void Add(System.SByte val) { Add(Create(val)); }
public static bool TryFormat(this System.SByte value, Span <char> destination, out int charsWritten, ReadOnlySpan <char> format = default) { throw new NotImplementedException(); }
internal System.SByte ReadSByte() { byte *pb = this.pb; System.SByte v = *(System.SByte *)pb; this.pb = pb + sizeof(System.SByte); return(v); }
public void EqualsSameTypes() { byte b1 = 35; sbyte sb2 = 35; decimal d4 = 35; double d5 = 35; float f6 = 35; int i7 = 35; uint u8 = 35; long l9 = 35; short s10 = 35; ushort us11 = 35; System.Byte b12 = 35; System.SByte sb13 = 35; System.Decimal d14 = 35; System.Double d15 = 35; System.Single s16 = 35; System.Int32 i17 = 35; System.UInt32 ui18 = 35; System.Int64 i19 = 35; System.UInt64 ui20 = 35; System.Int16 i21 = 35; System.UInt16 i22 = 35; Assert.AreEqual(35, b1); Assert.AreEqual(35, sb2); Assert.AreEqual(35, d4); Assert.AreEqual(35, d5); Assert.AreEqual(35, f6); Assert.AreEqual(35, i7); Assert.AreEqual(35, u8); Assert.AreEqual(35, l9); Assert.AreEqual(35, s10); Assert.AreEqual(35, us11); Assert.AreEqual(35, b12); Assert.AreEqual(35, sb13); Assert.AreEqual(35, d14); Assert.AreEqual(35, d15); Assert.AreEqual(35, s16); Assert.AreEqual(35, i17); Assert.AreEqual(35, ui18); Assert.AreEqual(35, i19); Assert.AreEqual(35, ui20); Assert.AreEqual(35, i21); Assert.AreEqual(35, i22); #if NET_2_0 byte? b23 = 35; sbyte? sb24 = 35; decimal?d25 = 35; double? d26 = 35; float? f27 = 35; int? i28 = 35; uint? u29 = 35; long? l30 = 35; short? s31 = 35; ushort? us32 = 35; Assert.AreEqual(35, b23); Assert.AreEqual(35, sb24); Assert.AreEqual(35, d25); Assert.AreEqual(35, d26); Assert.AreEqual(35, f27); Assert.AreEqual(35, i28); Assert.AreEqual(35, u29); Assert.AreEqual(35, l30); Assert.AreEqual(35, s31); Assert.AreEqual(35, us32); #endif }
private static bool TryParse(String s, NumberStyles style, NumberFormatInfo info, out SByte result) { result = 0; int i; if (!Number.TryParseInt32(s, style, info, out i)) { return(false); } if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number if ((i < 0) || i > Byte.MaxValue) { return(false); } result = (sbyte)i; return(true); } if (i < MinValue || i > MaxValue) { return(false); } result = (sbyte)i; return(true); }
public static Int8 Max(Int8 a, Int8 b) { return((a <= b) ? b : a); }
public BOOLEAN CheckUpdate(IntPtr sectionName, IntPtr keyName, IntPtr value, BOOLEAN isEncrypted) { return(Utility.WrapNativeSyncInvoke(() => this.CheckUpdateHelper(sectionName, keyName, value, isEncrypted), "ConfigStoreUpdateHandlerBroker.CheckUpdate")); }
public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out SByte result) { NumberFormatInfo.ValidateParseStyleInteger(style); return(TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result)); }
private void Update() { if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) { if (Input.GetKey(KeyCode.Space)) { MOVE_DIR = NONE; SMOOTHING_TIME = SMOOTHING_TIME_DECELERATING; if (!nukeTriggerDelayTimer.running) { nukeTriggerDelayTimer.Start(); } } else { if (Input.GetKey(KeyCode.A)) { MOVE_DIR = LEFT; SMOOTHING_TIME = SMOOTHING_TIME_ACCELERATING; TOUCH_POS_SPEED_SCALING = 1f; } else if (Input.GetKey(KeyCode.D)) { MOVE_DIR = RIGHT; SMOOTHING_TIME = SMOOTHING_TIME_ACCELERATING; TOUCH_POS_SPEED_SCALING = 1f; } else { MOVE_DIR = NONE; SMOOTHING_TIME = SMOOTHING_TIME_DECELERATING; } if (nukeTriggerDelayTimer.running) { nukeTriggerDelayTimer.Stop(); } } } else { // user is touching screen if (Input.touches.Length > 0) { // more than one finger if (Input.touches.Length > 1) { // stop movement, start nuke timer MOVE_DIR = NONE; SMOOTHING_TIME = SMOOTHING_TIME_DECELERATING; if (!nukeTriggerDelayTimer.running) { nukeTriggerDelayTimer.Start(); } } else { // only one finger // move appropriate direction and stop nuke timer if it's running if (Input.GetTouch(Input.touches.Length - 1).position.x < halfScreenWidth) { MOVE_DIR = LEFT; TOUCH_POS_SPEED_SCALING = (halfScreenWidth - Input.GetTouch(Input.touches.Length - 1).position.x) / halfScreenWidth; } else { MOVE_DIR = RIGHT; TOUCH_POS_SPEED_SCALING = (Input.GetTouch(Input.touches.Length - 1).position.x - halfScreenWidth) / halfScreenWidth; } SMOOTHING_TIME = SMOOTHING_TIME_ACCELERATING; if (nukeTriggerDelayTimer.running) { nukeTriggerDelayTimer.Stop(); } } } else { // no fingers on screen MOVE_DIR = NONE; SMOOTHING_TIME = SMOOTHING_TIME_DECELERATING; if (nukeTriggerDelayTimer.running) { nukeTriggerDelayTimer.Stop(); } } } }
public uint8_t dmpInitialize() { // reset device DEBUG_PRINTLN(F("\n\nResetting MPU6050...")); reset(); usleep(30000); // wait after reset // enable sleep mode and wake cycle /*Serial.println(F("Enabling sleep mode...")); * setSleepEnabled(true); * Serial.println(F("Enabling wake cycle...")); * setWakeCycleEnabled(true);*/ // disable sleep mode DEBUG_PRINTLN(F("Disabling sleep mode...")); setSleepEnabled(false); // get MPU hardware revision DEBUG_PRINTLN(F("Selecting user bank 16...")); setMemoryBank(0x10, true, true); DEBUG_PRINTLN(F("Selecting memory byte 6...")); setMemoryStartAddress(0x06); DEBUG_PRINTLN(F("Checking hardware revision...")); uint8_t hwRevision = readMemoryByte(); DEBUG_PRINT(F("Revision @ user[16][6] = ")); DEBUG_PRINTLNF(hwRevision); DEBUG_PRINTLN(F("Resetting memory bank selection to 0...")); setMemoryBank(0, false, false); // check OTP bank valid DEBUG_PRINTLN(F("Reading OTP bank valid flag...")); bool otpValid = getOTPBankValid() != 0; DEBUG_PRINT(F("OTP bank is ")); DEBUG_PRINTLN(otpValid ? F("valid!") : F("invalid!")); // get X/Y/Z gyro offsets DEBUG_PRINTLN(F("Reading gyro offset values...")); int8_t xgOffset = getXGyroOffset(); int8_t ygOffset = getYGyroOffset(); int8_t zgOffset = getZGyroOffset(); DEBUG_PRINT(F("X gyro offset = ")); DEBUG_PRINTLN(xgOffset); DEBUG_PRINT(F("Y gyro offset = ")); DEBUG_PRINTLN(ygOffset); DEBUG_PRINT(F("Z gyro offset = ")); DEBUG_PRINTLN(zgOffset); // setup weird slave stuff (?) DEBUG_PRINTLN(F("Setting slave 0 address to 0x7F...")); setSlaveAddress(0, 0x7F); DEBUG_PRINTLN(F("Disabling I2C Master mode...")); setI2CMasterModeEnabled(false); DEBUG_PRINTLN(F("Setting slave 0 address to 0x68 (self)...")); setSlaveAddress(0, 0x68); DEBUG_PRINTLN(F("Resetting I2C Master control...")); resetI2CMaster(); usleep(20000); // load DMP code into memory banks DEBUG_PRINT(F("Writing DMP code to MPU memory banks (")); DEBUG_PRINT(MPU6050_DMP_CODE_SIZE); DEBUG_PRINTLN(F(" bytes)")); if (writeProgMemoryBlock(dmpMemory, MPU6050_DMP_CODE_SIZE)) { printf("Success! DMP code written and verified.\n"); // write DMP configuration DEBUG_PRINT(F("Writing DMP configuration to MPU memory banks (")); DEBUG_PRINT(MPU6050_DMP_CONFIG_SIZE); DEBUG_PRINTLN(F(" bytes in config def)")); if (writeProgDMPConfigurationSet(dmpConfig, MPU6050_DMP_CONFIG_SIZE)) { printf("Success! DMP configuration written and verified.\n"); DEBUG_PRINTLN(F("Setting clock source to Z Gyro...")); setClockSource(MPU6050_CLOCK_PLL_ZGYRO); DEBUG_PRINTLN(F("Setting DMP and FIFO_OFLOW interrupts enabled...")); setIntEnabled(0x12); DEBUG_PRINTLN(F("Setting sample rate to 200Hz...")); setRate(4); // 1khz / (1 + 4) = 200 Hz DEBUG_PRINTLN(F("Setting external frame sync to TEMP_OUT_L[0]...")); setExternalFrameSync(MPU6050_EXT_SYNC_TEMP_OUT_L); DEBUG_PRINTLN(F("Setting DLPF bandwidth to 42Hz...")); setDLPFMode(MPU6050_DLPF_BW_42); DEBUG_PRINTLN(F("Setting gyro sensitivity to +/- 2000 deg/sec...")); setFullScaleGyroRange(MPU6050_GYRO_FS_2000); DEBUG_PRINTLN(F("Setting DMP configuration bytes (function unknown)...")); setDMPConfig1(0x03); setDMPConfig2(0x00); DEBUG_PRINTLN(F("Clearing OTP Bank flag...")); setOTPBankValid(false); DEBUG_PRINTLN(F("Setting X/Y/Z gyro offsets to previous values...")); setXGyroOffset(xgOffset); setYGyroOffset(ygOffset); setZGyroOffset(zgOffset); DEBUG_PRINTLN(F("Setting X/Y/Z gyro user offsets to zero...")); setXGyroOffsetUser(0); setYGyroOffsetUser(0); setZGyroOffsetUser(0); DEBUG_PRINTLN(F("Writing final memory update 1/7 (function unknown)...")); uint8_t[] dmpUpdate = new uint8_t[16]; int j; uint16_t pos = 0; for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("Writing final memory update 2/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("Resetting FIFO...")); resetFIFO(); DEBUG_PRINTLN(F("Reading FIFO count...")); uint8_t fifoCount = (byte)getFIFOCount(); uint8_t[] fifoBuffer = new uint8_t[10 * 128]; if (fifoCount > 0) { printf("Current FIFO count=" + fifoCount); getFIFOBytes(fifoBuffer, fifoCount); } else { DEBUG_PRINTLN("fifiCount=0!!"); } DEBUG_PRINTLN(F("Setting motion detection threshold to 2...")); setMotionDetectionThreshold(2); DEBUG_PRINTLN(F("Setting zero-motion detection threshold to 156...")); setZeroMotionDetectionThreshold(156); DEBUG_PRINTLN(F("Setting motion detection duration to 80...")); setMotionDetectionDuration(80); DEBUG_PRINTLN(F("Setting zero-motion detection duration to 0...")); setZeroMotionDetectionDuration(0); DEBUG_PRINTLN(F("Resetting FIFO...")); resetFIFO(); DEBUG_PRINTLN(F("Enabling FIFO...")); setFIFOEnabled(true); DEBUG_PRINTLN(F("Enabling DMP...")); setDMPEnabled(true); DEBUG_PRINTLN(F("Resetting DMP...")); resetDMP(); DEBUG_PRINTLN(F("Writing final memory update 3/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("Writing final memory update 4/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("Writing final memory update 5/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); printf("Waiting for FIFO count > 2...\n"); while ((fifoCount = (byte)getFIFOCount()) < 3) { ; } printf("Current FIFO count=" + fifoCount); DEBUG_PRINTLN(F("Reading FIFO data...")); getFIFOBytes(fifoBuffer, fifoCount); DEBUG_PRINTLN(F("Reading interrupt status...")); uint8_t mpuIntStatus = getIntStatus(); DEBUG_PRINT(F("Current interrupt status=")); DEBUG_PRINTLNF(mpuIntStatus); DEBUG_PRINTLN(F("Reading final memory update 6/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } readMemoryBlock(dmpUpdate, 3, dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("Waiting for FIFO count > 2...")); while ((fifoCount = (byte)getFIFOCount()) < 3) { ; } DEBUG_PRINT(F("Current FIFO count=")); DEBUG_PRINTLN(fifoCount); DEBUG_PRINTLN(F("Reading FIFO data...")); getFIFOBytes(fifoBuffer, fifoCount); DEBUG_PRINTLN(F("Reading interrupt status...")); mpuIntStatus = getIntStatus(); DEBUG_PRINT(F("Current interrupt status=")); DEBUG_PRINTLNF(mpuIntStatus); DEBUG_PRINTLN(F("Writing final memory update 7/7 (function unknown)...")); for (j = 0; j < 4 || j < dmpUpdate[2] + 3; j++, pos++) { dmpUpdate[j] = pgm_read_byte(dmpUpdates[pos]); } writeMemoryBlock(dmpUpdate.Skip(3).ToArray(), dmpUpdate[2], dmpUpdate[0], dmpUpdate[1]); DEBUG_PRINTLN(F("DMP is good to go! Finally.")); DEBUG_PRINTLN(F("Disabling DMP (you turn it on later)...")); setDMPEnabled(false); DEBUG_PRINTLN(F("Setting up internal 42-byte (default) DMP packet buffer...")); dmpPacketSize = 42; /*if ((dmpPacketBuffer = (uint8_t *)malloc(42)) == 0) { * return 3; // TODO: proper error code for no memory * }*/ DEBUG_PRINTLN(F("Resetting FIFO and clearing INT status one last time...")); resetFIFO(); getIntStatus(); } else { DEBUG_PRINTLN(F("ERROR! DMP configuration verification failed.")); return(2); // configuration block loading failed } } else { DEBUG_PRINTLN(F("ERROR! DMP code verification failed.")); return(1); // main binary block loading failed } return(0); // success }
static void Main(string[] args) { System.SByte sb = SByte.MaxValue; System.Byte b = Byte.MaxValue; System.Int16 i16 = Int16.MaxValue; System.Int32 i32 = Int32.MaxValue; System.Int64 i64 = Int64.MaxValue; System.UInt16 ui16 = UInt16.MaxValue; System.UInt32 ui32 = UInt32.MaxValue; System.UInt64 ui64 = UInt64.MaxValue; System.Char ch = 'C'; System.Boolean bol = true; System.Single fl = Single.MaxValue; System.Double db = Double.MaxValue; System.Decimal dc = Decimal.MaxValue; System.String st = "Hello, world!"; System.Object obj = null; /* * Console.WriteLine( * $"sb={sb}\n" + * $"b={b}\n" + * $"i16={i16}\n" + * $"i32={i32}\n" + * $"i64={i64}\n" + * $"ui16={ui16}\n" + * $"ui32={ui32}\n" + * $"ui64={ui64}\n" + * $"ch={ch}\n" + * $"bol={bol}\n" + * $"fl={fl}\n" + * $"db={db}\n" + * $"dc={dc}\n" + * $"st={st}\n" + * $"obj={obj}\n");*/ byte b1 = 1; short b2 = b1; int b3 = b2; long b4 = b3; double b5 = b4; //Console.WriteLine(b5); double d1 = 1.543; long d2 = (long)d1; Console.WriteLine("d2={0}", d2); int i1 = Int32.MaxValue; short i2 = (short)i1; Console.WriteLine("i2={0}", i2); short s1 = 5545; byte s2 = (byte)s1; Console.WriteLine("s2={0}", s2); int I1 = -123; uint I2 = (uint)I1; Console.WriteLine("I2={0}", I2); double D1 = 4.123031777776333; float D2 = (float)D1; Console.WriteLine("D2={0}", D2); int X = 10; object Obj; Obj = X; int Y = (int)Obj; Console.WriteLine("Y={0}", Y); var Str = "Hello, world!"; Console.WriteLine(Str.GetType()); int?null1 = null; int null2 = null1 ?? 5; Console.WriteLine("null2={0}", null2); char[] a = { 'f', 'f', 'f', 'f' }; string a1 = new string(a); string a2 = new string('f', 4); Console.WriteLine(a1 == a2); string Str1 = "Hello"; string Str2 = ", "; string Str3 = "world!"; Console.WriteLine(String.Concat(Str1, Str2, Str3)); Console.WriteLine(); Console.WriteLine("--------------------------------------------"); string text = "Thisstring"; text = text.Insert(4, " is"); text = text.Insert(7, " a "); text = text.Insert(10, "My "); text = text.Remove(10, 3); string[] words = text.Split(' '); foreach (string s in words) { Console.WriteLine(s); } Console.WriteLine("--------------------------------------------"); string NullSt = ""; Console.WriteLine($"Length={NullSt.Length}"); Console.WriteLine("--------------------------------------------"); StringBuilder StrB = new StringBuilder("world"); StrB.Append("!!!!!"); StrB.Insert(0, "Beautiful "); Console.WriteLine(StrB); Console.WriteLine("--------------------------------------------"); int[][] Mas = new int[3][]; Mas[0] = new int[5] { 1, 2, 3, 4, 5 }; Mas[1] = new int[4] { 1, 2, 3, 4 }; Mas[2] = new int[4] { 1, 2, 3, 4 }; for (int i = 0; i < Mas.Length; i++) { for (int j = 0; j < Mas[i].Length; j++) { Console.Write($" {Mas[i][j]} "); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("--------------------------------------------"); string[] MasStr = { "aaaaaaaaa", "11111111", "44444444444" }; Console.WriteLine($"Size MasStr={MasStr.Length}"); Console.WriteLine("Enter number and value\n"); int num = Int32.Parse(Console.ReadLine()); MasStr[num] = Console.ReadLine(); Console.WriteLine("--------------------------------------------"); Console.WriteLine(); for (int i = 0; i < MasStr.Length; i++) { Console.WriteLine(MasStr[i]); } Console.WriteLine(); Console.WriteLine("--------------------------------------------"); double[][] MasD = new double[3][]; for (int i = 0; i < MasD.Length; i++) { MasD[i] = new double[i + 1]; for (int j = 0; j < i + 1; j++) { MasD[i][j] = Double.Parse(Console.ReadLine()); } } for (int i = 0; i < MasD.Length; i++) { for (int j = 0; j < MasD[i].Length; j++) { Console.Write($" { MasD[i][j]} "); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("--------------------------------------------"); var MasInt = new[] { 12.23, 323.2, 322 }; var MasString = new[] { "ABC", null }; ValueTuple <int, string, char, string, ulong> cortage = (1, "22", 'f', "rrr", UInt64.MaxValue); Console.WriteLine($"{cortage.Item1} {cortage.Item3} { cortage.Item4}"); int CorInt = cortage.Item1; string CorStr1 = cortage.Item2; string CorStr2 = cortage.Item4; char CorCh = cortage.Item3; ulong CorUl = cortage.Item5; int[] arr = new int[4] { 1, 2, 3, 4 }; var Typle = CreateCortage(arr, text); Console.WriteLine(Typle); Console.WriteLine("--------------------------------------------"); Console.ReadKey(); }
public static Int8 Abs(Int8 value) { return(Math.Abs(value)); }
public bool Equals(SByte obj) { return(m_value == obj); }
public static extern IntPtr matrix_range_exp_create_int8_t_new3(int8_t start, int8_t end);
public static Int8 Min(Int8 a, Int8 b) { return((a >= b) ? b : a); }
public int CompareTo(SByte value) { return(m_value - value); }