#define YBO 8 #define YWF 4 #define MAX_FFT1_AVG1 6 #include #include #include "globdef.h" #include "uidef.h" #include "fft1def.h" #include "fft2def.h" #include "fft3def.h" #include "seldef.h" #include "graphcal.h" #include "screendef.h" #include "sigdef.h" #include "thrdef.h" #include "options.h" void update_meter_graph(void) { int i, j, k, m, n, pa, local_mg_pa; int ya, yb; int old_bar_y; // mgw_p points to the screen position corresponding to mg_px // in the mg_ arrays. // Move the data backwards on screen if necessary and adjust // mgw_p accordingly. hide_mouse(mg.xleft,mg.xright,mg.ytop,mg.ybottom); local_mg_pa=mg_pa; if(mg_bar) { old_bar_y=mg_bar_y; mg_bar_y=mg_y0; if(sw_onechan) { while(mg_px != local_mg_pa) { i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[mg_px]); if(i 0) { pa=mg_px; m=(mg_px+mg_mask)&mg_mask; if(sw_onechan) { for(j=mgw_p; j>=mg_first_xpixel; j--) { ya=-1; if( (mg.tracks&1)==0) { i=mg_rms_ypix[pa]; ya=i; yb=i; k=mg_rms_ypix[m]; if(k>ya)ya=k; if(kya)ya=i; if(iya)ya=k; if(k=mg_first_xpixel; j--) { ya=-1; if( (mg.tracks&1)==0) { i=mg_rms_ypix[2*pa]; ya=i; yb=i; k=mg_rms_ypix[2*m]; if(k>ya)ya=k; if(kya)ya=i; if(iya)ya=k; if(kya)ya=i; if(iya)ya=k; if(kya)ya=i; if(iya)ya=k; if(k=mg_last_xpixel-mg_first_xpixel) { n=0.8*(mg_last_xpixel-mg_first_xpixel); } mgw_p=mg_first_xpixel; mg_px=(local_mg_pa-(mg_last_xpixel-n-mg_first_xpixel)+mg_size)&mg_mask; } m=(mg_px+mg_mask)&mg_mask; if(sw_onechan) { i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[m]); if(img_ymin)i=mg_ymin; mg_rms_ypix[m]=i; i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[m]); if(img_ymin)i=mg_ymin; mg_peak_ypix[m]=i; } else { i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[2*m]); if(img_ymin)i=mg_ymin; mg_rms_ypix[2*m]=i; i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[2*m]); if(img_ymin)i=mg_ymin; mg_peak_ypix[2*m]=i; i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[2*m+1]); if(img_ymin)i=mg_ymin; mg_rms_ypix[2*m+1]=i; i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[2*m+1]); if(img_ymin)i=mg_ymin; mg_peak_ypix[2*m+1]=i; } if(sw_onechan) { while(mg_px != local_mg_pa) { if( (mg.tracks&1)==0) { i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[mg_px]); if(img_ymin)i=mg_ymin; mg_rms_ypix[mg_px]=i; k=mg_rms_ypix[m]; lir_line(mgw_p-1,k,mgw_p,i,14); } if( (mg.tracks&2)==0) { i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[mg_px]); if(img_ymin)i=mg_ymin; mg_peak_ypix[mg_px]=i; k=mg_peak_ypix[m]; lir_line(mgw_p-1,k,mgw_p,i,15); } m=mg_px; mg_px=(mg_px+1)&mg_mask; mgw_p++; } } else { while(mg_px != local_mg_pa) { if( (mg.tracks&1)==0) { i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[2*mg_px]); if(img_ymin)i=mg_ymin; mg_rms_ypix[2*mg_px]=i; k=mg_rms_ypix[2*m]; lir_line(mgw_p-1,k,mgw_p,i,11); i=mg_ymin-(mg.yzero+mg.ygain*mg_rms_meter[2*mg_px+1]); if(img_ymin)i=mg_ymin; mg_rms_ypix[2*mg_px+1]=i; k=mg_rms_ypix[2*m+1]; lir_line(mgw_p-1,k,mgw_p,i,12); } if( (mg.tracks&2)==0) { i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[2*mg_px]); if(img_ymin)i=mg_ymin; mg_peak_ypix[2*mg_px]=i; k=mg_peak_ypix[2*m]; lir_line(mgw_p-1,k,mgw_p,i,10); i=mg_ymin-(mg.yzero+mg.ygain*mg_peak_meter[2*mg_px+1]); if(img_ymin)i=mg_ymin; mg_peak_ypix[2*mg_px+1]=i; k=mg_peak_ypix[2*m+1]; lir_line(mgw_p-1,k,mgw_p,i,13); } m=mg_px; mg_px=(mg_px+1)&mg_mask; mgw_p++; } } } } void afc_cursor(void) { int i, j; if(mix1_fq_mid[fftx_nx] < 0)return; j=0.5+hg_first_xpixel+(mix1_fq_mid[fftx_nx]-hg_first_fq)/hg_hz_per_pixel; if(j < hg_first_xpixel)j = hg_first_xpixel; if(j > hg_last_xpixel)j = hg_last_xpixel; if(afc_curx != j || afc_old_cursor_color != afc_cursor_color) { hide_mouse(j,j,hg_cury0,hg_cury2); if(afc_curx > 0) { hide_mouse(afc_curx,afc_curx,hg_cury0,hg_cury2); if(afc_curx == hg_center) { for(i=hg_cury0; i0) { sellim_correction=1/pow(liminfo[ia],2.0); } } } hide_mouse(cg.xleft, cg.xright, cg.ytop, cg.ybottom); for(iy=0; iy= MAX_COLOR_SCALE)i=MAX_COLOR_SCALE-1; lir_fillbox(cg.xleft+1+3*ix,cg.ytop+1+3*iy,3,3,color_scale[i]); } } lir_line(cg_x0,cg.ytop,cg_x0,cg_y1,8); if(kill_all_flag) return; lir_hline(cg.xleft+1,cg_y0,cg.xright-1,8); if(kill_all_flag) return; lir_line(cg_x0,cg_y0,cg_chirpx,cg_chirpy,14); if(kill_all_flag) return; t2=0; t4=0; ia=basblock_pa; for(i=0; i=0) { s_meter_avg_filled_flag=TRUE; s_meter_avgnum++; s_meter_avg+=t4; t4=s_meter_avg/s_meter_avgnum; sprintf(s,"%f",10*log10(t4*baseband_pwrfac)); s[COH_SIDE]=0; lir_pixwrite(cg.xleft+1,cg.ybottom-4*text_height,s); sprintf(s,"%3d ",s_meter_avgnum); s[COH_SIDE]=0; lir_pixwrite(cg.xleft+1,cg.ybottom-5*text_height,s); } else { if(s_meter_avg_filled_flag==TRUE) { lir_fillbox(cg.xleft+1,cg.ybottom-5*text_height,3*cg_size,2*text_height,0); s_meter_avg_filled_flag=FALSE; } } s_meter_fast_attack_slow_decay=10*log10(t2*sellim_correction); sprintf(s,"%.2f ",s_meter_fast_attack_slow_decay); s[COH_SIDE-2]=0; lir_pixwrite(cg.xleft+2*text_width,cg.ybottom-2*text_height,s); t2*=sellim_correction; if(s_meter_peak_hold < t2) { s_meter_peak_hold=t2; lir_pixwrite(cg.xleft+2*text_width,cg.ybottom-3*text_height,s); } } void update_txtest(int xpix,int new_y2 ) { int new_y1, old_y1, old_y2; int ia, ib; char bkg_color; old_y2=fft1_spectrum[xpix]; fft1_old_spectrum[xpix]=old_y2; if(new_y2 < 0)new_y2=0; new_y2=wg.ybottom-1-new_y2; if(new_y2 < wg.yborder+1)new_y2=wg.yborder+1; if(xpix != wg_first_xpixel) { new_y1=fft1_spectrum[xpix-1]; old_y1=fft1_old_spectrum[xpix-1]; } else { new_y1=new_y2; old_y1=new_y2; } if( new_y2 != old_y2 || new_y1 != old_y1) { if(old_y1 > old_y2) { ia=old_y2; ib=old_y1; } else { ib=old_y2; ia=old_y1; } while(ia <= ib) { bkg_color=wg_background[ia]; lir_setpixel(xpix,ia,bkg_color); ia++; } if(new_y1 > new_y2) { ia=new_y2; ib=new_y1; } else { ib=new_y2; ia=new_y1; } while(ia <= ib) { lir_setpixel(xpix,ia,TXTEST_NARROW_COLOR); ia++; } fft1_spectrum[xpix]=new_y2; } } void update_txpeak(int xpix,int new_y2 ) { int new_y1, old_y1, old_y2; int ia, ib; char bkg_color; old_y2=txtest_ypeak[xpix]; txtest_old_ypeak[xpix]=old_y2; if(new_y2 < 0)new_y2=0; new_y2=wg.ybottom-1-new_y2; if(new_y2 < wg.yborder+1)new_y2=wg.yborder+1; if(old_y2 < new_y2)new_y2=old_y2; if(xpix == txtest_first_xpix) { bkg_color=wg_background[old_y2]; if(old_y2 == txtest_ypeak_decay[xpix])bkg_color=TXTEST_PEAK_DECAY_COLOR; lir_setpixel(xpix,old_y2,bkg_color); txtest_ypeak[xpix]=new_y2; lir_setpixel(xpix,new_y2,TXTEST_PEAK_POWER_COLOR); return; } new_y1=txtest_ypeak[xpix-1]; old_y1=txtest_old_ypeak[xpix-1]; if( new_y2 != old_y2 || new_y1 != old_y1 || txtest_peak_redraw ==0) { if(old_y1 > old_y2) { ia=old_y2; ib=old_y1; } else { ib=old_y2; ia=old_y1; } while(ia <= ib) { bkg_color=wg_background[ia]; if(ia == txtest_ypeak_decay[xpix])bkg_color=TXTEST_PEAK_DECAY_COLOR; lir_setpixel(xpix,ia,bkg_color); ia++; } if(new_y1 > new_y2) { ia=new_y2; ib=new_y1; } else { ib=new_y2; ia=new_y1; } while(ia <= ib) { lir_setpixel(xpix,ia,TXTEST_PEAK_POWER_COLOR); ia++; } txtest_ypeak[xpix]=new_y2; } txtest_peak_redraw++; if(txtest_peak_redraw > TXTEST_PEAK_REDRAW_COUNT) { txtest_peak_redraw=0; } } void update_txpeak_decay(int xpix,int new_y2 ) { int new_y1, old_y1, old_y2; int ia, ib; char bkg_color; old_y2=txtest_ypeak_decay[xpix]; txtest_old_ypeak_decay[xpix]=old_y2; if(new_y2 < 0)new_y2=0; new_y2=wg.ybottom-1-new_y2; if(new_y2 < wg.yborder+1)new_y2=wg.yborder+1; if(xpix != txtest_first_xpix) { new_y1=txtest_ypeak_decay[xpix-1]; old_y1=txtest_old_ypeak_decay[xpix-1]; } else { new_y1=new_y2; old_y1=new_y2; } if( new_y2 != old_y2 || new_y1 != old_y1) { if(old_y1 > old_y2) { ia=old_y2; ib=old_y1; } else { ib=old_y2; ia=old_y1; } while(ia <= ib) { bkg_color=wg_background[ia]; if(ia == txtest_ypeak[xpix])bkg_color=TXTEST_PEAK_POWER_COLOR; lir_setpixel(xpix,ia,bkg_color); ia++; } if(new_y1 > new_y2) { ia=new_y2; ib=new_y1; } else { ib=new_y2; ia=new_y1; } while(ia <= ib) { lir_setpixel(xpix,ia,TXTEST_PEAK_DECAY_COLOR); ia++; } txtest_ypeak_decay[xpix]=new_y2; } } void update_txavg(int xpix,int new_y2 ) { int new_y1, old_y1, old_y2; int ia, ib; char bkg_color; old_y2=txtest_yavg[xpix]; txtest_old_yavg[xpix]=old_y2; if(new_y2 < 0)new_y2=0; new_y2=wg.ybottom-1-new_y2; if(new_y2 < wg.yborder+1)new_y2=wg.yborder+1; if(xpix != txtest_first_xpix) { new_y1=txtest_yavg[xpix-1]; old_y1=txtest_old_yavg[xpix-1]; } else { new_y1=new_y2; old_y1=new_y2; } if( new_y2 != old_y2 || new_y1 != old_y1) { if(old_y1 > old_y2) { ia=old_y2; ib=old_y1; } else { ib=old_y2; ia=old_y1; } while(ia <= ib) { bkg_color=wg_background[ia]; if(ia == txtest_ypeak_decay[xpix])bkg_color=TXTEST_PEAK_DECAY_COLOR; if(ia == txtest_ypeak[xpix])bkg_color=TXTEST_PEAK_POWER_COLOR; lir_setpixel(xpix,ia,bkg_color); ia++; } if(new_y1 > new_y2) { ia=new_y2; ib=new_y1; } else { ib=new_y2; ia=new_y1; } while(ia <= ib) { lir_setpixel(xpix,ia,TXTEST_WIDE_AVERAGE_COLOR); ia++; } txtest_yavg[xpix]=new_y2; } } void show_txtest_spectrum(void) { int j, ia; float fxpix; float yval_avg, der_avg, next_y, next_y_avg; float yval_decay, der_decay, next_y_decay; float *z; int i,k,m,mm, new_y, xpix; float yval,der,t1; // Draw the normal fft1 spectrumn with lines. hide_mouse(wg_first_xpixel, wg_last_xpixel, wg.yborder, wg.ybottom); if(wg.xpoints_per_pixel == 1 || wg.pixels_per_xpoint == 1) { i=wg.first_xpoint+wg_first_xpixel-wg_first_xpixel; for(xpix=wg_first_xpixel; xpix < wg_last_xpixel; xpix++) { update_txtest(xpix,(int)(wg_yfac_log*log10(fft1_slowsum[i]*wg_yfac_power))); i++; } } else { if(wg.xpoints_per_pixel == 0) { // There are more pixels than data points so we must interpolate. i=wg.first_xpoint+(wg_first_xpixel-wg_first_xpixel)/wg.pixels_per_xpoint; new_y=wg_yfac_log*log10(fft1_slowsum[i]*wg_yfac_power); yval=new_y; if(i == wg.first_xpoint) { update_txtest(wg_first_xpixel,new_y); } i++; for(xpix=wg_first_xpixel; xpix>1,0,screen_height); mm=twice_rxchan; mask=timf3_mask; pa=timf3_ps; pb=(pa+timf3_osc_interval)&mask; t1=0; m=-1; while(pa != pb) { t2=timf3_float[pa ]*timf3_float[pa ]; for(j=1;j= 0) { pa=(m-ui.rx_rf_channels*screen_width/4)&timf3_mask; pa&=-mm; for(j=0; j=screen_height)k=screen_height-1; timf3_graph[mm*i+j]=k; } pa=(pa+mm)&timf3_mask; } for(j=0; j 0)lir_setpixel(hg_curx,i,hg_background[i]); lir_setpixel(hg_center,i,8); } hg_curx=hg_center; } void fq_scale(int x1, int x2, int y, int j, double fq_valstep, float fq_value, float fq_x, float fq_xstep) { int k; int xa,xb,xc,xd,ya,yb; char s[80]; float t1; xb=-1; ya=y+text_height-1; yb=y+text_height+2; hide_mouse(x1 ,x2, y+1, y+text_height+3); lir_fillbox(x1+2, y+1, x2-x1-4,text_height+2,0); lir_hline(x1,y+text_height+3,x2,7); xd=fq_x; while( xd < x2) { if(fq_value >=100000)fq_value-=100000; sprintf(s,"%.1f",fq_value); k=0; while(s[k]!=0)k++; xc=fq_x-k*text_width/2; xd=xc+k*text_width+2; if(xc > x1+2 && xd < x2) { lir_pixwrite(xc, y+2,s); if(xb > 0) { if(j <= 2 ) { xa=(fq_x+xb)/2; lir_line(xa,ya,xa,yb,14); if(kill_all_flag) return; } else { t1=0.2*(fq_x-xb)+0.5; xa=t1; lir_line(xb+xa,ya,xb+xa,yb,15); if(kill_all_flag) return; lir_line(fq_x-xa,ya,fq_x-xa,yb,15); if(kill_all_flag) return; t1=0.4*(fq_x-xb)+0.5; xa=t1; lir_line(xb+xa,ya,xb+xa,yb,15); if(kill_all_flag) return; lir_line(fq_x-xa,ya,fq_x-xa,yb,15); if(kill_all_flag) return; } } xb=fq_x; lir_line(fq_x,ya,fq_x,yb,15); if(kill_all_flag) return; lir_line(fq_x+1,ya,fq_x+1,yb,15); if(kill_all_flag) return; lir_line(fq_x-1,ya,fq_x-1,yb,15); if(kill_all_flag) return; } fq_x+=fq_xstep; fq_value+=fq_valstep; } } void hires_fq_scale(void) { int j, x1, x2, y; double fq_valstep; float fq_x, fq_xstep; double fq_value, fq_offset; if(mix1_selfreq[0] < 0)return; // Make a frequency scale on top of the high resolution spectrum. // We will show mix1_selfreq[0] in this graph (if it exists) hg_first_fq=mix1_selfreq[0]-hg_hz_per_pixel*hg_size/2; hg_first_point=hg_first_fq/hg_hz_per_pixel; if(hg_first_point<0)hg_first_point=0; hg_last_point=hg_first_point+hg_size; if(hg_last_point > fft2_size)hg_last_point=fft2_size; hg_first_point=hg_last_point-hg_size; if(hg_first_point<0) { lirerr(9998888); return; } hg_recalc_pointer=hg_first_point; hg_first_fq=hg_first_point*hg_hz_per_pixel; hg_first_fq+=1; // Express frequencies in Hz and do not place numbers closer than // 6 ascii characters. fq_valstep=7*hg_hz_per_pixel*text_width; j=adjust_scale(&fq_valstep); // Get the decimal fraction and convert it to Hz fq_offset=(frequency_scale_offset-(int)(frequency_scale_offset))*100000; fq_value=fq_valstep*(int)(0.5+(hg_first_fq+fq_offset)/fq_valstep); fq_x=hg_first_xpixel+(fq_value-hg_first_fq-fq_offset)/hg_hz_per_pixel; fq_xstep=fq_valstep/hg_hz_per_pixel; y=hg.ytop; x1=hgbutt[HG_FFT2_AVGNUM].x2; x2=hg.xright; fq_scale(x1, x2, y, j, fq_valstep, fq_value, fq_x, fq_xstep); hg_cursor(); } void make_hg_yscale(void) { char s[80]; int i,k; int ypixels, scale_y; double db_scalestep; float scale_value, yrange,db_ref; hide_mouse(hg.xleft,hg.xright, hg.ytop+4+text_height, hg_y0); lir_fillbox(hg.xleft+1,hg.ytop+4+text_height,hg.xright-hg.xleft-2, hg_y0-hg.ytop-5-text_height,0); for(i=0; i hg.ytop+db_scalestep/hg_db_per_pixel) { scale_y-=db_scalestep/hg_db_per_pixel; scale_value+=db_scalestep; if(scale_y+2*text_height-1 < hg.ybottom) { i=scale_value; if(i>=-9 && i<100 && scale_value-i < db_scalestep/2) { sprintf(s,"%2d",i); lir_pixwrite(hg.xleft+2,scale_y-text_height/2+2,s); } } if(scale_y+2+text_height < hg.ybottom) { hg_background[scale_y]=HG_DBSCALE_COLOR; lir_hline(hg_first_xpixel,scale_y,hg_last_xpixel,HG_DBSCALE_COLOR); if(kill_all_flag) return; } } hg_yfac_power=(float)(fft1_new_points)/fft1_size; hg_yfac_power=(HG_ZERO*hg_yfac_power)/fft1_size; hg_yfac_power/=(fft2_size*hg.spek_avgnum*pow(10.,0.1*db_ref)); if(fft_cntrl[FFT2_CURMODE].mmx != 0) { hg_yfac_power*=1<<(2*genparm[SECOND_FFT_ATT_N]); } hg_yfac_power*=1<<(2*genparm[FIRST_BCKFFT_ATT_N]); hg_yfac_log=10./hg_db_per_pixel; // Place a colour scale at the right hand side for(i=hg_y0; i>hg_ymax+text_height; i--) { scale_value=db_ref+(hg_y0-i)*hg_db_per_pixel; k=wg_waterf_cfac*((scale_value-wg.waterfall_db_zero)*10); if(k<0)k=0; if(k>=MAX_COLOR_SCALE)k=MAX_COLOR_SCALE-1; lir_hline(hg_last_xpixel+1,i,hg.xright-1,color_scale[k]); if(kill_all_flag) return; } make_wg_yfac(); update_bar(hg_ston1_x1,hg_ston1_x2,hg_ston_y0,hg_ston1_y,-1, HG_STON1_RANGE_COLOR,hg_stonbuf); update_bar(hg_ston2_x1,hg_ston2_x2,hg_ston_y0,hg_ston2_y,-1, HG_STON2_RANGE_COLOR,hg_stonbuf); hg_cursor(); afc_curx=-1; } void show_wtrfbutton(BUTTONS *butt, char *s) { int ix1, ix2, iy1, iy2; ix1=butt[0].x1; ix2=butt[0].x2; iy1=butt[0].y1; iy2=butt[0].y2; if( ix1 < 0 || ix1 >= screen_width || iy1 < 0 || iy2 >= screen_height ) { return; } hide_mouse(ix1-1,ix2+1,iy1-1,iy2+1); lir_fillbox(ix1-1,iy1-1,ix2-ix1+2,iy2-iy1+2,0); if(kill_all_flag) return; lir_hline(ix1,iy1,ix2,button_color); if(kill_all_flag) return; lir_hline(ix1,iy2,ix2,button_color); if(kill_all_flag) return; lir_line(ix1,iy1,ix1,iy2,button_color); if(kill_all_flag) return; lir_line(ix2,iy1,ix2,iy2,button_color); if(kill_all_flag) return; lir_pixwrite(ix1+text_width/2-1,iy1+2,s); } void baseband_fq_scale(void) { int j,y,x1,x2; double fq_valstep; float fq_x, fq_xstep; double fq_value, fq_offset; if(mix1_selfreq[0] < 0)return; bg_carrier_x=-1; // Make a frequency scale on top of the baseband spectrum. // We will show mix1_selfreq[0] in this graph (if it exists) bg_first_frequency=bg_hz_per_pixel*(bg_first_xpoint -fft3_size/2)+ mix1_selfreq[0]; // Express frequencies in Hz and do not place numbers closer than // 7 ascii characters. fq_valstep=7*bg_hz_per_pixel*text_width/bg.pixels_per_point; j=adjust_scale(&fq_valstep); // Get the decimal fraction and convert it to Hz fq_offset=(frequency_scale_offset-(int)(frequency_scale_offset))*100000; fq_value=fq_valstep*(int)(0.5+(bg_first_frequency+fq_offset)/fq_valstep); fq_x=bg_first_xpixel+bg.pixels_per_point* (fq_value-bg_first_frequency-fq_offset)/bg_hz_per_pixel; fq_xstep=bg.pixels_per_point*fq_valstep/bg_hz_per_pixel; y=bg.ytop; x1=bgbutt[BG_PIX_PER_PNT_INC].x2; x2=bgbutt[BG_RESOLUTION_DECREASE].x1; fq_scale(x1, x2, y, j, fq_valstep, fq_value, fq_x, fq_xstep); } void wide_fq_scale(void) { int i, j; int x1, x2, ya; double fq_valstep; float fq_x, fq_xstep; double fq_value, fq_offset; if(lir_status == LIR_POWTIM)return; // Make a frequency scale on top of the waterfall graph. // Express frequencies in Hz and do not place numbers closer than // 7 ascii characters. fq_valstep=7*wg_hz_per_pixel*text_width; j=adjust_scale(&fq_valstep); // The frequency scale is showing the last five digits of // the frequency in Hz (tens of kHz) // Get the frequency for the first bin of fft1 in tens of kHz. if(fg.passband_center != 0) { fq_offset=fg.passband_center*10-timf1_sampling_speed/200000; } else { fq_offset=0; } frequency_scale_offset=fq_offset; // Get the decimal fraction and convert it to Hz fq_offset=(fq_offset-(int)(fq_offset))*100000; i=0.5+(fq_offset+wg_first_frequency)/fq_valstep; fq_value=i*fq_valstep; fq_x=wg_first_xpixel+0.5+ (fq_value-wg_first_frequency-fq_offset)/wg_hz_per_pixel; ya=wg.ytop; x1=wgbutt[WG_FQMIN_INCREASE].x2; x2=wgbutt[WG_FQMAX_DECREASE].x1; fq_xstep=fq_valstep/wg_hz_per_pixel; fq_scale(x1, x2, ya, j, fq_valstep, fq_value, fq_x, fq_xstep); } void show_pol(void) { char s[80]; int angstep,i,x1,x2,y9,y2; float major,minor,z1,z2,a1,a2,c1,c2,c3; float pol_a,sina,pol_b; hide_mouse(pg.xleft,pg.xright,pg.ytop,pg.ybottom); // Make an ellipse to describe circular polarisation i=pgbutt[PG_ANGLE].x2-pgbutt[PG_ANGLE].x1; lir_fillbox(pgbutt[PG_ANGLE].x1,pgbutt[PG_ANGLE].y1,i,i,PG_BACKGROUND_COLOR); major=0.45*i; // The complex amplitudes in our two channels are: // re_x=cos(z)*cos(a) // im_x=sin(z)*cos(a) // re_y=sin(a)*(cos(z)*cos(w)-sin(z)*sin(w)) // im_y=sin(a)*(sin(z)*cos(w)+cos(z)*sin(w)) // z is the time function and a is the angle between main axis of // the incoming wave and the x channel. // If the antenna was twisted by the angle a, the signals would become: // re_a=cos(a)*re_x+sin(a)*re_y // im_a=cos(a)*im_x+sin(a)*im_y // re_b=cos(a)*re_y-sin(a)*re_x // im_b=cos(a)*im_y-sin(a)*im_x // This would maximise the a signal and minimise the b signal. // The power in the b channel is re_*re_b+im_b*im_b, and that is the // function we want the minimum for over one cycle of z. // re_b=cos(a)*sin(a)*(cos(z)*cos(w)-sin(z)*sin(w))-sin(a)*cos(z)*cos(a) // im_b=cos(a)*sin(a)*(sin(z)*cos(w)+cos(z)*sin(w))-sin(a)*sin(z)*cos(a) // re_b=sin(2*a)*(cos(z)*cos(w)-sin(z)*sin(w)-cos(z))/2 // im_b=sin(2*a)*(sin(z)*cos(w)+cos(z)*sin(w)-sin(z))/2 // The power in the b channel at minimum is: // B=sin(2*a)^2*( [cos(z)*cos(w)-sin(z)*sin(w)-cos(z)]^2 + // [sin(z)*cos(w)+cos(z)*sin(w)-sin(z)]^2 )/4 // B=0.5*sin(2*a)^2*(1-cos(2*w) ) // For linear polarisation B=0 and for circular B=0.5 // Illustrate the polarisation with an ellipse. // the axis power lengths are B and (1-B) pol_a=acos(pg.c1); if(pg.c3 == 0) { pg_b=0; } else { pg_b=atan2(pg.c3,pg.c2); } if(fabs(1-pg.c1*pg.c1-pg.c2*pg.c2-pg.c3*pg.c3) >0.001) { lirerr(887999); return; } // Rotate the coordinate system by pg.angle pol_b=pol_a-pg.angle*PI_L/180; if(pol_b > PI_L)pol_b-=PI_L; if(pol_b <0)pol_b+=PI_L; c1=cos(pol_b); c2=sin(pol_b)*cos(pg_b); c3=sin(pol_b)*sin(pg_b); z1=pow(sin(2*pol_a),2.)*0.5*(1-cos(2*pg_b)); minor=major*z1; angstep=2*major/PI_L; angstep*=sqrt(fabs(minor/major)); angstep++; angstep&=0xfffffffe; if(angstep < 2)angstep=2; z2=2*PI_L/angstep; z1=pol_a; angstep++; sina=sin(pol_b); x1=pg_x0+major*c1; y9=pg_y0-major*sina; for(i=0; i 0) { s[0]='R'; } else { s[0]='L'; } s[1]=0; lir_pixwrite(pg_x0-text_width/4,pg_y0-text_height/3,s); i=0.88*pg_b*(pgbutt[PG_CIRC].x2-pgbutt[PG_CIRC].x1)/PI_L; lir_line(pg_x0+i,pgbutt[PG_CIRC].y1,pg_x0+i,pgbutt[PG_CIRC].y2-1,15); }