public RemoteCube(Tlc5940 tlc5940) { this.tlc5940 = tlc5940; layers = Helper.CreateLayers(); cachedLayers = Helper.CreateLayers(); newData=new bool[6]; }
public Cube(Tlc5940 tlc5940,Animation anim) { this.tlc5940 = tlc5940; layers = Helper.CreateLayers(); animation = anim; //LedLayers[0].SetAllLedsColor(0,0,0); //LedLayers[1].SetAllLedsColor(1,0.5f,0); //LedLayers[2].SetAllLedsColor(0,0,0); //LedLayers[3].SetAllLedsColor(0,0.5f,1f); //LedLayers[4].SetAllLedsColor(0,0,0); //LedLayers[5].SetAllLedsColor(0.5f,0,0.7f); //for (int index = 0; index < LedLayers.Length; index++) //{ // LedLayers[index].WriteBufferFromLeds(layers[index].LayerBuffer12Bit); //} }
public static void CycleLayers(Layer[] layers,Tlc5940 tlc5940) { for (int index = 0; index < layers.Length; index++) { var layer = layers[index]; tlc5940.PushBuffer(ref layer.LayerBuffer12Bit); var previousIndex = index - 1; if (previousIndex < 0) { previousIndex = layers.Length - 1; } //layer-1 off layers[previousIndex].Off(); //confirm tlc5940.Confirm(); //layer on layer.On(); Thread.Sleep(2); } }
public static void Main() { var button = new InterruptPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); var led=new OutputPort(Pins.ONBOARD_LED, false); new Thread(() => { while (true) { led.Write(true); Thread.Sleep(500); led.Write(false); Thread.Sleep(200); } }).Start(); var tlc5940 = new Tlc5940(); //var anim = new Animation(); //var cube = new Cube(tlc5940,anim); //ThreadStart animThreadStart = anim.Rain; // var animThread = new Thread(animThreadStart) {Priority = ThreadPriority.Lowest}; var cube = new RemoteCube(tlc5940); ThreadStart tlcThreadStart = cube.Start; var tlcThread = new Thread(tlcThreadStart) {Priority = ThreadPriority.Highest}; tlcThread.Start(); //animThread.Start(); new Thread(() => { //SerialPortHelper.PrintLine(""); //SerialPortHelper.PrintLine("r"); var layer = Tlc5940.CreateBuffer(Config.TlcChannelCount); while (true) { Thread.Sleep(1); string line = SerialPortHelper.ReadLine(); if (line.Length > 0) { if (line.Length == 1) { if (line == "\t") { continue; } var layerIdx = Convert.ToInt32(line); bool readLayer; do { readLayer = SerialPortHelper.ReadLayer(ref layer); Thread.Sleep(1); } while (!readLayer); cube.NewLayerData(layerIdx, ref layer); } //if (line == "r") //{ // SerialPortHelper.PrintLine("s"); // continue; //} //if (line == "f") //{ // SerialPortHelper.PrintLine("f"); // continue; //} //SerialPortHelper.PrintLine(line); //if (line == "e") // SerialPortHelper.PrintLine("n"); } } }).Start(); }