Beispiel #1
0
//---------------------------------------------------------------------------
void __fastcall TClockAdjDlg::Do(short ds)
{
	if( m_Clock.Do(ds) ){
		TCanvas *pCanvas = m_pBitmapT->Canvas;
        TRect src;
        src.Left = 0; src.Right = m_pBitmapT->Width;
        src.Top = 0; src.Bottom = m_pBitmapT->Height;
        TRect trc = src;
		src.Bottom--;
        trc.Top++;
		pCanvas->CopyRect(trc, pCanvas, src);

		int sum = 0;
        int max = 0;
        int mp;
		int d;
        for( int i = 0; i < src.Right; i++ ){
			d = m_Clock.GetData(i);
			if( max < d ){
            	max = d;
                mp = i;
            }
            sum += d;

            d = (d - m_StgT.Sum) * 256 / m_StgT.VW;
            if( d >= 256 ) d = 255;
			if( d < 0 ) d = 0;
			pCanvas->Pixels[i][0] = m_tWaterColors[d];
        }
		pCanvas->Pixels[mp][0] = clRed;

        sum /= src.Right;
		m_StgT.Sum = (m_StgT.Sum + sum) / 2;
        m_StgT.Max = (m_StgT.Max + max) / 2;
        m_StgT.VW = m_StgT.Max - m_StgT.Sum;
        if( m_StgT.VW < 128 ) m_StgT.VW = 128;
		m_PointY++;
        m_PointRX++;
        if( m_PointRX >= PBoxT->Height ) m_PointRX = PBoxT->Height;
        PBoxTPaint(NULL);
    }
}
Beispiel #2
0
//---------------------------------------------------------------------------
void __fastcall TRxViewDlg::DrawWater(BOOL fClear)
{
	if( m_pRxSet == NULL ) return;
	if( !m_pBitmapFFT ) return;

    TCanvas *pCanvas = m_pBitmapFFT->Canvas;

    int fo = m_pRxSet->m_pDem->m_CarrierFreq;
	if( !m_MouseDown ){
		int ww = m_WaterWidth / ((m_pRxSet->Is170()||m_pRxSet->IsMFSK()) ? 4 : 8);
		int cfo = fo;
        if( m_pRxSet->IsMFSK() ){
			int off = m_pRxSet->m_pDem->m_MFSK_BW/2;
			if( m_pRxSet->m_Mode == MODE_mfsk_L ){
				cfo -= off;
            }
            else {
				cfo += off;
            }
        }
		if( (cfo < (m_WaterLowFQ+ww)) || (cfo > (m_WaterHighFQ-ww)) ){
			CalcWaterCenter();
	    }
    }

    TRect rc;
   	rc.Left = 0; rc.Top = 0; rc.Right = m_fftXW; rc.Bottom = m_fftYW;
	if( fClear ){
	   	pCanvas->Brush->Color = MainVARI->m_tWaterColset[0].c;
   		pCanvas->Pen->Color = MainVARI->m_tWaterColset[0].c;
   		pCanvas->FillRect(rc);
        InitWater();
    }

	TRect trc = rc;
    rc.Bottom--;
	trc.Top++;
	pCanvas->CopyRect(trc, pCanvas, rc);
	int xo = ((m_WaterLowFQ+(MainVARI->m_FFTSampFreq/FFT_SIZE))*FFT_SIZE/MainVARI->m_FFTSampFreq) + 0.5;
	int xl = 0.5 + (fo - m_pRxSet->m_Speed - m_WaterLowFQ) * m_fftXW / m_WaterWidth;
	int xh = 0.5 + (fo + m_pRxSet->m_Speed - m_WaterLowFQ) * m_fftXW / m_WaterWidth;
   	int x, y, xx;
	int sum = 0;
    int max = 0;
    int wmax = 0;
    double k = 256.0 / m_StgWater.VW;
   	for( x = 0; x < m_fftXW; x++ ){
		xx = xo + (x * m_FFTWindow / m_fftXW);
        y = MainVARI->m_fftout[xx];
        if( max < y ) max = y;
		if( (x >= xl) && (x <= xh) ){
            if( wmax < y ) wmax = y;
        }
		sum += y;

        y = (y - m_StgWater.Sum) * k;
		if( y < 0 ) y = 0;
        if( y >= 256 ) y = 255;

        pCanvas->Pixels[x][0] = MainVARI->m_tWaterColors[y];
   	}
    sum /= m_fftXW;
	if( (wmax-sum) >= 320 ){
       	max = wmax;
    }
	m_StgWater.Sum = (m_StgWater.Sum + sum) / 2;
    m_StgWater.Max = (m_StgWater.Max + max) / 2;
    m_StgWater.VW = m_StgWater.Max - m_StgWater.Sum;
	int low, high;
	if( m_pRxSet->m_pFFT->m_FFTGain ){
       	low = 5120; high = 7000;
    }
    else {
       	low = 6000; high = 6000;
    }
    if( MainVARI->m_TX == txINTERNAL ) high = 100000;
    if( m_StgWater.VW < low ) m_StgWater.VW = low;
    if( m_StgWater.VW > high ) m_StgWater.VW = high;
}
Beispiel #3
0
//---------------------------------------------------------------------
void __fastcall TClockAdjDlg::TimerTimer(TObject *Sender)
{
	if( pBitmap == NULL ) return;
	if( pDem == NULL ) return;
	if( pTick == NULL ) return;

	int *p = pTick->GetData();
	if( p == NULL ) return;

	TCanvas *tp = pBitmap->Canvas;

	int mx = -MAXINT;
	int mi = MAXINT;
	int x, xx, d;
	double k1 = 16384.0/double(m_agcMax - m_agcMin);
	double k2;
	if( SBAGC->Down ){
		k2 = 128.0 / 16384.0;
	}
	else {
		k2 = (128.0 * (s_Gain & 0x00ff)) / (4096 * 16);
	}
	int ax = -1;
	for( xx = 0; xx < pTick->m_Samp; xx++ ){
		int xv = xx + m_rBase;
		x = fmod(xv, m_Samp);
		x = x * pBitmap->Width / m_Samp;
		if( ax != x ){
			ax = x;
			if( !x ){
				if( m_MaxD ){
					tp->Pixels[m_MaxP][0] = clRed;
				}
				m_MaxD = 0;
				m_MaxP = 0;
				TRect rc;
				rc.Left = 0;
				rc.Right = pBitmap->Width - 1;
				rc.Top = 0;
				rc.Bottom = pBitmap->Height - 2;
				TRect src(rc);
				src.Bottom--;
				rc.Top++;
				tp->CopyRect(rc, tp, src);
			}
			d = p[xx];
			if( m_MaxD < d ){
				m_MaxD = d;
				m_MaxP = x;
			}
			if( mx < d ) mx = d;
			if( mi > d ) mi = d;
			if( SBAGC->Down ){
				d -= m_agcMin;
				if( m_agcMax > 0 ) d = double(d) * k1;
			}
			d = double(d) * k2;

			if( d >= 128 ) d = 127;
			if( d <= 0 ) d = 0;
			tp->Pixels[x][0] = TColor(ColorTable[127-d]);
		}
	}
	m_rBase += pTick->m_Samp;
#if 0
	for( x = 0; x < XR; x++){
		xx = (x * pTick->m_Samp)/pBitmap->Width;
		d = p[xx];
		if( mx < d ) mx = d;
		if( mi > d ) mi = d;
		if( SBAGC->Down ){
			d -= m_agcMin;
			if( m_agcMax > 0 ) d = double(d) * k1;
		}
		d = double(d) * k2;

		if( d >= 128 ) d = 127;
		if( d <= 0 ) d = 0;
		tp->Pixels[x][0] = TColor(ColorTable[127-d]);
	}
#endif
	m_agcSumMax -= m_agcMax;
	m_agcSumMax += mx;
	if( m_agcSumMax < (4096*AGCAVG) ) m_agcSumMax = (4096*AGCAVG);
	m_agcMax = m_agcSumMax / AGCAVG;
	m_agcMin = mi;
	if( m_agcMin > 2048 ) m_agcMin = 2048;
	m_PointY++;
	PaintBox->Canvas->Draw(0, 0, (TGraphic*)pBitmap);
	PaintCursor();
}