#include #include #include #include "globdef.h" #include "uidef.h" #include "fft1def.h" #include "fft2def.h" #include "fft3def.h" #include "sigdef.h" #include "screendef.h" #include "seldef.h" #include "thrdef.h" #include "txdef.h" #include "vernr.h" #include "hwaredef.h" #include "sdrdef.h" #include "keyboard_def.h" void set_default_cwproc_parms(void) { txcw.rise_time=10000; } void make_txproc_filename(void) { switch (rx_mode) { case MODE_SSB: sprintf(&ssbproc_filename[11],"%02d",tg.spproc_no); txproc_filename=ssbproc_filename; break; case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_QRSS: sprintf(&cwproc_filename[10],"%02d",tg.spproc_no); txproc_filename=cwproc_filename; break; default: txproc_filename=NULL; break; } } void save_tx_parms(char verbose) { int *wgi; char s[80]; char **partext; int i, nn, line; FILE *txpar_file; wgi=NULL; nn=0; partext=NULL; line=4; make_txproc_filename(); txpar_file=fopen(txproc_filename,"w"); if(txpar_file == NULL) { lirerr(381164); return; } switch (rx_mode) { case MODE_SSB: wgi=(void*)(&txssb); txssb.check=SSBPROC_VERNR; partext=ssbprocparm_text; nn=MAX_SSBPROC_PARM; break; case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_QRSS: wgi=(void*)(&txcw); partext=cwprocparm_text; nn=MAX_CWPROC_PARM; break; default: lirerr(918453); break; } for(i=0; i= MAX_DEVNAMES || ui.tx_dadev_no < 0 || ui.tx_dadev_no >= MAX_DEVNAMES || ui.tx_da_channels < 1 || ui.tx_da_channels > 2 || (ui.tx_da_bytes !=2 && ui.tx_da_bytes !=4) || (ui.tx_ad_bytes !=2 && ui.tx_ad_bytes !=4) ) return FALSE; return TRUE; } int read_txpar_file(void) { int i, j, k, nn; int *wgi; int rdbytes; FILE *txpar_file; char *testbuff; char **partext; partext=NULL; wgi=NULL; nn=0; if(check_tx_devices() == FALSE)return FALSE; testbuff = malloc(4096); if(testbuff == NULL) { lirerr(1286); return FALSE; } for(i=0; i<4096; i++)testbuff[i]=0; make_txproc_filename(); if(txproc_filename == NULL)return FALSE; txpar_file=fopen(txproc_filename,"r"); if(txpar_file != NULL) { rdbytes=fread(testbuff,1,4095,txpar_file); fclose(txpar_file); if(rdbytes >= 4095)goto reterr; switch (rx_mode) { case MODE_SSB: wgi=(void*)(&txssb); partext=ssbprocparm_text; nn=MAX_SSBPROC_PARM; break; case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_QRSS: wgi=(void*)(&txcw); partext=cwprocparm_text; nn=MAX_CWPROC_PARM; break; default: lirerr(918453); break; } k=0; for(i=0; i=rdbytes)goto reterr; sscanf(&testbuff[k],"[%d]",&wgi[i]); while(testbuff[k]!='\n' && k=rdbytes)goto reterr; } switch (rx_mode) { case MODE_SSB: if(txssb.check!=SSBPROC_VERNR || txssb.minfreq < SSB_MINFQ_LOW || txssb.minfreq > SSB_MINFQ_HIGH || txssb.maxfreq < SSB_MAXFQ_LOW || txssb.maxfreq > SSB_MAXFQ_HIGH || txssb.slope > SSB_MAXSLOPE || txssb.slope < SSB_MINSLOPE || txssb.bass > SSB_MAXBASS || txssb.bass < SSB_MINBASS || txssb.treble > SSB_MAXTREBLE || txssb.treble < SSB_MINTREBLE || txssb.mic_f_threshold < 0 || txssb.mic_f_threshold > SSB_MAX_MICF || txssb.mic_t_threshold < 0 || txssb.mic_t_threshold > SSB_MAX_MICT || txssb.mic_gain < 0 || txssb.mic_gain > SSB_MAX_MICGAIN || txssb.mic_agc_time < 0 || txssb.mic_agc_time > SSB_MAX_MICAGC_TIME || txssb.mic_out_gain < 0 || txssb.mic_out_gain > SSB_MAX_MICOUT_GAIN || txssb.rf1_gain < SSB_MIN_RF1_GAIN || txssb.rf1_gain > SSB_MAX_RF1_GAIN ) { goto reterr; } break; case MODE_WCW: case MODE_NCW: case MODE_HSMS: case MODE_QRSS: if( txcw.rise_time < 1000*CW_MIN_TIME_CONSTANT || txcw.rise_time > 1000*CW_MAX_TIME_CONSTANT) { goto reterr; } break; } } else { reterr:; free(testbuff); return FALSE; } free(testbuff); return TRUE; } void set_default_spproc_parms(void) { txssb.minfreq=200; txssb.maxfreq=2600; txssb.slope=6; txssb.bass=-8; txssb.treble=0; txssb.mic_f_threshold=15; } void check_tg_borders(void) { current_graph_minh=TG_VSIZ; current_graph_minw=TG_HSIZ; check_graph_placement((void*)(&tg)); set_graph_minwidth((void*)(&tg)); } void new_ssbproc_no(void) { int oldno; oldno=tg.spproc_no; tg.spproc_no=numinput_int_data; if(read_txpar_file() == FALSE) { tg.spproc_no=oldno; read_txpar_file(); } sc[SC_SHOW_TX_FQ]++; make_modepar_file(GRAPHTYPE_TG); } void new_tx_frequency(void) { float t1; tg.freq=numinput_float_data; t1=1000000*tg.freq; if(t1<-46000)t1=-46000; if(t1>46000)t1=46000; tx_output_phstep=2*PI_L*(t1+tx_ssbproc_fqshift)/ui.tx_da_speed; set_hardware_tx_frequency(); sc[SC_SHOW_TX_FQ]++; make_modepar_file(GRAPHTYPE_TG); } void help_on_tx_graph(void) { int msg_no; int event_no; // Set msg invalid in case we are not in any select area. msg_no=-1; for(event_no=0; event_no= mouse_x && tgbutt[event_no].y1 <= mouse_y && tgbutt[event_no].y2 >= mouse_y) { switch (event_no) { case TG_TOP: case TG_BOTTOM: case TG_LEFT: case TG_RIGHT: msg_no=101; break; case TG_INCREASE_FQ: msg_no=104; break; case TG_DECREASE_FQ: msg_no=103; break; case TG_NEW_TX_FREQUENCY: msg_no=105; break; case TG_CHANGE_SSBPROC_NO: msg_no=106; break; } } } help_message(msg_no); } void mouse_continue_tx_graph(void) { int i, j; switch (mouse_active_flag-1) { case TG_TOP: if(tg.ytop!=mouse_y)goto tgm; break; case TG_BOTTOM: if(tg.ybottom!=mouse_y)goto tgm; break; case TG_LEFT: if(tg.xleft!=mouse_x)goto tgm; break; case TG_RIGHT: if(tg.xright==mouse_x)break; tgm:; pause_screen_and_hide_mouse(); dual_graph_borders((void*)&tg,0); if(tg_oldx==-10000) { tg_oldx=mouse_x; tg_oldy=mouse_y; } else { i=mouse_x-tg_oldx; j=mouse_y-tg_oldy; tg_oldx=mouse_x; tg_oldy=mouse_y; tg.ytop+=j; tg.ybottom+=j; tg.xleft+=i; tg.xright+=i; check_tg_borders(); } graph_borders((void*)&tg,15); resume_thread(THREAD_SCREEN); break; default: goto await_release; } if(leftpressed == BUTTON_RELEASED)goto finish; return; await_release:; if(leftpressed != BUTTON_RELEASED) return; if(ui.network_flag != 2) { switch (mouse_active_flag-1) { case TG_INCREASE_FQ: if(hware_flag == 0) { tg.freq+=tg.band_increment; set_hardware_tx_frequency(); } break; case TG_DECREASE_FQ: if(hware_flag == 0) { tg.freq-=tg.band_increment; set_hardware_tx_frequency(); } break; case TG_NEW_TX_FREQUENCY: if(hware_flag == 0) { numinput_xpix=tgbutt[TG_NEW_TX_FREQUENCY].x1+3; numinput_ypix=tgbutt[TG_NEW_TX_FREQUENCY].y2-text_height+1; numinput_chars=FREQ_MHZ_DIGITS+7; erase_numinput_txt(); numinput_flag=FIXED_FLOAT_PARM; par_from_keyboard_routine=new_tx_frequency; } return; break; case TG_CHANGE_SSBPROC_NO: if(hware_flag == 0) { numinput_xpix=tgbutt[TG_CHANGE_SSBPROC_NO].x1+3+5*text_width; numinput_ypix=tgbutt[TG_CHANGE_SSBPROC_NO].y2-text_height+1; numinput_chars=2; erase_numinput_txt(); numinput_flag=FIXED_INT_PARM; par_from_keyboard_routine=new_ssbproc_no; } return; break; default: lirerr(872); break; } } finish:; leftpressed=BUTTON_IDLE; mouse_active_flag=0; make_tx_graph(TRUE); tg_oldx=-10000; } void mouse_on_tx_graph(void) { int event_no; // First find out is we are on a button or border line. for(event_no=0; event_no= mouse_x && tgbutt[event_no].y1 <= mouse_y && tgbutt[event_no].y2 >= mouse_y) { tg_old_y1=tg.ytop; tg_old_y2=tg.ybottom; tg_old_x1=tg.xleft; tg_old_x2=tg.xright; mouse_active_flag=1+event_no; current_mouse_activity=mouse_continue_tx_graph; return; } } // Not button or border. current_mouse_activity=mouse_nothing; mouse_active_flag=1; } void make_tx_graph(int clear_old) { pause_thread(THREAD_SCREEN); if(clear_old) { hide_mouse(tg_old_x1,tg_old_x2,tg_old_y1,tg_old_y2); lir_fillbox(tg_old_x1,tg_old_y1,tg_old_x2-tg_old_x1+1, tg_old_y2-tg_old_y1+1,0); } tg_flag=1; check_tg_borders(); hide_mouse(tg.xleft,tg.xright,tg.ytop,tg.ybottom); scro[tx_graph_scro].no=TRANSMIT_GRAPH; scro[tx_graph_scro].x1=tg.xleft; scro[tx_graph_scro].x2=tg.xright; scro[tx_graph_scro].y1=tg.ytop; scro[tx_graph_scro].y2=tg.ybottom; tgbutt[TG_LEFT].x1=tg.xleft; tgbutt[TG_LEFT].x2=tg.xleft; tgbutt[TG_LEFT].y1=tg.ytop; tgbutt[TG_LEFT].y2=tg.ybottom; tgbutt[TG_RIGHT].x1=tg.xright; tgbutt[TG_RIGHT].x2=tg.xright; tgbutt[TG_RIGHT].y1=tg.ytop; tgbutt[TG_RIGHT].y2=tg.ybottom; tgbutt[TG_TOP].x1=tg.xleft; tgbutt[TG_TOP].x2=tg.xright; tgbutt[TG_TOP].y1=tg.ytop; tgbutt[TG_TOP].y2=tg.ytop; tgbutt[TG_BOTTOM].x1=tg.xleft; tgbutt[TG_BOTTOM].x2=tg.xright; tgbutt[TG_BOTTOM].y1=tg.ybottom; tgbutt[TG_BOTTOM].y2=tg.ybottom; // Draw the border lines graph_borders((void*)&tg,7); tg_oldx=-10000; settextcolor(7); make_button(tg.xleft+text_width,tg.ybottom-text_height/2-2, tgbutt,TG_DECREASE_FQ,25); tgbutt[TG_NEW_TX_FREQUENCY].x1=tgbutt[TG_DECREASE_FQ].x2+0.5*text_width-2; tgbutt[TG_NEW_TX_FREQUENCY].x2=tgbutt[TG_NEW_TX_FREQUENCY].x1+ (FREQ_MHZ_DIGITS+9)*text_width; tgbutt[TG_NEW_TX_FREQUENCY].y1=tg.ybottom-text_height-3; tgbutt[TG_NEW_TX_FREQUENCY].y2=tgbutt[TG_NEW_TX_FREQUENCY].y1+text_height+1; make_button(tgbutt[TG_NEW_TX_FREQUENCY].x2+text_width, tg.ybottom-text_height/2-2, tgbutt,TG_INCREASE_FQ,24); tgbutt[TG_CHANGE_SSBPROC_NO].x1=tg.xleft+2; tgbutt[TG_CHANGE_SSBPROC_NO].x2=tg.xleft+2+7.5*text_width; tgbutt[TG_CHANGE_SSBPROC_NO].y1=tg.ybottom-2.5*(text_height+2); tgbutt[TG_CHANGE_SSBPROC_NO].y2=tgbutt[TG_CHANGE_SSBPROC_NO].y1+text_height+1; resume_thread(THREAD_SCREEN); sc[SC_SHOW_TX_FQ]++; make_modepar_file(GRAPHTYPE_TG); } void init_tx_graph(void) { if (read_modepar_file(GRAPHTYPE_TG) == 0) { tg.xright=screen_width-text_width;; tg.xleft=tg.xright-TG_HSIZ; tg.ybottom=screen_height-4*text_height; tg.ytop=tg.ybottom-TG_VSIZ; } if(tg.spproc_no<0)tg.spproc_no=0; if(tg.spproc_no>MAX_SSBPROC_FILES)tg.spproc_no=MAX_SSBPROC_FILES; tx_graph_scro=no_of_scro; make_tx_graph(FALSE); no_of_scro++; if(no_of_scro >= MAX_SCRO)lirerr(89); set_hardware_tx_frequency(); }