Skip to content

Commit 2529fe6

Browse files
authored
Refactor gain setting functions to use a common method
1 parent 72da796 commit 2529fe6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Source/Device/HYDRASDR.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,25 @@ namespace Device
126126

127127
void HYDRASDR::setLNA_AGC(int a)
128128
{
129-
if (hydrasdr_set_lna_agc(dev, a) != HYDRASDR_SUCCESS)
129+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_LNA_AGC, a) != HYDRASDR_SUCCESS)
130130
throw std::runtime_error("HYDRASDR: cannot set LNA AGC.");
131131
}
132132

133133
void HYDRASDR::setMixer_AGC(int a)
134134
{
135-
if (hydrasdr_set_mixer_agc(dev, a) != HYDRASDR_SUCCESS)
135+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_MIXER_AGC, a) != HYDRASDR_SUCCESS)
136136
throw std::runtime_error("HYDRASDR: cannot set MIXER AGC.");
137137
}
138138

139139
void HYDRASDR::setLNA_Gain(int a)
140140
{
141-
if (hydrasdr_set_lna_gain(dev, a) != HYDRASDR_SUCCESS)
141+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_LNA, a) != HYDRASDR_SUCCESS)
142142
throw std::runtime_error("HYDRASDR: cannot set LNA gain.");
143143
}
144144

145145
void HYDRASDR::setMixer_Gain(int a)
146146
{
147-
if (hydrasdr_set_mixer_gain(dev, a) != HYDRASDR_SUCCESS)
147+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_MIXER, a) != HYDRASDR_SUCCESS)
148148
throw std::runtime_error("HYDRASDR: cannot set Mixer gain.");
149149
}
150150

@@ -156,19 +156,19 @@ namespace Device
156156

157157
void HYDRASDR::setVGA_Gain(int a)
158158
{
159-
if (hydrasdr_set_vga_gain(dev, a) != HYDRASDR_SUCCESS)
159+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_VGA, a) != HYDRASDR_SUCCESS)
160160
throw std::runtime_error("HYDRASDR: cannot set VGA gain.");
161161
}
162162

163163
void HYDRASDR::setSensitivity_Gain(int a)
164164
{
165-
if (hydrasdr_set_sensitivity_gain(dev, a) != HYDRASDR_SUCCESS)
165+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_SENSITIVITY, a) != HYDRASDR_SUCCESS)
166166
throw std::runtime_error("HYDRASDR: cannot set Sensitivity gain.");
167167
}
168168

169169
void HYDRASDR::setLinearity_Gain(int a)
170170
{
171-
if (hydrasdr_set_linearity_gain(dev, a) != HYDRASDR_SUCCESS)
171+
if (hydrasdr_set_gain(dev, HYDRASDR_GAIN_TYPE_LINEARITY, a) != HYDRASDR_SUCCESS)
172172
throw std::runtime_error("HYDRASDR: cannot set Linearity gain.");
173173
}
174174

@@ -220,10 +220,8 @@ namespace Device
220220

221221
// Register 10 (0x0A): HPF corner frequency selection
222222
// Register 11 (0x0B): LPF corner frequency selection
223-
hydrasdr_r82x_write(dev, 10, 0xB0 | (15 - j));
224-
hydrasdr_r82x_write(dev, 11, 0xE0 | (15 - i));
225-
226-
std::cerr << "HYDRASDR: setting tuner bandwidth to " << tuner_bandwidth << " Hz, using HF range " << r82x_hf[j] << " Hz to " << r82x_lf[i] << " Hz." << std::endl;
223+
hydrasdr_rf_frontend_write(dev, 10, 0xB0 | (15 - j));
224+
hydrasdr_rf_frontend_write(dev, 11, 0xE0 | (15 - i));
227225
}
228226
}
229227
}

0 commit comments

Comments
 (0)