public async Task AutoCycle(int startDelaySec) { //await Run(() => Sequences.AutoCycle(Itr, Queue, startDelaySec)); await Run(() => Sequences.AutoCycle(Itr, startDelaySec)); LogProgress("AutoCycle stopped."); }
private async void OnUpdateSequenceYamlItem() { if (SelectedSequenceFile == null) { Log("Sequence File Doesn't exist", Category.Warn); return; } Log("Updating sequences."); try { //Clear sequences and convert the attract configs values to sequence item view models await Dispatcher.CurrentDispatcher.InvokeAsync(() => { Sequences?.Clear(); _skeletonGameAttract.GetAvailableSequences(SelectedSequenceFile.SequenceYaml); foreach (var sequence in SelectedSequenceFile.SequenceYaml.Sequences) { Sequences.Add(new SequenceItemViewModel(sequence)); } }); } catch (Exception ex) { Log(ex.Message, Category.Exception); throw; } }
// // INTERACTOR // public async void MouseMovementTest() { LogProgress("Mouse movement activated."); await Run(() => Sequences.MouseMoveTest(Itr)); LogProgress("Mouse movement cancelled."); }
public virtual void ReadChildData(BinaryReader reader) { int x = 0; _compressedColorPlateData.ReadBinary(reader); _processedPixelData.ReadBinary(reader); for (x = 0; (x < _sequences.Count); x = (x + 1)) { Sequences.Add(new BitmapGroupSequenceBlock()); Sequences[x].Read(reader); } for (x = 0; (x < _sequences.Count); x = (x + 1)) { Sequences[x].ReadChildData(reader); } for (x = 0; (x < _bitmaps.Count); x = (x + 1)) { Bitmaps.Add(new BitmapDataBlock()); Bitmaps[x].Read(reader); } for (x = 0; (x < _bitmaps.Count); x = (x + 1)) { Bitmaps[x].ReadChildData(reader); } }
public async void GotoCharSlot(uint charIdx) { await Run(() => { Sequences.ActivateClient(Itr); Sequences.SelectCharacter(Itr, charIdx, false); }); }
private void ExecuteRemoveSequenceCommand() { if (MessageBox.Show("Deseja realmente remover essa sequência?", "Remover", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { Sequences.Remove(SelectedSequence); } }
public void PlayerEnterWorld() { IsAlive = true; // seems like something that should be handled differently... IsOnline = true; // Save the the LoginTimestamp SetProperty(PropertyFloat.LoginTimestamp, Time.GetTimestamp()); var totalLogins = GetProperty(PropertyInt.TotalLogins) ?? 0; totalLogins++; SetProperty(PropertyInt.TotalLogins, totalLogins); Sequences.AddOrSetSequence(SequenceType.ObjectInstance, new UShortSequence((ushort)totalLogins)); // SendSelf will trigger the entrance into portal space SendSelf(); SendFriendStatusUpdates(); // Init the client with the chat channel ID's, and then notify the player that they've choined the associated channels. var setTurbineChatChannels = new GameEventSetTurbineChatChannels(Session, 0, 1, 2, 3, 4, 6, 7, 0, 0, 0); // TODO these are hardcoded right now var general = new GameEventDisplayParameterizedStatusMessage(Session, StatusMessageType2.YouHaveEnteredThe_Channel, "General"); var trade = new GameEventDisplayParameterizedStatusMessage(Session, StatusMessageType2.YouHaveEnteredThe_Channel, "Trade"); var lfg = new GameEventDisplayParameterizedStatusMessage(Session, StatusMessageType2.YouHaveEnteredThe_Channel, "LFG"); var roleplay = new GameEventDisplayParameterizedStatusMessage(Session, StatusMessageType2.YouHaveEnteredThe_Channel, "Roleplay"); Session.Network.EnqueueSend(setTurbineChatChannels, general, trade, lfg, roleplay); }
/// <summary> /// Clear the sequence alignment /// </summary> public virtual void Clear() { Consensus = null; Score = 0; Offsets.Clear(); Sequences.Clear(); }
public void AddSequence(string sequence, int value) { if (String.IsNullOrEmpty(sequence)) { return; } if (sequence.Length % 2 != 0) { throw new ArgumentException("Sequence has incorrect string length"); } Sequence s = new Sequence() { Value = value }; for (int sPos = 0; sPos < sequence.Length; sPos += 2) { string val = sequence.Substring(sPos, 2); Cell c = new Cell() { Value = val }; s.Cells.Add(c); } Sequences.Add(s); }
/// <summary> /// When implemented in a derived class, performs the execution of the activity. /// </summary> /// <param name="context">The execution context under which the activity executes.</param> protected override void Execute(CodeActivityContext context) { string filename = Filename.Get(context); ISequenceFormatter formatter = SequenceFormatters.FindFormatterByFileName(filename); if (formatter == null) { throw new ArgumentException("Could not determine formatter for " + filename); } if (LogOutput) { var tw = context.GetExtension <TextWriter>() ?? Console.Out; tw.WriteLine("Writing sequences to " + filename); } try { foreach (var s in Sequences.Get(context)) { formatter.Format(s); } } finally { formatter.Close(); } }
public async Task RenderAsync(CancellationToken cancellationToken = default) { var mapper = new MainModelMapper(); var sequenceViewModels = Sequences.Select(mapper.Map).ToList(); var sequencesVm = new Sequences(sequenceViewModels); var renderedMain = await Formatter.RenderTemplateAsync(sequencesVm, cancellationToken).ConfigureAwait(false); var databaseName = !IdentifierDefaults.Database.IsNullOrWhiteSpace() ? IdentifierDefaults.Database + " Database" : "Database"; var pageTitle = "Sequences · " + databaseName; var mainContainer = new Container(renderedMain, pageTitle, string.Empty); var renderedPage = await Formatter.RenderTemplateAsync(mainContainer, cancellationToken).ConfigureAwait(false); if (!ExportDirectory.Exists) { ExportDirectory.Create(); } var outputPath = Path.Combine(ExportDirectory.FullName, "sequences.html"); using var writer = File.CreateText(outputPath); await writer.WriteAsync(renderedPage.AsMemory(), cancellationToken).ConfigureAwait(false); await writer.FlushAsync().ConfigureAwait(false); }
/// <summary> /// Creates a <see cref="Sobol"/> using specified /// direction vectors. /// </summary> public Sobol(ulong[] directionVectors) { v = directionVectors; if (v == null) { throw new ArgumentNullException(); } if (v.Length < 64) { throw new ArgumentException("If you want to supply fewer than 64 direction vectors, use one of the other constructors."); } if (v.Length > 64) { throw new ArgumentException("Do not provide more than 64 direction vectors."); } for (int i = 0; i < 64; i++) { if (i < 63 && (v[i] << (i + 1)) != 0) { throw new ArgumentException($"{63 - i} least-significant bits of element {i} must be 0."); } if ((v[i] << i) == 0) { throw new ArgumentException($"Bit {63 - i} of element {i} must be 1."); } } ruler = Sequences.Ruler().GetEnumerator(); }
Sequences GetRandomEnum() { System.Array A = System.Enum.GetValues(typeof(Sequences)); Sequences V = (Sequences)A.GetValue(UnityEngine.Random.Range(0, A.Length)); return(V); }
void LoadSequences() { Sequences.Clear(); var soundSequences = SoundServiceSingleton.Instance.GetAllSoundSequences(); soundSequences.ForEach(x => Sequences.Add(x)); }
public Sequences GetSequences(int input, string seperator) { var sequences = new Sequences(); foreach (var sequence in _sequences) { switch (sequence.Name) { case SequenceType.All: sequences.AllSequence = SequenceFormatHelper.Format(seperator, sequence.GetSequence(input)); break; case SequenceType.Even: sequences.EvenSequence = SequenceFormatHelper.Format(seperator, sequence.GetSequence(input)); break; case SequenceType.Odd: sequences.OddSequence = SequenceFormatHelper.Format(seperator, sequence.GetSequence(input)); break; case SequenceType.Multiples: sequences.MultiplesSequence = SequenceFormatHelper.Format(seperator, sequence.GetSequence(input)); break; } } return(sequences); }
public static void RunSequence() { int i = 1; int l = 9; foreach (double number in Sequences.KappaNumberGenerator(l)) { Console.Write("K({0,2}, {1,2}): {2,-30}", l, i, number); if (++i % 3 == 1) { Console.WriteLine(); } } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Using the direct value calculation"); for (i = 1; i <= l;) { Console.Write("K({0,2}, {1,2}): {2,-30}", l, i, Sequences.KappaNumber(l, i)); if (++i % 3 == 1) { Console.WriteLine(); } } Console.WriteLine(); }
private void ExecuteSequences() { var sequences = Sequences.ToList(); TokenSource2 = new CancellationTokenSource(); _cancellationToken = TokenSource2.Token; Task.Factory.StartNew(() => { _cancellationToken.ThrowIfCancellationRequested(); foreach (var testSequence in sequences) { DriverContainer.Driver.SetPower((int)testSequence.Power); Thread.Sleep(200); DriverContainer.Driver.SetContinousDelay((int)testSequence.Delay); Thread.Sleep(200); DriverContainer.Driver.SetPulseDuration(testSequence.Duration); Thread.Sleep(200); DriverContainer.Driver.SetSide(testSequence.Side); Thread.Sleep(200); DriverContainer.Driver.PulseSingle(); Thread.Sleep((int)testSequence.Duration + (int)testSequence.Delay + 1000); _cancellationToken.ThrowIfCancellationRequested(); } IsRunningSequence = false; }, _cancellationToken); }
public static async void SetDiagramLsb(int nLsb) { Sequences.DiagramLsb = nLsb; Sequences.SetLSB(Sequences.DiagramLsb == 0); m_hvsCurrent.Update(); await m_dp.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, UpdateDiagrams); }
private Sobol(Sobol other) { v = other.v; value = other.value; skip = other.skip; ruler = Sequences.Ruler(skip).GetEnumerator(); }
/// <summary> /// Modified. /// Clears the SequenceAlignment /// Throws exception if SequenceAlignment is read only. /// </summary> public new void Clear() { Sequences.Clear(); Consensus = null; _score = 0; ProfilesMatrix.Clear(); }
// Inherited public override void Clear() { VramAllocation = 2048; int moldCount = Molds.Count; for (int i = 1; i < moldCount; i++) { Molds.RemoveAt(1); } int tileCount = Molds[0].Tiles.Count; for (int i = 1; i < tileCount; i++) { Molds[0].Tiles.RemoveAt(1); } Molds[0].Gridplane = false; UniqueTiles = new List <Mold.Tile>(); if (Molds[0].Tiles.Count > 0) { Molds[0].Tiles[0] = Molds[0].Tiles[0].New(false); UniqueTiles.Add(Molds[0].Tiles[0]); } int sequenceCount = Sequences.Count; for (int i = 1; i < sequenceCount; i++) { Sequences.RemoveAt(1); } Sequences[0].Frames = new List <Sequence.Frame>(); }
public void PlayerEnterWorld() { PlayerManager.SwitchPlayerFromOfflineToOnline(this); // Save the the LoginTimestamp var lastLoginTimestamp = Time.GetUnixTime(); SetProperty(PropertyInt.LoginTimestamp, (int)lastLoginTimestamp); Character.LastLoginTimestamp = lastLoginTimestamp; Character.TotalLogins++; CharacterChangesDetected = true; Sequences.SetSequence(SequenceType.ObjectInstance, new UShortSequence((ushort)Character.TotalLogins)); // SendSelf will trigger the entrance into portal space SendSelf(); // Init the client with the chat channel ID's, and then notify the player that they've choined the associated channels. var setTurbineChatChannels = new GameEventSetTurbineChatChannels(Session, 0, 1, 2, 3, 4, 6, 7, 0, 0, 0); // TODO these are hardcoded right now var general = new GameEventWeenieErrorWithString(Session, WeenieErrorWithString.YouHaveEnteredThe_Channel, "General"); var trade = new GameEventWeenieErrorWithString(Session, WeenieErrorWithString.YouHaveEnteredThe_Channel, "Trade"); var lfg = new GameEventWeenieErrorWithString(Session, WeenieErrorWithString.YouHaveEnteredThe_Channel, "LFG"); var roleplay = new GameEventWeenieErrorWithString(Session, WeenieErrorWithString.YouHaveEnteredThe_Channel, "Roleplay"); Session.Network.EnqueueSend(setTurbineChatChannels, general, trade, lfg, roleplay); // check if vassals earned XP while offline AddCPPoolToUnload(true); HandleDBUpdates(); }
public void CheckDuplicateWords(int lowerLimit, int upperLimit) { // Create unique sequences. List <string> uniqueSequences = new List <string>(); foreach (WordData sequence in Sequences) { if (!uniqueSequences.Contains(sequence.Letters)) { uniqueSequences.Add(sequence.Letters); } } // Check the number of occurances. foreach (String letters in uniqueSequences) { List <WordData> duplicates = Sequences.FindAll(x => x.Letters.Equals(letters)); duplicates.RemoveAt(0); // A duplicate does not include the word itself. if (duplicates.Any()) { if (duplicates.Count < lowerLimit || duplicates.Count > upperLimit) { ErrorMessages.Add(String.Format(CrozzleErrors.DuplicateWordCountError, letters, duplicates.Count, lowerLimit, upperLimit)); } } } }
protected override void OnExperimentStart() { // Initialize RL state Lots = new Lot[LotGenerator.TargetWIP]; Machines = new Machine[WorkStations.Values.SelectMany(x => x.Machines).Count()]; ProductTypes = new string[Sequences.Count()]; MachineIndexes.Clear(); ProductTypeIndexes.Clear(); int machineIndex = 0; foreach (Machine machine in WorkStations.Values.SelectMany(x => x.Machines).OrderBy(x => x.Index)) { Machines[machineIndex] = machine; MachineIndexes.Add(machine, machineIndex); machineIndex++; } int ptIndex = 0; foreach (string type in Sequences.Keys.OrderBy(x => x)) { ProductTypes[ptIndex] = type; ProductTypeIndexes.Add(type, ptIndex); ptIndex++; } State.Initialize(); // Initialize TargetCycleTimesPerStep in Sequences foreach (Sequence seq in Sequences.Values) { seq.CalculateTargetCycleTimesPerStep(); } }
private void PopulateMissingHashes <T>(DynamoMetadataType table, List <T> items) { var autoIncr = table.Fields.FirstOrDefault(x => x.IsAutoIncrement); if (autoIncr != null) { var seqRequiredPos = new List <int>(); for (int i = 0; i < items.Count; i++) { var item = items[i]; var value = autoIncr.GetValue(item); if (DynamoConverters.IsNumberDefault(value)) { seqRequiredPos.Add(i); } } if (seqRequiredPos.Count == 0) { return; } var nextSequences = Sequences.GetNextSequences(table, seqRequiredPos.Count); for (int i = 0; i < nextSequences.Length; i++) { var pos = seqRequiredPos[i]; autoIncr.SetValue(items[pos], nextSequences[i]); } } }
private static List <Shape> GetShapesInInteractiveSequenceWithAnimationsRemoved(PowerPointSlide currentSlide, Shape triggerShape, List <Shape> shapesToAnimate) { Sequences sequences = currentSlide.TimeLine.InteractiveSequences; // A set is used here so no duplicate shapes will be added ISet <Shape> shapesToAnimateSet = new HashSet <Shape>(shapesToAnimate); // Find the existing sequence that has the triggerShape for (int i = 1; i <= sequences.Count; i++) { Sequence sequence = sequences[i]; // Iterate from the back because of deletion for (int j = sequence.Count; j >= 1; j--) { Effect effect = sequence[j]; // A sequence is attached to a trigger shape. However we can only use the effect to find out // what is the trigger shape, thus we break when the first effect's trigger shape is not // what we are looking for and delete all effects from the sequence otherwise. if (effect.Timing.TriggerShape == triggerShape) { shapesToAnimateSet.Add(effect.Shape); effect.Delete(); } else { break; } } } return(new List <Shape>(shapesToAnimateSet)); }
public bitmap(CacheBase Cache, int Address) { EndianReader Reader = Cache.Reader; Reader.SeekTo(Address); #region Sequence Chunk Reader.SeekTo(Address + 60); int iCount = Reader.ReadInt32(); int iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Sequences.Add(new Sequence(Cache, iOffset + 60 * i)); } #endregion #region BitmapData Chunk Reader.SeekTo(Address + 68); iCount = Reader.ReadInt32(); iOffset = Reader.ReadInt32() - Cache.Magic; for (int i = 0; i < iCount; i++) { Bitmaps.Add(new BitmapData(Cache, iOffset + 116 * i)); } #endregion }
public void CheckDuplicateWords(int lowerLimit, int upperLimit) { // Create unique sequences. List <string> uniqueSequences = new List <string>(); foreach (WordData sequence in Sequences) { if (!uniqueSequences.Contains(sequence.Letters)) { uniqueSequences.Add(sequence.Letters); } } // Check the number of occurances. foreach (String letters in uniqueSequences) { List <WordData> duplicates = Sequences.FindAll(x => x.Letters.Equals(letters)); if (duplicates.Count > 1) { if (duplicates.Count < Configuration.MinimumNumberOfTheSameWord || duplicates.Count > Configuration.MaximumNumberOfTheSameWord) { ErrorMessages.Add(String.Format(CrozzleErrors.DuplicateWordCountError, letters, duplicates.Count, Configuration.MinimumNumberOfTheSameWord, Configuration.MaximumNumberOfTheSameWord)); } } } }
public void SumOfAllProductsWhereIdentityIsPandigitalSet_Is45228() { BigInteger expected = 45228; var candidates = Sequences.NumbersBetween(1, 10000) .Where(num => !num.HasRepeatedDigits()) .ToList(); var result = candidates .FullJoinWhere( candidates, (multiplicand, multiplier) => multiplicand > multiplier && (multiplicand * multiplier).ToDigits().Count() + multiplicand.ToDigits().Count() + multiplier.ToDigits().Count() == 9, (multiplicand, multiplier) => new List <BigInteger>() { multiplicand, multiplier, multiplicand * multiplier } ).Where(identity => !identity.HasRepeatedDigits()) .Where(identity => identity.IsPandigitalSet()) .Select(identity => identity[2]) // Product .ToHashSet() // Unique .Sum(); Assert.AreEqual(expected, result); }
public void TeleToMarketplace() { string message = $"{Name} is recalling to the marketplace."; var updateCombatMode = new GameMessagePrivateUpdatePropertyInt(Session.Player.Sequences, PropertyInt.CombatMode, (int)CombatMode.NonCombat); var motionMarketplaceRecall = new UniversalMotion(MotionStance.Standing, new MotionItem(MotionCommand.MarketplaceRecall)); var animationEvent = new GameMessageUpdateMotion(Guid, Sequences.GetCurrentSequence(SequenceType.ObjectInstance), Sequences, motionMarketplaceRecall); // TODO: This needs to be changed to broadcast sysChatMessage to only those in local chat hearing range // FIX: Recall text isn't being broadcast yet, need to address CurrentLandblock.EnqueueBroadcastSystemChat(this, message, ChatMessageType.Recall); Session.Network.EnqueueSend(updateCombatMode); DoMotion(motionMarketplaceRecall); // TODO: (OptimShi): Actual animation length is longer than in retail. 18.4s // float mpAnimationLength = MotionTable.GetAnimationLength((uint)MotionTableId, MotionCommand.MarketplaceRecall); // mpChain.AddDelaySeconds(mpAnimationLength); ActionChain mpChain = new ActionChain(); mpChain.AddDelaySeconds(14); // Then do teleport mpChain.AddChain(GetTeleportChain(MarketplaceDrop)); // Set the chain to run mpChain.EnqueueChain(); }
// Update is called once per frame void Update () { /*if( Input.GetKeyDown(KeyCode.Space)) { Debug.Log (sequences.ToString()); NextSequence(SequencePhase); Debug.Log (sequences.ToString()); }*/ currentSequence = CurrentSequence; sequences = (Sequences)CurrentSequence; }
public Database(string typeName, string server, string name, string connectionString) { this.typeName = typeName; this.server = server; this.name = name; this.connectionString = connectionString; connection = new OdbcConnection(this.connectionString); _tables = new Tables(this); _views = new Views(this); _sequences = new Sequences(this); _storedprocedures = new StoredProcedures(this); _functions = new Functions(this); _modules = new Modules(this); _mqts = new MQTS(this); }
static public bool NextSequence(string tag) { if (tag == "Slapen" && sequences.ToString() == "Slapen") { CurrentSequence = 0; sequences = Sequences.Opstaan; int levelToLoad = Application.loadedLevel + 1; Application.LoadLevel(levelToLoad); } else if(tag == "TvKijken" && sequences.ToString() == "TvKijken") { directionLight.GetComponent<DayNightTransition>().DayToNight(); } if (tag == sequences.ToString()) { Debug.Log(tag); CurrentSequence += 1; sequences = (Sequences)CurrentSequence; return true; } return false; }
public void TrySquence(Sequences seq, int lenMS, int timoutMS) { if (Seq == null) { Seq = new Sequence(seq, lenMS, timoutMS); return; } if (!Seq.Running) { Seq = new Sequence(seq, lenMS, timoutMS); } }
/// <summary> /// 測定状態の変更イベント /// </summary> /// <param name="status"></param> void testSquence_StatusChanged(Sequences.TestSequence.TestStatusType status) { if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate{ testSquence_StatusChanged(status); }); return; } switch (status) { case Sequences.TestSequence.TestStatusType.Run: controllerForm.SetMeasureStatus(frmMeasureController.MeasureStatus.Start); bAllReadyStart = true; this.measureTask.Start(); this.swMeasure.Reset(); this.swMeasure.Start(); ShowStatusMessage(AppResource.GetString("TXT_MEASURE_START")); break; case Sequences.TestSequence.TestStatusType.Pause: controllerForm.SetMeasureStatus(frmMeasureController.MeasureStatus.Stop); //for (int i = 0; i < this.graph2DList.Length; i++) //{ // if (this.graph2DList[i] != null) // { // this.graph2DList[i].IsRealTime = false; // } //} this.swMeasure.Stop(); ShowStatusMessage(AppResource.GetString("MSG_MEAS_STOP_TEST")); this.measureTask.Pause(); break; case Sequences.TestSequence.TestStatusType.Stop: controllerForm.SetMeasureStatus(frmMeasureController.MeasureStatus.Exit); ShowStatusMessage(AppResource.GetString("MSG_MEAS_END")); try { this.controllerForm.Enabled = false; this.graphControllerForm.Enabled = false; this.Enabled = false; RealTimeData.EndData(); this.measureTask.Pause(); bool bret = true; //データが一つでも受信されていればデータ保存する。 if (RealTimeData.receiveCount != 0) { ShowStatusMessage(AppResource.GetString("MSG_MEAS_SAVE_FILES")); // 測定設定ファイル群及びデータファイルを保存する bret = SaveMeasureFiles(); } if (bret) testSquence.ExitTest(); else { //画面終了しない。再開があるため。 return; } //測定完了フラグオン bMeasureClosed = true; } finally { this.controllerForm.Enabled = true; this.graphControllerForm.Enabled = true; this.Enabled = true; } //画面終了 if (this.InvokeRequired) this.Invoke((MethodInvoker)delegate() { this.Close(); }); else this.Close(); break; //緊急停止 case Sequences.TestSequence.TestStatusType.EmergencyStop: System.Threading.Tasks.Task task = new System.Threading.Tasks.Task( delegate { this.measureTask.Stop(); //測定を停止する。 testSquence.EndTest(); }); task.Start(); MessageBox.Show(AppResource.GetString("MSG_MEAS_EMERGENCY_STOP"), AppResource.GetString("TXT_MEASUREMENT"), MessageBoxButtons.OK, MessageBoxIcon.Stop); break; } }
public void reset() { _tables = new Tables(this); _views = new Views(this); _sequences = new Sequences(this); _storedprocedures = new StoredProcedures(this); _functions = new Functions(this); _modules = new Modules(this); _mqts = new MQTS(this); }
/// <summary> /// Defines a chain of RGB LEDs /// </summary> /// <param name="Chipset">The chipset used to daisychain the LEDs</param> /// <param name="LedCount">The amount of LEDs in the chain</param> /// <param name="SPI_Device">The SPI bus the chain is connected to</param> /// <param name="ChipSelect_Port">If there's a CS circuitry, specify it's pin</param> /// <param name="ChipSelect_ActiveState">If there's a CS circuitry, specify it's active state</param> public RgbLedStrip(Chipsets Chipset, int LedCount, SPI.SPI_module SPI_Device, Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState) { // The used chipset this._Chipset = Chipset; // Stores the amount of LEDs this.LedCount = LedCount; // Extends the arrays for the LED states and brightness this._LedState = new byte[LedCount * 3]; this._Brightness = new byte[LedCount]; // Settings for the LPD8806 chip if (Chipset == Chipsets.LPD8806) { // Creates a new buffer (final 3 bytes should always be 0 and tells the chain we're done for now) this._Buffer = new byte[LedCount * 3 + 3]; // Default sequence of the Adafruit strips this.Sequence = Sequences.GRB; } // Settings for the WS2801 chip if (Chipset == Chipsets.WS2801) { // Creates a new buffer this._Buffer = new byte[LedCount * 3]; // Default sequence of the Adafruit chains this.Sequence = Sequences.RGB; } // Configures the SPI bus this._Conn = new MultiSPI(new SPI.Configuration( ChipSelect_Port: ChipSelect_Port, ChipSelect_ActiveState: ChipSelect_ActiveState, ChipSelect_SetupTime: 0, ChipSelect_HoldTime: 0, Clock_IdleState: false, Clock_Edge: true, Clock_RateKHz: 1000, SPI_mod: SPI_Device )); // Set brightness only half way, most LED strips are just way too bright imho this.SetBrightnessAll(128); // Turns off all LEDs this.SetColorAll(0); // Writes for the first time this.Write(); }