mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 12:23:37 -05:00
Approx code for AutoZero control.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2618 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
f77af814e8
commit
979d5ba604
@ -1,4 +1,4 @@
|
||||
//--------------------------------------------------------------- MainWindow
|
||||
//---------------------------------------------------------------- MainWindow
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "devsetup.h"
|
||||
|
35
plotter.cpp
35
plotter.cpp
@ -99,7 +99,6 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw()
|
||||
|
||||
for(i=0; i<256; i++) { //Zero the histograms
|
||||
m_hist1[i]=0;
|
||||
m_hist2[i]=0;
|
||||
}
|
||||
|
||||
painter2D.setPen(Qt::green);
|
||||
@ -117,14 +116,14 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw()
|
||||
swide[i]=-swide[i];
|
||||
}
|
||||
y = 10.0*log10(swide[i]);
|
||||
int y1 = 5.0*gain*(y + 29 -m_plotZero);
|
||||
int y1 = 5.0*gain*(y + 37 - m_plotZero);
|
||||
if (y1<0) y1=0;
|
||||
if (y1>254) y1=254;
|
||||
if (swide[i]>1.e29) y1=255;
|
||||
m_hist1[y1]++;
|
||||
painter1.setPen(m_ColorTbl[y1]);
|
||||
painter1.drawPoint(i,0);
|
||||
int y2 = gain*(y + 34 -m_plotZero);
|
||||
int y2 = 0.7*gain*(y + 54 - m_plotZero);
|
||||
if (y2<0) y2=0;
|
||||
if (y2>254) y2=254;
|
||||
if (swide[i]>1.e29) y2=255;
|
||||
@ -140,15 +139,6 @@ void CPlotter::draw(float swide[], int i0, float splot[]) //draw()
|
||||
j++;
|
||||
}
|
||||
|
||||
for(i=0; i<NSMAX; i++) {
|
||||
y = 10.0*log10(splot[i]);
|
||||
int y1 = 5.0*gain*(y + 29 -m_plotZero);
|
||||
if (y1<0) y1=0;
|
||||
if (y1>254) y1=254;
|
||||
if (splot[i]>1.e29) y1=255;
|
||||
m_hist2[y1]++;
|
||||
}
|
||||
|
||||
if(swide[0]>1.0e29) m_line=0;
|
||||
m_line++;
|
||||
if(m_line == 13) {
|
||||
@ -413,28 +403,23 @@ void CPlotter::mouseDoubleClickEvent(QMouseEvent *event) //mouse2click
|
||||
|
||||
int CPlotter::autoZero() //autoZero()
|
||||
{
|
||||
int w = m_Size.width();
|
||||
m_z1=0;
|
||||
m_z2=0;
|
||||
int sum1=0;
|
||||
for(int i=0; i<256; i++) {
|
||||
sum1 += m_hist1[i];
|
||||
if(sum1 > m_Size.width()/2) {
|
||||
if(sum1 > int(0.7*w)) {
|
||||
m_z1=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int sum2=0;
|
||||
for(int i=0; i<256; i++) {
|
||||
sum2 += m_hist2[i];
|
||||
if(sum2 > 16384) {
|
||||
m_z2=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double gain = pow(10.0,0.05*(m_plotGain+7));
|
||||
// double dz1 = (m_z1-38)/(5.0*gain);
|
||||
double dz2 = (m_z2-28)/(5.0*gain);
|
||||
if(m_z2 < 255) m_plotZero = int(m_plotZero + dz2 + 0.5);
|
||||
if(m_z1 < 255) {
|
||||
double dz1 = m_z1/(5.0*gain);
|
||||
m_plotZero = int(m_plotZero + dz1 + 0.5);
|
||||
if(m_z1==0) m_plotZero = m_plotZero - 5;
|
||||
}
|
||||
return m_plotZero;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user