void timer_handler ( struct regs* r ) { dump_regs = *r; T.ticks++; if ( T.ticks % 1000 == 0 ) { T.uptime++; clock++; s = clock % 60; m = ( clock / 60 ) % 60; h = ( ( clock / 60 ) / 60 ) % 24; tsp[4] = s / 10; tsp[5] = s % 10; tsp[2] = m / 10; tsp[3] = m % 10; tsp[0] = h / 10; tsp[1] = h % 10; settextcolor ( 6, 0 ); putxy ( 48 + tsp[0], 5, 2 ); putxy ( 48 + tsp[1], 6, 2 ); putxy ( ':', 7, 2 ); putxy ( 48 + tsp[2], 8, 2 ); putxy ( 48 + tsp[3], 9, 2 ); putxy ( ':', 10, 2 ); putxy ( 48 + tsp[4], 11, 2 ); putxy ( 48 + tsp[5], 12, 2 ); settextcolor ( forecolor, 0 ); } }
void task_c() { int count = 0; while (1) { settextcolor(0xe,0x1); //screen_pos_puts("task_c:", 63, 0); screen_pos_putch(star[count % 4], 70, 0); settextcolor(0xf,0x0); count++; c_delay(); } }
//主页菜单 int MainMenu(){ int i = 1, y1 = 250; cleardevice(); IMAGE img; loadimage(&img, "1.jpg", 1000, 600, true); putimage(0, 0, &img); //设置主菜单文字 setlocale(LC_ALL, "chs");//解决中文乱码,在头文件locale.h中 settextstyle(80, 0, "华文彩云",0,0,10000,0,0,0); settextcolor(MAGENTA); setbkmode(TRANSPARENT);/*处理文字后面的黑色,使文字后的背景为图片*/ outtextxy(400, 150, "菜单"); settextcolor(DARKGRAY); settextstyle(40, 0, "幼圆",0,0,1000,0,1,0); int WIDTH = textwidth(_T("1 画图")); outtextxy(WDIS, 250, _T("1 画图")); outtextxy(WDIS, 300, _T("2 分形")); outtextxy(WDIS, 350, _T("3 配置")); outtextxy(WDIS, 400, _T("4 退出")); //获取鼠标信息 FlushMouseMsgBuffer(); while (true){ if (MouseHit()){ //检测 m = GetMouseMsg();//获取鼠标状态 if (m.uMsg == WM_LBUTTONDOWN){ while (m.x >= WDIS&&m.x <= WIDTH+WDIS&&m.y >= 250 && m.y <= 425){ if (m.y >= y1&&m.y <= 25 + y1) return i; else if (y1 >= 400) break; else y1 += 50, i++; } } } //通过按键也可以实现主菜单跳转 if (_kbhit()){ char c = _getch(); if (c >= '1'&&c <= '4') return (c - '0'); } } _getch(); closegraph(); }
void erase_numinput_txt(void) { int i; pause_screen_and_hide_mouse(); settextcolor(15); numinput_txt[0]='_'; for(i=1; i<numinput_chars; i++)numinput_txt[i]=' '; numinput_txt[numinput_chars]=0; lir_pixwrite(numinput_xpix,numinput_ypix,numinput_txt); numinput_curpos=0; settextcolor(7); resume_thread(THREAD_SCREEN); }
void show_offset(void) { char s[80]; settextcolor(15); sprintf(s,"Offset-fine(Hz): %d ",ug.offs_hz[ug_band_no]); s[25]=0; lir_pixwrite(ug.xleft+1.5*text_width,ug.ytop+1+3.5*text_height,s); sprintf(s,"Offset-raw(Khz): %d ",ug.offs_khz[ug_band_no]); s[25]=0; lir_pixwrite(ug.xleft+1.5*text_width,ug.ytop+2.5*text_height,s); settextcolor(7); offset_hz= ug.offs_hz[ug_band_no]; offset_khz=ug.offs_khz[ug_band_no]; }
static void initconio(void) { int x, y; initialized = 1; initscr(); start_color(); nonl(); raw(); noecho(); win = newwin(0,0,0,0); keypad(win,TRUE); meta(win,TRUE); idlok(win,TRUE); scrollok(win,TRUE); getmaxyx(win, height, width); /* Color initialization */ for (x = 0; x < 8; x++) { for (y = 0; y < 8; y++) { init_pair((y<<3)+x, x, y); } } settextcolor(WHITE, BLACK); }
void panic(const char *str) { __asm__ __volatile__("cli"); settextcolor(14,4); printk("Kernel PANIC!! --> %s\n", str); while(1) ; // loop forever }
void assert_failed(const char *file, uint32_t line, const char *desc) { __asm__ __volatile__("cli"); settextcolor(14,4); printk("ASSERTION FAILED!!\n"); printk("File(%s: %d): %s\n", file, line, desc); while(1) ; // loop forever }
void task_c_remove() { asm("cli"); task_destroy(taskc_tid); asm("sti"); memset(StackC, 0, sizeof(StackC)); settextcolor(0xf,0x0); screen_pos_putch(' ', 70, 0); }
void gameloop(void) { char t = ' '; while(1) { delayTime(.01); t = getkeypressedimprove(); if(t == 27) break; if ((t >= '0') && (t <= '7')) { setscreffect(t - '0'); } else if(t == 'q') { attron(A_UNDERLINE); } else if(t == 'w') { attron(A_REVERSE); } else if(t == 'e') { attron(A_BLINK); } else if(t == 'r') { attron(A_BOLD); } else if(t == 't') { attron(A_NORMAL); } if(t == ' ') { setcursorvisible(false); } else { setcursorvisible(true); } if(t == ERR) { settextcolor(white); setgroundcolor(black); printw("@"); } else if(t == '\t') { move(0,0); } else if (t == 'p') { printw("(%d, %d) ", getscreensizebymvcurs().x, getscreensizebymvcurs().y); } else { settextcolor(red); setgroundcolor(green); printw("%c",t); } } }
void display_ball_count(int * ball_count) { setbkcolor(WHITE); clearrectangle(890, 535, 960, 560); //刷新球数区域 settextcolor(BLACK); setbkcolor(WHITE); TCHAR ball_count_display[10]; _stprintf_s(ball_count_display, _T("%d"), *ball_count); //将int型转换为TCHAR outtextxy(890, 530, ball_count_display); return; }
void make_users_control_graph(void) { pause_thread(THREAD_SCREEN); // Set a negative number here. // In case several windows are desired, give them different // negative numbers and use scro[m].no to decide what to do // in your mouse_on_users_graph routine. scro[users_graph_scro].no=USERS_GRAPH_TYPE1; // These are the coordinates of the border lines. scro[users_graph_scro].x1=ug.xleft; scro[users_graph_scro].x2=ug.xright; scro[users_graph_scro].y1=ug.ytop; scro[users_graph_scro].y2=ug.ybottom; // Each border line is treated as a button. // That is for the mouse to get hold of them so the window can be moved. ugbutt[UG_LEFT].x1=ug.xleft; ugbutt[UG_LEFT].x2=ug.xleft; ugbutt[UG_LEFT].y1=ug.ytop; ugbutt[UG_LEFT].y2=ug.ybottom; ugbutt[UG_RIGHT].x1=ug.xright; ugbutt[UG_RIGHT].x2=ug.xright; ugbutt[UG_RIGHT].y1=ug.ytop; ugbutt[UG_RIGHT].y2=ug.ybottom; ugbutt[UG_TOP].x1=ug.xleft; ugbutt[UG_TOP].x2=ug.xright; ugbutt[UG_TOP].y1=ug.ytop; ugbutt[UG_TOP].y2=ug.ytop; ugbutt[UG_BOTTOM].x1=ug.xleft; ugbutt[UG_BOTTOM].x2=ug.xright; ugbutt[UG_BOTTOM].y1=ug.ybottom; ugbutt[UG_BOTTOM].y2=ug.ybottom; // Draw the border lines graph_borders((void*)&ug,7); settextcolor(7); make_button(ug.xleft+text_width,ug.ybottom-3*text_height/2-2, ugbutt,UG_DECREASE_PAR1,25); make_button(ug.xright-text_width,ug.ybottom-3*text_height/2-2, ugbutt,UG_INCREASE_PAR1,24); make_button(ug.xleft+text_width,ug.ybottom-text_height/2-2, ugbutt,UG_DO_WHATEVER,'A'); show_user_parms(); resume_thread(THREAD_SCREEN); }
void kmain( void* mbd, unsigned int magic ) { /* Installations */ gdt_install(); idt_install(); isrs_install(); irq_install(); timer_install(); keyboard_install(); init_video(); __asm__ __volatile__ ("sti"); // Disable interrupts settextcolor(0x0F, 0x00); unsigned char string[] = "Welcome to Gulinux 0.01. For a list of commands, type help.\n"; putsa(string); for(;;); }
void show_user_parms(void) { int i; char s[80]; extern char serport_name[10]; FILE *Fp; // Show the user parameters on screen // and issue hardware commands if required. // Use hware_flag to direct calls to control_hware() when cpu time // is available in case whatever you want to do takes too much time // to be done immediately. // Note that mouse control is done in the narrowband processing thread // and that you can not use lir_sleep to wait for hardware response here. hide_mouse(ug.xleft, ug.xright,ug.ytop,ug.ybottom); sprintf(s,"CALIBRATE"); settextcolor(11); lir_pixwrite(ug.xleft+.5*text_width,ug.ytop+0.35*text_height,s); sprintf(s," CAT FREQUENCY CONTROL FOR TRX: %s ",list[transceiver_number].name); settextcolor(14); lir_pixwrite(ug.xleft+10.5*text_width,ug.ytop+0.35*text_height,s); settextcolor(15); sprintf(s," SERIAL PORT:%s ",serport_name); lir_pixwrite(ug.xleft+.5*text_width,ug.ytop+1.5*text_height,s); settextcolor(7); show_offset(); //DISPLAY MESSAGES IN MESSAGE-AREA OF USERGRAPH // Fill message with blanks up to character MAX_MSGSIZE-2 blankfill_ugmsg(ug_msg0); blankfill_ugmsg(ug_msg1); blankfill_ugmsg(ug_msg2); settextcolor(ug_msg_color); lir_pixwrite(ug.xleft+31*text_width,ug.ytop+1.5*text_height,ug_msg0); lir_pixwrite(ug.xleft+31*text_width,ug.ytop+2.5*text_height,ug_msg1); lir_pixwrite(ug.xleft+31*text_width,ug.ytop+3.5*text_height,ug_msg2); settextcolor(7); //save screenposition and offset-values in usergraph, to usergraph parameter file Fp=fopen(ugfile,"w"); fprintf(Fp,"%d\n%d\n%i\n%i\n",ug.xleft,ug.ytop,serport_number,transceiver_number); for(i=0; i<NO_OF_BANDS; i++)fprintf(Fp,"%d\n",ug.offs_hz[i]); for(i=0; i<NO_OF_BANDS; i++)fprintf(Fp,"%d\n",ug.offs_khz[i]); fclose(Fp); }
void make_users_control_graph(void) { pause_thread(THREAD_SCREEN); // Set a negative number here. // In case several windows are desired, give them different // negative numbers and use scro[m].no to decide what to do // in your mouse_on_users_graph routine. check_ug_borders(); // required for move graph scro[users_graph_scro].no=USERS_GRAPH_TYPE1; // These are the coordinates of the border lines. scro[users_graph_scro].x1=ug.xleft; scro[users_graph_scro].x2=ug.xright; scro[users_graph_scro].y1=ug.ytop; scro[users_graph_scro].y2=ug.ybottom; // Each border line is treated as a button. // That is for the mouse to get hold of them so the window can be moved. ugbutt[UG_LEFT].x1=ug.xleft; ugbutt[UG_LEFT].x2=ug.xleft+2; ugbutt[UG_LEFT].y1=ug.ytop; ugbutt[UG_LEFT].y2=ug.ybottom; ugbutt[UG_RIGHT].x1=ug.xright; ugbutt[UG_RIGHT].x2=ug.xright-2; ugbutt[UG_RIGHT].y1=ug.ytop; ugbutt[UG_RIGHT].y2=ug.ybottom; ugbutt[UG_TOP].x1=ug.xleft; ugbutt[UG_TOP].x2=ug.xright; ugbutt[UG_TOP].y1=ug.ytop; ugbutt[UG_TOP].y2=ug.ytop+2; ugbutt[UG_BOTTOM].x1=ug.xleft; ugbutt[UG_BOTTOM].x2=ug.xright; ugbutt[UG_BOTTOM].y1=ug.ybottom; ugbutt[UG_BOTTOM].y2=ug.ybottom-2; // Draw the border lines graph_borders((void*)&ug,7); ug_oldx=-10000; //from freq_control settextcolor(7); make_button(ug.xleft+27.5*text_width+2,ug.ybottom-1*text_height/2-1, ugbutt,UG_DECREASE_OFFS_HZ,25); make_button(ug.xleft+29*text_width+2,ug.ybottom-1*text_height/2-1, ugbutt,UG_INCREASE_OFFS_HZ,24); make_button(ug.xleft+27.5*text_width+2,ug.ybottom-3*text_height/2-1, ugbutt,UG_DECREASE_OFFS_KHZ,25); make_button(ug.xleft+29*text_width+2,ug.ybottom-3*text_height/2-1, ugbutt,UG_INCREASE_OFFS_KHZ,24); make_button(ug.xleft+27.5*text_width+2,ug.ybottom-5*text_height/2-1, ugbutt,UG_DECREASE_SERPORT_NMBR,25); make_button(ug.xleft+29*text_width+2,ug.ybottom-5*text_height/2-1, ugbutt,UG_INCREASE_SERPORT_NMBR,24); make_button(ug.xleft+57.5*text_width+2,ug.ytop+1.5*text_height/2-1, ugbutt,UG_DECREASE_TRANSCEIVER_NMBR,25); make_button(ug.xleft+59*text_width+2,ug.ytop+1.5*text_height/2-1, ugbutt,UG_INCREASE_TRANSCEIVER_NMBR,24); show_user_parms(); //draw separatorlines in usergraph //vertical lir_line(ug.xleft+30.5*text_width,ug.ytop+1.3*text_height,ug.xleft+30.5*text_width,ug.ybottom,7); lir_line(ug.xleft+10*text_width,ug.ytop+0*text_height,ug.xleft+10*text_width,ug.ytop+1.3*text_height,7); //horizontal lir_line(ug.xleft,ug.ytop+1.3*text_height,ug.xright,ug.ytop+1.3*text_height,7); // resume_thread(THREAD_SCREEN); }
void get_numinput_chars(void) { int i, flag; flag=0; if(lir_inkey == 10 || lir_inkey == 13) { switch (numinput_flag) { case FIXED_INT_PARM: sscanf(numinput_txt,"%d",&numinput_int_data); break; case FIXED_FLOAT_PARM: sscanf(numinput_txt,"%f",&numinput_float_data); break; } numinput_flag|=DATA_READY_PARM; lir_inkey=0; return; } pause_screen_and_hide_mouse(); settextcolor(15); if(lir_inkey == 8 || lir_inkey == 127 || lir_inkey == ARROW_LEFT_KEY) { if(numinput_curpos==0)goto gncx; numinput_curpos--; numinput_txt[numinput_curpos]='_'; numinput_txt[numinput_curpos+1]=' '; lir_pixwrite(numinput_xpix,numinput_ypix,numinput_txt); goto gncx; } if( (lir_inkey >= '0' && lir_inkey <= '9') || numinput_flag == TEXT_PARM) { flag=1; } if(numinput_curpos == 0 && lir_inkey == '-' && numinput_flag != TEXT_PARM) { flag=1; } if( numinput_flag == FIXED_FLOAT_PARM) { if(lir_inkey == '.' || lir_inkey == 'E') { for(i=0; i<numinput_curpos; i++)if(numinput_txt[i] == lir_inkey)goto gncx; flag=1; } if(numinput_curpos > 0 && lir_inkey == '-') { if(numinput_txt[numinput_curpos-1] == 'E') { flag=1; } } } if(flag == 1) { numinput_txt[numinput_curpos]=lir_inkey; numinput_curpos++; } if(numinput_curpos > numinput_chars-1) { numinput_curpos=numinput_chars-1; } else { numinput_txt[numinput_curpos]='_'; } numinput_txt[numinput_curpos+1]=0; lir_pixwrite(numinput_xpix,numinput_ypix,numinput_txt); gncx:; settextcolor(7); resume_thread(THREAD_SCREEN); }
/* Sets our text-mode VGA pointer, then clears the screen for us */ void init_video(void) { textmemptr = (unsigned short *)0xB8000; settextcolor(1,7); cls(); }
void users_extra(void) { // Demo code for users_extra by ON5GN, Pierre // // color codes: // //0 - black. //1 - blue. //2 - green. //3 - cyan. //4 - red. //5 - magenta. //6 - brown. //7 - grey. //8 - dark grey (light black). //9 - light blue. //10 - light green. //11 - light cyan. //12 - light red. //13 - light magenta. //14 - yellow (light brown). //15 - white (light grey). // struct tm *tm_ptr; time_t the_time; char s[80]; char s1[80]; double freq_Mhz; double freq_khz; double freq_hz; double bw; double bw_khz; double bw_hz; // Hide the mouse while we update the screen so it will // not be destroyed by what we write. hide_mouse(0,screen_width,0,text_height); //display mode sprintf (s,"MODE=%s",rxmodes[rx_mode]); settextcolor(12); //red lir_text (1,0,s); //display bandwith bw =0.001*baseband_bw_hz; bw_khz= floor (bw); bw_hz= floor ((bw-(bw_khz))*1000); if (bw_khz) { sprintf (s,"B/W=%.3f Hz ",bw); } else { sprintf (s,"B/W=%3.0f Hz ",bw_hz); } settextcolor(14); //yellow lir_text(1,1,s); //display frequency if(mix1_selfreq[0] < 0) { sprintf (s,"FREQ= off "); } else { freq_Mhz= floor(hwfreq/1000) ; freq_khz= floor (hwfreq-(freq_Mhz*1000)) ; freq_hz= floor (hwfreq*1000-(freq_Mhz*1000000)-(freq_khz*1000)) ; sprintf (s,"FREQ=%3.0f.%03.0f.%03.0f Hz ",freq_Mhz,freq_khz,freq_hz); } settextcolor(10); // light green lir_text(20,1,s); //display UTC date and time in ISO 8601 format (void) time(&the_time); tm_ptr=gmtime(&the_time); sprintf(s,"UTC= %4d:%02d:%02d %02d:%02d:%02d ", tm_ptr->tm_year+1900, tm_ptr->tm_mon+1, tm_ptr->tm_mday, tm_ptr->tm_hour,tm_ptr->tm_min, tm_ptr->tm_sec); settextcolor (9); //9 light blue: lir_text(45,1,s); // display NETWORK mode s1[0]='\0'; if((ui.network_flag & NET_RXOUT_RAW16) != 0) strncat ( s1,"RAW16 ",6); if((ui.network_flag & NET_RXOUT_RAW18) != 0) strncat ( s1,"RAW18 ",6); if((ui.network_flag & NET_RXOUT_RAW24) != 0) strncat ( s1,"RAW24 ",6); if((ui.network_flag & NET_RXOUT_FFT1) != 0) strncat ( s1,"FFT1 ",6); if((ui.network_flag & NET_RXOUT_TIMF2) != 0) strncat ( s1,"TIMF2 ",6); if((ui.network_flag & NET_RXOUT_FFT2) != 0) strncat ( s1,"FFT2 ",6); if (strlen(s1) == 0) strncat ( s1,"off ",6); switch (ui.network_flag & NET_RX_INPUT) { case NET_RXIN_RAW16: strncat (s1," RX->RAW16",9); break; case NET_RXIN_RAW18: strncat(s1," RX->RAW18",9); break; case NET_RXIN_RAW24: strncat (s1," RX->RAW24",9); break; case NET_RXIN_FFT1: strncat (s1," RX->FFT1",9); break; default: strncat (s1," RX->off",9); break; } sprintf (s,"NETWORK= SEND->%s",s1); settextcolor(3); //cyan lir_text(45,0,s); settextcolor(7); }
void cal_iqbalance(void) { char s[80]; int seg,color; int ia,ib; int i,j,k,m,n,mm,errskip; float z[2*MAX_ADCHAN]; float t1,t2,t3; caliq_clear_flag=TRUE; clear_fft1_filtercorr(); bal_updflag=-1; bal_segments=32; bal_screen=screen_width; make_power_of_two(&bal_screen); if(bal_screen > screen_width)bal_screen>>=1; mm=twice_rxchan; restart:; thread_status_flag[THREAD_CAL_IQBALANCE]=THRFLAG_ACTIVE; if(bal_segments > BAL_MAX_SEG)bal_segments = BAL_MAX_SEG; if(bal_segments > fft1_size/4)bal_segments = fft1_size/4; if(bal_segments < 8)bal_segments = 8; cal_initscreen(); lir_text(0,1,"Connect signal generator to antenna input(s)."); sprintf(s,"The frequency range is split in %d segments.",bal_segments); lir_text(0,2,s); lir_text(0,3,"Tune and wait for each segment to become green."); settextcolor(14); lir_text(5,4,"+/- => Change no of segments"); lir_text(7,5, "S => Save current RAM contents to disk"); lir_text(7,6, "C => Clear RAM"); lir_text(7,7, "U => Compute new calibration and store in RAM"); settextcolor(7); if(caliq_clear_flag) { for(i=0; i<=bal_segments; i++)bal_flag[i]=0; } lir_refresh_screen(); while(thread_command_flag[THREAD_CAL_IQBALANCE] == THRFLAG_ACTIVE) { clear_lines(8,9); errskip=0; for(j=0; j<ui.rx_ad_channels; j++) { t1=(100*ad_maxamp[j])/0x8000; if(t1>90) { settextcolor(12); lir_text(10,8,"O V E R L O A D"); errskip=1; } if(t1<5) { settextcolor(12); lir_text(10,8,"Signal too weak"); errskip=1; } sprintf(s,"A/D(%d) %.2f%%",j,t1); lir_text(20*j,9,s); settextcolor(7); } workload_reset_flag++; while(fft1_pb==fft1_px && thread_command_flag[THREAD_CAL_IQBALANCE] == THRFLAG_ACTIVE) { lir_sem_wait(SEM_FFT1); } // Skip old data in case the cpu is a bit slow. while( ((fft1_pb-fft1_px+fft1_mask+1)&fft1_mask) > 2*fft1_block && thread_command_flag[THREAD_CAL_IQBALANCE] == THRFLAG_ACTIVE) { lir_sem_wait(SEM_FFT1); fft1_nx=(fft1_nx+1)&fft1n_mask; fft1_px=fft1_nx*fft1_block; } // Convert complex amplitudes to power and phase, store in cal_buf. // Get the point of maximum. t2=0; k=0; for(i=0; i<fft1_size; i++) { t1=0; for(j=0; j<mm; j+=2) { cal_buf[mm*i+j]=pow(fft1_float[fft1_px+mm*i+j ],2.0)+ pow(fft1_float[fft1_px+mm*i+j+1],2.0); t1+=cal_buf[mm*i+j]; cal_buf[mm*i+j+1]=atan2(fft1_float[fft1_px+mm*i+j+1], fft1_float[fft1_px+mm*i+j ]); } if(t2<t1) { t2=t1; k=i; } } fft1_nx=(fft1_nx+1)&fft1n_mask; fft1_px=(fft1_px+fft1_block)&fft1_mask; if(errskip==1) goto skipdat; if(k<2)k=2; if(k>fft1_size-3)k=fft1_size-3; // Since we use a sin power 4 window a peak will be a few points wide. // collect the average amplitude ratio and average phase sum // Use power as weight factor in averaging. clear_lines(10,10); for(j=0; j<mm; j+=2) { z[2*j]=z[2*j+1]=z[2*j+2]=z[2*j+3]=0; for(i=k-2; i<=k+2; i++) { m=fft1_size-i; t1=cal_buf[mm*m+j+1]+cal_buf[mm*i+j+1]; if(t1<-PI_L)t1+=2*PI_L; if(t1>PI_L)t1-=2*PI_L; t3=cal_buf[mm*i+j]; t2=sqrt(cal_buf[mm*m+j]/cal_buf[mm*i+j]); z[2*j]+=t3; z[2*j+1]+=t3*t2; z[2*j+2]+=t3*t1; z[2*j+3]+=t3*i; } z[2*j+1]/=z[2*j]; z[2*j+2]/=z[2*j]; z[2*j+3]/=z[2*j]; ia=z[2*j+3]+0.5; ib=ia+4; ia=ia-4; if(ia<0)ia=0; if(ib>fft1_size)ib=fft1_size; if(cal_buf[mm*ia+j]+cal_buf[mm*ib+j]>0.02*cal_buf[mm*k+j]) { lir_text(0,10,"Signal too unstable"); goto skipdat; } } clear_lines(10,10); seg=(bal_segments*z[3])/fft1_size+0.5; if(seg > bal_segments)seg=bal_segments; for(j=2; j<mm; j+=2) { k=(bal_segments*z[2*j+3])/fft1_size+0.5; if(seg != k ) { lir_text(0,10,"Channels differ"); goto skipdat; } } if(bal_flag[seg]==BAL_AVGNUM) { sprintf(s,"Segment %d ok",seg); lir_text(0,10,s); goto skipdat_a; } k=(bal_flag[seg]*bal_segments+seg)*ui.rx_rf_channels; for(j=0; j<ui.rx_rf_channels; j++) { bal_pos[k+j]=z[4*j+3]+0.5; bal_phsum[k+j]=z[4*j+2]; bal_amprat[k+j]=z[4*j+1]; } bal_flag[seg]++; skipdat_a:; for(j=0; j<ui.rx_rf_channels; j++) { sprintf(s,"Ch(%d) A=%f ph=%f",j,z[4*j+1],z[4*j+2]); lir_text(30*j,11,s); } skipdat:; m=fft1_size/bal_screen; for(j=0; j<mm; j+=2) { for(i=0; i<bal_screen; i++) { lir_setpixel(i, cal_graph[bal_screen*j+i], 0); k=i*m; if(k>fft1_size-m)k=fft1_size-m; t2=0; for(n=0;n<m;n++)t2+=cal_buf[mm*(k+n-m/2)+j]; t2/=m; t2=0.03*log10(t2)-0.05; if(t2 <-0.28)t2=-0.28; if(t2 > 0.28)t2= 0.28; if(j>0)t2-=.2; cal_graph[bal_screen*j+i]=screen_height*(0.5-t2); seg=(float)(bal_segments*k)/fft1_size+0.5; color=13; if(bal_flag[seg]==0) color=15; if(bal_flag[seg]==BAL_AVGNUM)color=10; lir_setpixel(i, cal_graph[bal_screen*j+i], color); } } lir_refresh_screen(); } if(thread_command_flag[THREAD_CAL_IQBALANCE]==THRFLAG_IDLE) { thread_status_flag[THREAD_CAL_IQBALANCE]=THRFLAG_IDLE; while(thread_command_flag[THREAD_CAL_IQBALANCE]==THRFLAG_IDLE) { lir_sem_wait(SEM_FFT1); fft1_nx=(fft1_nx+1)&fft1n_mask; fft1_px=fft1_nx*fft1_block; } if(thread_command_flag[THREAD_CAL_IQBALANCE]==THRFLAG_ACTIVE)goto restart; } thread_status_flag[THREAD_CAL_IQBALANCE]=THRFLAG_RETURNED; while(thread_command_flag[THREAD_CAL_IQBALANCE] != THRFLAG_NOT_ACTIVE) { lir_sleep(1000); } }
void mouse_continue_users_graph(void) { switch (mouse_active_flag-1) { // Move border lines immediately. // for other functions, wait until button is released. // Look in freq_control.c how to move a fixed size window. case UG_TOP: graph_borders((void*)&ug,0); ug.ytop=mouse_y; graph_borders((void*)&ug,15); break; case UG_BOTTOM: graph_borders((void*)&ug,0); ug.ybottom=mouse_y; graph_borders((void*)&ug,15); break; case UG_LEFT: graph_borders((void*)&ug,0); ug.xleft=mouse_x; graph_borders((void*)&ug,15); break; case UG_RIGHT: graph_borders((void*)&ug,0); ug.xright=mouse_x; graph_borders((void*)&ug,15); break; default: goto await_release; } if(leftpressed == BUTTON_RELEASED)goto finish; return; await_release:; if(leftpressed != BUTTON_RELEASED) return; // Assuming the user wants to control hardware we // allow commands only when data is not over the network. if( (ui.network_flag&NET_RX_INPUT) == 0) { switch (mouse_active_flag-1) { case UG_INCREASE_PAR1: ug.par1++; break; case UG_DECREASE_PAR1: ug.par1--; break; case UG_DO_WHATEVER: // Issue hardware commands or fill the screen // with whatever you like. // Use hware_flag to direct calls to control_hware() when cpu time // is available in case whatever you want to do takes too much time // to be done immediately. ug.par3++; if(ug.par3 < 16) { settextcolor(ug.par3); lir_text(0,screen_last_line-8,"USERS 'DO WHATEVER' PRESSED"); } else { ug.par3=0; lir_text(0,screen_last_line-8," "); } settextcolor(7); break; default: // This should never happen. lirerr(211053); break; } } finish:; hide_mouse(ug_old_x1,ug_old_x2,ug_old_y1,ug_old_y2); leftpressed=BUTTON_IDLE; mouse_active_flag=0; graph_borders((void*)&ug,0); lir_fillbox(ug_old_x1,ug_old_y1,ug_old_x2-ug_old_x1,ug_old_y2-ug_old_y1,0); make_users_control_graph(); }
int init_sdr14(void) { char ss[80]; char sn[80]; char s[80]; int i, line; float t1; FILE *sdr14_file; int *sdr_pi; char *looking; looking="Looking for an SDR on the USB port."; // Set device_no to appropriate values if some dedicated hardware // is selected by the user. // ------------------------------------------------------------ // See if there is an SDR-14 or an SDR-IQ on the system. settextcolor(12); lir_text(10,10,looking); SNDLOG"\n%s",looking); lir_text(10,11,"Reset CPU, USB and SDR hardware if system hangs here."); lir_refresh_screen(); open_sdr14(); settextcolor(7); clear_lines(10,11); lir_refresh_screen(); line=0; if(sdr != -1) { SNDLOG"open_sdr14 sucessful.\n"); lir_text(5,5,"An SDR is detected on the USB port."); lir_text(5,6,"Do you want to use it for RX input (Y/N)?"); qsdr:; await_processed_keyboard(); if(kill_all_flag) goto sdr14_errexit; if(lir_inkey == 'Y') { sdr_target_name(sn); sprintf(s,"Target name: %s",sn); SNDLOG"%s\n",s); lir_text(5,10,s); if( strcmp(sdr14_name_string,sn) == 0) { ui.rx_addev_no=SDR14_DEVICE_CODE; } if( strcmp(sdriq_name_string,sn) == 0) { ui.rx_addev_no=SDRIQ_DEVICE_CODE; } if(ui.rx_addev_no == -1) { lir_text(5,12,"Unknown hardware, can not use."); lir_text(5,13,press_any_key); await_keyboard(); if(kill_all_flag) goto sdr14_errexit; clear_screen(); } else { ui.rx_input_mode=IQ_DATA+DIGITAL_IQ; ui.rx_rf_channels=1; ui.rx_ad_channels=2; ui.rx_admode=0; sdr_target_serial_number(ss); sprintf(s,"Serial no: %s",ss); lir_text(5,11,s); sdr_target_interface_version(ss); i=(short int)ss[0]; sprintf(s,"Interface version: %d.%02d",i/100,i%100); lir_text(5,12,s); sdr_target_boot_version(ss); i=(short int)ss[0]; sprintf(s,"PIC boot version: %d.%02d",i/100,i%100); lir_text(5,13,s); sdr_target_firmware_version(ss); i=(short int)ss[0]; sprintf(s,"PIC firmware version: %d.%02d",i/100,i%100); lir_text(5,14,s); lir_text(10,16,"PRESS ANY KEY"); restart_sdr14par:; await_processed_keyboard(); if(kill_all_flag) goto sdr14_errexit; clear_screen(); sprintf(s,"%s selected for input",sn); lir_text(10,line,s); line++; if(ui.newcomer_mode == 0) { lir_text(5,line,"Set CIC2 decimation (2 - 16)"); sdr14.m_cic2=lir_get_integer(35, line, 2, 2,16); if(kill_all_flag)goto sdr14_errexit; t1=SDR14_SAMPLING_CLOCK/sdr14.m_cic2; sprintf(s,"clk=%.2f MHz",t1); lir_text(39,line,s); line++; lir_text(5,line,"Set CIC5 decimation (2 - 32)"); sdr14.m_cic5=lir_get_integer(35, line, 2, 2,32); if(kill_all_flag)goto sdr14_errexit; t1/=sdr14.m_cic5; sprintf(s,"clk=%.4f MHz",t1); lir_text(39,line,s); line++; lir_text(5,line,"Set RCF decimation (2 - 32)"); sdr14.m_rcf=lir_get_integer(35, line, 2, 2,32); if(kill_all_flag)goto sdr14_errexit; t1/=sdr14.m_rcf; ui.rx_ad_speed=t1*1000000; if(ui.rx_ad_speed > MAX_SDR14_SPEED) { line++; settextcolor(12); lir_text(5,line, "ERROR The sampling speed is far too high for USB 1.0"); line++; lir_text(5,line,press_any_key); settextcolor(7); goto restart_sdr14par; } } else { sdr14.m_cic2=10; t1=SDR14_SAMPLING_CLOCK/sdr14.m_cic2; sdr14.m_cic5=10; t1/=sdr14.m_cic5; line++; for(i=4; i<8; i++) { sprintf(s,"RCF= %d Speed %f kHz",i,1000*t1/i); lir_text(0,line,s); line++; } line++; lir_text(5,line,"Set RCF decimation (4 - 7)"); sdr14.m_rcf=lir_get_integer(35, line, 2, 4,7); if(kill_all_flag)goto sdr14_errexit; t1/=sdr14.m_rcf; ui.rx_ad_speed=t1*1000000; } sprintf(s,"clk=%.2f kHz",t1*1000); lir_text(39,line,s); line++; lir_text(5,line,"Set RCF output shift (0 - 7)"); sdr14.ol_rcf=lir_get_integer(35, line, 2, 0,7); if(kill_all_flag)goto sdr14_errexit; line++; if(ui.newcomer_mode == 0) { lir_text(5,line,"Set sampling clock shift (Hz)"); sdr14.clock_adjust=lir_get_integer(35, line, 6,-10000,10000); if(kill_all_flag)goto sdr14_errexit; line++; } else { sdr14.clock_adjust=0; } adjusted_sdr_clock=SDR14_SAMPLING_CLOCK+0.000001*sdr14.clock_adjust, ui.rx_ad_speed=1000000.*adjusted_sdr_clock/(M_CIC2*M_CIC5*M_RCF); if(ui.rx_addev_no == SDR14_DEVICE_CODE) { lir_text(5,line,"Select direct input (0 - 1)"); sdr14.input=lir_get_integer(35, line, 2, 0, 1); if(kill_all_flag)return 0; } else { if(ui.newcomer_mode == 0) { lir_text(5,line,"Attenuation below which to use 10dB (10 - 25)"); sdr14.input=lir_get_integer(52, line, 2, 10, 25); if(kill_all_flag)return 0; } else { sdr14.input=20; } } sdr14_file=fopen("par_sdr14","w"); if(sdr14_file == NULL) { lirerr(381264); sdr14_errexit:; close_sdr14(); clear_screen(); return 0; } sdr14.check=SDR14PAR_VERNR; sdr_pi=(void*)(&sdr14); for(i=0; i<MAX_SDR14_PARM; i++) { fprintf(sdr14_file,"%s [%d]\n",sdr14_parm_text[i],sdr_pi[i]); } parfile_end(sdr14_file); } }
void cmd_null(uint8_t argc, char * argv[]) { settextcolor(0x40); puts("That command does not exist."); }