Add M17 namespace in M17 related source files

Now M17 source files reside in the M17 namespace, the OPMODE_ prefix
was added to all opmode enums to avoid a name clash.
pull/68/head
Niccolò Izzo 2021-11-08 13:50:36 +01:00 zatwierdzone przez Silvano Seva
rodzic 876cb87d57
commit 6588a6718e
16 zmienionych plików z 79 dodań i 59 usunięć

Wyświetl plik

@ -28,6 +28,9 @@
#include <cstdint>
#include <array>
namespace M17
{
/**
* Modulator device for M17 protocol.
*/
@ -118,4 +121,6 @@ private:
bool stopTx; ///< Stop transmission request.
};
} /* M17 */
#endif /* M17_MODULATOR_H */

Wyświetl plik

@ -32,6 +32,9 @@
#include "M17Frame.h"
#include "M17Modulator.h"
namespace M17
{
/**
* M17 transmitter.
*/
@ -87,4 +90,6 @@ private:
uint16_t frameNumber; ///< Current frame number.
};
} /* M17 */
#endif /* M17TRANSMITTER_H */

Wyświetl plik

@ -86,7 +86,7 @@ public:
*/
virtual opmode getID()
{
return NONE;
return OPMODE_NONE;
}
/**

Wyświetl plik

@ -78,7 +78,7 @@ public:
*/
virtual opmode getID() override
{
return FM;
return OPMODE_FM;
}
/**

Wyświetl plik

@ -80,7 +80,7 @@ public:
*/
virtual opmode getID() override
{
return M17;
return OPMODE_M17;
}
/**
@ -104,8 +104,8 @@ private:
void sendData(const bool lastFrame = false);
bool enterRx; ///< Flag for RX management.
M17Modulator modulator; ///< M17 modulator.
M17Transmitter m17Tx; ///< M17 transmission manager.
M17::M17Modulator modulator; ///< M17 modulator.
M17::M17Transmitter m17Tx; ///< M17 transmission manager.
};
#endif /* OPMODE_M17_H */

Wyświetl plik

@ -75,10 +75,10 @@ enum bandwidth
*/
enum opmode
{
NONE = 0, /**< No opMode selected */
FM = 1, /**< Analog FM */
DMR = 2, /**< DMR */
M17 = 3 /**< M17 */
OPMODE_NONE = 0, /**< No opMode selected */
OPMODE_FM = 1, /**< Analog FM */
OPMODE_DMR = 2, /**< DMR */
OPMODE_M17 = 3 /**< M17 */
};
/**

Wyświetl plik

@ -31,6 +31,9 @@
#include <stdio.h>
#endif
namespace M17
{
M17Modulator::M17Modulator()
{
@ -98,7 +101,7 @@ void M17Modulator::generateBaseband()
for(size_t i = 0; i < idleBuffer->size(); i++)
{
float elem = static_cast< float >(idleBuffer->at(i));
idleBuffer->at(i) = static_cast< int16_t >(rrc(elem) * 7168.0);
idleBuffer->at(i) = static_cast< int16_t >(M17::rrc(elem) * 7168.0);
}
}
@ -156,3 +159,5 @@ void M17Modulator::emitBaseband()
#else
void M17Modulator::emitBaseband() { }
#endif
} /* M17 */

Wyświetl plik

@ -23,6 +23,9 @@
#include <M17/M17Interleaver.h>
#include <M17/M17Transmitter.h>
namespace M17
{
static constexpr std::array<uint8_t, 2> LSF_SYNC_WORD = {0x55, 0xF7};
static constexpr std::array<uint8_t, 2> DATA_SYNC_WORD = {0xFF, 0x5D};
@ -123,3 +126,5 @@ void M17Transmitter::send(const payload_t& payload, const bool isLast)
modulator.send(DATA_SYNC_WORD, frame, isLast);
}
} /* M17 */

Wyświetl plik

@ -46,7 +46,7 @@ void rtx_init(pthread_mutex_t *m)
/*
* Default initialisation for rtx status
*/
rtxStatus.opMode = NONE;
rtxStatus.opMode = OPMODE_NONE;
rtxStatus.bandwidth = BW_25;
rtxStatus.txDisable = 0;
rtxStatus.opStatus = OFF;
@ -76,7 +76,7 @@ void rtx_init(pthread_mutex_t *m)
void rtx_terminate()
{
rtxStatus.opStatus = OFF;
rtxStatus.opMode = NONE;
rtxStatus.opMode = OPMODE_NONE;
currMode->disable();
radio_terminate();
}
@ -122,7 +122,7 @@ void rtx_taskFunc()
if(reconfigure)
{
// Force TX and RX tone squelch to off for OpModes different from FM.
if(rtxStatus.opMode != FM)
if(rtxStatus.opMode != OPMODE_FM)
{
rtxStatus.txToneEn = 0;
rtxStatus.rxToneEn = 0;
@ -145,9 +145,9 @@ void rtx_taskFunc()
switch(rtxStatus.opMode)
{
case NONE: currMode = &noMode; break;
case FM: currMode = &fmMode; break;
case M17: currMode = &m17Mode; break;
case OPMODE_NONE: currMode = &noMode; break;
case OPMODE_FM: currMode = &fmMode; break;
case OPMODE_M17: currMode = &m17Mode; break;
default: currMode = &noMode;
}

Wyświetl plik

@ -742,7 +742,7 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
switch(ui_state.input_number)
{
case 1:
if(state.channel.mode == FM)
if(state.channel.mode == OPMODE_FM)
{
state.channel.fm.txTone++;
state.channel.fm.txTone %= MAX_TONE_INDEX;
@ -751,7 +751,7 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
}
break;
case 2:
if(state.channel.mode == FM)
if(state.channel.mode == OPMODE_FM)
{
tone_flags++;
tone_flags %= 4;
@ -770,7 +770,7 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
*sync_rtx = true;
break;
case 4:
if(state.channel.mode == FM)
if(state.channel.mode == OPMODE_FM)
{
state.channel.bandwidth++;
state.channel.bandwidth %= 3;
@ -779,12 +779,12 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx)
break;
case 5:
// Cycle through radio modes
if(state.channel.mode == FM)
state.channel.mode = DMR;
else if(state.channel.mode == DMR)
state.channel.mode = M17;
else if(state.channel.mode == M17)
state.channel.mode = FM;
if(state.channel.mode == OPMODE_FM)
state.channel.mode = OPMODE_DMR;
else if(state.channel.mode == OPMODE_DMR)
state.channel.mode = OPMODE_M17;
else if(state.channel.mode == OPMODE_M17)
state.channel.mode = OPMODE_FM;
*sync_rtx = true;
break;
case 7:
@ -1104,7 +1104,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break;
// Digital Mode VFO screen
case MODE_VFO:
if(state.channel.mode == M17)
if(state.channel.mode == OPMODE_M17)
{
// Dst ID input
if(ui_state.edit_mode)
@ -1179,7 +1179,7 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
break;
// Digital Mode MEM screen
case MODE_MEM:
if(state.channel.mode == M17)
if(state.channel.mode == OPMODE_M17)
{
// Dst ID input
if(ui_state.edit_mode)

Wyświetl plik

@ -56,15 +56,15 @@ void _ui_drawMainTop()
// Print radio mode on top bar
switch(last_state.channel.mode)
{
case FM:
case OPMODE_FM:
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "FM");
break;
case DMR:
case OPMODE_DMR:
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "DMR");
break;
case M17:
case OPMODE_M17:
gfx_print(layout.top_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, "M17");
break;
@ -165,7 +165,7 @@ void _ui_drawMainBottom()
uint8_t mic_level = platform_getMicLevel();
switch(last_state.channel.mode)
{
case FM:
case OPMODE_FM:
gfx_drawSmeter(meter_pos,
meter_width,
meter_height,
@ -173,14 +173,14 @@ void _ui_drawMainBottom()
squelch,
yellow_fab413);
break;
case DMR:
case OPMODE_DMR:
gfx_drawSmeterLevel(meter_pos,
meter_width,
meter_height,
rssi,
mic_level);
break;
case M17:
case OPMODE_M17:
gfx_drawSmeterLevel(meter_pos,
meter_width,
meter_height,

Wyświetl plik

@ -679,20 +679,20 @@ bool _ui_drawMacroMenu()
// First row
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413, "1");
if (last_state.channel.mode == FM)
if (last_state.channel.mode == OPMODE_FM)
{
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " %6.1f",
ctcss_tone[last_state.channel.fm.txTone]/10.0f);
}
else if (last_state.channel.mode == M17)
else if (last_state.channel.mode == OPMODE_M17)
{
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " ");
}
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
yellow_fab413, "2 ");
if (last_state.channel.mode == FM)
if (last_state.channel.mode == OPMODE_FM)
{
char encdec_str[9] = { 0 };
bool tone_tx_enable = last_state.channel.fm.txToneEn;
@ -708,7 +708,7 @@ bool _ui_drawMacroMenu()
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
color_white, encdec_str);
}
else if (last_state.channel.mode == M17)
else if (last_state.channel.mode == OPMODE_M17)
{
char encdec_str[9] = " ";
gfx_print(layout.line1_pos, layout.top_font, TEXT_ALIGN_CENTER,
@ -724,7 +724,7 @@ bool _ui_drawMacroMenu()
(layout.line3_pos.y - layout.line1_pos.y)/2};
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_LEFT,
yellow_fab413, "4");
if (last_state.channel.mode == FM)
if (last_state.channel.mode == OPMODE_FM)
{
char bw_str[8] = { 0 };
switch (last_state.channel.bandwidth)
@ -742,7 +742,7 @@ bool _ui_drawMacroMenu()
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_LEFT,
color_white, bw_str);
}
else if (last_state.channel.mode == M17)
else if (last_state.channel.mode == OPMODE_M17)
{
gfx_print(pos_2, layout.top_font, TEXT_ALIGN_LEFT,
color_white, " ");
@ -753,13 +753,13 @@ bool _ui_drawMacroMenu()
char mode_str[9] = "";
switch(last_state.channel.mode)
{
case FM:
case OPMODE_FM:
snprintf(mode_str, 9," FM");
break;
case DMR:
case OPMODE_DMR:
snprintf(mode_str, 9," DMR");
break;
case M17:
case OPMODE_M17:
snprintf(mode_str, 9," M17");
break;
}

Wyświetl plik

@ -56,7 +56,7 @@ void _ui_drawModeDetails(ui_state_t* ui_state)
switch(last_state.channel.mode)
{
case FM:
case OPMODE_FM:
// Get Bandwith string
if(last_state.channel.bandwidth == BW_12_5)
snprintf(bw_str, 8, "12.5");
@ -87,7 +87,7 @@ void _ui_drawModeDetails(ui_state_t* ui_state)
ctcss_tone[last_state.channel.fm.txTone]/10.0f,
encdec_str);
break;
case DMR:
case OPMODE_DMR:
// Print talkgroup on line 2 of 3
gfx_printLine(2, 3, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.mode_font_small,
@ -97,7 +97,7 @@ void _ui_drawModeDetails(ui_state_t* ui_state)
layout.horizontal_pad, layout.mode_font_small,
TEXT_ALIGN_LEFT, color_white, "ID:");
break;
case M17:
case OPMODE_M17:
// Print M17 Source ID on line 2 of 3
gfx_printLine(2, 3, layout.top_h, SCREEN_HEIGHT - layout.bottom_h,
layout.horizontal_pad, layout.mode_font_small,

Wyświetl plik

@ -197,20 +197,20 @@ void radio_setOpmode(const enum opmode mode)
{
switch(mode)
{
case FM:
case OPMODE_FM:
gpio_clearPin(DMR_SW); // Disconnect analog paths for DMR
gpio_setPin(FM_SW); // Enable analog RX stage after superhet
C5000.fmMode(); // HR_C5000 in FM mode
C5000.setInputGain(+3); // Input gain in dB, as per TYT firmware
break;
case DMR:
case OPMODE_DMR:
gpio_clearPin(FM_SW); // Disable analog RX stage after superhet
gpio_setPin(DMR_SW); // Enable analog paths for DMR
//C5000_dmrMode();
break;
case M17:
case OPMODE_M17:
gpio_clearPin(DMR_SW); // Disconnect analog paths for DMR
gpio_setPin(FM_SW); // Enable analog RX stage after superhet
C5000.fmMode(); // HR_C5000 in FM mode
@ -282,7 +282,7 @@ void radio_enableTx()
switch(config->opMode)
{
case FM:
case OPMODE_FM:
{
FmConfig cfg = (config->bandwidth == BW_12_5) ? FmConfig::BW_12p5kHz
: FmConfig::BW_25kHz;
@ -290,7 +290,7 @@ void radio_enableTx()
}
break;
case M17:
case OPMODE_M17:
C5000.startAnalogTx(TxAudioSource::LINE_IN, FmConfig::BW_25kHz);
break;

Wyświetl plik

@ -112,18 +112,18 @@ void radio_setOpmode(const enum opmode mode)
{
switch(mode)
{
case FM:
case OPMODE_FM:
at1846s.setOpMode(AT1846S_OpMode::FM); // AT1846S in FM mode
C6000.fmMode(); // HR_C6000 in FM mode
C6000.setInputGain(-3); // Input gain in dB, as per TYT firmware
break;
case DMR:
case OPMODE_DMR:
at1846s.setOpMode(AT1846S_OpMode::DMR);
// C6000.dmrMode();
break;
case M17:
case OPMODE_M17:
at1846s.setOpMode(AT1846S_OpMode::DMR); // AT1846S in DMR mode, disables RX filter
C6000.fmMode(); // HR_C6000 in FM mode
C6000.setInputGain(+3); // Input gain in dB, found experimentally
@ -191,7 +191,7 @@ void radio_enableTx()
switch(config->opMode)
{
case FM:
case OPMODE_FM:
{
FmConfig cfg = (config->bandwidth == BW_12_5) ? FmConfig::BW_12p5kHz
: FmConfig::BW_25kHz;
@ -199,7 +199,7 @@ void radio_enableTx()
}
break;
case M17:
case OPMODE_M17:
C6000.startAnalogTx(TxAudioSource::LINE_IN, FmConfig::BW_25kHz);
break;

Wyświetl plik

@ -43,10 +43,10 @@ void radio_tuneVcxo(const int16_t vhfOffset, const int16_t uhfOffset)
void radio_setOpmode(const enum opmode mode)
{
std::string mStr(" ");
if(mode == NONE) mStr = "NONE";
if(mode == FM) mStr = "FM";
if(mode == DMR) mStr = "DMR";
if(mode == M17) mStr = "M17";
if(mode == OPMODE_NONE) mStr = "NONE";
if(mode == OPMODE_FM) mStr = "FM";
if(mode == OPMODE_DMR) mStr = "DMR";
if(mode == OPMODE_M17) mStr = "M17";
printf("radio_linux: setting opmode to %s\n", mStr.c_str());
}