蓝桥杯单片机第11届国赛程序题参考答案_11届蓝桥杯单片机国赛答案-程序员宅基地

技术标签: 蓝桥杯单片机国赛  51单片机  嵌入式硬件  单片机  

        答案仅供参考,有错误欢迎指正,非常感谢!!!

        文件较多,代码较长,感谢查看!!!

目录

main.h

main.c

Init.h

Init.c

SMG.h

SMG.c

DSQ.h

DSQ.c

YanShi.h

YanShi.c

JZKey.h

JZKey.c

ds1302.h

ds1302.c

iic.h

iic.c

onewire.h

onewire.

main.h

#ifndef __MAIN_H_
#define __MAIN_H_

#define uchar unsigned char
#define uint unsigned int
	
#include <STC15F2K60S2.H>

#include "Init.h"
#include "SMG.h"
#include "DSQ.h"
#include "YanShi.h"
#include "JZKey.h"
#include "ds1302.h"
#include "iic.h"
#include "onewire.h"

void LED_Show();
void XianShi();
void JieMian_ChuLi();
void ShuJu_DuQu();
void CanShu_JieMian();
void ShuJu_JieMian();

#endif

main.c

#include "main.h"

uchar flag0=0;
uchar jie_mian=0;
uchar key_num;
uchar xian_shi;
char ShiJian_CanShu=17;
char WenDu_CanShu=25;
char ZhiShiDeng_CanShu=4;
char ShiJian_CanShu_temp,WenDu_CanShu_temp,ZhiShiDeng_CanShu_temp;
double wen_du;
uchar guang_min;
uchar flag=0;
int wen_du_temp;
uint dian_ya;
int time_flag=0;
uchar ZhiShiDeng_flag;

void main(){
	Init_BanZi();
	DSQ_0_Init();
	JZKey_Init();
	DS1302_XieDate(16,59,50);
	while(1){
		ShuJu_DuQu();
		key_num=JZKey_GetDate();
		if(key_num==4){//选择界面,0:数据界面;1:参数界面
			JieMian_ChuLi();
		}
		if(jie_mian){//参数界面
			CanShu_JieMian();
		}
		else{//数据界面
			ShuJu_JieMian();
		}
	}
}

void DSQ_0_ZhongDuan() interrupt 1{
	flag0++;
	flag=1;
	if(dian_ya>250){//没有遮挡光敏电阻
		time_flag--;
		if(time_flag<=0){//时间超过3秒,L4-L8熄灭
			time_flag=0;
			ZhiShiDeng_flag=0;
		}
	}
	else{//有遮挡光敏电阻
		time_flag++;
		if(time_flag>=3000){//时间超过3秒,L4-L8点亮
			time_flag=3000;
			ZhiShiDeng_flag=1;
		}
	}
	if(flag0>=1){
		flag0=0;
		XianShi();
		LED_Show();//LED显示
	}
}

void LED_Show(){//8个LED的状态
	uchar L1=0xff;
	uchar L2=0xff;
	uchar L3=0xff;
	uchar L4_8=0xff;
	if(ShiJian_CanShu>8){//参数大于8时的情况
		if((shi>=ShiJian_CanShu&&shi<=23)||(shi>=0&&shi<=8)){//处于之间,L1点亮
			L1=0xfe;
		}
		else{//不处于之间,L1熄灭
			L1=0xff;
		}
	}
	else{//参数小于8时的情况
		if(shi>=ShiJian_CanShu&&shi<=8){
			L1=0xfe;
		}
		else{
			L1=0xff;
		}
	}
	if(wen_du<WenDu_CanShu){//温度小于温度参数,L2点亮
		L2=0xfd;
	}
	else{//L2熄灭
		L2=0xff;
	}
	if(dian_ya>250){//没有遮挡光敏电阻,L3熄灭
		L3=0xff;
	}
	else{//有遮挡光敏电阻,L3点亮
		L3=0xfb;
	}
	if(ZhiShiDeng_flag){
		P2=(P2&0x1f)|0x00;
		switch(ZhiShiDeng_CanShu){
			case 4:{
				L4_8=0xf7;
				break;
			}
			case 5:{
				L4_8=0xef;
				break;
			}
			case 6:{
				L4_8=0xdf;
				break;
			}
			case 7:{
				L4_8=0xbf;
				break;
			}
			case 8:{
				L4_8=0x7f;
				break;
			}
		}
	}
	else{
		L4_8=0xff;
	}
	P0=L1&L2&L3&L4_8;
	P2=(P2&0x1f)|0x80;
	P2=(P2&0x1f)|0x00;
}

void XianShi(){//数码管显示的界面
	switch(xian_shi){
		case 1:{//时间数据显示
			SMG_Show(shi/10,shi%10,17,fen/10,fen%10,17,miao/10,miao%10);
			break;
		}
		case 2:{//温度数据显示
			if(wen_du_temp>=100){
				SMG_Show(12,16,16,16,16,wen_du_temp/100,((wen_du_temp/10)%10)+32,wen_du_temp%10);
			}
			else if(wen_du_temp>=0){
				SMG_Show(12,16,16,16,16,16,(wen_du_temp/10)+32,wen_du_temp%10);
			}
			else if(wen_du_temp<0&&wen_du_temp>-100){
				wen_du_temp=-wen_du_temp;
				SMG_Show(12,16,16,16,16,17,(wen_du_temp/10)+32,wen_du_temp%10);
			}
			break;
		}
		case 3:{//亮暗状态显示
			if(dian_ya>250){//没有遮挡光敏电阻
				SMG_Show(14,16,(dian_ya/100)+32,(dian_ya/10)%10,dian_ya%10,16,16,0);
			}
			else{//有遮挡光敏电阻
				SMG_Show(14,16,(dian_ya/100)+32,(dian_ya/10)%10,dian_ya%10,16,16,1);
			}
			break;
		}
		case 4:{
			SMG_Show(24,1,16,16,16,16,ShiJian_CanShu_temp/10,ShiJian_CanShu_temp%10);
			break;
		}
		case 5:{
			SMG_Show(24,2,16,16,16,16,WenDu_CanShu_temp/10,WenDu_CanShu_temp%10);
			break;
		}
		case 6:{
			SMG_Show(24,3,16,16,16,16,16,ZhiShiDeng_CanShu_temp);
			break;
		}
	}
}

void JieMian_ChuLi(){//界面处理
	jie_mian++;
	jie_mian=jie_mian%2;
}

void ShuJu_DuQu(){//数据读取
	if(flag==1){
		guang_min=IIC_ADC_GetDate(1);
		dian_ya=guang_min/51.0*100;
		flag=0;
	}
	if(flag==1){
		wen_du=DS18B20_GetWendu();
		wen_du_temp=wen_du*10;
		flag=0;
	}
	if(flag==1){
		DS1302_GetDate();
		flag=0;
	}
}

void CanShu_JieMian(){//参数界面
	uchar i=0;
	ShiJian_CanShu_temp=ShiJian_CanShu;
	WenDu_CanShu_temp=WenDu_CanShu;
	ZhiShiDeng_CanShu_temp=ZhiShiDeng_CanShu;
	while(1){
		ShuJu_DuQu();
		key_num=JZKey_GetDate();
		if(key_num==4){
			JieMian_ChuLi();
			ShiJian_CanShu=ShiJian_CanShu_temp;
			WenDu_CanShu=WenDu_CanShu_temp;
			ZhiShiDeng_CanShu=ZhiShiDeng_CanShu_temp;
			return;
		}
		else if(key_num==5){
			i++;
			i=i%3;
		}
		switch(i){//选择数码管显示界面
			case 0:{//时间参数
				xian_shi=4;
				if(key_num==8){
					ShiJian_CanShu_temp--;
					if(ShiJian_CanShu_temp<=0){
						ShiJian_CanShu_temp=0;
					}
				}
				else if(key_num==9){
					ShiJian_CanShu_temp++;
					if(ShiJian_CanShu_temp>=23){
						ShiJian_CanShu_temp=23;
					}
				}
				break;
			}
			case 1:{//温度参数
				xian_shi=5;
				if(key_num==8){
					WenDu_CanShu_temp--;
					if(WenDu_CanShu_temp<=0){
						WenDu_CanShu_temp=0;
					}
				}
				else if(key_num==9){
					WenDu_CanShu_temp++;
					if(WenDu_CanShu_temp>=99){
						WenDu_CanShu_temp=99;
					}
				}
				break;
			}
			case 2:{//指示灯状态
				xian_shi=6;
				if(key_num==8){
					ZhiShiDeng_CanShu_temp--;
					if(ZhiShiDeng_CanShu_temp<=4){
						ZhiShiDeng_CanShu_temp=4;
					}
				}
				else if(key_num==9){
					ZhiShiDeng_CanShu_temp++;
					if(ZhiShiDeng_CanShu_temp>=8){
						ZhiShiDeng_CanShu_temp=8;
					}
				}
				break;
			}
		}
	}
}

void ShuJu_JieMian(){//数据界面
	uchar i=0;
	while(1){
		ShuJu_DuQu();
		key_num=JZKey_GetDate();
		if(key_num==4){
			JieMian_ChuLi();
			return;
		}
		else if(key_num==5){
			i++;
			i=i%3;
		}
		switch(i){//选择数码管显示界面
			case 0:{//时间
				xian_shi=1;
				break;
			}
			case 1:{//温度
				xian_shi=2;
				break;
			}
			case 2:{//亮暗状态
				xian_shi=3;
				break;
			}
		}
	}
}

Init.h

#ifndef __INIT_H_
#define __INIT_H_

#include <STC15F2K60S2.H>

void Init_BanZi();

#endif

Init.c

#include "Init.h"

void Init_BanZi(){
	P2=(P2&0x1f)|0xa0;
	P0=0x00;
	P2=(P2&0x1f)|0x80;
	P0=0xff;
}

SMG.h

#ifndef __SMG_H_
#define __SMG_H_

#include <STC15F2K60S2.H>

void SMG_Init();
void SMG_Show(unsigned char n1,n2,n3,n4,n5,n6,n7,n8);

#endif

SMG.c

#include "SMG.h"

unsigned char code SMG_ZK[]={                       //????
//   0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
    0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71,
//black  -     H    J    K    L    N    o   P    U     t    G    Q    r   M    y
    0x00,0x40,0x76,0x1E,0x70,0x38,0x37,0x5C,0x73,0x3E,0x78,0x3d,0x67,0x50,0x37,0x6e,
    0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xEF,0x46};    //0. 1. 2. 3. 4. 5. 6. 7. 8. 9. -1

void SMG_Init(){
	P2=(P2&0x1f)|0xc0;
	P0=0xff;
	P2=(P2&0x1f)|0xe0;
	P0=0xff;
}

void SMG_Show(unsigned char n1,n2,n3,n4,n5,n6,n7,n8){
	static unsigned char i=0;
	i++;
	i=i%8;
	P2=(P2&0x1f)|0xc0;
	switch(i){
		case 1:{
			P0=0x01;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n1];
			break;
		}
		case 2:{
			P0=0x02;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n2];
			break;
		}
		case 3:{
			P0=0x04;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n3];
			break;
		}
		case 4:{
			P0=0x08;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n4];
			break;
		}
		case 5:{
			P0=0x10;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n5];
			break;
		}
		case 6:{
			P0=0x20;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n6];
			break;
		}
		case 7:{
			P0=0x40;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n7];
			break;
		}
		case 0:{
			P0=0x80;
			P2=(P2&0x1f)|0xe0;
			P0=~SMG_ZK[n8];
			break;
		}
	}
	P2=(P2&0x1f)|0x00;
}

DSQ.h

#ifndef __DSQ_H_
#define __DSQ_H_

#include <STC15F2K60S2.H>

void DSQ_0_Init();

#endif

DSQ.c

#include "DSQ.h"

void DSQ_0_Init(){
	AUXR |= 0x80;		//?????1T??
	TMOD &= 0xF0;		//???????
	TL0 = 0x20;		//??????
	TH0 = 0xD1;		//??????
	TF0 = 0;		//??TF0??
	TR0 = 1;		//???0????
	EA=1;
	ET0=1;
}

YanShi.h

#ifndef __YANSHI_H_
#define __YANSHI_H_

#include <STC15F2K60S2.H>
#include "intrins.h"

void Delay1ms();
void Delay2ms();
void Delay10ms();

#endif

YanShi.c

#include "YanShi.h"

void Delay1ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}

void Delay2ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 24;
	j = 85;
	do
	{
		while (--j);
	} while (--i);
}

void Delay10ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 117;
	j = 184;
	do
	{
		while (--j);
	} while (--i);
}

JZKey.h

#ifndef __JZKEY_H_
#define __JZKEY_H_

#include "YanShi.h"

void JZKey_Init();
unsigned char JZKey_GetDate();

#endif

JZKey.c

#include "JZKey.h"

void JZKey_Init(){
	P30=1;
	P31=1;
	P32=1;
	P33=1;
	P34=0;
	P35=0;
	P42=0;
	P44=0;
}

unsigned char JZKey_GetDate(){
	unsigned char key_num=0;
	if(P30==0){
		P30=0;
		P34=1;
		P35=1;
		P42=1;
		P44=1;
		if(P34==0){
			Delay10ms();
			if(P34==0){
				key_num=19;
			}
			while(P34==0);
		}
		else if(P35==0){
			Delay10ms();
			if(P35==0){
				key_num=15;
			}
			while(P35==0);
		}
		else if(P42==0){
			Delay10ms();
			if(P42==0){
				key_num=11;
			}
			while(P42==0);
		}
		else if(P44==0){
			Delay10ms();
			if(P44==0){
				key_num=7;
			}
			while(P44==0);
		}
	}
	else if(P31==0){
		P31=0;
		P34=1;
		P35=1;
		P42=1;
		P44=1;
		if(P34==0){
			Delay10ms();
			if(P34==0){
				key_num=18;
			}
			while(P34==0);
		}
		else if(P35==0){
			Delay10ms();
			if(P35==0){
				key_num=14;
			}
			while(P35==0);
		}
		else if(P42==0){
			Delay10ms();
			if(P42==0){
				key_num=10;
			}
			while(P42==0);
		}
		else if(P44==0){
			Delay10ms();
			if(P44==0){
				key_num=6;
			}
			while(P44==0);
		}
	}
	else if(P32==0){
		P32=0;
		P34=1;
		P35=1;
		P42=1;
		P44=1;
		if(P34==0){
			Delay10ms();
			if(P34==0){
				key_num=17;
			}
			while(P34==0);
		}
		else if(P35==0){
			Delay10ms();
			if(P35==0){
				key_num=13;
			}
			while(P35==0);
		}
		else if(P42==0){
			Delay10ms();
			if(P42==0){
				key_num=9;
			}
			while(P42==0);
		}
		else if(P44==0){
			Delay10ms();
			if(P44==0){
				key_num=5;
			}
			while(P44==0);
		}
	}
	else if(P33==0){
		P33=0;
		P34=1;
		P35=1;
		P42=1;
		P44=1;
		if(P34==0){
			Delay10ms();
			if(P34==0){
				key_num=16;
			}
			while(P34==0);
		}
		else if(P35==0){
			Delay10ms();
			if(P35==0){
				key_num=12;
			}
			while(P35==0);
		}
		else if(P42==0){
			Delay10ms();
			if(P42==0){
				key_num=8;
			}
			while(P42==0);
		}
		else if(P44==0){
			Delay10ms();
			if(P44==0){
				key_num=4;
			}
			while(P44==0);
		}
	}
	JZKey_Init();
	return key_num;
}

ds1302.h

#ifndef __DS1302_H
#define __DS1302_H

#include <STC15F2K60S2.H>

extern unsigned char shi,fen,miao;

void Write_Ds1302(unsigned char temp);
void Write_Ds1302_Byte( unsigned char address,unsigned char dat );
unsigned char Read_Ds1302_Byte( unsigned char address );

void DS1302_XieDate(unsigned char h,m,s);
void DS1302_GetDate();

#endif

ds1302.c

/*
  程序说明: DS1302驱动程序
  软件环境: Keil uVision 4.10 
  硬件环境: CT107单片机综合实训平台 8051,12MHz
  日    期: 2011-8-9
*/

#include "ds1302.h"
#include <intrins.h>

unsigned char shi,fen,miao;

sbit SCK=P1^7;		
sbit SDA=P2^3;		
sbit RST = P1^3;   // DS1302复位												

void Write_Ds1302(unsigned  char temp) 
{
	unsigned char i;
	for (i=0;i<8;i++)     	
	{ 
		SCK=0;
		SDA=temp&0x01;
		temp>>=1; 
		SCK=1;
	}
}   

void Write_Ds1302_Byte( unsigned char address,unsigned char dat )     
{
 	RST=0;	_nop_();
 	SCK=0;	_nop_();
 	RST=1; 	_nop_();  
 	Write_Ds1302(address);	
 	Write_Ds1302(dat);		
 	RST=0; 
}

unsigned char Read_Ds1302_Byte ( unsigned char address )
{
 	unsigned char i,temp=0x00;
 	RST=0;	_nop_();
 	SCK=0;	_nop_();
 	RST=1;	_nop_();
 	Write_Ds1302(address);
 	for (i=0;i<8;i++) 	
 	{		
		SCK=0;
		temp>>=1;	
 		if(SDA)
 		temp|=0x80;	
 		SCK=1;
	} 
 	RST=0;	_nop_();
 	SCK=0;	_nop_();
	SCK=1;	_nop_();
	SDA=0;	_nop_();
	SDA=1;	_nop_();
	return (temp);			
}

void DS1302_XieDate(unsigned char h,m,s){
	h=(h/10)*16+(h%10);
	m=(m/10)*16+(m%10);
	s=(s/10)*16+(s%10);
	Write_Ds1302_Byte(0x8e,0x00);
	Write_Ds1302_Byte(0x84,h);
	Write_Ds1302_Byte(0x82,m);
	Write_Ds1302_Byte(0x80,s);
	Write_Ds1302_Byte(0x8e,0x80);
}

void DS1302_GetDate(){
	shi=Read_Ds1302_Byte(0x85);
	fen=Read_Ds1302_Byte(0x83);
	miao=Read_Ds1302_Byte(0x81);
	shi=(shi/16)*10+(shi%16);
	fen=(fen/16)*10+(fen%16);
	miao=(miao/16)*10+(miao%16);
}

iic.h

#ifndef __INIT_H_
#define __INIT_H_

#include <STC15F2K60S2.H>

void Init_BanZi();

#endif

iic.c

/*
  程序说明: IIC总线驱动程序
  软件环境: Keil uVision 4.10 
  硬件环境: CT107单片机综合实训平台 8051,12MHz
  日    期: 2011-8-9
*/

#include "iic.h"
#include "intrins.h"

#define DELAY_TIME 5

#define SlaveAddrW 0xA0
#define SlaveAddrR 0xA1

//总线引脚定义
sbit SDA = P2^1;  /* 数据线 */
sbit SCL = P2^0;  /* 时钟线 */

void IIC_Delay(unsigned char i)
{
    do{_nop_();}
    while(i--);        
}
//总线启动条件
void IIC_Start(void)
{
    SDA = 1;
    SCL = 1;
    IIC_Delay(DELAY_TIME);
    SDA = 0;
    IIC_Delay(DELAY_TIME);
    SCL = 0;	
}

//总线停止条件
void IIC_Stop(void)
{
    SDA = 0;
    SCL = 1;
    IIC_Delay(DELAY_TIME);
    SDA = 1;
    IIC_Delay(DELAY_TIME);
}

//发送应答
void IIC_SendAck(bit ackbit)
{
    SCL = 0;
    SDA = ackbit;  					// 0:应答,1:非应答
    IIC_Delay(DELAY_TIME);
    SCL = 1;
    IIC_Delay(DELAY_TIME);
    SCL = 0; 
    SDA = 1;
    IIC_Delay(DELAY_TIME);
}

//等待应答
bit IIC_WaitAck(void)
{
    bit ackbit;
	
    SCL  = 1;
    IIC_Delay(DELAY_TIME);
    ackbit = SDA;
    SCL = 0;
    IIC_Delay(DELAY_TIME);
    return ackbit;
}

//通过I2C总线发送数据
void IIC_SendByte(unsigned char byt)
{
    unsigned char i;

    for(i=0; i<8; i++)
    {
        SCL  = 0;
        IIC_Delay(DELAY_TIME);
        if(byt & 0x80) SDA  = 1;
        else SDA  = 0;
        IIC_Delay(DELAY_TIME);
        SCL = 1;
        byt <<= 1;
        IIC_Delay(DELAY_TIME);
    }
    SCL  = 0;  
}

//从I2C总线上接收数据
unsigned char IIC_RecByte(void)
{
    unsigned char i, da;
    for(i=0; i<8; i++)
    {   
    	SCL = 1;
	IIC_Delay(DELAY_TIME);
	da <<= 1;
	if(SDA) da |= 1;
	SCL = 0;
	IIC_Delay(DELAY_TIME);
    }
    return da;    
}

unsigned char IIC_ADC_GetDate(unsigned char di_zhi){
	unsigned char date;
	IIC_Start();
	IIC_SendByte(0x90);
	IIC_WaitAck();
	IIC_SendByte(di_zhi);
	IIC_WaitAck();
	IIC_Stop();
	
	IIC_Start();
	IIC_SendByte(0x91);
	IIC_WaitAck();
	date=IIC_RecByte();
	IIC_SendAck(1);
	IIC_WaitAck();
	IIC_Stop();
	return date;
}

onewire.h

#ifndef __ONEWIRE_H
#define __ONEWIRE_H

#include <STC15F2K60S2.H>

unsigned char rd_temperature(void);  //; ;

double DS18B20_GetWendu();

#endif

onewire.c

/*
  程序说明: 单总线驱动程序
  软件环境: Keil uVision 4.10 
  硬件环境: CT107单片机综合实训平台(外部晶振12MHz) STC89C52RC单片机
  日    期: 2011-8-9
*/
#include "onewire.h"

sbit DQ = P1^4;  //单总线接口

//单总线延时函数
void Delay_OneWire(unsigned int t)  //STC89C52RC
{
	unsigned char i;
	while(t--){
		for(i=0;i<12;i++);
	}
}

//通过单总线向DS18B20写一个字节
void Write_DS18B20(unsigned char dat)
{
	unsigned char i;
	for(i=0;i<8;i++)
	{
		DQ = 0;
		DQ = dat&0x01;
		Delay_OneWire(5);
		DQ = 1;
		dat >>= 1;
	}
	Delay_OneWire(5);
}

//从DS18B20读取一个字节
unsigned char Read_DS18B20(void)
{
	unsigned char i;
	unsigned char dat;
  
	for(i=0;i<8;i++)
	{
		DQ = 0;
		dat >>= 1;
		DQ = 1;
		if(DQ)
		{
			dat |= 0x80;
		}	    
		Delay_OneWire(5);
	}
	return dat;
}

//DS18B20设备初始化
bit init_ds18b20(void)
{
  	bit initflag = 0;
  	
  	DQ = 1;
  	Delay_OneWire(12);
  	DQ = 0;
  	Delay_OneWire(80);
  	DQ = 1;
  	Delay_OneWire(10); 
    initflag = DQ;     
  	Delay_OneWire(5);
  
  	return initflag;
}

double DS18B20_GetWendu(){
	double wen_du,zheng_shu,xiao_shu;
	unsigned char di,gao;
	init_ds18b20();
	Write_DS18B20(0xcc);
	Write_DS18B20(0x44);
	Delay_OneWire(200);
	
	init_ds18b20();
	Write_DS18B20(0xcc);
	Write_DS18B20(0xbe);
	di=Read_DS18B20();
	gao=Read_DS18B20();
	if(gao>=248){
		di=~di;
		gao=~gao;
		if(di==0xff){
			di=0;
			gao++;
		}
		else{
			di++;
		}
		zheng_shu=((gao<<4)|(di>>4))*1.0;
		xiao_shu=(di&0x0f)*0.0625;
		wen_du=-(zheng_shu+xiao_shu);
	}
	else{
		zheng_shu=((gao<<4)|(di>>4))*1.0;
		xiao_shu=(di&0x0f)*0.0625;
		wen_du=(zheng_shu+xiao_shu);
	}
	return wen_du;
}

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/CETET/article/details/123722083

智能推荐

class和struct的区别-程序员宅基地

文章浏览阅读101次。4.class可以有⽆参的构造函数,struct不可以,必须是有参的构造函数,⽽且在有参的构造函数必须初始。2.Struct适⽤于作为经常使⽤的⼀些数据组合成的新类型,表示诸如点、矩形等主要⽤来存储数据的轻量。1.Class⽐较适合⼤的和复杂的数据,表现抽象和多级别的对象层次时。2.class允许继承、被继承,struct不允许,只能继承接⼝。3.Struct有性能优势,Class有⾯向对象的扩展优势。3.class可以初始化变量,struct不可以。1.class是引⽤类型,struct是值类型。

android使用json后闪退,应用闪退问题:从json信息的解析开始就会闪退-程序员宅基地

文章浏览阅读586次。想实现的功能是点击顶部按钮之后按关键字进行搜索,已经可以从服务器收到反馈的json信息,但从json信息的解析开始就会闪退,加载listview也不知道行不行public abstract class loadlistview{public ListView plv;public String js;public int listlength;public int listvisit;public..._rton转json为什么会闪退

如何使用wordnet词典,得到英文句子的同义句_get_synonyms wordnet-程序员宅基地

文章浏览阅读219次。如何使用wordnet词典,得到英文句子的同义句_get_synonyms wordnet

系统项目报表导出功能开发_积木报表 多线程-程序员宅基地

文章浏览阅读521次。系统项目报表导出 导出任务队列表 + 定时扫描 + 多线程_积木报表 多线程

ajax 如何从服务器上获取数据?_ajax 获取http数据-程序员宅基地

文章浏览阅读1.1k次,点赞9次,收藏9次。使用AJAX技术的好处之一是它能够提供更好的用户体验,因为它允许在不重新加载整个页面的情况下更新网页的某一部分。另外,AJAX还使得开发人员能够创建更复杂、更动态的Web应用程序,因为它们可以在后台与服务器进行通信,而不需要打断用户的浏览体验。在Web开发中,AJAX(Asynchronous JavaScript and XML)是一种常用的技术,用于在不重新加载整个页面的情况下,从服务器获取数据并更新网页的某一部分。使用AJAX,你可以创建异步请求,从而提供更快的响应和更好的用户体验。_ajax 获取http数据

Linux图形终端与字符终端-程序员宅基地

文章浏览阅读2.8k次。登录退出、修改密码、关机重启_字符终端

随便推点

Python与Arduino绘制超声波雷达扫描_超声波扫描建模 python库-程序员宅基地

文章浏览阅读3.8k次,点赞3次,收藏51次。前段时间看到一位发烧友制作的超声波雷达扫描神器,用到了Arduino和Processing,可惜啊,我不会Processing更看不懂人家的程序,咋办呢?嘿嘿,所以我就换了个思路解决,因为我会一点Python啊,那就动手吧!在做这个案例之前先要搞明白一个问题:怎么将Arduino通过超声波检测到的距离反馈到Python端?这个嘛,我首先想到了串行通信接口。没错!就是串口。只要Arduino将数据发送给COM口,然后Python能从COM口读取到这个数据就可以啦!我先写了一个测试程序试了一下,OK!搞定_超声波扫描建模 python库

凯撒加密方法介绍及实例说明-程序员宅基地

文章浏览阅读4.2k次。端—端加密指信息由发送端自动加密,并且由TCP/IP进行数据包封装,然后作为不可阅读和不可识别的数据穿过互联网,当这些信息到达目的地,将被自动重组、解密,而成为可读的数据。不可逆加密算法的特征是加密过程中不需要使用密钥,输入明文后由系统直接经过加密算法处理成密文,这种加密后的数据是无法被解密的,只有重新输入明文,并再次经过同样不可逆的加密算法处理,得到相同的加密密文并被系统重新识别后,才能真正解密。2.使用时,加密者查找明文字母表中需要加密的消息中的每一个字母所在位置,并且写下密文字母表中对应的字母。_凯撒加密

工控协议--cip--协议解析基本记录_cip协议embedded_service_error-程序员宅基地

文章浏览阅读5.7k次。CIP报文解析常用到的几个字段:普通类型服务类型:[0x00], CIP对象:[0x02 Message Router], ioi segments:[XX]PCCC(带cmd和func)服务类型:[0x00], CIP对象:[0x02 Message Router], cmd:[0x101], fnc:[0x101]..._cip协议embedded_service_error

如何在vs2019及以后版本(如vs2022)上添加 添加ActiveX控件中的MFC类_vs添加mfc库-程序员宅基地

文章浏览阅读2.4k次,点赞9次,收藏13次。有时候我们在MFC项目开发过程中,需要用到一些微软已经提供的功能,如VC++使用EXCEL功能,这时候我们就能直接通过VS2019到如EXCEL.EXE方式,生成对应的OLE头文件,然后直接使用功能,那么,我们上篇文章中介绍了vs2017及以前的版本如何来添加。但由于微软某些方面考虑,这种方式已被放弃。从上图中可以看出,这一功能,在从vs2017版本15.9开始,后续版本已经删除了此功能。那么我们如果仍需要此功能,我们如何在新版本中添加呢。_vs添加mfc库

frame_size (1536) was not respected for a non-last frame_frame_size (1024) was not respected for a non-last-程序员宅基地

文章浏览阅读785次。用ac3编码,执行编码函数时报错入如下:[ac3 @ 0x7fed7800f200] frame_size (1536) was not respected for anon-last frame (avcodec_encode_audio2)用ac3编码时每次送入编码器的音频采样数应该是1536个采样,不然就会报上述错误。这个数字并非刻意固定,而是跟ac3内部的编码算法原理相关。全网找不到,国内音视频之路还有很长的路,音视频人一起加油吧~......_frame_size (1024) was not respected for a non-last frame

Android移动应用开发入门_在安卓移动应用开发中要在活动类文件中声迷你一个复选框变量-程序员宅基地

文章浏览阅读230次,点赞2次,收藏2次。创建Android应用程序一个项目里面可以有很多模块,而每一个模块就对应了一个应用程序。项目结构介绍_在安卓移动应用开发中要在活动类文件中声迷你一个复选框变量

推荐文章

热门文章

相关标签