private static List <PropertyInfo> GetProprites(OBJS.Types Type, Type BaseType) { List <PropertyInfo> Props = new List <PropertyInfo>(); List <PropertyInfo> RawPropertyInfos = new List <PropertyInfo>(BaseType.GetProperties()); RawPropertyInfos.ForEach(RPI => { var WTF = RPI.GetCustomAttributes(true); var Attrs = RPI.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true); Attrs.ToString(); }); List <PropertyInfo> PropertyInfo = new List <PropertyInfo>(RawPropertyInfos.Where(A => A.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).Where(B => ((OBJS.XMLDatabaseRetriveItem)B).Type == Type).Any())); return(PropertyInfo); }
public void start() { //var cmdThread = new TCommandLineThread(); //cmdThread.start(); Console.WriteLine("starte test"); //testFunc(); Console.WriteLine("beende test"); var bits = larne.io.ic.IOUtils.getBits(1); foreach (var bit in bits) Console.Write(bit ? 1 : 0); Console.WriteLine(); //var bytes = larne.io.ic.IOUtils.ToByteArray(bits); //foreach (var b in bytes) Console.WriteLine(b); //Console.WriteLine() ; var device = new RPI(); //var D16_SDI = new GPIOMem(GPIOPins.V2_GPIO_25, GPIODirection.Out, false); //var D17_CLK = new GPIOMem(GPIOPins.V2_GPIO_08, GPIODirection.Out, false); //var CS = new GPIOMem(GPIOPins.V2_GPIO_07, GPIODirection.Out, false); //var RST = device.createPin(GPIOPins.V2_GPIO_23, GPIODirection.Out, false); //var RS = new GPIOMem(GPIOPins.V2_GPIO_24, GPIODirection.Out, false); //--- //var D16_SDI = new GPIOMem(GPIOPins.V2_GPIO_10, GPIODirection.Out, false); //var D17_CLK = new GPIOMem(GPIOPins.V2_GPIO_11, GPIODirection.Out, false); //var CS = new GPIOMem(GPIOPins.V2_GPIO_08, GPIODirection.Out, false); //var RST = device.createPin(GPIOPins.V2_GPIO_18, GPIODirection.Out, false); //var RS = new GPIOMem(GPIOPins.V2_GPIO_04, GPIODirection.Out, false); //var spi = new TSPIEmulator(D16_SDI, null, D17_CLK, CS); var rnd = new Random(); var watch = new System.Diagnostics.Stopwatch(); //var bus = new TOLEDSPIFastDataBus(spi, RST, RS); //var lcd = new TOLEDDisplay(bus); var hw = new TIOHardware(); hw.init(); hw.displayPowerOn(); var lcd = hw.lcd; lcd.background(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))); lcd.orientation(3); var bg = (Bitmap)Image.FromFile(chess.shared.Config.applicationPath + "tmp/test.bmp"); //lcd.drawImage(bmp, 0, 0, bmp.Width, bmp.Height); lcd.cls(); adapter = new TOLEDDisplayAdapter(lcd); //adapter.update(bg, 0, 0, lcd.width, lcd.height); var bmp = new Bitmap(lcd.width, lcd.height); var gfx = Graphics.FromImage(bmp); gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; var st = new List<string>(); st.Add("Erster Eintrag"); st.Add("Zweiter Eintrag"); st.Add("Dritter Eintrag"); st.Add("Vierter Eintrag"); st.Add("Fünfter Eintrag"); st.Add("Sechster Eintrag"); st.Add("Siebter Eintrag"); st.Add("Achter Eintrag"); st.Add("Neunter Eintrag"); st.Add("Zehnter Eintrag"); //lcd.debug(); lcd.fill(40, 10, 20, 30, Color.Red.ToArgb()); //Console.ReadLine(); while (true) { CommandLineThread.processEvents(onConsoleLine); //gfx.Clear(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))); gfx.DrawImage(bg, 0, 0); st.Add(st[0]); st.RemoveAt(0); //gfx.DrawString(string.Join("\n", st.ToArray()), new Font(FontFamily.GenericSansSerif, 11), new SolidBrush(Color.DarkBlue), new PointF(0, 0)); gfx.DrawString("S", new Font(FontFamily.GenericSansSerif, 18), new SolidBrush(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))), new PointF(rnd.Next(120) - 10, rnd.Next(130) - 10)); watch.Restart(); adapter.update(bmp, 0, 0, lcd.width, lcd.height); //lcd.background(Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255))); //lcd.cls(); Console.WriteLine(watch.ElapsedMilliseconds); System.Threading.Thread.Sleep(400); } Console.ReadLine(); }
public void init() { var device = new RPI(); var namedPins = new TNamedPins(); //namedPins.Add("LOW", device.createPin(GPIOPins.V2_GPIO_03, GPIODirection.Out, false)); //namedPins.Add("HI", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, true)); //namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_02, GPIODirection.Out, false)); //namedPins.Add("OE", null); //namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_04, GPIODirection.Out, false)); //namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, false)); //namedPins.Add("SRCLR", null); //namedPins.Add("O7", device.createPin(GPIOPins.V2_GPIO_10, GPIODirection.In)); //namedPins.Add("CP", device.createPin(GPIOPins.V2_GPIO_09, GPIODirection.Out, false)); //namedPins.Add("PL", device.createPin(GPIOPins.V2_GPIO_11, GPIODirection.Out, false)); //--- namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, false)); namedPins.Add("OE", null); namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_22, GPIODirection.Out, false)); namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, false)); namedPins.Add("SRCLR", null); namedPins.Add("O7", device.createPin(GPIOPins.V2_GPIO_23, GPIODirection.In)); namedPins.Add("CP", device.createPin(GPIOPins.V2_GPIO_24, GPIODirection.Out, false)); namedPins.Add("PL", device.createPin(GPIOPins.V2_GPIO_25, GPIODirection.Out, false)); sipo = new TSIPO(namedPins["SER"], namedPins["OE"], namedPins["RCLK"], namedPins["SRCLK"], namedPins["SRCLR"]); //sipo.setBits(new int[200]); //clear all //WARNING: CAN DESTROY SCREEN! USE POWER UP / DOWN SEQUENCE!! piso = new TPISO(namedPins["O7"], namedPins["PL"], namedPins["CP"]); ledMapping = new TBitMapping(8); ledMapping.setMapping(0, 1, 2, 3, 7, 6, 5, 4); ledMappingBottom = new TBitMapping(8); ledMappingBottom.setMapping(0, 1, 2, 3, 7, 6, 5, 4); //OK? ledMappingRight = new TBitMapping(8); ledMappingRight.setMapping(0, 1, 2, 3, 7, 6, 5, 4); //OK //1000 0000 ledMappingSpecial = new TBitMapping(8); ledMappingSpecial.setMapping(0, 1, 2, 3, 7, 6, 5, 4); //CHECK outMapping = new TBitMapping(8); //outMapping.setMapping(4, 0, 1, 2, 5, 6, 7, 3); //outMapping.setMapping(3, 7, 6, 5, 2, 1, 0, 4); outMapping.setMapping(7, 6, 5, 4, 3, 2, 1, 0); //0000 //0001 //outMappingBugFix = new TBitMapping(8); //outMappingBugFix.setMapping(4, 0, 1, 2, 5, 7, 6, 3); sideMapping = new TBitMapping(8); //sideMapping.setMapping(7, 0, 1, 2, 3, 4, 5, 6); sideMapping.setMapping(0, 1, 2, 3, 4, 5, 6, 7); sideSwitchesOld = new bool[sideSwitchCount]; sideSwitchesNew = new bool[sideSwitchCount]; sideSwitchesOldDelay = new bool[sideSwitchCount]; sideSwitchesNewDelay = new bool[sideSwitchCount]; //screen var D16_SDI = new GPIOMem(GPIOPins.V2_GPIO_10, GPIODirection.Out, false); var D17_CLK = new GPIOMem(GPIOPins.V2_GPIO_11, GPIODirection.Out, false); var CS = new GPIOMem(GPIOPins.V2_GPIO_08, GPIODirection.Out, false); var RST = device.createPin(GPIOPins.V2_GPIO_18, GPIODirection.Out, false); var RS = new GPIOMem(GPIOPins.V2_GPIO_04, GPIODirection.Out, false); var spi = new TSPIEmulator(D16_SDI, null, D17_CLK, CS); var watch = new System.Diagnostics.Stopwatch(); var bus = new TOLEDSPIFastDataBus(spi, RST, RS); lcd = new TOLEDDisplay(bus, this); lcd.orientation(3); lcd.background(Color.Black); displayPowerOff(); }
static void Main(string[] args) { Console.WriteLine("huhu2"); //var p1 = new GPIOFile(GPIO.GPIOPins.GPIO02, GPIO.DirectionEnum.IN); //while (true) { // Console.Write(p1.Read() ? "1" : "0"); // System.Threading.Thread.Sleep(1000); //} var device = new RPI(); var namedPins = new TNamedPins(); namedPins.Add("LOW", device.createPin(GPIOPins.V2_GPIO_03, GPIODirection.Out, false)); namedPins.Add("HI", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, true)); namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_02, GPIODirection.Out, false)); namedPins.Add("OE", null); namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_04, GPIODirection.Out, false)); namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, false)); namedPins.Add("SRCLR", null); namedPins.Add("O7", device.createPin(GPIOPins.V2_GPIO_10, GPIODirection.In)); namedPins.Add("CP", device.createPin(GPIOPins.V2_GPIO_09, GPIODirection.Out, false)); namedPins.Add("PL", device.createPin(GPIOPins.V2_GPIO_11, GPIODirection.Out, false)); //while (true) // if (namedPins["O7"].Read()) { // Console.Write("1"); // System.Threading.Thread.Sleep(100); // } var sipo = new TSIPO(namedPins["SER"], namedPins["OE"], namedPins["RCLK"], namedPins["SRCLK"], namedPins["SRCLR"]); sipo.setBits(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); //return; var piso = new TPISO(namedPins["O7"], namedPins["PL"], namedPins["CP"]); var sipoArray = new TSIPOArray(sipo, 16); var ledMapping = new TBitMapping(8); ledMapping.setMapping(0, 1, 7, 6, 2, 3, 4, 5); var outMapping = new TBitMapping(8); //outMapping.setMapping(0, 2, 3, 4, 6, 1, 5, 7); outMapping.setMapping(4, 0, 1, 2, 5, 6, 3, 7); var readBitCount = 64; var lastBits = new bool[readBitCount]; var ledBits = new bool[88]; while (true) { //sipo.setBits(new int[] { 1, 0, 1, 0, 1, 0, 1, 0 }); //System.Threading.Thread.Sleep(200); //sipo.setBits(new int[] { 0, 1, 0, 1, 0, 1, 0, 1 }); //System.Threading.Thread.Sleep(200); //continue; piso.load(); piso.readBits(8*0, false); var tmpBits = outMapping.convert(piso.readBits(8, false)).ToArray(); for (var i = 0; i < 8; i++) { if (tmpBits[i] != lastBits[i]) { foreach (var bit in tmpBits) { Console.Write(bit ? "1" : "0"); } Console.Write(" "); break; } } lastBits = tmpBits; Array.Copy(lastBits, ledBits, 8); //foreach (var bit in tmpBits) { // Console.Write(bit ? "1" : "0"); //} //Console.Write(" "); //if (namedPins["O7"].Read()) ledBits[0] = true; //for (var i = 0; i < readBitCount; i++) { // if (tmpBits[i]) // switch (i) { // case 0: // ledBits[2] = true; // break; // case 1: // ledBits[1] = true; // break; // case 2: // ledBits[0] = true; // break; // case 3: // ledBits[7] = true; // break; // case 4: // ledBits[3] = true; // break; // case 5: // ledBits[4] = true; // break; // case 6: // ledBits[5] = true; // break; // case 7: // ledBits[6] = true; // break; // } //} //ledBits[6] = true; //sipoArray.setBits(ledMapping.convert(ledBits), 0); sipoArray.flush(); //var rowCount = 2; //var columnCount = 4;// 4; //var inputArray = new bool[columnCount, rowCount]; //for (var column = 0; column < columnCount; column++) { // var columnBits = new bool[8]; // columnBits[column] = true; // sipoArray.setBits(columnBits); // sipoArray.flush(); // var row = 0; // foreach (var bit in piso.readBits(rowCount)) { // Console.Write(bit ? "1" : "0"); // inputArray[column, row] = bit; // ledBits[(row * columnCount) + column] = bit; // row++; // } // Console.WriteLine(); //} //Console.WriteLine(); //sipoArray.setBits(ledMapping.convert(ledBits), 8); //sipoArray.flush(); //System.Threading.Thread.Sleep(500); //Console.Write(" "); //namedPins["PL"].Write(true); //System.Threading.Thread.Sleep(100); //namedPins["PL"].Write(false); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(false); //System.Threading.Thread.Sleep(100); //printPin(namedPins["O7"]); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(true); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(false); //System.Threading.Thread.Sleep(100); //printPin(namedPins["O7"]); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(true); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(false); //System.Threading.Thread.Sleep(100); //printPin(namedPins["O7"]); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(true); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(false); //System.Threading.Thread.Sleep(100); //printPin(namedPins["O7"]); //System.Threading.Thread.Sleep(100); //namedPins["CP"].Write(true); //System.Threading.Thread.Sleep(100); //System.Threading.Thread.Sleep(1000); } }
public void setPin(int gpio, bool state) { var device = new RPI(); using (var pin = device.createPin((GPIOPins)gpio, GPIODirection.Out)) { pin.Write(state); } }
public void allPinsOn() { var namedPins = new TNamedPins(); var device = new RPI(); namedPins.Add("LOW", device.createPin(GPIOPins.V2_GPIO_03, GPIODirection.Out, true)); namedPins.Add("HI", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, true)); namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_02, GPIODirection.Out, true)); namedPins.Add("OE", null); namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_04, GPIODirection.Out, true)); namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, true)); namedPins.Add("SRCLR", null); namedPins.Add("O7", device.createPin(GPIOPins.V2_GPIO_10, GPIODirection.Out)); namedPins.Add("CP", device.createPin(GPIOPins.V2_GPIO_09, GPIODirection.Out, true)); namedPins.Add("PL", device.createPin(GPIOPins.V2_GPIO_11, GPIODirection.Out, true)); namedPins.Add("D16_SDI", device.createPin(GPIOPins.V2_GPIO_25, GPIODirection.Out, true)); namedPins.Add("D17_CLK", device.createPin(GPIOPins.V2_GPIO_08, GPIODirection.Out, true)); namedPins.Add("CS", device.createPin(GPIOPins.V2_GPIO_07, GPIODirection.Out, true)); namedPins.Add("RST", device.createPin(GPIOPins.V2_GPIO_23, GPIODirection.Out, true)); namedPins.Add("RS", device.createPin(GPIOPins.V2_GPIO_24, GPIODirection.Out, true)); foreach (var entry in namedPins) { if (entry.Value != null) { entry.Value.PinDirection = GPIODirection.Out; entry.Value.Write(true); } } }
public void test1() { var device = new RPI(); var namedPins = new TNamedPins(); namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, false)); namedPins.Add("OE", null); namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_22, GPIODirection.Out, false)); namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, false)); namedPins.Add("SRCLR", null); //var sipo = new TSIPO(namedPins["SER"], namedPins["OE"], namedPins["RCLK"], namedPins["SRCLK"], namedPins["SRCLR"]); //var bits = new List<bool>(); //for (var i = 128 - 1; i >= 0; i--) // bits.Add(i == exceptIndex ? !state : state); //sipo.setBits(bits); for (var i = 0; i < 3; i++) { namedPins["SER"].Write(true); System.Threading.Thread.Sleep(750); namedPins["SRCLK"].Write(true); System.Threading.Thread.Sleep(750); namedPins["SRCLK"].Write(false); System.Threading.Thread.Sleep(750); namedPins["RCLK"].Write(true); System.Threading.Thread.Sleep(750); namedPins["RCLK"].Write(false); System.Threading.Thread.Sleep(750); } }
public void setAllSipo(bool state, int exceptIndex = -1) { var device = new RPI(); var namedPins = new TNamedPins(); namedPins.Add("SER", device.createPin(GPIOPins.V2_GPIO_17, GPIODirection.Out, false)); namedPins.Add("OE", null); namedPins.Add("RCLK", device.createPin(GPIOPins.V2_GPIO_22, GPIODirection.Out, false)); namedPins.Add("SRCLK", device.createPin(GPIOPins.V2_GPIO_27, GPIODirection.Out, false)); namedPins.Add("SRCLR", null); var sipo = new TSIPO(namedPins["SER"], namedPins["OE"], namedPins["RCLK"], namedPins["SRCLK"], namedPins["SRCLR"]); var bits = new List<bool>(); for (var i = 128 - 1; i >= 0; i--) bits.Add(i == exceptIndex ? !state : state); sipo.setBits(bits); }