private void initializeSketch() { sketch = Sketch.Current; sketch.RegisterStats(false); sketch.SetMillis(0); sketch.Setup(); performHandshake(); // load an empty program, just in case. sketch.WriteSerial(emptyProgram); sketch.Loop(); }
private IEnumerable <ExecutionSnapshot> getSnapshots(IEnumerable <byte> pins) { sketch.WriteSerial(program); while (currentTime <= targetTime) { sketch.SetMillis(currentTime); sketch.Loop(); ExecutionSnapshot currentSnapshot = new ExecutionSnapshot(); currentSnapshot.ms = currentTime; for (int i = 0; i < currentSnapshot.pins.Length; i++) { currentSnapshot.pins[i] = (byte)(pins.Contains(pinMap[i]) ? (sketch.GetPinValue(pinMap[i]) == 0 ? 0 : 1) : 0); } yield return(currentSnapshot); currentTime++; } }