Easily disable the transmitter with one button press

This commit is contained in:
Jordan Sherer 2020-04-15 15:23:41 -04:00
parent 09ecc6d19e
commit a2d5c8fbcf
6 changed files with 80 additions and 35 deletions

View File

@ -652,6 +652,7 @@ private:
bool heartbeat_ack_snr_; bool heartbeat_ack_snr_;
bool relay_disabled_; bool relay_disabled_;
bool monitor_off_at_startup_; bool monitor_off_at_startup_;
bool transmit_off_at_startup_;
bool monitor_last_used_; bool monitor_last_used_;
bool log_as_DATA_; bool log_as_DATA_;
bool report_in_comments_; bool report_in_comments_;
@ -833,6 +834,7 @@ bool Configuration::heartbeat_ack_snr() const {
} }
bool Configuration::relay_off() const { return m_->relay_disabled_; } bool Configuration::relay_off() const { return m_->relay_disabled_; }
bool Configuration::monitor_off_at_startup () const {return m_->monitor_off_at_startup_;} bool Configuration::monitor_off_at_startup () const {return m_->monitor_off_at_startup_;}
bool Configuration::transmit_off_at_startup () const { return m_->transmit_off_at_startup_; }
bool Configuration::monitor_last_used () const {return m_->rig_is_dummy_ || m_->monitor_last_used_;} bool Configuration::monitor_last_used () const {return m_->rig_is_dummy_ || m_->monitor_last_used_;}
bool Configuration::log_as_DATA () const { return false; } bool Configuration::log_as_DATA () const { return false; }
bool Configuration::report_in_comments () const {return m_->report_in_comments_;} bool Configuration::report_in_comments () const {return m_->report_in_comments_;}
@ -1572,6 +1574,7 @@ void Configuration::impl::initialize_models ()
ui_->heartbeat_ack_snr_check_box->setChecked(heartbeat_ack_snr_); ui_->heartbeat_ack_snr_check_box->setChecked(heartbeat_ack_snr_);
ui_->relay_disabled_check_box->setChecked(relay_disabled_); ui_->relay_disabled_check_box->setChecked(relay_disabled_);
ui_->monitor_off_check_box->setChecked (monitor_off_at_startup_); ui_->monitor_off_check_box->setChecked (monitor_off_at_startup_);
ui_->transmit_off_check_box->setChecked (transmit_off_at_startup_);
ui_->monitor_last_used_check_box->setChecked (monitor_last_used_); ui_->monitor_last_used_check_box->setChecked (monitor_last_used_);
ui_->log_as_RTTY_check_box->setChecked (log_as_DATA_); ui_->log_as_RTTY_check_box->setChecked (log_as_DATA_);
ui_->stations_table_view->setEnabled(ui_->auto_switch_bands_check_box->isChecked()); ui_->stations_table_view->setEnabled(ui_->auto_switch_bands_check_box->isChecked());
@ -1996,6 +1999,7 @@ void Configuration::impl::read_settings ()
heartbeat_ack_snr_ = settings_->value("HeartbeatAckSNR", false).toBool(); heartbeat_ack_snr_ = settings_->value("HeartbeatAckSNR", false).toBool();
relay_disabled_ = settings_->value ("RelayOFF", false).toBool (); relay_disabled_ = settings_->value ("RelayOFF", false).toBool ();
monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool (); monitor_off_at_startup_ = settings_->value ("MonitorOFF", false).toBool ();
transmit_off_at_startup_ = settings_->value ("TransmitOFF", false).toBool ();
monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool (); monitor_last_used_ = settings_->value ("MonitorLastUsed", false).toBool ();
spot_to_reporting_networks_ = settings_->value ("PSKReporter", true).toBool (); spot_to_reporting_networks_ = settings_->value ("PSKReporter", true).toBool ();
spot_to_aprs_ = settings_->value("SpotToAPRS", true).toBool(); spot_to_aprs_ = settings_->value("SpotToAPRS", true).toBool();
@ -2216,6 +2220,7 @@ void Configuration::impl::write_settings ()
settings_->setValue ("HeartbeatAckSNR", heartbeat_ack_snr_); settings_->setValue ("HeartbeatAckSNR", heartbeat_ack_snr_);
settings_->setValue ("RelayOFF", relay_disabled_); settings_->setValue ("RelayOFF", relay_disabled_);
settings_->setValue ("MonitorOFF", monitor_off_at_startup_); settings_->setValue ("MonitorOFF", monitor_off_at_startup_);
settings_->setValue ("TransmitOFF", transmit_off_at_startup_);
settings_->setValue ("MonitorLastUsed", monitor_last_used_); settings_->setValue ("MonitorLastUsed", monitor_last_used_);
settings_->setValue ("PSKReporter", spot_to_reporting_networks_); settings_->setValue ("PSKReporter", spot_to_reporting_networks_);
settings_->setValue ("SpotToAPRS", spot_to_aprs_); settings_->setValue ("SpotToAPRS", spot_to_aprs_);
@ -2857,6 +2862,7 @@ void Configuration::impl::accept ()
heartbeat_ack_snr_ = ui_->heartbeat_ack_snr_check_box->isChecked(); heartbeat_ack_snr_ = ui_->heartbeat_ack_snr_check_box->isChecked();
relay_disabled_ = ui_->relay_disabled_check_box->isChecked(); relay_disabled_ = ui_->relay_disabled_check_box->isChecked();
monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked (); monitor_off_at_startup_ = ui_->monitor_off_check_box->isChecked ();
transmit_off_at_startup_ = ui_->transmit_off_check_box->isChecked ();
monitor_last_used_ = ui_->monitor_last_used_check_box->isChecked (); monitor_last_used_ = ui_->monitor_last_used_check_box->isChecked ();
type_2_msg_gen_ = static_cast<Type2MsgGen> (ui_->type_2_msg_gen_combo_box->currentIndex ()); type_2_msg_gen_ = static_cast<Type2MsgGen> (ui_->type_2_msg_gen_combo_box->currentIndex ());
log_as_DATA_ = ui_->log_as_RTTY_check_box->isChecked (); log_as_DATA_ = ui_->log_as_RTTY_check_box->isChecked ();

View File

@ -148,6 +148,7 @@ public:
bool heartbeat_ack_snr() const; bool heartbeat_ack_snr() const;
bool relay_off() const; bool relay_off() const;
bool monitor_off_at_startup () const; bool monitor_off_at_startup () const;
bool transmit_off_at_startup () const;
bool monitor_last_used () const; bool monitor_last_used () const;
bool log_as_DATA () const; bool log_as_DATA () const;
bool report_in_comments () const; bool report_in_comments () const;

View File

@ -316,7 +316,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>724</width> <width>724</width>
<height>537</height> <height>566</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_26"> <layout class="QVBoxLayout" name="verticalLayout_26">
@ -364,6 +364,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="transmit_off_check_box">
<property name="text">
<string>Transmit (TX) off at startup</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="monitor_last_used_check_box"> <widget class="QCheckBox" name="monitor_last_used_check_box">
<property name="visible"> <property name="visible">

View File

@ -1018,6 +1018,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
} }
// prep // prep
prepareMonitorControls();
prepareHeartbeatMode(canCurrentModeSendHeartbeat() && ui->actionModeJS8HB->isChecked()); prepareHeartbeatMode(canCurrentModeSendHeartbeat() && ui->actionModeJS8HB->isChecked());
auto enterFilter = new EnterKeyPressEater(); auto enterFilter = new EnterKeyPressEater();
@ -3302,6 +3303,10 @@ void MainWindow::on_monitorButton_toggled(bool checked){
void MainWindow::on_monitorTxButton_toggled(bool checked){ void MainWindow::on_monitorTxButton_toggled(bool checked){
resetPushButtonToggleText(ui->monitorTxButton); resetPushButtonToggleText(ui->monitorTxButton);
if(!checked){
on_stopTxButton_clicked();
}
} }
void MainWindow::on_tuneButton_toggled(bool checked){ void MainWindow::on_tuneButton_toggled(bool checked){
@ -5957,6 +5962,7 @@ void MainWindow::startTx()
return; return;
} }
#endif #endif
auto text = ui->extFreeTextMsgEdit->toPlainText(); auto text = ui->extFreeTextMsgEdit->toPlainText();
if(!ensureCreateMessageReady(text)){ if(!ensureCreateMessageReady(text)){
return; return;
@ -5989,18 +5995,21 @@ void MainWindow::startTx()
void MainWindow::startTx2() void MainWindow::startTx2()
{ {
if (!m_modulator->isActive ()) { // TODO - not thread safe // cannot start transmitting while the modulator is active
double fSpread=0.0; if (m_modulator->isActive ()) {
double snr=99.0; return;
QString t=ui->tx5->currentText();
if(t.mid(0,1)=="#") fSpread=t.mid(1,5).toDouble();
m_modulator->setSpread(fSpread); // TODO - not thread safe
t=ui->tx6->text();
if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble();
if(snr>0.0 or snr < -50.0) snr=99.0;
transmit (snr);
ui->signal_meter_widget->setValue(0,0);
} }
double fSpread=0.0;
double snr=99.0;
QString t=ui->tx5->currentText();
if(t.mid(0,1)=="#") fSpread=t.mid(1,5).toDouble();
m_modulator->setSpread(fSpread); // TODO - not thread safe
t=ui->tx6->text();
if(t.mid(0,1)=="#") snr=t.mid(1,5).toDouble();
if(snr>0.0 or snr < -50.0) snr=99.0;
transmit (snr);
ui->signal_meter_widget->setValue(0,0);
} }
void MainWindow::stopTx() void MainWindow::stopTx()
@ -6786,6 +6795,7 @@ void MainWindow::resetMessageUI(){
ui->extFreeTextMsg->clear(); ui->extFreeTextMsg->clear();
ui->extFreeTextMsgEdit->clear(); ui->extFreeTextMsgEdit->clear();
ui->extFreeTextMsgEdit->setReadOnly(false); ui->extFreeTextMsgEdit->setReadOnly(false);
update_dynamic_property (ui->extFreeTextMsgEdit, "transmitting", false); update_dynamic_property (ui->extFreeTextMsgEdit, "transmitting", false);
if(ui->startTxButton->isChecked()){ if(ui->startTxButton->isChecked()){
@ -6831,11 +6841,20 @@ bool MainWindow::ensureNotIdle(){
return false; return false;
} }
bool MainWindow::ensureCanTransmit(){
return ui->monitorTxButton->isChecked();
}
bool MainWindow::ensureCreateMessageReady(const QString &text){ bool MainWindow::ensureCreateMessageReady(const QString &text){
if(text.isEmpty()){ if(text.isEmpty()){
return false; return false;
} }
if(!ensureCanTransmit()){
on_stopTxButton_clicked();
return false;
}
if(!ensureCallsignSet()){ if(!ensureCallsignSet()){
on_stopTxButton_clicked(); on_stopTxButton_clicked();
return false; return false;
@ -6850,7 +6869,9 @@ bool MainWindow::ensureCreateMessageReady(const QString &text){
on_stopTxButton_clicked(); on_stopTxButton_clicked();
ui->monitorButton->setChecked(false); ui->monitorButton->setChecked(false);
ui->monitorTxButton->setChecked(false);
on_monitorButton_clicked(false); on_monitorButton_clicked(false);
on_monitorTxButton_toggled(false);
foreach(auto obj, this->children()){ foreach(auto obj, this->children()){
if(obj->isWidgetType()){ if(obj->isWidgetType()){
@ -7312,16 +7333,6 @@ QString MainWindow::calculateDistance(QString const& value, int *pDistance, int
void MainWindow::on_startTxButton_toggled(bool checked) void MainWindow::on_startTxButton_toggled(bool checked)
{ {
if(checked){ if(checked){
// auto text = ui->extFreeTextMsgEdit->toPlainText();
// if(ensureCreateMessageReady(text)){
//
// auto txText = createMessage(text);
// if(txText != text){
// ui->extFreeTextMsgEdit->setPlainText(txText);
// }
//
// startTx();
// }
startTx(); startTx();
} else { } else {
resetMessage(); resetMessage();
@ -7661,6 +7672,11 @@ bool MainWindow::canCurrentModeSendHeartbeat(){
return false; return false;
} }
void MainWindow::prepareMonitorControls(){
// on_monitorButton_toggled(!m_config.monitor_off_at_startup());
ui->monitorTxButton->setChecked(!m_config.transmit_off_at_startup());
}
void MainWindow::prepareHeartbeatMode(bool enabled){ void MainWindow::prepareHeartbeatMode(bool enabled){
// heartbeat is only available in a supported HB mode // heartbeat is only available in a supported HB mode
ui->hbMacroButton->setVisible(enabled); ui->hbMacroButton->setVisible(enabled);
@ -9448,11 +9464,6 @@ void MainWindow::resetPushButtonToggleText(QPushButton *btn){
#endif #endif
} }
void MainWindow::on_monitorTxButton_clicked(){
ui->monitorTxButton->setChecked(false);
on_stopTxButton_clicked();
}
void MainWindow::on_stopTxButton_clicked() //Stop Tx void MainWindow::on_stopTxButton_clicked() //Stop Tx
{ {
if (m_tune) stop_tuning (); if (m_tune) stop_tuning ();
@ -9646,6 +9657,7 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const&
{ {
// initializing // initializing
on_monitorButton_clicked (!m_config.monitor_off_at_startup ()); on_monitorButton_clicked (!m_config.monitor_off_at_startup ());
on_monitorTxButton_toggled (!m_config.transmit_off_at_startup ());
} }
if (s.frequency () != old_state.frequency () || s.split () != m_splitMode) if (s.frequency () != old_state.frequency () || s.split () != m_splitMode)
@ -9853,8 +9865,6 @@ void MainWindow::aprsSetLocal ()
void MainWindow::transmitDisplay (bool transmitting) void MainWindow::transmitDisplay (bool transmitting)
{ {
ui->monitorTxButton->setChecked(transmitting);
if (transmitting == m_transmitting) { if (transmitting == m_transmitting) {
if (transmitting) { if (transmitting) {
ui->signal_meter_widget->setValue(0,0); ui->signal_meter_widget->setValue(0,0);
@ -10061,6 +10071,7 @@ int MainWindow::rxSnrThreshold(int submode){
void MainWindow::displayTransmit(){ void MainWindow::displayTransmit(){
// Transmit Activity // Transmit Activity
update_dynamic_property (ui->startTxButton, "transmitting", m_transmitting); update_dynamic_property (ui->startTxButton, "transmitting", m_transmitting);
update_dynamic_property (ui->monitorTxButton, "transmitting", m_transmitting);
} }
void MainWindow::updateModeButtonText(){ void MainWindow::updateModeButtonText(){
@ -10147,10 +10158,11 @@ void MainWindow::updateRepeatButtonDisplay(){
} }
void MainWindow::updateTextDisplay(){ void MainWindow::updateTextDisplay(){
bool canTransmit = ensureCanTransmit();
bool isTransmitting = isMessageQueuedForTransmit(); bool isTransmitting = isMessageQueuedForTransmit();
bool emptyText = ui->extFreeTextMsgEdit->toPlainText().isEmpty(); bool emptyText = ui->extFreeTextMsgEdit->toPlainText().isEmpty();
ui->startTxButton->setDisabled(isTransmitting || emptyText); ui->startTxButton->setDisabled(!canTransmit || isTransmitting || emptyText);
if(m_txTextDirty){ if(m_txTextDirty){
// debounce frame and word count // debounce frame and word count
@ -10262,7 +10274,12 @@ void MainWindow::updateTextStatsDisplay(QString text, int count){
} }
void MainWindow::updateTxButtonDisplay(){ void MainWindow::updateTxButtonDisplay(){
// update transmit button // can we transmit at all?
bool canTransmit = ensureCanTransmit();
qDebug() << "can transmit?" << canTransmit << m_tune << isMessageQueuedForTransmit();
// if we're tuning or have a message queued
if(m_tune || isMessageQueuedForTransmit()){ if(m_tune || isMessageQueuedForTransmit()){
int count = m_txFrameCount; int count = m_txFrameCount;
@ -10307,8 +10324,7 @@ void MainWindow::updateTxButtonDisplay(){
buttonText = "Send"; buttonText = "Send";
} }
ui->startTxButton->setText(buttonText); ui->startTxButton->setText(buttonText);
ui->startTxButton->setEnabled(canTransmit && m_txFrameCountEstimate > 0);
ui->startTxButton->setEnabled(m_txFrameCountEstimate > 0);
ui->startTxButton->setFlat(false); ui->startTxButton->setFlat(false);
} }
} }

View File

@ -162,6 +162,7 @@ public slots:
bool ensureCallsignSet(bool alert=true); bool ensureCallsignSet(bool alert=true);
bool ensureKeyNotStuck(QString const& text); bool ensureKeyNotStuck(QString const& text);
bool ensureNotIdle(); bool ensureNotIdle();
bool ensureCanTransmit();
bool ensureCreateMessageReady(const QString &text); bool ensureCreateMessageReady(const QString &text);
QString createMessage(QString const& text, bool *pDisableTypeahead); QString createMessage(QString const& text, bool *pDisableTypeahead);
QString appendMessage(QString const& text, bool isData, bool *pDisableTypeahead); QString appendMessage(QString const& text, bool isData, bool *pDisableTypeahead);
@ -216,7 +217,6 @@ private slots:
void on_autoButton_clicked (bool); void on_autoButton_clicked (bool);
void on_labDialFreq_clicked(); void on_labDialFreq_clicked();
void resetPushButtonToggleText(QPushButton *btn); void resetPushButtonToggleText(QPushButton *btn);
void on_monitorTxButton_clicked();
void on_stopTxButton_clicked(); void on_stopTxButton_clicked();
void on_dialFreqUpButton_clicked(); void on_dialFreqUpButton_clicked();
void on_dialFreqDownButton_clicked(); void on_dialFreqDownButton_clicked();
@ -288,6 +288,7 @@ private slots:
void on_actionModeMultiDecoder_toggled(bool checked); void on_actionModeMultiDecoder_toggled(bool checked);
void on_actionModeAutoreply_toggled(bool checked); void on_actionModeAutoreply_toggled(bool checked);
bool canCurrentModeSendHeartbeat(); bool canCurrentModeSendHeartbeat();
void prepareMonitorControls();
void prepareHeartbeatMode(bool enabled); void prepareHeartbeatMode(bool enabled);
void on_actionJS8_triggered(); void on_actionJS8_triggered();
void on_TxFreqSpinBox_valueChanged(int arg1); void on_TxFreqSpinBox_valueChanged(int arg1);

View File

@ -672,12 +672,16 @@ QPushButton:checked {
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<pointsize>9</pointsize> <weight>50</weight>
<bold>false</bold>
</font> </font>
</property> </property>
<property name="visible"> <property name="visible">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip">
<string>Enable or disable the transmitter</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QPushButton { <string notr="true">QPushButton {
background-color:lightgray; background-color:lightgray;
@ -688,6 +692,10 @@ QPushButton:checked {
} }
QPushButton:checked { QPushButton:checked {
background-color:#22FF22;
}
QPushButton[transmitting=&quot;true&quot;] {
background-color:#FF2222; background-color:#FF2222;
}</string> }</string>
</property> </property>
@ -697,6 +705,9 @@ QPushButton:checked {
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat"> <property name="flat">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -752,6 +763,9 @@ QPushButton:checked {
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>false</bool>
</property>
<property name="flat"> <property name="flat">
<bool>false</bool> <bool>false</bool>
</property> </property>