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

📄 msg.c

📁 51单片机C语言常用模块与综合系统设计实例精讲
💻 C
字号:
#include <stdio.h>
#include <absacc.h>
#include <stdarg.h>
#include <./Atmel/at89x52.h>
#include "source.h"	
/****HBS=half bottom screen ****/
#define HBS_MSG_DEEP    10 //设置为screen_hbs函数定义消息的深度
unsigned char hbs_msg[HBS_MSG_DEEP];
unsigned char hbs_tail=0;
unsigned char hbs_head=0;
void send_hbs_msg(unsigned char msg){//向screen_hbs函数的消息队列发送消息
	hbs_msg[hbs_head]=msg;
	hbs_head++;
	hbs_head %=HBS_MSG_DEEP;
}
unsigned char  read_hbs_msg(void){//从screen_hbs函数的消息队列中读取消息
	unsigned char ret_msg;
	if(hbs_tail!=hbs_head){//消息队列不为空,返回消息
		ret_msg=hbs_msg[hbs_tail];
		hbs_tail++;
		hbs_tail %=HBS_MSG_DEEP;
		return ret_msg;
	}
	else{
		return 0;//消息队列为空,返回0
	}
}	
void change_hbs_fsm(unsigned char fsm){//改变screen_hbs函数里的状态机
	screen.hbs_fsm=fsm;
}
/******以下消息函数的功能同以上的说明****/
#define STATUS_MSG_DEEP    10
unsigned char status_msg[STATUS_MSG_DEEP];
unsigned char status_tail=0;
unsigned char status_head=0;
void send_status_msg(unsigned char msg){
	status_msg[status_head]=msg;
	status_head++;
	status_head %=STATUS_MSG_DEEP;
}
unsigned char  read_status_msg(void){
	unsigned char ret_msg;
	if(status_tail!=status_head){//消息队列不为空,返回消息
		ret_msg=status_msg[status_tail];
		status_tail++;
		status_tail %=STATUS_MSG_DEEP;
		return ret_msg;
	}
	else{
		return 0;//消息队列为空,返回0
	}
}
void change_status_fsm(unsigned char fsm){//改变状态机
	screen.status_fsm=fsm;
}

⌨️ 快捷键说明

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