/// <summary> /// Creates the SenseHat object. /// </summary> public static Task <ISenseHat> GetSenseHat() { Pi.Init <BootstrapWiringPi>(); return(_getSenseHatTask); }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); // Logical Functions["if"] = new If(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row() { SkipArgumentEvaluation = true }; Functions["rows"] = new Rows() { SkipArgumentEvaluation = true }; Functions["column"] = new Column() { SkipArgumentEvaluation = true }; Functions["columns"] = new Columns() { SkipArgumentEvaluation = true }; Functions["choose"] = new Choose(); Functions["index"] = new Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset() { SkipArgumentEvaluation = true }; // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); }
static void TestSweep() { Console.WriteLine("Testing a servo motor in a sweeping motion"); var angle = 0d; var step = 0.1d; var done = false; using (var left = Pi.Gpio.Pin(leftPin, PinKind.InputPullUp)) using (var right = Pi.Gpio.Pin(rightPin, PinKind.InputPullUp)) using (var servo = new ServoMotor(maxAngle)) { servo.PulseWidths(0.5, 2.5); servo.Start(); var timer = PreciseTimer.Every(1, () => { if (done) { return(false); } angle += step; var a = angle % (maxAngle * 2); if (a > maxAngle) { a = (maxAngle * 2) - a; } servo.Angle = a; return(true); }); Console.WriteLine("Click the button to stop this test"); // Connect rotate and click events left.OnRisingEdge += Rotate; Pi.Gpio.Pin(buttonPin, PinKind.InputPullUp).WaitForEdge(PinEdge.Rising); left.OnRisingEdge -= Rotate; done = true; timer.Wait(); servo.Angle = 0; Pi.Wait(2000); // Called on the falling edge of the left pin void Rotate(object sender, PinEventHandlerArgs args) { if (args.Bounced) { return; } var s = step; if (left.Value == right.Value) { s += 0.1; } else { s -= 0.1; } if (s < 0) { s = 0; } step = s; Console.WriteLine("servo step {0:0.0}°", step); } } }
public static void Main(string[] args) { Console.WriteLine("Enter the device address:"); int expanderAddress = int.TryParse(Console.ReadLine(), out int address) ? address : GpioExpander.DefaultAddress; try { #if WIRING_PI Pi.Init <BootstrapWiringPi>(); _expander = Pi.I2C.GetGpioExpander(expanderAddress); #endif #if NOT_WIRING_PI _expander = I2cBus.Create(1).GetGpioExpander(expanderAddress); #endif } catch (Exception error) { Console.WriteLine($"Fail initialization GPIO Expander. Error: {error}"); return; } if (args.Length == 0) { Console.WriteLine("Select a mode:\n1. {0}\n2. {1}\n3. {2}\n4. {3}\n5. {4}\n6. {5}\n7. {6}\n", nameof(Analog1), nameof(Analog2), nameof(Digital), nameof(Port), nameof(Pwm), "Address/Reset", nameof(Adc)); switch (Console.ReadLine()) { case nameof(Analog1): { Analog1(); break; } case nameof(Analog2): { Analog2(); break; } case nameof(Digital): { Digital(); break; } case nameof(Port): { Port(); break; } case nameof(Pwm): { Pwm(); break; } case nameof(Adc): { Adc(); break; } case "Address": case "Reset": { AddressOrReset(); break; } default: { Console.WriteLine("Invalid program mode."); break; } } } else if (args[0].Equals("Freq", StringComparison.OrdinalIgnoreCase)) { FindFreq(); } else { Console.WriteLine("Invalid app mode."); } _expander?.Dispose(); Console.WriteLine("Application is shutting down..."); }
public static long Deg2Rad(long deg) { return(deg.Mul(Pi.Div(HalfCircle))); }
/// <summary> /// Probe the sensor by reading pin data /// </summary> private void ReadPin() { IsUpdateSuccessful = false; try { // Send the sensor our trigger signal pin.Write(false); // Wait at least 18ms for sensor initialization Pi.Wait(20); // Send the start signal pin.Write(true); // Wait 20μs - 40μs Pi.WaitMicroseconds(30); pin.Kind = PinKind.InputPullUp; // Sensor should take over and go low if (!pin.WaitLow(Pi.Microseconds(100))) { // FAIL: sensor did not take over return; } // Wait for the sensor to switch to high if (!pin.WaitHigh(Pi.Microseconds(100))) { // FAIL: sensor did not send high return; } // Wait for sensor to begin data bits if (!pin.WaitLow(Pi.Microseconds(100))) { // FAIL: sensor did not begin sending a data bit return; } // Elapsed is the duration a data bit was held high double elapsed = 0; // A buffer for eight bits of data byte data = 0; // Now we can begin reading 40 data bits for (int i = 0; i < 40; i++) { // Wait for the data bit if (!pin.WaitHigh(Pi.Microseconds(100))) { // FAIL: no data bit was sent return; } // Measure the data bit if (!pin.WaitLow(Pi.Microseconds(100), out elapsed)) { // FAIL: data bit was too long return; } // Make room to store the next data bit data <<= 1; // If elapsed was more than 40µs then the data bit is 1 if (elapsed > 0.04d) { data |= 1; } // If 8 bits were read then copy those bits to our buffer if (((i + 1) % 8) == 0) { buffer[i / 8] = data; } } // Success is reached if the checksum passes if ((buffer[4] == ((buffer[0] + buffer[1] + buffer[2] + buffer[3]) & 0xFF))) { IsUpdateSuccessful = (buffer[0] != 0) || (buffer[2] != 0); } } finally { // Set pin to high and for next update pin.Kind = PinKind.Output; pin.Write(true); // And set the last update time lastUpdate = Pi.Now; } }
List <Pi> getPiData(string tagName, DateTime StartDate, DateTime EndDate, out string unit) { ////DateTime startTime = DateTime.Now.AddSeconds(-1); ////DateTime endTime = DateTime.Now; ////TimeSpan span = new TimeSpan(0, 5, 0); PISDK.PISDK sdk = new PISDK.PISDK(); //PISDK.Server srv = sdk.Servers["mus-as-126.corp.pdo.om"]; //srv.Open("UID=upoa;PWD=upoa"); string piServer = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PIServer"]) ? "mus-as-126.corp.pdo.om" : ConfigurationSettings.AppSettings["PIServer"]; string piCredentials = string.IsNullOrEmpty(ConfigurationSettings.AppSettings["PICredentials"]) ? "UID=upoa;PWD=upoa" : ConfigurationSettings.AppSettings["PICredentials"]; Server srv = sdk.Servers[piServer]; srv.Open(piCredentials); string nameConcat = ""; int i = 0; PISDK.PIPoints myPoints = srv.PIPoints; PointList list = srv.GetPoints("tag = '*" + tagName + "*'"); int count = list.Count; PIData data = list[1].Data; unit = list[1].PointAttributes["EngUnits"].Value.ToString(); PIValues values; List <string> stringValues = new List <string>(); List <DateTime> timeValues = new List <DateTime>(); List <Pi> piData = new List <Pi>(); try { ////DateTime DateTimeStart = new DateTime(); ////DateTimeStart = Convert.ToDateTime(StartDate); ////DateTime DateTimeEnd = new DateTime(); ////DateTimeEnd = Convert.ToDateTime(EndDate); ////if (!string.IsNullOrEmpty(Request.Form["txtStartDate"])) ////{ //// TimeSpan timeSpan = new TimeSpan(int.Parse(ddlHoursStart.SelectedValue), int.Parse(ddlMinutesStart.SelectedValue), 0); //// DateTimeStart.Add(timeSpan); //// DateTimeEnd.AddHours(int.Parse(ddlHoursEnd.SelectedValue)); //// DateTimeEnd.AddMinutes(int.Parse(ddlMinutesEnd.SelectedValue)); ////} values = data.RecordedValues(StartDate, EndDate); foreach (PIValue value in values) { try { if (value.Value.GetType().IsCOMObject) { stringValues.Add((value.Value as DigitalState).Name.ToString()); PITimeServer.PITime pt = value.TimeStamp; } else { stringValues.Add((value.Value).ToString()); Pi p = new Pi(); p.time = value.TimeStamp.LocalDate; p.value = Convert.ToString(value.Value); p.tag = tagName; piData.Add(p); } } catch (Exception ex) { //throw ex; } } } catch (Exception ex) { } return(piData); }
public Dragino(Dictionary <String, String> settings) : base(settings) { Pi.Init <BootstrapWiringPi>(); this.ParseConfig(); this.Interfaces = 1; }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["concat"] = new Concat(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["search"] = new Search(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); Functions["value"] = new Value(); Functions["trim"] = new Trim(); Functions["clean"] = new Clean(); Functions["unicode"] = new Unicode(); Functions["unichar"] = new Unichar(); Functions["numbervalue"] = new NumberValue(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["acot"] = new Acot(); Functions["acoth"] = new Acoth(); Functions["cos"] = new Cos(); Functions["cot"] = new Cot(); Functions["coth"] = new Coth(); Functions["cosh"] = new Cosh(); Functions["csc"] = new Csc(); Functions["csch"] = new Csch(); Functions["power"] = new Power(); Functions["gcd"] = new Gcd(); Functions["lcm"] = new Lcm(); Functions["sec"] = new Sec(); Functions["sech"] = new SecH(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["ceiling.precise"] = new CeilingPrecise(); Functions["ceiling.math"] = new CeilingMath(); Functions["iso.ceiling"] = new IsoCeiling(); Functions["combin"] = new Combin(); Functions["combina"] = new Combina(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["factdouble"] = new FactDouble(); Functions["floor"] = new Floor(); Functions["floor.precise"] = new FloorPrecise(); Functions["floor.math"] = new FloorMath(); Functions["radians"] = new Radians(); Functions["roman"] = new Roman(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["sumxmy2"] = new Sumxmy2(); Functions["sumx2my2"] = new SumX2mY2(); Functions["sumx2py2"] = new SumX2pY2(); Functions["seriessum"] = new Seriessum(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["mround"] = new Mround(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["rank"] = new Rank(); Functions["rank.eq"] = new Rank(); Functions["rank.avg"] = new Rank(true); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); Functions["odd"] = new Odd(); Functions["even"] = new Even(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); Functions["type"] = new TypeFunction(); // Logical Functions["if"] = new If(); Functions["ifs"] = new Ifs(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); Functions["switch"] = new Switch(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row(); Functions["rows"] = new Rows(); Functions["column"] = new Column(); Functions["columns"] = new Columns(); Functions["choose"] = new Choose(); Functions["index"] = new RefAndLookup.Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset(); // Date Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days"] = new Days(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); Functions["workday.intl"] = new WorkdayIntl(); Functions["networkdays"] = new Networkdays(); Functions["networkdays.intl"] = new NetworkdaysIntl(); Functions["datevalue"] = new DateValue(); Functions["timevalue"] = new TimeValue(); // Database Functions["dget"] = new Dget(); Functions["dcount"] = new Dcount(); Functions["dcounta"] = new DcountA(); Functions["dmax"] = new Dmax(); Functions["dmin"] = new Dmin(); Functions["dsum"] = new Dsum(); Functions["daverage"] = new Daverage(); Functions["dvar"] = new Dvar(); Functions["dvarp"] = new Dvarp(); //Finance Functions["pmt"] = new Pmt(); }
/// <summary> /// Starts the service. /// </summary> public void Start() { try { //message _logger = Log.Instance; _logger.WriteMessage("Service", "=========================================="); _logger.WriteMessage("Service", "Starting service.."); //start time _startTime = DateTime.Now; //events Console.CancelKeyPress += Console_CancelKeyPress; //config _logger.WriteMessage("Service", "Loading configuration.."); IConfigurationRoot root = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("Config.json", optional: true, reloadOnChange: false) .Build(); _config = new Config(root); _logger.WriteMessage("Service", $"Service version is {_config.ServiceVersion}"); //init pi (if linux) if (_config.IsLinux) { Pi.Init <BootstrapWiringPi>(); } //singletons _logger.WriteMessage("Service", "Creating support structures.."); ((Log)Log.Instance).Initialize(_config.IsWindows ? "C:\\Temp\\" : "/var/log/", _config.ServiceVersion); _errorCache = new ErrorCache(null, _config.ErrorRetention); _errorHandler = new ErrorHandler(_errorCache, _logger); _serviceState = new ServiceState(_errorHandler, _logger, ServiceStateType.Down); _serviceStats = new ServiceStats(_errorHandler); _heartbeat = new Heartbeat(_errorHandler, _config, _logger, _serviceStats, _serviceState); _piInfo = new PiInfo(_config); _gpio = new GpioManager(_errorHandler, _config); //stats writers _statsWriters.Add(_serviceState); _statsWriters.Add(_serviceStats); _statsWriters.Add(_gpio); _statsWriters.Add(_piInfo); _statsWriters.Add((IStatsWriter)_errorCache); //start health thread _logger.WriteMessage("Service", "Starting health thread.."); _healthThread = new Thread(Health_Thread) { IsBackground = true }; _healthThread.Start(); //finish init on another thread, finish start Task.Run(() => { //start gpio loop _gpio.Initialize(); //wait for ip assignment WaitForIPAssignment(); //start heatbeat timer _heartbeat.Start(); //start http listener StartHttpListener(); }); //log start operation _serviceStats.LogOperation("ServiceStart", DateTime.Now.Subtract(_startTime)); //wait for exit signal _exitSignal.WaitOne(); } catch (Exception ex) { if (_errorHandler != null) { _errorHandler.LogError(ex); } else { Console.WriteLine(ex); } } }
public FanHandler(int controlGpio) { Pi.Init <BootstrapWiringPi>(); myControlGpio = controlGpio; }
private static async Task <int> Main(string[] args) { bool mode = false; Pi.Init <BootstrapWiringPi>();//初始化通信接口,分配内存空间等 var Count = 0; var Exit = false; _ = Task.Factory.StartNew(() => { var clkPin = Pi.Gpio[BcmPin.Gpio23]; //引用16接口 var dataPin = Pi.Gpio[BcmPin.Gpio24]; //引用18接口 clkPin.PinMode = GpioPinDriveMode.Output; //设置16接口模式为输出 dataPin.PinMode = GpioPinDriveMode.Output; //设置18接口模式为输出 init: { Show(0xC0, 0x40); Show(0xC1, 0x40); Show(0xC2, 0x40); Show(0xC3, 0x40); } Console.CancelKeyPress += delegate { startDisp(); writeByte(0x80); stopDisp(); }; void startDisp() { //数据输入开始 clkPin.Write(GpioPinValue.High); //CLK拉为高电平 dataPin.Write(GpioPinValue.High); //DIO拉为高电平 dataPin.Write(GpioPinValue.Low); //和上面那句指令一起就是DIO由高变低 clkPin.Write(GpioPinValue.Low); //然后CLK上的时钟信号拉低,DIO接口的数据允许改变,代表开始写入数据 } void stopDisp() { //结束条件是CLK为高时,DIO由低电平变为高电平 clkPin.Write(GpioPinValue.Low); //先拉低CLK,代表允许DIO改变数据 dataPin.Write(GpioPinValue.Low); //拉低DIO clkPin.Write(GpioPinValue.High); //CLK拉高,满足结束条件前半部分 dataPin.Write(GpioPinValue.High); //DIO由低变高,代表数据输入结束 } void writeByte(byte input) { //开始写入数据 for (int i = 0; i < 8; i++) //每次写入一个byte,一共8bit { clkPin.Write(GpioPinValue.Low); //确保无误输入前再拉低一次时钟 ,代表开始写入数据 if ((input & 0x01) == 1) //判断每一位的高低电平 { dataPin.Write(GpioPinValue.High); } else { dataPin.Write(GpioPinValue.Low); } input >>= 1; //每写入完毕一次,移动一位 clkPin.Write(GpioPinValue.High); //每次输入完一位,就拉高一次时钟 } //应答信号ACK,这里本来是用来判断DIO脚是否被自动拉低,代表上面写入的数据TM1637已经接受到了, //但是我们这里闲麻烦,直接将CLK信号低高低的拉,让芯片直接执行下一步操作 clkPin.Write(GpioPinValue.Low); //先拉低 clkPin.Write(GpioPinValue.High); //需要判断D是否为低电平此期间C一直拉高 clkPin.Write(GpioPinValue.Low); //应答完毕以后拉低C } void Show(byte address, byte show) { //Start transmission startDisp(); //开始写入指令 C高D高D低 writeByte(0x44); //40H模式地址自动+1,44H模式固定地址 stopDisp(); //结束写入指令 C低D低C高D高 //上述完成数据指令设置 //设置光标位置为11000000,光标位置每次输入+1 startDisp(); writeByte(address); //设置首地址 //Write text //数据从01000000写到01111111 // // A // --- // F | | B // -G- // E | | C // --- // D /* * XGFEDCBA * 10000000 * 00111111, // 0 * 00000110, // 1 * 01011011, // 2 * 01001111, // 3 * 01100110, // 4 * 01101101, // 5 * 01111101, // 6 * 00000111, // 7 * 01111111, // 8 * 01101111, // 9 * 01110111, // A * 01111100, // b * 00111001, // C * 01011110, // d * 01111001, // E * 01110001 // F */ //写入字符 writeByte(show); //停止写入 startDisp(); //开始写入亮度 startDisp(); //开始写入指令 writeByte(0x8f); //最大亮度 stopDisp(); //停止写入 } clkPin.Write(GpioPinValue.High); //初始化电平为低,可不加 dataPin.Write(GpioPinValue.High); //初始化电平为低,可不加 var ShowCount = false; while (true) { if (mode) { var Date = DateTime.Now.ToString("HHmm").ToCharArray(); Show(0xC3, numbers[Date[Date.Length - 1] - 48]); if (Date.Length > 1) { Show(0xC2, numbers[Date[Date.Length - 2] - 48]); } else { Show(0xC2, 0x40); } if (Date.Length > 2) { if (ShowCount) { ShowCount = false; Show(0xC1, (byte)(numbers[Date[Date.Length - 3] - 48] | 0x80)); } else { ShowCount = true; Show(0xC1, numbers[Date[Date.Length - 3] - 48]); } } else { Show(0xC1, 0x40); } if (Date.Length > 3) { Show(0xC0, numbers[Date[Date.Length - 4] - 48]); } else { Show(0xC0, 0x40); } //Interlocked.Increment(ref Count); if (Exit) { startDisp(); writeByte(0x80); stopDisp(); break; } Thread.Sleep(250); } else { var Date = Count.ToString().ToCharArray(); Show(0xC3, numbers[Date[Date.Length - 1] - 48]); if (Date.Length > 1) { Show(0xC2, numbers[Date[Date.Length - 2] - 48]); } else { Show(0xC2, 0x40); } if (Date.Length > 2) { Show(0xC1, numbers[Date[Date.Length - 3] - 48]); } else { Show(0xC1, 0x40); } if (Date.Length > 3) { Show(0xC0, numbers[Date[Date.Length - 4] - 48]); } else { Show(0xC0, 0x40); } //Interlocked.Increment(ref Count); if (Count == 10000) { Count = 0; } if (Exit) { startDisp(); writeByte(0x80); stopDisp(); break; } Thread.Sleep(100); } } }); _ = Task.Factory.StartNew(() => { var Shock = Pi.Gpio[BcmPin.Gpio22]; Shock.PinMode = GpioPinDriveMode.Input; System.Diagnostics.Stopwatch StartWatch = new System.Diagnostics.Stopwatch(); System.Diagnostics.Stopwatch KeepWatch = new System.Diagnostics.Stopwatch(); var KeyCount = 0; while (true) { Thread.Sleep(50); if (!Shock.Read() && !KeepWatch.IsRunning)//按下按钮,计时未开始 { KeepWatch.Restart(); } else if (Shock.Read() && KeepWatch.IsRunning)//松开按钮,计时开始中,松开按钮计时 { KeepWatch.Stop(); StartWatch.Restart(); KeyCount++; } else if (!Shock.Read() && KeepWatch.IsRunning && KeepWatch.ElapsedMilliseconds > 1000)//按下按钮,计时开始中 { if (KeepWatch.ElapsedMilliseconds > 1000) { Count = 0; } else if (KeepWatch.ElapsedMilliseconds > 5000) { Exit = true; Thread.Sleep(100); ShutdownResetEvent.SetResult(0); } } else if (Shock.Read() && KeepWatch.IsRunning && StartWatch.ElapsedMilliseconds > 200) { StartWatch.Restart(); KeyCount++; } if (KeyCount != 0 && StartWatch.ElapsedMilliseconds > 500) { switch (KeyCount) { case 1: { if (Count > 0 && !mode) { Interlocked.Decrement(ref Count); } } break; case 2: { if (!mode) { Interlocked.Increment(ref Count); } } break; default: { if (KeyCount > 6) { mode = mode ? false : true; } } break; } KeepWatch.Stop(); StartWatch.Stop(); KeyCount = 0; } /* if (!Shock.Read() && !KeepWatch.IsRunning) * { * KeepWatch.Restart(); * } * else if (Shock.Read() && KeepWatch.IsRunning) * { * if(KeepWatch.ElapsedMilliseconds < 1000&& Count > 0&& !mode) * Interlocked.Decrement(ref Count); * KeepWatch.Stop(); * } * else if (KeepWatch.IsRunning && KeepWatch.ElapsedMilliseconds > 5000) * { * //Exit = true; * Thread.Sleep(100); * mode = mode ? false : true; * // ShutdownResetEvent.SetResult(0); * } * else if (KeepWatch.IsRunning && KeepWatch.ElapsedMilliseconds > 1000) * { * Count = 0; * } * else if (KeepWatch.IsRunning&&KeepWatch.ElapsedMilliseconds > 6000) * { * KeepWatch.Stop(); * }*/ /*if (!Shock.Read() && !KeySign) * { * KeySign = true; * if(Count>0) * Interlocked.Decrement(ref Count); * } * if (Shock.Read() && KeySign) * { * KeySign = false; * }*/ } }); _ = Task.Factory.StartNew(() => { var Tilt = Pi.Gpio[BcmPin.Gpio04]; Tilt.PinMode = GpioPinDriveMode.Input; var KeySign = false; System.Diagnostics.Stopwatch KeepWatch = new System.Diagnostics.Stopwatch(); while (true) { Thread.Sleep(50); /* if (Tilt.Read() && !KeySign) * { * KeySign = true; * if (!KeepWatch.IsRunning) * Interlocked.Increment(ref Count); * KeepWatch.Restart(); * }else if (!Tilt.Read() && KeySign) * { * KeySign = false; * } * if (KeepWatch.ElapsedMilliseconds > 4000) KeepWatch.Stop();*/ if (!Tilt.Read() && !KeySign) { KeySign = true; if (!KeepWatch.IsRunning) { Interlocked.Increment(ref Count); } KeepWatch.Restart(); } else if (Tilt.Read() && KeySign) { KeySign = false; } if (KeepWatch.ElapsedMilliseconds > 4000) { KeepWatch.Stop(); } } }); return(await ShutdownResetEvent.Task.ConfigureAwait(false)); }
public void Initiate() { Pi.Init <BootstrapWiringPi>(); }
private static void Main(string[] args) { Pi.Init <BootstrapWiringPi>(); //初始化通信接口,分配内存空间等 var clkPin = Pi.Gpio[BcmPin.Gpio23]; //引用16接口 var dataPin = Pi.Gpio[BcmPin.Gpio24]; //引用18接口 clkPin.PinMode = GpioPinDriveMode.Output; //设置16接口模式为输出 dataPin.PinMode = GpioPinDriveMode.Output; //设置18接口模式为输出 clkPin.Write(GpioPinValue.High); //初始化电平为低,可不加 dataPin.Write(GpioPinValue.High); //初始化电平为低,可不加 Console.CancelKeyPress += delegate { startDisp(); writeByte(0x80); stopDisp(); }; // var B = Pi.Gpio[BcmPin.Gpio25];//引用16接口 //var G = Pi.Gpio[BcmPin.Gpio08];//引用18接口 //var R = Pi.Gpio[BcmPin.Gpio07];//引用18接口 /* B.PinMode = GpioPinDriveMode.Output; * G.PinMode = GpioPinDriveMode.Output; * R.PinMode = GpioPinDriveMode.Output; * while (true) * { * B.Write(GpioPinValue.High); * G.Write(GpioPinValue.High); * R.Write(GpioPinValue.High); * Thread.Sleep(1000); * B.Write(GpioPinValue.Low); * G.Write(GpioPinValue.High); * R.Write(GpioPinValue.High); * Thread.Sleep(1000); * B.Write(GpioPinValue.High); * G.Write(GpioPinValue.Low); * R.Write(GpioPinValue.High); * Thread.Sleep(1000); * B.Write(GpioPinValue.High); * G.Write(GpioPinValue.High); * R.Write(GpioPinValue.Low); * Thread.Sleep(1000); * B.Write(GpioPinValue.High); * G.Write(GpioPinValue.Low); * R.Write(GpioPinValue.Low); * Thread.Sleep(1000); * }*/ void startDisp() { //数据输入开始 clkPin.Write(GpioPinValue.High); //CLK拉为高电平 dataPin.Write(GpioPinValue.High); //DIO拉为高电平 dataPin.Write(GpioPinValue.Low); //和上面那句指令一起就是DIO由高变低 clkPin.Write(GpioPinValue.Low); //然后CLK上的时钟信号拉低,DIO接口的数据允许改变,代表开始写入数据 } void stopDisp() { //结束条件是CLK为高时,DIO由低电平变为高电平 clkPin.Write(GpioPinValue.Low); //先拉低CLK,代表允许DIO改变数据 dataPin.Write(GpioPinValue.Low); //拉低DIO clkPin.Write(GpioPinValue.High); //CLK拉高,满足结束条件前半部分 dataPin.Write(GpioPinValue.High); //DIO由低变高,代表数据输入结束 } void writeByte(byte input) { //开始写入数据 for (int i = 0; i < 8; i++) //每次写入一个byte,一共8bit { clkPin.Write(GpioPinValue.Low); //确保无误输入前再拉低一次时钟 ,代表开始写入数据 if ((input & 0x01) == 1) //判断每一位的高低电平 { dataPin.Write(GpioPinValue.High); } else { dataPin.Write(GpioPinValue.Low); } input >>= 1; //每写入完毕一次,移动一位 clkPin.Write(GpioPinValue.High); //每次输入完一位,就拉高一次时钟 } //应答信号ACK,这里本来是用来判断DIO脚是否被自动拉低,代表上面写入的数据TM1637已经接受到了, //但是我们这里闲麻烦,直接将CLK信号低高低的拉,让芯片直接执行下一步操作 clkPin.Write(GpioPinValue.Low); //先拉低 clkPin.Write(GpioPinValue.High); //需要判断D是否为低电平此期间C一直拉高 clkPin.Write(GpioPinValue.Low); //应答完毕以后拉低C } void Show(byte address, byte show) { //Start transmission startDisp(); //开始写入指令 C高D高D低 writeByte(0x44); //40H模式地址自动+1,44H模式固定地址 stopDisp(); //结束写入指令 C低D低C高D高 //上述完成数据指令设置 //设置光标位置为11000000,光标位置每次输入+1 startDisp(); writeByte(address); //设置首地址 //Write text //数据从01000000写到01111111 // // A // --- // F | | B // -G- // E | | C // --- // D /* * XGFEDCBA * 00111111, // 0 * 00000110, // 1 * 01011011, // 2 * 01001111, // 3 * 01100110, // 4 * 01101101, // 5 * 01111101, // 6 * 00000111, // 7 * 01111111, // 8 * 01101111, // 9 * 01110111, // A * 01111100, // b * 00111001, // C * 01011110, // d * 01111001, // E * 01110001 // F */ //写入字符 writeByte(show); //停止写入 startDisp(); //开始写入亮度 startDisp(); //开始写入指令 writeByte(0x8f); //最大亮度 stopDisp(); //停止写入 } void Show2() { //设置基本参数 startDisp(); //开始写入指令 writeByte(0x40); //指定功能参数 stopDisp(); //结束写入指令 //设置显示地址以及显示内容 startDisp(); writeByte(0xC0); //设置首地址,指向第一个字符 var Date = DateTime.Now.ToString("hhmm").ToCharArray(); //获得当前日期,并表示为小时分钟 byte[] Characters = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71 }; //0~9,A,b,C,d,E,F /*for (int i = 0; i < Date.Length; i++) * { * if (i != 1) writeByte(Characters[Date[i] - 48]);//从Characters数组根据索引获得字符显示的编码 * else writeByte((byte)(Characters[Date[1] - 48] + 0x80));//第二个字符带有冒号,因此将第一位空置拉高 * }*/ startDisp(); writeByte(0xC0); writeByte(Characters[Date[0] - 48]); stopDisp(); startDisp(); writeByte(0xC1); writeByte(Characters[Date[1] - 48]); stopDisp(); startDisp(); writeByte(0xC2); writeByte(Characters[Date[2] - 48]); stopDisp(); startDisp(); writeByte(0xC3); writeByte(Characters[Date[3] - 48]); stopDisp(); //开始写入亮度 startDisp(); writeByte(0x8f); stopDisp(); } /* for (byte i = 0x40; i < 0x7f; i++) * { * Show((byte)(i | 0x80)); * Thread.Sleep(10000); * }*/ /* while (true) * { * Show2(); * }*/ while (true) { var Date = DateTime.Now.ToString("hhmm").ToCharArray(); Show(0xC0, numbers[Date[0] - 48]); Show(0xC1, (byte)(numbers[Date[1] - 48] + 0x80)); Show(0xC2, numbers[Date[2] - 48]); Show(0xC3, numbers[Date[3] - 48]); Thread.Sleep(1000); Date = DateTime.Now.ToString("mmss").ToCharArray(); Show(0xC0, numbers[Date[0] - 48]); Show(0xC1, (byte)(numbers[Date[1] - 48] + 0x80)); Show(0xC2, numbers[Date[2] - 48]); Show(0xC3, numbers[Date[3] - 48]); Thread.Sleep(1000); } foreach (var item in numbers) { /* if (item == 0x7f) Show(0x00 + 0x80); * else Show((byte)(item + 0x80));*/ Show(0xC0, (byte)(item)); Show(0xC1, (byte)(item + 0x80)); Show(0xC2, (byte)(item)); Show(0xC3, (byte)(item)); Thread.Sleep(1000); } Console.WriteLine(); /*if (ij == 0xC6) * { * ij = 0xC0; * }*/ startDisp(); writeByte(0x80); stopDisp(); Thread.Sleep(100); }
public SensorPoller(ILogger <SensorPoller> logger) { _logger = logger; Pi.Init <BootstrapWiringPi>(); }
private static Function[] ProduceFunctions() { Function[] retval = new Function[368]; retval[0] = new Count(); // COUNT retval[FunctionID.IF] = new If(); // IF retval[2] = LogicalFunction.ISNA; // IsNA retval[3] = LogicalFunction.ISERROR; // IsERROR retval[FunctionID.SUM] = AggregateFunction.SUM; // SUM retval[5] = AggregateFunction.AVERAGE; // AVERAGE retval[6] = AggregateFunction.MIN; // MIN retval[7] = AggregateFunction.MAX; // MAX retval[8] = new Row(); // ROW retval[9] = new Column(); // COLUMN retval[10] = new Na(); // NA retval[11] = new Npv(); // NPV retval[12] = AggregateFunction.STDEV; // STDEV retval[13] = NumericFunction.DOLLAR; // DOLLAR retval[14] = new NotImplementedFunction(); // FIXED retval[15] = NumericFunction.SIN; // SIN retval[16] = NumericFunction.COS; // COS retval[17] = NumericFunction.TAN; // TAN retval[18] = NumericFunction.ATAN; // ATAN retval[19] = new Pi(); // PI retval[20] = NumericFunction.SQRT; // SQRT retval[21] = NumericFunction.EXP; // EXP retval[22] = NumericFunction.LN; // LN retval[23] = NumericFunction.LOG10; // LOG10 retval[24] = NumericFunction.ABS; // ABS retval[25] = NumericFunction.INT; // INT retval[26] = NumericFunction.SIGN; // SIGN retval[27] = NumericFunction.ROUND; // ROUND retval[28] = new Lookup(); // LOOKUP retval[29] = new Index(); // INDEX retval[30] = new NotImplementedFunction(); // REPT retval[31] = TextFunction.MID; // MID retval[32] = TextFunction.LEN; // LEN retval[33] = new Value(); // VALUE retval[34] = new True(); // TRUE retval[35] = new False(); // FALSE retval[36] = new And(); // AND retval[37] = new Or(); // OR retval[38] = new Not(); // NOT retval[39] = NumericFunction.MOD; // MOD retval[40] = new NotImplementedFunction(); // DCOUNT retval[41] = new NotImplementedFunction(); // DSUM retval[42] = new NotImplementedFunction(); // DAVERAGE retval[43] = new NotImplementedFunction(); // DMIN retval[44] = new NotImplementedFunction(); // DMAX retval[45] = new NotImplementedFunction(); // DSTDEV retval[46] = new NotImplementedFunction(); // VAR retval[47] = new NotImplementedFunction(); // DVAR retval[48] = TextFunction.TEXT; // TEXT retval[49] = new NotImplementedFunction(); // LINEST retval[50] = new NotImplementedFunction(); // TREND retval[51] = new NotImplementedFunction(); // LOGEST retval[52] = new NotImplementedFunction(); // GROWTH retval[53] = new NotImplementedFunction(); // GOTO retval[54] = new NotImplementedFunction(); // HALT retval[56] = new NotImplementedFunction(); // PV retval[57] = FinanceFunction.FV; // FV retval[58] = FinanceFunction.NPER; // NPER retval[59] = FinanceFunction.PMT; // PMT retval[60] = new NotImplementedFunction(); // RATE retval[61] = new NotImplementedFunction(); // MIRR retval[62] = new Irr(); // IRR retval[63] = new Rand(); // RAND retval[64] = new Match(); // MATCH retval[65] = DateFunc.instance; // DATE retval[66] = new TimeFunc(); // TIME retval[67] = CalendarFieldFunction.DAY; // DAY retval[68] = CalendarFieldFunction.MONTH; // MONTH retval[69] = CalendarFieldFunction.YEAR; // YEAR retval[70] = new NotImplementedFunction(); // WEEKDAY retval[71] = CalendarFieldFunction.HOUR; retval[72] = CalendarFieldFunction.MINUTE; retval[73] = CalendarFieldFunction.SECOND; retval[74] = new Now(); retval[75] = new NotImplementedFunction(); // AREAS retval[76] = new Rows(); // ROWS retval[77] = new Columns(); // COLUMNS retval[FunctionID.OFFSET] = new Offset(); // Offset.Evaluate has a different signature retval[79] = new NotImplementedFunction(); // ABSREF retval[80] = new NotImplementedFunction(); // RELREF retval[81] = new NotImplementedFunction(); // ARGUMENT retval[82] = TextFunction.SEARCH; retval[83] = new NotImplementedFunction(); // TRANSPOSE retval[84] = new NotImplementedFunction(); // ERROR retval[85] = new NotImplementedFunction(); // STEP retval[86] = new NotImplementedFunction(); // TYPE retval[87] = new NotImplementedFunction(); // ECHO retval[88] = new NotImplementedFunction(); // SetNAME retval[89] = new NotImplementedFunction(); // CALLER retval[90] = new NotImplementedFunction(); // DEREF retval[91] = new NotImplementedFunction(); // WINDOWS retval[92] = new NotImplementedFunction(); // SERIES retval[93] = new NotImplementedFunction(); // DOCUMENTS retval[94] = new NotImplementedFunction(); // ACTIVECELL retval[95] = new NotImplementedFunction(); // SELECTION retval[96] = new NotImplementedFunction(); // RESULT retval[97] = NumericFunction.ATAN2; // ATAN2 retval[98] = NumericFunction.ASIN; // ASIN retval[99] = NumericFunction.ACOS; // ACOS retval[FunctionID.CHOOSE] = new Choose(); retval[101] = new Hlookup(); // HLOOKUP retval[102] = new Vlookup(); // VLOOKUP retval[103] = new NotImplementedFunction(); // LINKS retval[104] = new NotImplementedFunction(); // INPUT retval[105] = LogicalFunction.ISREF; // IsREF retval[106] = new NotImplementedFunction(); // GetFORMULA retval[107] = new NotImplementedFunction(); // GetNAME retval[108] = new NotImplementedFunction(); // SetVALUE retval[109] = NumericFunction.LOG; // LOG retval[110] = new NotImplementedFunction(); // EXEC retval[111] = TextFunction.CHAR; // CHAR retval[112] = TextFunction.LOWER; // LOWER retval[113] = TextFunction.UPPER; // UPPER retval[114] = new NotImplementedFunction(); // PROPER retval[115] = TextFunction.LEFT; // LEFT retval[116] = TextFunction.RIGHT; // RIGHT retval[117] = TextFunction.EXACT; // EXACT retval[118] = TextFunction.TRIM; // TRIM retval[119] = new Replace(); // Replace retval[120] = new Substitute(); // SUBSTITUTE retval[121] = new NotImplementedFunction(); // CODE retval[122] = new NotImplementedFunction(); // NAMES retval[123] = new NotImplementedFunction(); // DIRECTORY retval[124] = TextFunction.FIND; // Find retval[125] = new NotImplementedFunction(); // CELL retval[126] = new NotImplementedFunction(); // IsERR retval[127] = LogicalFunction.ISTEXT; // IsTEXT retval[128] = LogicalFunction.ISNUMBER; // IsNUMBER retval[129] = LogicalFunction.ISBLANK; // IsBLANK retval[130] = new T(); // T retval[131] = new NotImplementedFunction(); // N retval[132] = new NotImplementedFunction(); // FOPEN retval[133] = new NotImplementedFunction(); // FCLOSE retval[134] = new NotImplementedFunction(); // FSIZE retval[135] = new NotImplementedFunction(); // FReadLN retval[136] = new NotImplementedFunction(); // FRead retval[137] = new NotImplementedFunction(); // FWriteLN retval[138] = new NotImplementedFunction(); // FWrite retval[139] = new NotImplementedFunction(); // FPOS retval[140] = new NotImplementedFunction(); // DATEVALUE retval[141] = new NotImplementedFunction(); // TIMEVALUE retval[142] = new NotImplementedFunction(); // SLN retval[143] = new NotImplementedFunction(); // SYD retval[144] = new NotImplementedFunction(); // DDB retval[145] = new NotImplementedFunction(); // GetDEF retval[146] = new NotImplementedFunction(); // REFTEXT retval[147] = new NotImplementedFunction(); // TEXTREF retval[FunctionID.INDIRECT] = null; // Indirect.Evaluate has different signature retval[149] = new NotImplementedFunction(); // REGISTER retval[150] = new NotImplementedFunction(); // CALL retval[151] = new NotImplementedFunction(); // AddBAR retval[152] = new NotImplementedFunction(); // AddMENU retval[153] = new NotImplementedFunction(); // AddCOMMAND retval[154] = new NotImplementedFunction(); // ENABLECOMMAND retval[155] = new NotImplementedFunction(); // CHECKCOMMAND retval[156] = new NotImplementedFunction(); // RenameCOMMAND retval[157] = new NotImplementedFunction(); // SHOWBAR retval[158] = new NotImplementedFunction(); // DELETEMENU retval[159] = new NotImplementedFunction(); // DELETECOMMAND retval[160] = new NotImplementedFunction(); // GetCHARTITEM retval[161] = new NotImplementedFunction(); // DIALOGBOX retval[162] = TextFunction.CLEAN; // CLEAN retval[163] = new NotImplementedFunction(); // MDETERM retval[164] = new NotImplementedFunction(); // MINVERSE retval[165] = new NotImplementedFunction(); // MMULT retval[166] = new NotImplementedFunction(); // FILES retval[167] = new NotImplementedFunction(); // IPMT retval[168] = new NotImplementedFunction(); // PPMT retval[169] = new Counta(); // COUNTA retval[170] = new NotImplementedFunction(); // CANCELKEY retval[175] = new NotImplementedFunction(); // INITIATE retval[176] = new NotImplementedFunction(); // REQUEST retval[177] = new NotImplementedFunction(); // POKE retval[178] = new NotImplementedFunction(); // EXECUTE retval[179] = new NotImplementedFunction(); // TERMINATE retval[180] = new NotImplementedFunction(); // RESTART retval[181] = new NotImplementedFunction(); // HELP retval[182] = new NotImplementedFunction(); // GetBAR retval[183] = AggregateFunction.PRODUCT; // PRODUCT retval[184] = NumericFunction.FACT; // FACT retval[185] = new NotImplementedFunction(); // GetCELL retval[186] = new NotImplementedFunction(); // GetWORKSPACE retval[187] = new NotImplementedFunction(); // GetWINDOW retval[188] = new NotImplementedFunction(); // GetDOCUMENT retval[189] = new NotImplementedFunction(); // DPRODUCT retval[190] = LogicalFunction.ISNONTEXT; // IsNONTEXT retval[191] = new NotImplementedFunction(); // GetNOTE retval[192] = new NotImplementedFunction(); // NOTE retval[193] = new NotImplementedFunction(); // STDEVP retval[194] = new NotImplementedFunction(); // VARP retval[195] = new NotImplementedFunction(); // DSTDEVP retval[196] = new NotImplementedFunction(); // DVARP retval[197] = NumericFunction.TRUNC; // TRUNC retval[198] = LogicalFunction.ISLOGICAL; // IsLOGICAL retval[199] = new NotImplementedFunction(); // DCOUNTA retval[200] = new NotImplementedFunction(); // DELETEBAR retval[201] = new NotImplementedFunction(); // UNREGISTER retval[204] = new NotImplementedFunction(); // USDOLLAR retval[205] = new NotImplementedFunction(); // FindB retval[206] = new NotImplementedFunction(); // SEARCHB retval[207] = new NotImplementedFunction(); // ReplaceB retval[208] = new NotImplementedFunction(); // LEFTB retval[209] = new NotImplementedFunction(); // RIGHTB retval[210] = new NotImplementedFunction(); // MIDB retval[211] = new NotImplementedFunction(); // LENB retval[212] = NumericFunction.ROUNDUP; // ROUNDUP retval[213] = NumericFunction.ROUNDDOWN; // ROUNDDOWN retval[214] = new NotImplementedFunction(); // ASC retval[215] = new NotImplementedFunction(); // DBCS retval[216] = new NotImplementedFunction(); // RANK retval[219] = new Address(); // AddRESS retval[220] = new Days360(); // DAYS360 retval[221] = new NotImplementedFunction(); // TODAY retval[222] = new NotImplementedFunction(); // VDB retval[227] = AggregateFunction.MEDIAN; // MEDIAN retval[228] = new Sumproduct(); // SUMPRODUCT retval[229] = NumericFunction.SINH; // SINH retval[230] = NumericFunction.COSH; // COSH retval[231] = NumericFunction.TANH; // TANH retval[232] = NumericFunction.ASINH; // ASINH retval[233] = NumericFunction.ACOSH; // ACOSH retval[234] = NumericFunction.ATANH; // ATANH retval[235] = new NotImplementedFunction(); // DGet retval[236] = new NotImplementedFunction(); // CreateOBJECT retval[237] = new NotImplementedFunction(); // VOLATILE retval[238] = new NotImplementedFunction(); // LASTERROR retval[239] = new NotImplementedFunction(); // CUSTOMUNDO retval[240] = new NotImplementedFunction(); // CUSTOMREPEAT retval[241] = new NotImplementedFunction(); // FORMULAConvert retval[242] = new NotImplementedFunction(); // GetLINKINFO retval[243] = new NotImplementedFunction(); // TEXTBOX retval[244] = new NotImplementedFunction(); // INFO retval[245] = new NotImplementedFunction(); // GROUP retval[246] = new NotImplementedFunction(); // GetOBJECT retval[247] = new NotImplementedFunction(); // DB retval[248] = new NotImplementedFunction(); // PAUSE retval[250] = new NotImplementedFunction(); // RESUME retval[252] = new NotImplementedFunction(); // FREQUENCY retval[253] = new NotImplementedFunction(); // AddTOOLBAR retval[254] = new NotImplementedFunction(); // DELETETOOLBAR retval[FunctionID.EXTERNAL_FUNC] = null; // ExternalFunction is a FreeREfFunction retval[256] = new NotImplementedFunction(); // RESetTOOLBAR retval[257] = new NotImplementedFunction(); // EVALUATE retval[258] = new NotImplementedFunction(); // GetTOOLBAR retval[259] = new NotImplementedFunction(); // GetTOOL retval[260] = new NotImplementedFunction(); // SPELLINGCHECK retval[261] = new NotImplementedFunction(); // ERRORTYPE retval[262] = new NotImplementedFunction(); // APPTITLE retval[263] = new NotImplementedFunction(); // WINDOWTITLE retval[264] = new NotImplementedFunction(); // SAVETOOLBAR retval[265] = new NotImplementedFunction(); // ENABLETOOL retval[266] = new NotImplementedFunction(); // PRESSTOOL retval[267] = new NotImplementedFunction(); // REGISTERID retval[268] = new NotImplementedFunction(); // GetWORKBOOK retval[269] = AggregateFunction.AVEDEV; // AVEDEV retval[270] = new NotImplementedFunction(); // BETADIST retval[271] = new NotImplementedFunction(); // GAMMALN retval[272] = new NotImplementedFunction(); // BETAINV retval[273] = new NotImplementedFunction(); // BINOMDIST retval[274] = new NotImplementedFunction(); // CHIDIST retval[275] = new NotImplementedFunction(); // CHIINV retval[276] = NumericFunction.COMBIN; // COMBIN retval[277] = new NotImplementedFunction(); // CONFIDENCE retval[278] = new NotImplementedFunction(); // CRITBINOM retval[279] = new Even(); // EVEN retval[280] = new NotImplementedFunction(); // EXPONDIST retval[281] = new NotImplementedFunction(); // FDIST retval[282] = new NotImplementedFunction(); // FINV retval[283] = new NotImplementedFunction(); // FISHER retval[284] = new NotImplementedFunction(); // FISHERINV retval[285] = NumericFunction.FLOOR; // FLOOR retval[286] = new NotImplementedFunction(); // GAMMADIST retval[287] = new NotImplementedFunction(); // GAMMAINV retval[288] = NumericFunction.CEILING; // CEILING retval[289] = new NotImplementedFunction(); // HYPGEOMDIST retval[290] = new NotImplementedFunction(); // LOGNORMDIST retval[291] = new NotImplementedFunction(); // LOGINV retval[292] = new NotImplementedFunction(); // NEGBINOMDIST retval[293] = new NotImplementedFunction(); // NORMDIST retval[294] = new NotImplementedFunction(); // NORMSDIST retval[295] = new NotImplementedFunction(); // NORMINV retval[296] = new NotImplementedFunction(); // NORMSINV retval[297] = new NotImplementedFunction(); // STANDARDIZE retval[298] = new Odd(); // ODD retval[299] = new NotImplementedFunction(); // PERMUT retval[300] = new NotImplementedFunction(); // POISSON retval[301] = new NotImplementedFunction(); // TDIST retval[302] = new NotImplementedFunction(); // WEIBULL retval[303] = new Sumxmy2(); // SUMXMY2 retval[304] = new Sumx2my2(); // SUMX2MY2 retval[305] = new Sumx2py2(); // SUMX2PY2 retval[306] = new NotImplementedFunction(); // CHITEST retval[307] = new NotImplementedFunction(); // CORREL retval[308] = new NotImplementedFunction(); // COVAR retval[309] = new NotImplementedFunction(); // FORECAST retval[310] = new NotImplementedFunction(); // FTEST retval[311] = new NotImplementedFunction(); // INTERCEPT retval[312] = new NotImplementedFunction(); // PEARSON retval[313] = new NotImplementedFunction(); // RSQ retval[314] = new NotImplementedFunction(); // STEYX retval[315] = new NotImplementedFunction(); // SLOPE retval[316] = new NotImplementedFunction(); // TTEST retval[317] = new NotImplementedFunction(); // PROB retval[318] = AggregateFunction.DEVSQ; // DEVSQ retval[319] = new NotImplementedFunction(); // GEOMEAN retval[320] = new NotImplementedFunction(); // HARMEAN retval[321] = AggregateFunction.SUMSQ; // SUMSQ retval[322] = new NotImplementedFunction(); // KURT retval[323] = new NotImplementedFunction(); // SKEW retval[324] = new NotImplementedFunction(); // ZTEST retval[325] = AggregateFunction.LARGE; // LARGE retval[326] = AggregateFunction.SMALL; // SMALL retval[327] = new NotImplementedFunction(); // QUARTILE retval[328] = new NotImplementedFunction(); // PERCENTILE retval[329] = new NotImplementedFunction(); // PERCENTRANK retval[330] = new Mode(); // MODE retval[331] = new NotImplementedFunction(); // TRIMMEAN retval[332] = new NotImplementedFunction(); // TINV retval[334] = new NotImplementedFunction(); // MOVIECOMMAND retval[335] = new NotImplementedFunction(); // GetMOVIE retval[336] = TextFunction.CONCATENATE; // CONCATENATE retval[337] = NumericFunction.POWER; // POWER retval[338] = new NotImplementedFunction(); // PIVOTAddDATA retval[339] = new NotImplementedFunction(); // GetPIVOTTABLE retval[340] = new NotImplementedFunction(); // GetPIVOTFIELD retval[341] = new NotImplementedFunction(); // GetPIVOTITEM retval[342] = NumericFunction.RADIANS;; // RADIANS retval[343] = NumericFunction.DEGREES; // DEGREES retval[344] = new Subtotal(); // SUBTOTAL retval[345] = new Sumif(); // SUMIF retval[346] = new Countif(); // COUNTIF retval[347] = new Countblank(); // COUNTBLANK retval[348] = new NotImplementedFunction(); // SCENARIOGet retval[349] = new NotImplementedFunction(); // OPTIONSLISTSGet retval[350] = new NotImplementedFunction(); // IsPMT retval[351] = new NotImplementedFunction(); // DATEDIF retval[352] = new NotImplementedFunction(); // DATESTRING retval[353] = new NotImplementedFunction(); // NUMBERSTRING retval[354] = new NotImplementedFunction(); // ROMAN retval[355] = new NotImplementedFunction(); // OPENDIALOG retval[356] = new NotImplementedFunction(); // SAVEDIALOG retval[357] = new NotImplementedFunction(); // VIEWGet retval[358] = new NotImplementedFunction(); // GetPIVOTDATA retval[359] = new NotImplementedFunction(); // HYPERLINK retval[360] = new NotImplementedFunction(); // PHONETIC retval[361] = new NotImplementedFunction(); // AVERAGEA retval[362] = new Maxa(); // MAXA retval[363] = new Mina(); // MINA retval[364] = new NotImplementedFunction(); // STDEVPA retval[365] = new NotImplementedFunction(); // VARPA retval[366] = new NotImplementedFunction(); // STDEVA retval[367] = new NotImplementedFunction(); // VARA return(retval); }
static void Main(string[] args) { Pi.Init <BootstrapWiringPi>(); //Pins used to create the doors buttons var door0Pin = Pi.Gpio[BcmPin.Gpio12]; var door1Pin = Pi.Gpio[BcmPin.Gpio05]; var door2Pin = Pi.Gpio[BcmPin.Gpio06]; var door3Pin = Pi.Gpio[BcmPin.Gpio13]; var mDoorsState = new Dictionary <string, bool>() { { "door 0", !door0Pin.Read() }, { "door 1", !door1Pin.Read() }, }; var wDoorsState = new Dictionary <string, bool>() { { "door 2", !door2Pin.Read() }, { "door 3", !door3Pin.Read() }, }; "antes del sync".Info(); InitialSync(mDoorsState, wDoorsState); "despues del sync".Info(); var mbDoorsButtons = new Dictionary <string, Button>() { { "door 0", new Button(door0Pin, GpioPinResistorPullMode.PullDown) }, { "door 1", new Button(door1Pin, GpioPinResistorPullMode.PullDown) }, }; var wbDoorsButtons = new Dictionary <string, Button>() { { "door 2", new Button(door2Pin, GpioPinResistorPullMode.PullDown) }, { "door 3", new Button(door3Pin, GpioPinResistorPullMode.PullDown) }, }; "buttons".Info(); mbDoorsButtons.ForEach((key, value) => { value.Pressed += (s, e) => { mDoorsState[key] = false; var availableDoors = mDoorsState.Where(x => x.Value == true).ToArray().Length; JsonClient.Post <Dictionary <string, bool> >(postUrl + $"/{mBathId}/{availableDoors}", new { }).GetAwaiter().GetResult(); }; value.Released += (s, e) => { mDoorsState[key] = true; var availableDoors = mDoorsState.Where(x => x.Value == true).ToArray().Length; JsonClient.Post <Dictionary <string, bool> >(postUrl + $"/{mBathId}/{availableDoors}", new { }).GetAwaiter().GetResult(); }; }); wbDoorsButtons.ForEach((key, value) => { value.Pressed += (s, e) => { wDoorsState[key] = false; var availableDoors = wDoorsState.Where(x => x.Value == true).ToArray().Length; JsonClient.Post <Dictionary <string, bool> >(postUrl + $"/{wBathId}/{availableDoors}", new { }).GetAwaiter().GetResult(); }; value.Released += (s, e) => { wDoorsState[key] = true; var availableDoors = wDoorsState.Where(x => x.Value == true).ToArray().Length; JsonClient.Post <Dictionary <string, bool> >(postUrl + $"/{wBathId}/{availableDoors}", new { }).GetAwaiter().GetResult(); }; }); Console.ReadKey(); }