//background color for signal graphs #define LOG_ZERO -0.8 #define LINFAC 0.000025 #include #include "globdef.h" #include "uidef.h" #include "fft1def.h" #include "screendef.h" #include "thrdef.h" #include "powtdef.h" #define OUTTEST_SIZE 16 #define LAST_LINE 9 float *ch1_y; float *ch2_y; int *ch1_yold; int *ch2_yold; int adtest_yzer; int adtest_ymax; void show_adtest(void) { float ya, yb; int x; if(powtim_displaymode == 0) { if( (ui.rx_input_mode&IQ_DATA) != 0) { for(x=0; x 1)ya= 1; yb*=adtest_scale*LINFAC; if(yb < -1)yb=-1; if(yb > 1)yb= 1; ch1_yold[x]=adtest_yzer-ya*adtest_ymax; ch2_yold[x]=adtest_yzer-yb*adtest_ymax; if(ch1_yold[x] == ch2_yold[x]) { lir_setpixel(x,ch1_yold[x],15); } else { lir_setpixel(x,ch1_yold[x],14); lir_setpixel(x,ch2_yold[x],12); } } } else { for(x=0; x 1)ya= 1; ch1_yold[x]=adtest_yzer-ya*adtest_ymax; lir_setpixel(x,ch1_yold[x],15); } } } else { if( (ui.rx_input_mode&IQ_DATA) != 0) { for(x=1; x 1)ya= 1; yb*=adtest_scale*LINFAC; if(yb < -1)yb=-1; if(yb > 1)yb= 1; ch1_yold[x]=adtest_yzer-ya*adtest_ymax; ch2_yold[x]=adtest_yzer-yb*adtest_ymax; lir_line(x-1,ch1_yold[x-1],x,ch1_yold[x],14); if(kill_all_flag) return; lir_line(x-1,ch2_yold[x-1],x,ch2_yold[x],12); if(kill_all_flag) return; } } else { for(x=0; x 1)ya= 1; ch1_yold[x]=adtest_yzer-ya*adtest_ymax; lir_setpixel(x,ch1_yold[x],15); } } } lir_refresh_screen(); } void rx_adtest(void) { int local_workload_reset; int local_adtest_new; int i, j, x, p0, p_increment, points, px, p_max; int traces; int maxmin_counter; int ad_maxval1,ad_minval1,ad_maxval2,ad_minval2; float ya,yb; int pixmode; char s[80]; clear_screen(); ch1_y=(void*)fftw_tmp; ch2_y=(void*)fft1_tmp; ch1_yold=(void*)fftn_tmp; ch2_yold=(void*)fft1_char; local_workload_reset=workload_reset_flag; local_adtest_new=adtest_new; ad_maxval1=0; ad_minval1=0; ad_maxval2=0; ad_minval2=0; maxmin_counter=0; settextcolor(14); lir_text(10,0,"TEST OF A/D INPUT (soundcard for RX)"); settextcolor(7); adtest_scale=1; powtim_pause_flag=0; adtest_new=0; adtest_channel=0; powtim_displaymode=0; // Use lines 1 to LAST_LINE+2 for text messages. i=(LAST_LINE+2)*text_height; i+=text_height/2; j=screen_height-i; if(j < 4*text_height) { lirerr(1046); goto adtest_exit; } j/=2; adtest_yzer=screen_height-j-1; adtest_ymax=j; for(i=0; i32bit 1=>16bit. //pixmode bit1 0=>normal 1=>IQ data //pixmode bit2 0=>one 1=>two rx channels //pixmode bit3 channel 0 or 1 (if two channels) settextcolor(15); sprintf(s,"pixmode=%d scale=%3.3fdB (%f) ", pixmode,20*log10(adtest_scale),adtest_scale); lir_text(1,LAST_LINE-1,s); while(thread_command_flag[THREAD_RX_ADTEST] == THRFLAG_ACTIVE) { if(local_workload_reset!=workload_reset_flag) { ad_maxval1=0; ad_minval1=0; ad_maxval2=0; ad_minval2=0; maxmin_counter=0; local_workload_reset=workload_reset_flag; } lir_sem_wait(SEM_TIMF1); if(powtim_pause_flag != 0)timf1p_px = timf1p_pa; if(timf1p_px != timf1p_pa) { points=((timf1p_pa-timf1p_px+timf1_bytes)&timf1_bytemask)/ bytes_per_fragment; if(points > screen_width) { points=screen_width; timf1p_px=(timf1p_pa-points*bytes_per_fragment+timf1_bytes)& timf1_bytemask; } p0=(timf1p_px-ad_read_bytes+timf1_bytes)&timf1_bytemask; timf1p_px=timf1p_pa; p_increment=bytes_per_fragment; p_max=timf1_bytes; if( (ui.rx_input_mode&DWORD_INPUT) == 0) { p_increment/=sizeof(short int); p_max/=sizeof(short int); p0/=sizeof(short int); } else { p_increment/=sizeof(int); p_max/=sizeof(int); p0/=sizeof(int); } p_max--; maxmin_counter+=points; if(maxmin_counter > ui.rx_ad_speed/4) { if( (ui.rx_input_mode&DWORD_INPUT) != 0) { ad_maxval1/=2048; ad_minval1/=2048; ad_maxval2/=2048; ad_minval2/=2048; } sprintf(s,"AD max = %06d ",ad_maxval1); lir_text(1,LAST_LINE,s); sprintf(s,"AD min = %06d ",ad_minval1); lir_text(41,LAST_LINE,s); if( (ui.rx_input_mode&IQ_DATA) != 0) { sprintf(s,"%06d ",ad_maxval2); lir_text(22,LAST_LINE,s); sprintf(s,"%06d ",ad_minval2); lir_text(62,LAST_LINE,s); } ad_maxval1=ad_minval1=ad_maxval2=ad_minval2=0; maxmin_counter=0; } sprintf(s,"N=%d inc=%d ",points,p_increment); lir_text(60,LAST_LINE-1,s); i=0; for( px=0; pxtimf1_int[p0])ad_minval1=timf1_int[p0]; ya=(float)(timf1_int[p0])/65536; break; case 1: // One channel 16 bit. Oscilloscope raw data case 5: // Two channels 16 bit. Oscilloscope raw data ch0 if(ad_maxval1timf1_short_int[p0])ad_minval1=timf1_short_int[p0]; ya=timf1_short_int[p0]; break; case 2: // One channel IQ 32 bit. Oscilloscope raw data. case 6: // Two channels IQ 32 bit. Oscilloscope raw data ch0. if(ad_maxval1timf1_int[p0 ])ad_minval1=timf1_int[p0 ]; if(ad_maxval2timf1_int[p0+1])ad_minval2=timf1_int[p0+1]; ya=(float)(timf1_int[p0 ])/65536; yb=(float)(timf1_int[p0+1])/65536; break; case 3: // One channel IQ 16 bit. Oscilloscope raw data. case 7: // Two channels IQ 16 bit. Oscilloscope raw data ch0. if(ad_maxval1timf1_short_int[p0 ])ad_minval1=timf1_short_int[p0 ]; if(ad_maxval2timf1_short_int[p0+1])ad_minval2=timf1_short_int[p0+1]; ya=timf1_short_int[p0 ]; yb=timf1_short_int[p0+1]; break; case 12: // Two channels 32 bit. Oscilloscope raw data ch1 if(ad_maxval1timf1_int[p0+1])ad_minval1=timf1_int[p0+1]; ya=(float)(timf1_int[p0+1])/65536; break; case 13: // Two channels 16 bit. Oscilloscope raw data ch1 if(ad_maxval1timf1_short_int[p0+1])ad_minval1=timf1_short_int[p0+1]; ya=timf1_short_int[p0+1]; break; case 14: // Two channels IQ 32 bit. Oscilloscope raw data ch1 if(ad_maxval1timf1_int[p0+2])ad_minval1=timf1_int[p0+2]; if(ad_maxval2timf1_int[p0+3])ad_minval2=timf1_int[p0+3]; ya=(float)(timf1_int[p0+2])/65536; yb=(float)(timf1_int[p0+3])/65536; break; case 15: // Two channels IQ 16 bit. Oscilloscope raw data ch0. if(ad_maxval1timf1_short_int[p0+2])ad_minval1=timf1_short_int[p0+2]; if(ad_maxval2timf1_short_int[p0+3])ad_minval2=timf1_short_int[p0+3]; ya=timf1_short_int[p0+2]; yb=timf1_short_int[p0+3]; break; default: ya=0; yb=0; break; } ch1_y[x]=ya; ch2_y[x]=yb; p0=(p0+p_increment)&p_max; x++; if(x>=screen_width) { x=0; if(i==0) { show_adtest(); if(kill_all_flag) goto adtest_exit; } i++; } } } if(local_adtest_new != adtest_new) { local_adtest_new=adtest_new; goto restart; } } if(thread_command_flag[THREAD_RX_ADTEST]==THRFLAG_IDLE) { thread_status_flag[THREAD_RX_ADTEST]=THRFLAG_IDLE; while(thread_command_flag[THREAD_RX_ADTEST] == THRFLAG_IDLE) { lir_sem_wait(SEM_TIMF1); timf1p_px=(timf1p_px+timf1_blockbytes)&timf1_bytemask; } if(thread_command_flag[THREAD_RX_ADTEST] == THRFLAG_ACTIVE)goto restart; } adtest_exit:; thread_status_flag[THREAD_RX_ADTEST]=THRFLAG_RETURNED; }