예제 #1
0
        /// <summary>
        /// Clears out information, but will not stop events. This should be called when a new station is tuned to
        /// </summary>
        public void Reset()
        {
            //Apply changes
            rdsSupported = false;
            piCode       = 0;
            psComplete   = false;
            rtComplete   = false;
            timeComplete = false;
            psBuffer     = CreateEmptyBuffer(8);
            rtBuffer     = CreateEmptyBuffer(64);

            //Fire events
            OnPsBufferUpdated?.Invoke(this, psBuffer);
            OnPsNameUpdated?.Invoke(this, "");
            OnRtTextUpdated?.Invoke(this, "");
            OnRtBufferUpdated?.Invoke(this, rtBuffer);
            OnRtBufferCleared?.Invoke(this);
            OnReset?.Invoke(this);
        }
예제 #2
0
        /// <summary>
        /// Processes 0A and 0B "basic tuning and switching" frame types 0b00000 and 0b00001
        /// </summary>
        private void ProcessFramePayload_BasicInfo(RDSFrame frame)
        {
            //Read the header flags
            bool flagTa = 1 == ((frame.b >> (HEADER_OFFSET - 0)) & 0b0000000000000001);
            bool flagMs = 1 == ((frame.b >> (HEADER_OFFSET - 1)) & 0b0000000000000001);
            bool flagDi = 1 == ((frame.b >> (HEADER_OFFSET - 2)) & 0b0000000000000001);

            //Get the code bits. These are just used for the text for the most part just for the PS name
            byte decoderControlCode = (byte)((frame.b >> (HEADER_OFFSET - 4)) & 0b0000000000000011);

            //Get the two PS code characters
            char psA = (char)((frame.d >> 8) & 0x00FF);
            char psB = (char)((frame.d >> 0) & 0x00FF);

            //Write to the PS buffer
            psBuffer[(decoderControlCode * 2) + 0] = psA;
            psBuffer[(decoderControlCode * 2) + 1] = psB;

            //Set flags for the characters updated if they're in sequential order
            if (decoderControlCode == psUpdatedFrameIndex)
            {
                psUpdatedFrameIndex++;
            }

            //Check if we've completed it
            if (psUpdatedFrameIndex == 4)
            {
                //Completed!
                //Update state
                psName              = new string(psBuffer);
                psComplete          = true;
                psUpdatedFrameIndex = 0;

                //Fire events
                OnPsNameUpdated?.Invoke(this, psName);
            }

            //Send updated events
            OnPsBufferUpdated?.Invoke(this, psBuffer);
        }