第十三届蓝桥杯国赛

#include <STC15F2K60S2.H>
#include "mywave.h"
#include "display.h"
#include "pcf8591.h"
#include "eeprom.h"
#include "intrins.h"
void DisplaySMG_info();
void control_led_jdq();
sbit s4 = P3^3;
sbit s5 = P3^2;
sbit s6 = P3^1;
sbit s7 = P3^0;
code unsigned char Seg_dot[] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
code unsigned char Seg_Table[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
unsigned char count_200ms = 0;
unsigned char count_1s = 0;
unsigned int distance = 0;//距离值
unsigned int count_f = 0;//频率值
unsigned int adc_smg = 0;
float adc_volt = 0;
unsigned char humidity = 0;//湿度
unsigned char count_100ms = 0;
unsigned char f_param = 90;//频率参数
unsigned char h_param = 40;//湿度参数
unsigned char dis_param = 6;//距离参数
unsigned char UI = 0;// 0-频率界面 1-湿度界面 2-测距界面 3-参数界面
unsigned char UI_param = 0;//0-频率参数 1-湿度参数 2-距离参数
unsigned char f_mode = 0;//0-Hz显示 1-KHz显示
unsigned char dis_mode = 0;//0-CM显示 1-M显示
unsigned int f_int = 0;//数码管显示KHz单位的频率
float f_temp = 0;//频率单位转KHz
unsigned char stat_led = 0xff;
unsigned char stat_jdq = 0x00;
unsigned char count_01s = 0;
unsigned char num_jdq = 0;//继电器开关次数
unsigned char count_s7 = 0;//长按计数
unsigned char stat_s7 = 0;//按键S7按下和松开的状态
unsigned char stat_on_off = 0;//防止继电器开计数多次频繁计数
unsigned char pwm = 0;//周期计数
unsigned char duty_pwm = 0;//占空比
unsigned char count_50ms = 0;
unsigned char stat_on_off1 = 0;//防止继电器关计数多次频繁计数
void Delay20ms()		//@12.000MHz
{
	unsigned char i, j, k;

	_nop_();
	_nop_();
	i = 1;
	j = 234;
	k = 113;
	do
	{
		do
		{
			while (--k);
		} while (--j);
	} while (--i);
}

void Timer1Init(void)		//200微秒@12.000MHz
{
	AUXR &= 0xBF;		//定时器时钟12T模式
	TMOD &= 0x0F;		//设置定时器模式
	TMOD |= 0x10;		//设置定时器模式
	TL1 = 0x38;		//设置定时初值
	TH1 = 0xFF;		//设置定时初值
	TF1 = 0;		//清除TF1标志
	TR1 = 1;		//定时器1开始计时
	ET1 = 1;
	EA = 1;
}

void Sevice_timer1() interrupt 3
{
	EA = 0;
	TL1 = 0x38;		//设置定时初值
	TH1 = 0xFF;		//设置定时初值
	pwm++;
	if(pwm == duty_pwm)
	{
		stat_jdq &= 0xdf;
	}
	else if(pwm == 5)
	{
		pwm = 0;
		stat_jdq |= 0x20;
	}
	SelectHC573(5,stat_jdq);
	EA = 1;
}
void Init_timer0()
{
	AUXR &= 0x7f;
	TMOD &= 0xf0;
	TMOD |= 0x05;
	TH0 = TL0 = 0;
	TR0 = 1;
	ET0 = 0;
}
void Init_timer2()
{
	AUXR &= 0xf3;
	T2L = 0xf0;
	T2H = 0xd8;
	AUXR |= 0x10;
	IE2 |= 0x04;
	EA = 1;
}
void Sevice_timer2() interrupt 12
{
	DisplaySMG_info();
	count_200ms++;
	count_1s++;
	count_100ms++;
	count_50ms++;
	if(count_50ms == 5)
	{
		count_50ms = 0;
		control_led_jdq();
	}
	if(count_100ms == 5)
	{
		count_100ms = 0;
		adc_volt = read_myadc();
	}
	if(count_1s == 100)
	{
		TR0 = 0;
		count_1s = 0;
		count_f = (TH0 << 8) | TL0;
		TH0 = TL0 = 0;
		TR0 = 1;
	}
	if(count_200ms == 20)
	{
		count_200ms = 0;
		distance = measure_distan();
	}
	if(UI == 3)
	{
		count_01s++;
		if(count_01s == 10)
		{
			count_01s = 0;
			if(UI_param == 0)
			{
				stat_led |= 0x04;
				if((stat_led | 0xfe) == 0xfe)
				{
					stat_led |= 0x01;
				}
				else
				{
					stat_led &= 0xfe;
				}
			}
			else if(UI_param == 1)
			{
				stat_led |= 0x01;
				if((stat_led | 0xfd) == 0xfd)
				{
					stat_led |= 0x02;
				}
				else
				{
					stat_led &= 0xfd;
				}
			}
			else if(UI_param == 2)
			{
				stat_led |= 0x02;
				if((stat_led | 0xfb) == 0xfb)
				{
					stat_led |= 0x04;
				}
				else
				{
					stat_led &= 0xfb;
				}
			}
		}
		SelectHC573(4,stat_led);
	}
	if(stat_s7 == 1)
	{
		count_s7++;
	}
	else if(stat_s7 == 2)
	{
		if(count_s7 > 100)
		{
			num_jdq = 0;
			save_data(0x00,num_jdq);
			count_s7 = 0;
			stat_s7 = 0;
		}
	}
}
void DisplaySMG_info()
{
	switch(UI)
	{
		case 0:
			DisplaySMG_Bit(0,0x8e);
			if(f_mode == 0)
			{
				if(count_f > 99999)
				DisplaySMG_Bit(2,Seg_Table[count_f / 100000]);
				if(count_f > 9999)
				DisplaySMG_Bit(3,Seg_Table[count_f / 10000 % 10]);
				if(count_f > 999)
				DisplaySMG_Bit(4,Seg_Table[count_f / 1000 % 10]);
				if(count_f > 99)
				DisplaySMG_Bit(5,Seg_Table[count_f / 100 % 10]);
				if(count_f > 9)
				DisplaySMG_Bit(6,Seg_Table[count_f / 10 % 10]);
				DisplaySMG_Bit(7,Seg_Table[count_f % 10]);
			}
	        else if(f_mode == 1)
			{
				f_temp = (float)count_f / 1000;
				f_int = f_temp * 10;
				if(f_int > 99999)
				DisplaySMG_Bit(2,Seg_Table[f_int / 100000]);
				if(f_int > 9999)
				DisplaySMG_Bit(3,Seg_Table[f_int / 10000 % 10]);
				if(f_int > 999)
				DisplaySMG_Bit(4,Seg_Table[f_int / 1000 % 10]);
				if(f_int > 99)
				DisplaySMG_Bit(5,Seg_Table[f_int / 100 % 10]);
				DisplaySMG_Bit(6,Seg_dot[f_int / 10 % 10]);
				DisplaySMG_Bit(7,Seg_Table[f_int % 10]);
			}
		break;
		case 1:
			DisplaySMG_Bit(0,0x89);
			DisplaySMG_Bit(6,Seg_Table[humidity / 10]);
			DisplaySMG_Bit(7,Seg_Table[humidity % 10]);
		break;
		case 2:
			DisplaySMG_Bit(0,0x88);
			if(dis_mode == 0)
			{
				if(distance > 99)
				DisplaySMG_Bit(5,Seg_Table[distance / 100]);
				if(distance > 9)
				DisplaySMG_Bit(6,Seg_Table[distance / 10 % 10]);
				DisplaySMG_Bit(7,Seg_Table[distance  % 10]);
			}
			else if(dis_mode == 1)
			{
				DisplaySMG_Bit(5,Seg_dot[distance / 100]);
				DisplaySMG_Bit(6,Seg_Table[distance / 10 % 10]);
				DisplaySMG_Bit(7,Seg_Table[distance  % 10]);
			}
		break;
		case 3:
			if(UI_param == 0)
			{
				DisplaySMG_Bit(0,0x8c);
				DisplaySMG_Bit(1,Seg_Table[1]);
				if(f_param > 99)
				DisplaySMG_Bit(5,Seg_Table[f_param  / 100 % 10]);
		        DisplaySMG_Bit(6,Seg_dot[f_param / 10 % 10]);
				DisplaySMG_Bit(7,Seg_Table[f_param  % 10]);
			}
			else if(UI_param == 1)
			{
				DisplaySMG_Bit(0,0x8c);
				DisplaySMG_Bit(1,Seg_Table[2]);
				DisplaySMG_Bit(6,Seg_Table[h_param / 10]);
				DisplaySMG_Bit(7,Seg_Table[h_param  % 10]);
			}
			else if(UI_param == 2)
			{
				DisplaySMG_Bit(0,0x8c);
				DisplaySMG_Bit(1,Seg_Table[3]);
				DisplaySMG_Bit(6,Seg_dot[dis_param / 10]);
				DisplaySMG_Bit(7,Seg_Table[dis_param  % 10]);
			}
			
		break;
	}
}
void scan_key()
{
	if(s4 == 0)
	{
		Delay20ms();
		if(s4 == 0)
		{
			if(UI == 0)
			{
				UI = 1;
			}
			else if(UI == 1)
			{
				UI = 2;
			}
			else if(UI == 2)
			{
				UI_param = 0;
				UI = 3;
			}
			else if(UI == 3)
			{
				UI = 0;
			}
			while(s4 == 0);
		}
	}
	else if(s5 == 0)
	{
		Delay20ms();
		if(s5 == 0)
		{
			if(UI == 3)
			{
				if(UI_param == 0)
				{
					UI_param = 1;
				}
				else if(UI_param == 1)
				{
					UI_param = 2;
				}
				else if(UI_param == 2)
				{
					UI_param = 0;
				}
			}
			while(s5 == 0);
		}
	}
	else if(s6 == 0)
	{
		Delay20ms();
		if(s6 == 0)
		{
			if((UI == 3) && (UI_param == 0))
			{
				if(f_param == 120)
				{
					f_param = 10;
				}
				else
				{
					f_param += 5;
				}
			}
			else if((UI == 3) && (UI_param == 1))
			{
				if(h_param == 60)
				{
					h_param = 10;
				}
				else
				{
					h_param += 10;
				}
			}
			else if((UI == 3) && (UI_param == 2))
			{
				if(dis_param == 12)
				{
					dis_param = 1;
				}
				else
				{
					dis_param += 1;
				}
			}
			if(UI == 2)
			{
				if(dis_mode == 0)
				{
					dis_mode = 1;
				}
				else if(dis_mode == 1)
				{
					dis_mode = 0;
				}
			}
			while(s6 == 0);
		}
	}
	else if(s7 == 0)
	{
		Delay20ms();
		if(s7 == 0)
		{
			if((UI == 3) && (UI_param == 0))
			{
				if(f_param == 10)
				{
					f_param = 120;
				}
				else
				{
					f_param -= 5;
				}
			}
			else if((UI == 3) && (UI_param == 1))
			{
				if(h_param == 10)
				{
					h_param = 60;
				}
				else
				{
					h_param -= 10;
				}
			}
			else if((UI == 3) && (UI_param == 2))
			{
				if(dis_param == 1)
				{
					dis_param = 12;
				}
				else
				{
					dis_param -= 1;
				}
			}
			if(UI == 0)
			{
				if(f_mode == 0)
				{
					f_mode = 1;
				}
				else
				{
					f_mode = 0;
				}
			}
			if(UI == 1)
			{
				stat_s7 = 1;
			}
			while(s7 == 0);
			if(UI == 1)
			{
				stat_s7 = 2;
			}
		}
	}
}
void deal_data()
{
	unsigned char dac_value = 0;
	if(adc_volt < 5.0)
	humidity = 20 * adc_volt;
	if(humidity < h_param)
	{
		Set_mydac(51);
	}
	else if(humidity <= 80)
	{
		dac_value = (((4.0/(80-h_param))*humidity + ((float)(80-(5*(char)h_param))/(80-h_param))) * 51);
		Set_mydac(dac_value);	
	}
	else
	{
		Set_mydac(255);
	}

}
void control_led_jdq()
{
	if(distance > (dis_param * 10))
	{
		stat_jdq |= 0x10;
		stat_led &= 0xdf;
		stat_on_off1 = 0;
		if(stat_on_off == 0)//继电器开计数
		{
			num_jdq++;
			stat_on_off = 1;
			save_data(0x00,num_jdq);
		}
	}
	else
	{
		stat_jdq &= 0xef;
		stat_led |= 0x20;
		stat_on_off = 0;
		if(stat_on_off1 == 0)//继电器关计数
		{
			num_jdq++;
			stat_on_off1 = 1;
			save_data(0x00,num_jdq);
		}
	}
	if(UI == 0)
	{
		stat_led |= 0x04;
		stat_led &= 0xfe;
	}
	else if(UI == 1)
	{
		stat_led |= 0x01;
		stat_led &= 0xfd;
	}
	else if(UI == 2)
	{
		stat_led |= 0x02;
		stat_led &= 0xfb;
	}
	if(count_f > (f_param * 100))
	{
		stat_led &= 0xf7;
		duty_pwm = 4;
	}
	else
	{
		stat_led |= 0x08;
		duty_pwm = 1;
	}
	if(humidity > h_param)
	{
		stat_led &= 0xef;
	}
	else
	{
		stat_led |= 0x10;
	}
	SelectHC573(5,stat_jdq);
	SelectHC573(4,stat_led);
}
void main()
{
	Init_timer2();
	Init_timer0();
	SelectHC573(5,0x00);
	SelectHC573(4,0xff);
	DisplaySMG_All(0xff);
	Timer1Init();
	while(1)
	{
		deal_data();
		scan_key();
	}
}

需要完整工程可私信

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第十三届蓝桥杯国赛web前端组(大学组)第七题是要求设计一个会议管理系统,可以帮助用户方便地组织和管理会议。针对这个题目,我可以给出如下的解答: 一个完善的会议管理系统应具备以下功能。首先,用户可以创建会议,设定会议的时间、地点和议程,并邀请参会人员。其次,系统应支持参会人员提前确认参会或者请假的功能,在会议开始前能清晰获得与会人员的参会情况。同时,会议管理系统还应能够提供参会人员的名单和联系方式,以便组织者能够随时与与会人员取得联系。 此外,会议管理系统还应提供会议资料的上传和下载功能,参会人员可以方便地查看和下载与会议相关的文档和资料。除此之外,系统还应支持会议纪要和决议的记录,可以方便地生成会议记录与会议结果,以便参会人员能够回顾会议内容。 为了提升系统的易用性和便捷性,我建议在系统中设计一个直观友好的用户界面,方便用户进行各项操作。同时,系统还应能够提供即时通知功能,包括会议时间变动、参会人员请假等信息的推送,以便参会人员能够及时了解会议动态。 此外,为了保证会议的隐私和安全,会议管理系统还应具备相应的权限管理功能,不同的角色可以拥有不同的权限。例如,组织者可以有创建、修改和删除会议的权力,而参会人员只能查看和下载相关资料。 综上所述,一个功能完善、界面友好、易用便捷的会议管理系统将大大提高会议的管理效率和参会人员的体验,并且满足方便、高效组织会议的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值