Exemplo n.º 1
0
        public string GetDetailsString()
        {
            var           status  = GetStatus();
            StringBuilder details = new StringBuilder();

            details.Append($" STATUS\t = 0x{status:X2}");
            details.Append($" RX_DR={((status & (1 << RX_DR)) != 0 ? 1 : 0):X2}");
            details.Append($" TX_DS={((status & (1 << TX_DS)) != 0 ? 1 : 0):X2}");
            details.Append($" MAX_RT={((status & (1 << MAX_RT)) != 0 ? 1 : 0):X2}");
            details.Append($" RX_P_NO={((status >> RX_P_NO) & 7):X2}");
            details.AppendLine($" TX_FULL={((status & (1 << TX_FULL)) != 0 ? 1 : 0):X2}");

            details.AppendLine(GetSettingString(" RX_ADDR_P0-1", RX_ADDR_P0, 5, 2));
            details.AppendLine(GetSettingString(" RX_ADDR_P2-5", RX_ADDR_P2, 1, 4));
            details.AppendLine(GetSettingString(" TX_ADDR", TX_ADDR, 5, 1));

            details.AppendLine(GetSettingString(" RX_PW_P0-6", RX_PW_P0, 1, 6));
            details.AppendLine(GetSettingString(" EN_AA", EN_AA));
            details.AppendLine(GetSettingString(" EN_RXADDR", EN_RXADDR));
            details.AppendLine(GetSettingString(" RF_CH", RF_CH));
            details.AppendLine(GetSettingString(" RF_SETUP", RF_SETUP));
            details.AppendLine(GetSettingString(" DYNPD/FEATURE", DYNPD, 1, 2));

            details.AppendLine(Nrf24L01Config.Read(this).ToString());

            details.AppendLine($" DataRate\t = {GetDataRate()}");
            var model = "NRF24L01" + (isPlusModel ? "+" : "");

            details.AppendLine($" Model\t\t = {model}");
            details.AppendLine($" CRC Length\t = {GetCRCLength()} bits");
            details.AppendLine($" PA Power\t = {GetPALevel()}");
            return(details.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set Working Mode
        /// </summary>
        /// <param name="mode">Working Mode</param>
        public void SetWorkingMode(ChipWorkMode mode)
        {
            var cfg = Nrf24L01Config.Read(this);

            if (cfg.ChipMode != mode)
            {
                cfg.ChipMode = mode;
                cfg.Persist(this);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Mask maximum retries event
        /// </summary>
        /// <param name="value"></param>
        public void MaskMaxRetries(bool value)
        {
            var cfg = Nrf24L01Config.Read(this);

            if (cfg.MaskMaximumRetries != value)
            {
                cfg.MaskMaximumRetries = value;
                cfg.Persist(this);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Mask data sent event
        /// </summary>
        /// <param name="value"></param>
        public void MaskDataSent(bool value)
        {
            var cfg = Nrf24L01Config.Read(this);

            if (cfg.MaskDataSent != value)
            {
                cfg.MaskDataSent = value;
                cfg.Persist(this);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Set CRC Length
        /// </summary>
        /// <param name="length"></param>
        public void SetCRCLength(CRCLength length)
        {
            var cfg = Nrf24L01Config.Read(this);

            if (cfg.CRCLength != length)
            {
                cfg.CRCLength = length;
                cfg.Persist(this);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set Power Mode
        /// </summary>
        /// <param name="mode">Power Mode</param>
        public void SetPowerMode(PowerMode mode)
        {
            var cfg = Nrf24L01Config.Read(this);

            if (cfg.Power != mode)
            {
                cfg.Power = mode;
                cfg.Persist(this);
                if (mode == PowerMode.PowerUp)
                {
                    MicrosecondTimer.Wait(1600); // according to docs, need to wait only for 1500
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns crc length (in bits)
 /// </summary>
 /// <returns></returns>
 public CRCLength GetCRCLength()
 {
     return(Nrf24L01Config.Read(this).CRCLength);
 }