wfview/freqmemory.cpp

67 wiersze
1.4 KiB
C++
Czysty Zwykły widok Historia

2018-11-07 23:54:03 +00:00
#include "freqmemory.h"
2021-02-23 21:21:22 +00:00
#include "logcategories.h"
2018-11-07 23:54:03 +00:00
2020-03-12 03:58:31 +00:00
// Copytight 2017-2020 Elliott H. Liggett
2018-11-07 23:54:03 +00:00
freqMemory::freqMemory()
{
// NOTE: These are also present in the header and
// the array must be changed if these are changed.
numPresets = 100;
maxIndex = numPresets - 1;
initializePresets();
2018-11-07 23:54:03 +00:00
}
void freqMemory::initializePresets()
{
// qInfo() << "Initializing " << numPresets << " memory channels";
for(unsigned int p=0; p < numPresets; p++)
{
presets[p].frequency = 14.1 + p/1000.0;
presets[p].mode = modeUSB;
presets[p].isSet = true;
}
}
void freqMemory::setPreset(unsigned int index, double frequency, mode_kind mode)
{
if(index <= maxIndex)
{
presets[index].frequency = frequency;
presets[index].mode = mode;
presets[index].isSet = true;
}
}
preset_kind freqMemory::getPreset(unsigned int index)
{
//validate then return
if(index <= maxIndex)
{
return presets[index];
}
// else, return something obviously wrong
preset_kind temp;
temp.frequency=12.345;
temp.mode = modeUSB;
temp.isSet = false;
return temp;
}
unsigned int freqMemory::getNumPresets()
{
return numPresets;
}
void freqMemory::dumpMemory()
{
for(unsigned int p=0; p < numPresets; p++)
{
qInfo(logSystem()) << "Index: " << p << " freq: " << presets[p].frequency << " Mode: " << presets[p].mode << " isSet: " << presets[p].isSet;
}
}