mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-09 18:27:49 -04:00
Fix for gain sliders not perfectly following integer gain steps from the menu (i.e RSPx RF gains)
This commit is contained in:
parent
e44af72b00
commit
4b077af873
@ -17,6 +17,7 @@
|
|||||||
#include "CubicSDRDefs.h"
|
#include "CubicSDRDefs.h"
|
||||||
#include "AppFrame.h"
|
#include "AppFrame.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(GainCanvas, wxGLCanvas) EVT_PAINT(GainCanvas::OnPaint)
|
wxBEGIN_EVENT_TABLE(GainCanvas, wxGLCanvas) EVT_PAINT(GainCanvas::OnPaint)
|
||||||
EVT_IDLE(GainCanvas::OnIdle)
|
EVT_IDLE(GainCanvas::OnIdle)
|
||||||
@ -75,7 +76,9 @@ void GainCanvas::OnIdle(wxIdleEvent &event) {
|
|||||||
for (auto gi : gainPanels) {
|
for (auto gi : gainPanels) {
|
||||||
if (gi->getChanged()) {
|
if (gi->getChanged()) {
|
||||||
areGainsChangedHere = true;
|
areGainsChangedHere = true;
|
||||||
wxGetApp().setGain(gi->getName(), gi->getValue());
|
// Gain only displays integer gain values, so the applied gain
|
||||||
|
//value to exactly that.
|
||||||
|
wxGetApp().setGain(gi->getName(), (int)(gi->getValue()));
|
||||||
//A gain may be exposed as setting also so assure refresh of the menu also.
|
//A gain may be exposed as setting also so assure refresh of the menu also.
|
||||||
wxGetApp().notifyMainUIOfDeviceChange(false); //do not piggyback to us...
|
wxGetApp().notifyMainUIOfDeviceChange(false); //do not piggyback to us...
|
||||||
|
|
||||||
@ -263,19 +266,19 @@ bool GainCanvas::updateGainValues() {
|
|||||||
// do not update if a change is already pending.
|
// do not update if a change is already pending.
|
||||||
if (!gainPanels[panelIndex]->getChanged()) {
|
if (!gainPanels[panelIndex]->getChanged()) {
|
||||||
|
|
||||||
//read the actual gain from the device.
|
//read the actual gain from the device, round it
|
||||||
float actualGain = (float)devInfo->getCurrentGain(SOAPY_SDR_RX, 0, gi.first);
|
float actualRoundedGain = (float)std::round(devInfo->getCurrentGain(SOAPY_SDR_RX, 0, gi.first));
|
||||||
|
|
||||||
//do nothing if the difference is less than 1.0, since the panel do not show it anyway.
|
//do nothing if the difference is less than 1.0, since the panel do not show it anyway.
|
||||||
if (std::abs(actualGain - gainPanels[panelIndex]->getValue()) > 1.0) {
|
if ((int)actualRoundedGain != (int)(gainPanels[panelIndex]->getValue())) {
|
||||||
|
|
||||||
gainPanels[panelIndex]->setValue(actualGain);
|
gainPanels[panelIndex]->setValue(actualRoundedGain);
|
||||||
|
|
||||||
//update the config with this value :
|
//update the config with this value :
|
||||||
//a consequence of such updates is that the use setting
|
//a consequence of such updates is that the use setting
|
||||||
// is overriden by the current one in AGC mode.
|
// is overriden by the current one in AGC mode.
|
||||||
//TODO: if it not desirable, do not update in AGC mode.
|
//TODO: if it not desirable, do not update in AGC mode.
|
||||||
devConfig->setGain(gi.first, actualGain);
|
devConfig->setGain(gi.first, actualRoundedGain);
|
||||||
|
|
||||||
isRefreshNeeded = true;
|
isRefreshNeeded = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user