CatRadio/rigcommand.cpp

189 wiersze
5.8 KiB
C++

2022-03-12 19:30:51 +00:00
/**
** This file is part of the CatRadio project.
2024-04-12 22:46:59 +00:00
** Copyright 2022-2024 Gianfranco Sordetti IZ8EWD <iz8ewd@pianetaradio.it>.
2022-03-12 19:30:51 +00:00
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#include "rigcommand.h"
#include "rigdata.h"
#include <rig.h> //Hamlib
#include <QDebug>
extern rigSettings rigGet;
extern rigSettings rigSet;
extern rigCommand rigCmd;
extern rigCommand rigCap;
2024-04-12 22:46:59 +00:00
//* Set band to default frequency or use band change if radio has capability
2022-03-12 19:30:51 +00:00
void set_band (int band)
{
2022-10-30 15:20:53 +00:00
if (rigCap.bandChange==0)
2022-03-12 19:30:51 +00:00
{
2022-10-30 15:20:53 +00:00
freq_t freq;
switch (band)
{
case 160: freq = 1840000; break;
case 80: freq = 3600000; break;
case 60: freq = 5355000; break;
case 40: freq = 7100000; break;
case 30: freq = 10130000; break;
case 20: freq = 14100000; break;
case 17: freq = 18120000; break;
case 15: freq = 21150000; break;
case 12: freq = 24940000; break;
case 10: freq = 28320000; break;
case 6: freq = 50150000; break;
case 2: freq = 144300000; break;
case 70: freq = 432200000; break;
case 1: freq = 5000000; break; //General
default: freq = rigSet.freqMain; break;
}
rigSet.freqMain = freq;
rigCmd.freqMain = 1;
2022-03-12 19:30:51 +00:00
}
2022-10-30 15:20:53 +00:00
else
{
int bandt;
switch (band)
{
case 160: bandt = RIG_BAND_160M; break;
case 80: bandt = RIG_BAND_80M; break;
case 60: bandt = RIG_BAND_60M; break;
case 40: bandt = RIG_BAND_40M; break;
case 30: bandt = RIG_BAND_30M; break;
case 20: bandt = RIG_BAND_20M; break;
case 17: bandt = RIG_BAND_17M; break;
case 15: bandt = RIG_BAND_15M; break;
case 12: bandt = RIG_BAND_12M; break;
case 10: bandt = RIG_BAND_10M; break;
case 6: bandt = RIG_BAND_6M; break;
case 2: bandt = RIG_BAND_144MHZ; break;
case 70: bandt = RIG_BAND_430MHZ; break;
case 1: bandt = RIG_BAND_GEN; break;
default: bandt = RIG_BAND_20M; break;
}
2022-03-12 19:30:51 +00:00
2022-10-30 15:20:53 +00:00
rigSet.band = bandt;
rigCmd.bandChange = 1;
}
2022-03-12 19:30:51 +00:00
}
2024-04-12 22:46:59 +00:00
//* Set split to 5kHz and activate it
2022-03-12 19:30:51 +00:00
void quick_split ()
{
2022-04-12 17:51:35 +00:00
rigSet.freqSub = rigGet.freqMain + 5000;
rigSet.modeSub = rigGet.mode;
rigSet.split = RIG_SPLIT_ON;
rigCmd.freqSub = 1;
rigCmd.modeSub = 1;
2022-03-12 19:30:51 +00:00
rigCmd.split = 1;
}
2024-04-16 17:46:23 +00:00
//* Send CW keyer message 1-5
2024-04-12 22:46:59 +00:00
void send_cw_mem (int memory)
{
rigSet.cwMem = (char)(memory + '0');
rigCmd.cwSend = 1;
}
//* Convert AGC int value to hamlib enumerated
2022-03-12 19:30:51 +00:00
agc_level_e levelagcvalue (int agcValue)
{
agc_level_e agcLevel;
switch (agcValue)
{
case 0: agcLevel = RIG_AGC_OFF; break;
case 1: agcLevel = RIG_AGC_SUPERFAST; break;
case 2: agcLevel = RIG_AGC_FAST; break;
case 3: agcLevel = RIG_AGC_SLOW; break;
case 4: agcLevel = RIG_AGC_USER; break;
case 5: agcLevel = RIG_AGC_MEDIUM; break;
case 6: agcLevel = RIG_AGC_AUTO; break;
default: agcLevel = RIG_AGC_AUTO; break;
}
return agcLevel;
}
2024-04-12 22:46:59 +00:00
//* Convert AGC string to hamlib enumerated
2022-03-12 19:30:51 +00:00
agc_level_e levelagcstr (QString agcString)
{
agc_level_e agcLevel;
if (agcString == "OFF") agcLevel = RIG_AGC_OFF;
else if (agcString == "SUPERFAST") agcLevel = RIG_AGC_SUPERFAST;
else if (agcString == "FAST") agcLevel = RIG_AGC_FAST;
else if (agcString == "SLOW") agcLevel = RIG_AGC_SLOW;
else if (agcString == "USER") agcLevel = RIG_AGC_USER;
else if (agcString == "MEDIUM") agcLevel = RIG_AGC_MEDIUM;
else agcLevel = RIG_AGC_AUTO;
return agcLevel;
}
2024-04-12 22:46:59 +00:00
//* Convert AGC hamlib enumerated to hamlib value_t
2022-03-12 19:30:51 +00:00
value_t valueagclevel (agc_level_e agcLevel)
{
value_t value;
if (agcLevel == RIG_AGC_OFF) value.i = 0;
else if (agcLevel == RIG_AGC_SUPERFAST) value.i = 1;
else if (agcLevel == RIG_AGC_FAST) value.i = 2;
else if (agcLevel == RIG_AGC_SLOW) value.i = 3;
else if (agcLevel == RIG_AGC_USER) value.i = 4;
else if (agcLevel == RIG_AGC_MEDIUM) value.i = 5;
else value.i = 6; //RIG_AGC_AUTO
return value;
}
2024-04-12 22:46:59 +00:00
//* Convert antenna string to hamlib ant_t
2022-03-12 19:30:51 +00:00
ant_t antstr (QString antString)
{
ant_t ant;
if (antString == "NONE") ant = RIG_ANT_NONE;
else if (antString == "ANT1") ant = RIG_ANT_1;
else if (antString == "ANT2") ant = RIG_ANT_2;
else if (antString == "ANT3") ant = RIG_ANT_3;
else if (antString == "ANT4") ant = RIG_ANT_4;
else if (antString == "ANT5") ant = RIG_ANT_5;
else if (antString == "UNK") ant = RIG_ANT_UNKNOWN;
else if (antString == "CURR") ant = RIG_ANT_CURR;
else ant = RIG_ANT_UNKNOWN;
return ant;
}
2024-04-16 17:46:23 +00:00
//* Convert Submeter combo box string into hamlib RIG_LEVEL constant
2022-11-03 19:24:55 +00:00
unsigned long long levelmeterstr (QString meterString)
2022-03-12 19:30:51 +00:00
{
2022-11-03 19:24:55 +00:00
unsigned long long levelMeter;
2022-03-12 19:30:51 +00:00
if (meterString == "SWR") levelMeter = RIG_LEVEL_SWR;
else if (meterString == "ALC") levelMeter = RIG_LEVEL_ALC;
2022-11-03 19:24:55 +00:00
else if (meterString == "COMP") levelMeter = RIG_LEVEL_COMP;
else if (meterString == "ID") levelMeter = RIG_LEVEL_ID_METER;
else if (meterString == "VDD") levelMeter = RIG_LEVEL_VD_METER;
2022-03-12 19:30:51 +00:00
else levelMeter = RIG_METER_NONE;
return levelMeter;
}