Skip to content

Commit

Permalink
SI474X Arduino Library
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2clr committed Jul 11, 2021
1 parent c5a3c32 commit 6edb1a5
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 29 deletions.
76 changes: 76 additions & 0 deletions SI4735.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
#define FM_RSQ_STATUS 0x23
#define FM_RDS_STATUS 0x24 // Returns RDS information for current channel and reads an entry from the RDS FIFO.

#define FM_NB_DETECT_THRESHOLD 0x1900 // Sets the threshold for detecting impulses in dB above the noise floor. Default value is 16.
#define FM_NB_INTERVAL 0x1901 // Interval in micro-seconds that original samples are replaced by interpolated clean sam- ples. Default value is 24 μs.
#define FM_NB_RATE 0x1902 // Noise blanking rate in 100 Hz units. Default value is 64.
#define FM_NB_IIR_FILTER 0x1903 // Sets the bandwidth of the noise floor estimator Default value is 300.
#define FM_NB_DELAY 0x1904 // Delay in micro-seconds before applying impulse blanking to the original sam- ples. Default value is 133.

// FM RDS properties
#define FM_RDS_INT_SOURCE 0x1500
#define FM_RDS_INT_FIFO_COUNT 0x1501
Expand Down Expand Up @@ -1775,6 +1781,76 @@ class SI4735
sendProperty(FM_SOFT_MUTE_MAX_ATTENUATION, smattn);
};

/**
* @brief Set the Fm Noise Blank Threshold
* @details Sets the threshold for detecting impulses in dB above the noise floor. The CTS bit (and optional interrupt) is set when it is safe to send the next command.
* @param parameter (from 0 to 90. default is 10)
*/
inline void setFmNoiseBlankThreshold(uint16_t parameter)
{
sendProperty(FM_NB_DETECT_THRESHOLD, parameter);
};

/**
* @brief Set the Fm Noise Blank
* @details Sets Noise blanking rate in 100 Hz units
* @details Sets the Interval in micro-seconds that original samples are replaced by sample-hold clean samples.
* @details Sets the bandwidth of the noise floor estimator.
*
* @details ATTENTION: It works on SI474X. It may not work on SI473X devices.
*
* @param nb_rate Noise blanking rate in 100 Hz units. Default value is 64.
* @param nb_interval Interval in micro-seconds that original samples are replaced by interpolated clean samples. Default value is 55 μs.
* @param nb_irr_filter Sets the bandwidth of the noise floor estimator. Default value is 300.
*/
inline void setFmNoiseBlank(uint16_t nb_rate = 64, uint16_t nb_interval = 55, uint16_t nb_irr_filter = 300)
{
sendProperty(FM_NB_RATE, nb_rate);
sendProperty(FM_NB_INTERVAL, nb_interval);
sendProperty(FM_NB_IIR_FILTER, nb_irr_filter);
}

/**
* @brief Set the Fm Noise Blank Interval
* @details Interval in micro-seconds that original samples are replaced by interpolated clean samples.
* @param parameter ( from 8 to 48. default value is 24)
*/
inline void setFmNoiseBlankInterval(uint16_t parameter)
{
sendProperty(FM_NB_INTERVAL, parameter);
};

/**
* @brief Set the Fm Noise Blank Rate
* @details Noise blanking rate in 100 Hz units.
*
* @param parameter ( from 1 to 64. default value is 64)
*/
inline void setFmNoiseBlankRate(uint16_t parameter)
{
sendProperty(FM_NB_RATE, parameter);
};

/**
* @brief Set the Fm Noise Blank Delay
* @details Delay in micro-seconds before applying impulse blanking to the original samples.
* @param parameter ( from 125 to 219. default value is 170)
*/
inline void setFmNoiseBlankDelay(uint16_t parameter)
{
sendProperty(FM_NB_DELAY, parameter);
};

/**
* @brief Set the FmNoiseBlank IIR Filter
* @details Sets the bandwidth of the noise floor estimator.
* @param parameter (from 300 to 1600. default value is 300)
*/
inline void setFmNoiseBlank_IIR_Filter(uint16_t parameter)
{
sendProperty(FM_NB_IIR_FILTER, parameter);
}

/**
* @ingroup group08
* @brief Sets the AM Receive de-emphasis to 50 or disable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,11 @@ void setButton(Adafruit_GFX_Button *button, int16_t col, int16_t lin, int16_t wi


void setButtonsFM() {
setButton(&bFilter, 270, KEYBOARD_LIN_OFFSET + 295, 70, 49, "BW", true);
setButton(&bSoftMute, 45, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bSMuteRate, 120, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bSlop, 195, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bAGC, 270, KEYBOARD_LIN_OFFSET + 240, 70, 49, "AGC On", true);
setButton(&bFilter, 270, KEYBOARD_LIN_OFFSET + 295, 70, 49, (char *) "BW", true);
setButton(&bSoftMute, 45, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bSMuteRate, 120, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bSlop, 195, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bAGC, 270, KEYBOARD_LIN_OFFSET + 240, 70, 49, (char *) "AGC On", true);
}

void showTemplate()
Expand Down Expand Up @@ -622,26 +622,26 @@ void showTemplate()
bSync.initButton(&tft, 270, 350, 70, 49, WHITE, CYAN, BLACK, (char *)"DE", 1);
*/

setButton(&bPreviousBand, 45, KEYBOARD_LIN_OFFSET + 130, 70, 49, "Band-", true);
setButton(&bNextBand, 120, KEYBOARD_LIN_OFFSET + 130, 70, 49, "Band+", true);
setButton(&bVolumeLevel, 195, KEYBOARD_LIN_OFFSET + 130, 70, 49, "Vol", true);
setButton(&bAudioMute, 270, KEYBOARD_LIN_OFFSET + 130, 70, 49, "Mute", true);
setButton(&bSeekDown, 45, KEYBOARD_LIN_OFFSET + 185, 70, 49, "Seek-", true);
setButton(&bSeekUp, 120, KEYBOARD_LIN_OFFSET + 185, 70, 49, "Seek+", true);
setButton(&bBFO, 195, KEYBOARD_LIN_OFFSET + 185, 70, 49, "BFO", true);
setButton(&bStep, 270, KEYBOARD_LIN_OFFSET + 185, 70, 49, "Step", true);
setButton(&bFM, 45, KEYBOARD_LIN_OFFSET + 240, 70, 49, "FM", true);
setButton(&bMW, 120, KEYBOARD_LIN_OFFSET + 240, 70, 49, "MW", true);
setButton(&bSW, 195, KEYBOARD_LIN_OFFSET + 240, 70, 49, "SW", true);
setButton(&bAGC, 270, KEYBOARD_LIN_OFFSET + 240, 70, 49, "AGC On", true);
setButton(&bAM, 45, KEYBOARD_LIN_OFFSET + 295, 70, 49, "AM", true);
setButton(&bLSB, 120, KEYBOARD_LIN_OFFSET + 295, 70, 49, "LSB", true);
setButton(&bUSB, 195, KEYBOARD_LIN_OFFSET + 295, 70, 49, "USB", true);
setButton(&bFilter, 270, KEYBOARD_LIN_OFFSET + 295, 70, 49, "BW", true);
setButton(&bSoftMute, 45, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bSMuteRate, 120, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bSlop, 195, KEYBOARD_LIN_OFFSET + 350, 70, 49, "---", true);
setButton(&bSync, 270, KEYBOARD_LIN_OFFSET + 350, 70, 49, "SYNC", true);
setButton(&bPreviousBand, 45, KEYBOARD_LIN_OFFSET + 130, 70, 49, (char *) "Band-", true);
setButton(&bNextBand, 120, KEYBOARD_LIN_OFFSET + 130, 70, 49, (char *) "Band+", true);
setButton(&bVolumeLevel, 195, KEYBOARD_LIN_OFFSET + 130, 70, 49, (char *) "Vol", true);
setButton(&bAudioMute, 270, KEYBOARD_LIN_OFFSET + 130, 70, 49, (char *) "Mute", true);
setButton(&bSeekDown, 45, KEYBOARD_LIN_OFFSET + 185, 70, 49, (char *) "Seek-", true);
setButton(&bSeekUp, 120, KEYBOARD_LIN_OFFSET + 185, 70, 49, (char *) "Seek+", true);
setButton(&bBFO, 195, KEYBOARD_LIN_OFFSET + 185, 70, 49, (char *) "BFO", true);
setButton(&bStep, 270, KEYBOARD_LIN_OFFSET + 185, 70, 49, (char *) "Step", true);
setButton(&bFM, 45, KEYBOARD_LIN_OFFSET + 240, 70, 49, (char *) "FM", true);
setButton(&bMW, 120, KEYBOARD_LIN_OFFSET + 240, 70, 49, (char *) "MW", true);
setButton(&bSW, 195, KEYBOARD_LIN_OFFSET + 240, 70, 49, (char *) "SW", true);
setButton(&bAGC, 270, KEYBOARD_LIN_OFFSET + 240, 70, 49, (char *) "AGC On", true);
setButton(&bAM, 45, KEYBOARD_LIN_OFFSET + 295, 70, 49, (char *) "AM", true);
setButton(&bLSB, 120, KEYBOARD_LIN_OFFSET + 295, 70, 49, (char *) "LSB", true);
setButton(&bUSB, 195, KEYBOARD_LIN_OFFSET + 295, 70, 49, (char *) "USB", true);
setButton(&bFilter, 270, KEYBOARD_LIN_OFFSET + 295, 70, 49, (char *) "BW", true);
setButton(&bSoftMute, 45, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bSMuteRate, 120, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bSlop, 195, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "---", true);
setButton(&bSync, 270, KEYBOARD_LIN_OFFSET + 350, 70, 49, (char *) "SYNC", true);

// Exibe os botões (teclado touch)
setDrawButtons(true);
Expand Down Expand Up @@ -941,7 +941,7 @@ void showRSSI()
if (currentMode != FM)
{
//dBuV to S point conversion HF
if ((rssi >= 0) and (rssi <= 1))
if (rssi <= 1)
spoint = 12; // S0
if ((rssi > 1) and (rssi <= 1))
spoint = 24; // S1
Expand Down Expand Up @@ -1319,7 +1319,7 @@ void switchFilter(uint8_t v)
delay(MIN_ELAPSED_TIME); // waits a little more for releasing the button.
}

void switchSync(int8_t v) {
void switchSync( /*int8_t v */) {
if (currentMode != FM)
{
currentBFO = 0;
Expand Down Expand Up @@ -1700,7 +1700,7 @@ void loop(void)
else if (bSync.justPressed())
{
cmdSync = !cmdSync;
switchSync(0);
switchSync(/*0*/);
delay(MIN_ELAPSED_TIME);
}
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=PU2CLR SI4735
version=2.1.0
version=2.1.1
author=Ricardo Lima Caratti, pu2clr@gmail.com
maintainer=Ricardo Lima Caratti
sentence=Control your Silicon Labs SI47XX Family (Si4730, Si4732, Si4731, Si4734, Si4735, Si4740, Si4745 etc) BROADCAST AM/FM/SW RADIO RECEIVER.
Expand Down

0 comments on commit 6edb1a5

Please sign in to comment.