mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-12 23:26:10 -05:00
Changed Low-perf mode into a CPU usage submenu (low, Normal, High) where High means PFBCH2 usage
This commit is contained in:
parent
462da6cdf7
commit
6faa2f87b3
@ -306,7 +306,7 @@ AppConfig::AppConfig() : configName("") {
|
||||
winH.store(0);
|
||||
winMax.store(false);
|
||||
showTips.store(true);
|
||||
lowPerfMode.store(false);
|
||||
perfMode.store(PERF_NORMAL);
|
||||
themeId.store(0);
|
||||
fontScale.store(0);
|
||||
snap.store(1);
|
||||
@ -393,12 +393,12 @@ bool AppConfig::getShowTips() {
|
||||
return showTips.load();
|
||||
}
|
||||
|
||||
void AppConfig::setLowPerfMode(bool show) {
|
||||
lowPerfMode.store(show);
|
||||
void AppConfig::setPerfMode(PerfModeEnum show) {
|
||||
perfMode.store(show);
|
||||
}
|
||||
|
||||
bool AppConfig::getLowPerfMode() {
|
||||
return lowPerfMode.load();
|
||||
AppConfig::PerfModeEnum AppConfig::getPerfMode() {
|
||||
return perfMode.load();
|
||||
}
|
||||
|
||||
wxRect *AppConfig::getWindow() {
|
||||
@ -590,7 +590,7 @@ bool AppConfig::save() {
|
||||
|
||||
*window_node->newChild("max") = winMax.load();
|
||||
*window_node->newChild("tips") = showTips.load();
|
||||
*window_node->newChild("low_perf_mode") = lowPerfMode.load();
|
||||
*window_node->newChild("perf_mode") = (int)perfMode.load();
|
||||
*window_node->newChild("theme") = themeId.load();
|
||||
*window_node->newChild("font_scale") = fontScale.load();
|
||||
*window_node->newChild("snap") = snap.load();
|
||||
@ -689,7 +689,7 @@ bool AppConfig::load() {
|
||||
|
||||
if (cfg.rootNode()->hasAnother("window")) {
|
||||
int x = 0 ,y = 0 ,w = 0 ,h = 0;
|
||||
int max = 0 ,tips = 0 ,lpm = 0 ,mpc = 0;
|
||||
int max = 0 ,tips = 0 ,perf_mode = 0 ,mpc = 0;
|
||||
|
||||
DataNode *win_node = cfg.rootNode()->getNext("window");
|
||||
|
||||
@ -716,11 +716,19 @@ bool AppConfig::load() {
|
||||
showTips.store(tips?true:false);
|
||||
}
|
||||
|
||||
if (win_node->hasAnother("low_perf_mode")) {
|
||||
win_node->getNext("low_perf_mode")->element()->get(lpm);
|
||||
lowPerfMode.store(lpm?true:false);
|
||||
}
|
||||
// default:
|
||||
perfMode.store(PERF_NORMAL);
|
||||
|
||||
if (win_node->hasAnother("perf_mode")) {
|
||||
win_node->getNext("perf_mode")->element()->get(perf_mode);
|
||||
|
||||
if (perf_mode == (int)PERF_LOW) {
|
||||
perfMode.store(PERF_LOW);
|
||||
} else if (perf_mode == (int)PERF_HIGH) {
|
||||
perfMode.store(PERF_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
if (win_node->hasAnother("theme")) {
|
||||
int theme;
|
||||
win_node->getNext("theme")->element()->get(theme);
|
||||
|
@ -83,6 +83,14 @@ private:
|
||||
|
||||
class AppConfig {
|
||||
public:
|
||||
|
||||
enum PerfModeEnum {
|
||||
PERF_LOW = 0,
|
||||
PERF_NORMAL = 1,
|
||||
PERF_HIGH = 2
|
||||
};
|
||||
|
||||
|
||||
AppConfig();
|
||||
std::string getConfigDir();
|
||||
DeviceConfig *getDevice(std::string deviceId);
|
||||
@ -99,8 +107,8 @@ public:
|
||||
void setShowTips(bool show);
|
||||
bool getShowTips();
|
||||
|
||||
void setLowPerfMode(bool lpm);
|
||||
bool getLowPerfMode();
|
||||
void setPerfMode(PerfModeEnum mode);
|
||||
PerfModeEnum getPerfMode();
|
||||
|
||||
void setTheme(int themeId);
|
||||
int getTheme();
|
||||
@ -185,7 +193,7 @@ private:
|
||||
std::string configName;
|
||||
std::map<std::string, DeviceConfig *> deviceConfig;
|
||||
std::atomic_int winX,winY,winW,winH;
|
||||
std::atomic_bool winMax, showTips, lowPerfMode, modemPropsCollapsed;
|
||||
std::atomic_bool winMax, showTips, modemPropsCollapsed;
|
||||
std::atomic_int themeId;
|
||||
std::atomic_int fontScale;
|
||||
std::atomic_llong snap;
|
||||
@ -203,5 +211,7 @@ private:
|
||||
std::atomic_int rigModel, rigRate;
|
||||
std::string rigPort;
|
||||
std::atomic_bool rigEnabled, rigFollowMode, rigControlMode, rigCenterLock, rigFollowModem;
|
||||
|
||||
std::atomic<PerfModeEnum> perfMode;
|
||||
#endif
|
||||
};
|
||||
|
@ -869,12 +869,30 @@ void AppFrame::updateDeviceParams() {
|
||||
showTipMenuItem = newSettingsMenu->AppendCheckItem(wxID_SET_TIPS, "Show Hover Tips");
|
||||
showTipMenuItem->Check(wxGetApp().getConfig()->getShowTips());
|
||||
|
||||
lowPerfMode = wxGetApp().getConfig()->getLowPerfMode();
|
||||
lowPerfMenuItem = newSettingsMenu->AppendCheckItem(wxID_LOW_PERF, "Reduce CPU Usage");
|
||||
if (lowPerfMode) {
|
||||
lowPerfMenuItem->Check(true);
|
||||
// CPU usage menu:
|
||||
performanceMenuItems.clear();
|
||||
|
||||
wxMenu *subMenu = new wxMenu;
|
||||
|
||||
performanceMenuItems[wxID_PERF_BASE + (int)AppConfig::PERF_HIGH] = subMenu->AppendRadioItem(wxID_PERF_BASE + (int)AppConfig::PERF_HIGH, "High (enhanced)");
|
||||
performanceMenuItems[wxID_PERF_BASE + (int)AppConfig::PERF_NORMAL] = subMenu->AppendRadioItem(wxID_PERF_BASE + (int)AppConfig::PERF_NORMAL, "Normal");
|
||||
performanceMenuItems[wxID_PERF_BASE + (int)AppConfig::PERF_LOW] = subMenu->AppendRadioItem(wxID_PERF_BASE + (int)AppConfig::PERF_LOW, "Low (slow UI)");
|
||||
|
||||
AppConfig::PerfModeEnum perfMode = wxGetApp().getConfig()->getPerfMode();
|
||||
|
||||
if (perfMode == AppConfig::PERF_HIGH) {
|
||||
wxGetApp().setChannelizerType(SDRPostThreadChannelizerType::SDRPostPFBCH2);
|
||||
} else {
|
||||
wxGetApp().setChannelizerType(SDRPostThreadChannelizerType::SDRPostPFBCH);
|
||||
}
|
||||
|
||||
performanceMenuItems[wxID_PERF_BASE + (int)perfMode]->Check(true);
|
||||
|
||||
wxMenuItem* selectedPerfModeItem = performanceMenuItems[wxID_PERF_BASE + (int)perfMode];
|
||||
|
||||
performanceMenuItems[wxID_PERF_CURRENT] = newSettingsMenu->AppendSubMenu(subMenu, "CPU usage");
|
||||
performanceMenuItems[wxID_PERF_CURRENT]->SetItemLabel(getSettingsLabel("CPU usage", selectedPerfModeItem->GetItemLabel().ToStdString()));
|
||||
|
||||
newSettingsMenu->AppendSeparator();
|
||||
|
||||
settingsMenuItems.clear();
|
||||
@ -1827,10 +1845,30 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.GetId() == wxID_LOW_PERF) {
|
||||
lowPerfMode = lowPerfMenuItem->IsChecked();
|
||||
wxGetApp().getConfig()->setLowPerfMode(lowPerfMode);
|
||||
else if (event.GetId() >= wxID_PERF_BASE && event.GetId() <= wxID_PERF_BASE + (int)AppConfig::PERF_HIGH) {
|
||||
|
||||
int perfEnumAsInt = event.GetId() - wxID_PERF_BASE;
|
||||
AppConfig::PerfModeEnum perfEnumSet = AppConfig::PERF_NORMAL;
|
||||
|
||||
if (perfEnumAsInt == (int)AppConfig::PERF_HIGH) {
|
||||
perfEnumSet = AppConfig::PERF_HIGH;
|
||||
|
||||
} else if (perfEnumAsInt == (int)AppConfig::PERF_LOW) {
|
||||
perfEnumSet = AppConfig::PERF_LOW;
|
||||
}
|
||||
|
||||
wxGetApp().getConfig()->setPerfMode(perfEnumSet);
|
||||
|
||||
//update Channelizer mode:
|
||||
if (perfEnumSet == AppConfig::PERF_HIGH) {
|
||||
wxGetApp().setChannelizerType(SDRPostThreadChannelizerType::SDRPostPFBCH2);
|
||||
} else {
|
||||
wxGetApp().setChannelizerType(SDRPostThreadChannelizerType::SDRPostPFBCH);
|
||||
}
|
||||
|
||||
//update UI
|
||||
wxMenuItem* selectedPerfModeItem = performanceMenuItems[event.GetId()];
|
||||
performanceMenuItems[wxID_PERF_CURRENT]->SetItemLabel(getSettingsLabel("CPU usage", selectedPerfModeItem->GetItemLabel().ToStdString()));
|
||||
}
|
||||
else if (event.GetId() == wxID_SET_TIPS ) {
|
||||
if (wxGetApp().getConfig()->getShowTips()) {
|
||||
@ -2324,7 +2362,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
if (!this->IsActive()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(30));
|
||||
} else {
|
||||
if (lowPerfMode) {
|
||||
if (wxGetApp().getConfig()->getPerfMode() == AppConfig::PERF_LOW) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(30));
|
||||
} else {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
|
@ -39,7 +39,6 @@
|
||||
#define wxID_SDR_DEVICES 2008
|
||||
#define wxID_AGC_CONTROL 2009
|
||||
#define wxID_SDR_START_STOP 2010
|
||||
#define wxID_LOW_PERF 2011
|
||||
#define wxID_SET_DB_OFFSET 2012
|
||||
#define wxID_ABOUT_CUBICSDR 2013
|
||||
|
||||
@ -70,9 +69,12 @@
|
||||
|
||||
#define wxID_SETTINGS_BASE 2300
|
||||
|
||||
#define wxID_ANTENNA_CURRENT 2500
|
||||
#define wxID_ANTENNA_CURRENT 2350
|
||||
#define wxID_ANTENNA_CURRENT_TX 2501
|
||||
#define wxID_ANTENNAS_BASE 2502
|
||||
#define wxID_ANTENNAS_BASE 2352
|
||||
|
||||
#define wxID_PERF_CURRENT 2400
|
||||
#define wxID_PERF_BASE 2401
|
||||
|
||||
#define wxID_DEVICE_ID 3500
|
||||
|
||||
@ -229,6 +231,8 @@ private:
|
||||
//depending on context, maps the item id to wxMenuItem*,
|
||||
//OR the submenu item id to its parent wxMenuItem*.
|
||||
std::map<int, wxMenuItem *> settingsMenuItems;
|
||||
|
||||
std::map<int, wxMenuItem *> performanceMenuItems;
|
||||
|
||||
std::map<int, wxMenuItem *> audioSampleRateMenuItems;
|
||||
|
||||
@ -242,7 +246,7 @@ private:
|
||||
wxMenu *displayMenu = nullptr;
|
||||
wxMenuItem *agcMenuItem = nullptr;
|
||||
wxMenuItem *iqSwapMenuItem = nullptr;
|
||||
wxMenuItem *lowPerfMenuItem = nullptr;
|
||||
|
||||
wxMenu *fileMenu = nullptr;
|
||||
wxMenu *settingsMenu = nullptr;
|
||||
wxMenu *recordingMenu = nullptr;
|
||||
@ -269,8 +273,6 @@ private:
|
||||
std::atomic_bool modemPropertiesUpdated;
|
||||
wxMenuItem *showTipMenuItem;
|
||||
|
||||
bool lowPerfMode;
|
||||
|
||||
wxMenuItem *hideBookmarksItem;
|
||||
bool saveDisabled;
|
||||
|
||||
|
@ -659,6 +659,21 @@ const std::string& CubicSDR::getAntennaName() {
|
||||
return antennaName;
|
||||
}
|
||||
|
||||
void CubicSDR::setChannelizerType(SDRPostThreadChannelizerType chType) {
|
||||
if (sdrPostThread && !sdrPostThread->isTerminated()) {
|
||||
sdrPostThread->setChannelizerType(chType);
|
||||
}
|
||||
}
|
||||
|
||||
SDRPostThreadChannelizerType CubicSDR::getChannelizerType() {
|
||||
|
||||
if (sdrPostThread && !sdrPostThread->isTerminated()) {
|
||||
return sdrPostThread->getChannelizerType();
|
||||
}
|
||||
|
||||
return SDRPostThreadChannelizerType::SDRPostPFBCH;
|
||||
}
|
||||
|
||||
long long CubicSDR::getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
@ -95,6 +95,9 @@ public:
|
||||
|
||||
void setAntennaName(const std::string& name);
|
||||
const std::string& getAntennaName();
|
||||
|
||||
void setChannelizerType(SDRPostThreadChannelizerType chType);
|
||||
SDRPostThreadChannelizerType getChannelizerType();
|
||||
|
||||
|
||||
void setSampleRate(long long rate_in);
|
||||
|
@ -21,8 +21,8 @@ SDRPostThread::SDRPostThread() : IOThread(), buffers("SDRPostThreadBuffers"), vi
|
||||
channelizer = nullptr;
|
||||
channelizer2 = nullptr;
|
||||
|
||||
// Channel mode default temporary for testing
|
||||
chanMode = 1;
|
||||
// Channel mode default is PFBCH
|
||||
chanMode = (int)SDRPostPFBCH;
|
||||
lastChanMode = 0;
|
||||
|
||||
sampleRate = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user