1
/***************************************************************************
2
csquelch.cpp - description
5
copyright : (C) 2000 by Volker Schroer
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* based on the work of Moe Wheatly, AE4JY *
16
***************************************************************************/
20
#define Black color[0]
21
#define Grey color[64]
22
#define Cyan color[127]
23
#define Yellow color[192]
25
mySlider::mySlider(QWidget *parent, const char *name = 0) : QSlider(0,100,10,50,QSlider::Vertical,parent,name)
27
setBackgroundColor(Black);
31
SquelchStatus = false;
38
/** Painting Slider Background depending on Threshold and Signal Strength */
39
void mySlider::paintEvent(QPaintEvent *)
46
scale =(100- SquelchLevel)*y/100;
47
slide =(100- Threshold)*y/100;
52
p.fillRect(0,scale,20,y-scale,Yellow);
54
p.fillRect(0,scale,20,y-scale,Grey);
55
paintSlider(&p,colorGroup(),QRect(0,slide,20,5));
61
/** sets a new Threshold for Squelch */
62
void mySlider::newThreshold(int value)
74
CSquelch::CSquelch(QWidget *parent, const char *name ) :QGroupBox(1,Horizontal,"Squelch",parent,name)
77
setFrameStyle(QFrame::WinPanel | QFrame::Raised);
78
setAlignment(AlignCenter);
83
Slider = new mySlider(this);
84
connect(Slider,SIGNAL(valueChanged(int)),Slider,SLOT(newThreshold(int)));
85
OnOff = new QRadioButton("On/Off",this);
86
OnOff->setChecked(true);
87
connect(OnOff,SIGNAL(clicked()),this,SLOT(turnOnOffSquelch()));
97
bool CSquelch::SquelchOn()
102
return Slider->SquelchStatus;
106
void CSquelch::setSquelchLevel(int i)
108
if ( ((Slider->SquelchLevel - i) > 2) || ((i - Slider->SquelchLevel) > 2 ))
110
if ( i > Slider->SquelchLevel ) // Signalquality raises
111
Slider->SquelchStatus = Slider->SquelchStatus || (i > Slider->Threshold);
113
else // Signalquality falls
114
Slider->SquelchStatus = Slider->SquelchStatus && (i > Slider->Threshold);
115
Slider->SquelchLevel=i;
120
void CSquelch::setSquelchStatus(bool squelch)
123
Slider->SquelchStatus = Slider->SquelchStatus || squelch;
126
void CSquelch::turnOnOffSquelch()
128
OnOffStatus = !OnOffStatus;