⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 freqkey.cpp

📁 串口可交换程序
💻 CPP
字号:
#include <graphics.h>
#include <stdio.h>
#include "keydef.h"
#include "g_func.h"
#include "global.h"
#include "cursor.h"
#include "freqkey.h"
#include "updown.h"
#include "numkeyp.h"

const char *freq[]={"频  率","起始频率","终止频率","中心频率","扫频宽度","点   频","",""};
const char *source_res[]={"源分辨率"," MHz"," KHz"," Hz","","","","返回"};

//extern void rst_num_mem();
void freq_hardkey()
{
	_keyid=FREQ;
/*		  if(_chab[ch_sel].on_off==1&&_chab[!ch_sel].on_off==0)
			ch_sel=!ch_sel;


	  else  if(_chab[ch_sel].on_off==1&&count==0&&_chab[!ch_sel].on_off==1)
	   {		ch_sel=!ch_sel;
			count++;
	   }
*/
	refresh_up();
	if(_lst_frqkey[ch_sel][0]==0)
		_softkeyid=1;
	else
		_softkeyid=_lst_frqkey[ch_sel][0];
	_softkeyid1=0;
	rst_num_mem();
	if(_softkeyid==6||_softkeyid==7){
		digital_en=0;
		curs_flag=0;	//add at 04-05-31,lingyi
	}
	else{
		digital_en=1;
		curs_flag=1;	//add at 04-05-31,lingyi
//		cursor();
	}
	disp_menu12((char **)freq,7);
	border_freq();
	refresh_updown_f();
	vision();
}

void freq_softkey(KEY key)
{
	short i;
	switch (key)
	{
	case F1:
		if(_softkeyid==6&&_softkeyid1!=0)                ///在源分辨率条件下,在其他键条件下f1键的功能
		{
/*			_softkeyid1=61;
			_lst_frqkey[chs][1]=61;
			digital_en=0;
			curs_flag=0;
			_freq[ch_sel].resolve=MHZ;
			refresh_updown_f();*/
		}
		else{
			_softkeyid=1;
			_lst_frqkey[ch_sel][0]=1;
			digital_en=1;
			curs_flag=1;
			rst_num_mem();
			refresh_updown_f();
		}
		border_freq();
		break;
	case F2:
		if(_softkeyid==6&&_softkeyid1!=0)                               ///在源分辨率条件下,在其他键条件下f2键的功能
		{
/*			_softkeyid1=62;
			_lst_frqkey[ch_sel][1]=62;
			digital_en=0;
			curs_flag=0;
			_freq[ch_sel].resolve=KHZ;
			refresh_updown_f();*/
		}
		else{
			_softkeyid=2;
			_lst_frqkey[ch_sel][0]=2;
			digital_en=1;
			curs_flag=1;
			rst_num_mem();
			refresh_updown_f();
		}
		border_freq();
		break;
	case F3:
		if(_softkeyid==6&&_softkeyid1!=0)                           ///在源分辨率条件下,在其他键条件下f3键的功能
		{
/*			_softkeyid1=63;
			_lst_frqkey[ch_sel][1]=63;
			digital_en=0;
			curs_flag=0;
			_freq[ch_sel].resolve=HZ;
			refresh_updown_f();*/
		}
		else{
			_softkeyid=3;
			_lst_frqkey[ch_sel][0]=3;
			digital_en=1;
			curs_flag=1;
			rst_num_mem();
			refresh_updown_f();
		}
		border_freq();
		break;
	case F4:
		if(_softkeyid==6&&_softkeyid1!=0)
		{
//			digital_en=0;
//			curs_flag=0;
		}
		else
		{
			_softkeyid=4;
			_lst_frqkey[ch_sel][0]=4;
			border_freq();
			digital_en=1;
			curs_flag=1;
			rst_num_mem();
			refresh_updown_f();
		}
		break;
	case F5:
		if(_softkeyid==6&&_softkeyid1!=0)
		{
//			digital_en=0;
//			curs_flag=0;
		}
		else
		{
			_softkeyid=5;
			_lst_frqkey[ch_sel][0]=5;
			border_freq();
			_freq[ch_sel].start_freq=_freq[ch_sel].dot_freq;
			_freq[ch_sel].end_freq=_freq[ch_sel].dot_freq;
			update_cs_f();
			_freq[ch_sel].is_dot_freq=TRUE;
			stat_xch=1;
			for(i=0;i<8;i++)
				if(_marker[ch_sel].mark[i].on_off==ON)
					_marker[ch_sel].mark[i].freq=_freq[ch_sel].dot_freq;
			for(i=0;i<3;i++)
				_marker[ch_sel].marker_fun[i].on_off=OFF;
			_marker[ch_sel].max_mkr.on_off=OFF;
			_marker[ch_sel].min_mkr.on_off=OFF;
			_marker[ch_sel].cen_mkr.on_off=OFF;
			digital_en=1;
			curs_flag=1;
			rst_num_mem();
			refresh_updown_f();
		}
		break;
	case F6:
/*		if(_softkeyid==6&&_softkeyid1!=0)
			break;                                         ///f6键的功能
		_softkeyid=6;
		_lst_frqkey[ch_sel][0]=6;
		if(_freq[ch_sel].resolve==MHZ)
			_softkeyid1=61;
		else if(_freq[ch_sel].resolve==KHZ)
			_softkeyid1=62;
		if(_freq[ch_sel].resolve==HZ)
			_softkeyid1=63;

		digital_en=0;
		curs_flag=0;       //add at 04-05-31
		disp_menu12((char**)source_res,7);
		refresh_updown_f();
		border_freq();*/
		break;
	case F7:
		if((_softkeyid==6)||(_softkeyid1==61)||(_softkeyid1==62)||(_softkeyid1==63))     ///f7键的返回功能
		{
/*			_softkeyid1=0;
			rst_num_mem();
			disp_menu12((char **)freq,7);
			_softkeyid=6;
			border_freq();
			refresh_updown_f();
//			_softkeyid=0;
			digital_en=0;
			curs_flag=0;*/
		}
		break;
	default:
		break;
	}
}
///频率的上下刷新程序,written by maoweiying
/*void refresh_updown_f()
{                char msg[20];
				 clear_rect(35,440,499,475);
				 clear_rect(35,440,499,475);


		if((_softkeyid==1)||(_softkeyid==2))
		{
			if(_softkeyid==1)
			{	Outchar12(35,462,"起始频率:",TEXTFURLN);

				khz_ormhz(_freq[ch_sel].start_freq,2);
				init_cur_frq(_freq[ch_sel].start_freq);

			}
			else if(_softkeyid==2)
			{
				Outchar12(35,462,"终止频率:",TEXTFURLN);

				khz_ormhz(_freq[ch_sel].end_freq,2);
				init_cur_frq(_freq[ch_sel].end_freq);
			}
		}



		else if((_softkeyid==3)||(_softkeyid==4))
		{
			if(_softkeyid==3)
			{	Outchar12(35,462,"中心频率:",TEXTFURLN);
				init_cur_frq(_freq[ch_sel].center_freq);
				khz_ormhz(_freq[ch_sel].center_freq,2);
			}
			else if(_softkeyid==4)
			{ 	Outchar12(35,462,"扫频宽度:",TEXTFURLN);
				init_cur_frq(_freq[ch_sel].freq_width);
				khz_ormhz(_freq[ch_sel].freq_width,2);
			}

		}


		else if(_softkeyid==5)
		{
			Outchar12(35,462,"点频输出:",TEXTFURLN);

			init_cur_frq(_freq[ch_sel].dot_freq);
		}
		else if(_softkeyid==6)

		{

			Outchar12(35,462,"起始频率:",TEXTFURLN);


		}refr_ln3();

} */
void refresh_updown_f()
{
	refr_ln3();
	CLR_LN4;
	if(_softkeyid==1)
	{
		Outchar12(35,462,"起始频率:",TEXTFURLN);
		khz_ormhz(_freq[ch_sel].start_freq,2);
		init_cur_frq(_freq[ch_sel].start_freq);
		cursor();     //modify at 04-05-31
	}
	else if(_softkeyid==2)
	{
		Outchar12(35,462,"终止频率:",TEXTFURLN);
		khz_ormhz(_freq[ch_sel].end_freq,2);
		init_cur_frq(_freq[ch_sel].end_freq);
		cursor();     //modify at 04-05-31
	}
	else if(_softkeyid==3)
	{
		Outchar12(35,462,"中心频率:",TEXTFURLN);
		init_cur_frq(_freq[ch_sel].center_freq);
		khz_ormhz(_freq[ch_sel].center_freq,2);
		cursor();     //modify at 04-05-31
	}
	else if(_softkeyid==4)
	{
		Outchar12(35,462,"扫频宽度:",TEXTFURLN);
		init_cur_frq(_freq[ch_sel].freq_width);
		khz_ormhz(_freq[ch_sel].freq_width,2);
		cursor();     //modify at 04-05-31
	}
	else if(_softkeyid==5)
	{
		Outchar12(35,462,"点频输出:",TEXTFURLN);
		init_cur_frq(_freq[ch_sel].dot_freq);
		khz_ormhz(_freq[ch_sel].dot_freq,2);
		cursor();     //modify at 04-05-31
	}
	else if(_softkeyid==6)
	{	Outchar12(35,462,"源分辨率:",TEXTFURLN);

		if(_freq[ch_sel].resolve==MHZ)
			Outchar12(105,462,"MHz",TEXTDIGITAL);
		else if(_freq[ch_sel].resolve==KHZ)
			Outchar12(105,462,"KHz",TEXTDIGITAL);
		else if(_freq[ch_sel].resolve==HZ)
			Outchar12(105,462,"Hz",TEXTDIGITAL);
	}

}
void khz_ormhz(long pf,int p)//单位换算程序  written by maoweiying
{
	char msg[20];
	int x1,x2,y;
	int col;
	double pff;
	if(p==0){
		x1=105;
		x2=230;
		y=445;
		   if(ch_sel==0)
	   col=_system.colora;
	   else if(ch_sel==1)
	   col=_system.colorb;

	}
	if(p==1){
		x1=375;
		x2=500;
		y=445;
			   if(ch_sel==0)
	   col=_system.colora;
	   else if(ch_sel==1)
	   col=_system.colorb;
	   //		col=TEXTTHRLN;
	}
	if(p==2){
		x1=105;
		x2=230;
		y=462;
		col=TEXTDIGITAL;
	}
	if(p==3){
		x1=375;
		x2=500;
		y=462;
		col=TEXTDIGITAL;
	}
	if(pf<1000)
	{
		sprintf(msg,"%ld",pf);
		Outchar12(x1,y,msg,col);
		disable();
		setcolor(col);
		outtextxy(x2,y+2,"Hz");
	}
	else if(/*1000<=pf &&*/ pf<1000000)
	{
		pff=(double)pf/1000;
		sprintf(msg,"%.3f",pff);
		Outchar12(x1,y,msg,col);
		disable();
		setcolor(col);
		outtextxy(x2,y+2,"kHz");
	}
	else if(1000000<=pf&&pf<=50000000)
	{
		pff=(double)pf/1000000;
		sprintf(msg,"%.6f",pff);
		Outchar12(x1,y,msg,col);
		disable();
		setcolor(col);
		outtextxy(x2,y+2,"MHz");
	}

}
void border_freq()
{
	int i;
	erase_smal_border(1);
	for(i=1;i<7;i++)
		erase_smal_border(i);
	if(_softkeyid1!=0)
		draw_smal_border(_softkeyid1-_softkeyid*10);
	else
		draw_smal_border(_softkeyid);
}
/*
void border_freq()
{
  int i;
  static int pp=-1;  static int tt=-1;
  if((_softkeyid==1)||(_softkeyid==2)||(_softkeyid==3)||(_softkeyid==4)||(_softkeyid==5))
  {	erase_smal_border(pp);

	for(i=1;i<6;i++)
	{
		if(_softkeyid==i)
		{


			draw_smal_border(i);
			pp=i;
		 }


	}
  }
  else if(_softkeyid==6)
  {
	erase_smal_border(tt);

	if(_freq[ch_sel].resolve==MHZ)
	{
		
		draw_smal_border(1);
		tt=1;
	}
	else if(_freq[ch_sel].resolve==KHZ)
	{
		
		draw_smal_border(2);
		tt=2;
	}
	else if(_freq[ch_sel].resolve==HZ)
	{
		
		draw_smal_border(3);
		tt=3;
	}
  }
}*/
void refr_ln3()
{   int color,color1;
	clear_rect(35,443,539,461);
	clear_rect(35,443,539,461);
	if(_keyid==FREQ){
		if(_softkeyid==3||_softkeyid==4){
			if(ch_sel==0)
			color=_system.colora;
			else if(ch_sel==1)
			color=_system.colorb;
			Outchar12(35,445,"中心频率:                扫频宽度:",color);
			khz_ormhz(_freq[ch_sel].center_freq,0);
			khz_ormhz(_freq[ch_sel].freq_width,1);
		}
		else if(_softkeyid==5){
			Outchar12(35,445,"点频输出:",ch_sel==0?_system.colora:_system.colorb);
			khz_ormhz(_freq[ch_sel].dot_freq,0);
		}
		else
			goto ffff;
	}
	else{

ffff:   if(ch_sel==0)
			color1=_system.colora;
			else if(ch_sel==1)
			color1=_system.colorb;
		Outchar12(35,445,"起始频率:                终止频率:",color1);
		khz_ormhz(_freq[ch_sel].start_freq,0);
		khz_ormhz(_freq[ch_sel].end_freq,1);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -