private void nudChanBw_ValueChanged(object sender, EventArgs e) { Decimal[] rxBwFreqTable = SX1276.ComputeRxBwFreqTable(this.device.FrequencyXo, this.device.ModulationType); int num1 = (int)(this.nudChanBw.Value - this.RxBw); int index; if (num1 >= -1 && num1 <= 1) { index = Array.IndexOf <Decimal>(rxBwFreqTable, this.RxBw) - num1; } else { int mant = 0; int exp = 0; Decimal num2 = new Decimal(0); SX1276.ComputeRxBwMantExp(this.device.FrequencyXo, this.device.ModulationType, this.nudChanBw.Value, ref mant, ref exp); Decimal rxBw = SX1276.ComputeRxBw(this.device.FrequencyXo, this.device.ModulationType, mant, exp); index = Array.IndexOf <Decimal>(rxBwFreqTable, rxBw); } this.nudChanBw.ValueChanged -= new EventHandler(this.nudChanBw_ValueChanged); this.nudChanBw.Value = rxBwFreqTable[index]; this.nudChanBw.ValueChanged += new EventHandler(this.nudChanBw_ValueChanged); this.RxBw = this.nudChanBw.Value; this.device.SetRxBw(this.RxBw); }
private void ComputeStartupTimmings() { if (device.ModulationType == ModulationTypeEnum.OOK) { Tcf = 34.0 / (4.0 * (double)device.RxBw); TxTsTr = 5E-06 + 0.5 * (double)device.Tbit; } else { Tcf = 21.0 / (4.0 * (double)device.RxBw); double num = 4E-05; switch ((byte)device.PaRamp) { case (byte)0: num = 0.0034; break; case (byte)1: num = 0.002; break; case (byte)2: num = 0.001; break; case (byte)3: num = 0.0005; break; case (byte)4: num = 0.00025; break; case (byte)5: num = 0.000125; break; case (byte)6: num = 0.0001; break; case (byte)7: num = 6.2E-05; break; case (byte)8: num = 5E-05; break; case (byte)9: num = 4E-05; break; case (byte)10: num = 3.1E-05; break; case (byte)11: num = 2.5E-05; break; case (byte)12: num = 2E-05; break; case (byte)13: num = 1.5E-05; break; case (byte)14: num = 1.2E-05; break; case (byte)15: num = 1E-05; break; } TxTsTr = 5E-06 + 1.25 * num + 0.5 * (double)device.Tbit; } lblAgcOnValue.Text = device.AgcAutoOn ? "ON" : "OFF"; lblAfcOnValue.Text = device.AfcAutoOn ? "ON" : "OFF"; if (!device.AfcAutoOn) { int mant = 0; int exp = 0; SX1276.ComputeRxBwMantExp(device.FrequencyXo, device.ModulationType, device.RxBw, ref mant, ref exp); double num1 = 1.0 / (2.0 * (double)device.FrequencyXo / (double)mant); double num2 = 1.0 / (4.0 * (double)device.RxBw); RxTsRe = !(device.RxBw <= new Decimal(160000)) ? 2E-05 + 76.0 * num1 + 24.0 * num2 : 2E-05 + 12.0 * num1 + 24.0 * num2; RxTsRssi = (double)device.RssiSmoothing * num2; RxTsReTsRssi = RxTsRe + RxTsRssi; } else { int mant = 0; int exp = 0; SX1276.ComputeRxBwMantExp(device.FrequencyXo, device.ModulationType, device.AfcRxBw, ref mant, ref exp); double num1 = 1.0 / (2.0 * (double)device.FrequencyXo / (double)mant); double num2 = 1.0 / (4.0 * (double)device.AfcRxBw); RxTsRe = !(device.AfcRxBw <= new Decimal(160000)) ? 2E-05 + 76.0 * num1 + 24.0 * num2 : 2E-05 + 12.0 * num1 + 24.0 * num2; RxTsRssi = (double)device.RssiSmoothing * num2; RxTsReTsRssi = RxTsRe + RxTsRssi; } }