制袋机程序.rar

源代码在线查看: includes.h

软件大小: 237 K
上传用户: lifan
关键词: 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				/***************************************
				* 文件名:INCLUDES.h
				* 描述:
				* 最后修改时间:2010.4.19
				****************************************/
				#ifndef __INCLUDES_H__
				#define __INCLUDES_H__
				
				//#include
				#include 
				#include 
				#include 
				//#include 
				//include 
				
				//Common
				
				#define bool char
				#define uchar unsigned char
				#define uint unsigned int
				#define ulong unsigned long
				#define TRUE  1
				#define FLASE 0
				#define true  1
				#define false 0
				
				
				enum MODE
				{
				  MODE_NULL = 0,	//无效
				  MODE_RUNABLE,
				  MODE_TEST,			//测试,无效
				  MODE_MANUAL,		//手动,无效
				  MODE_PARAMODIFY,//参数修改
				  MODE_RUN,				//运行
				  MODE_PASSWORD,	//设置密码
				};
				
				struct G_STATUS
				{
				  //模式
				  enum MODE Mode;//参数修改模式、运行模式、测试模式、手动模式
				
				  //触摸屏状态
				  bool bTouchPressed;//当前触摸屏是否被按下,手动清除
				  uint x;//
				  uint y;//
				  bool bButtonPressed;//
				  uchar Button_id;//
				
				  //密码
				  bool bPasswordDialog;
				  uchar Password;
				  uchar PasswordCount;
				  bool bParaModifyPermitted;
				
				  //参数修改时光标的位置
				  uchar nPage;//表格页数
				  uchar Modify_Index;
				  uchar Modify_Position;
				
				  //状态量
				  uchar ItemState[140];//5*28
				  bool bUpdated_ItemState[140];//
				
				  //LED灯状态
				  uchar LED_Status;
				  bool bUpdated_LED_Status;
				
				  uchar LED_Modify_Position;//数码管编辑位置
				
				  //继电器状态
				  uchar Relay_Status1;
				  uchar Relay_Status2;
				  
				  bool bDianzheng;
				  bool bDianfan;
				  bool bTrack;
				};
				
				
				
				//extern struct STATUS xdata g_Status;
				extern struct G_STATUS xdata g_Status;
				
				//Lib Functions
				void delay_us(uint a);
				void delay_ms(uint a);
				void memset(uchar *pSrc, uchar c, uint len);
				
				
				//MODULES' FUNCTIONS
				
				/***************************SYSTEM FUNCTION****************************/
				#define INTR_ALL_ENABLE    (EA = 1)
				#define INTR_ALL_DISABLE   (EA = 0)
				#define INTR_INT0_ENABLE   (EX0 = 1)
				#define INTR_INT0_DISABLE  (EX0 = 0)
				#define INTR_INT1_ENALBE   (EX1 = 1)
				#define INTR_INT1_DISABLE  (EX1 = 0)
				#define INTR_T0_ENABLE     (ET0 = 1)
				#define INTR_T0_DISABLE    (ET0 = 0)
				#define INTR_T1_ENABLE     (ET1 = 1)
				#define INTR_T1_DISABLE    (ET1 = 0)
				#define INTR_UART_ENABLE   (ES = 1)
				#define INTR_UART_DISABLE  (ES = 0)
				/***************************SYSTEM FUNCTION END************************/
				
				/***************************TIME FUNCTION ***************************/
				void Delay(uint ms);
				void SetTimer(uint ms);
				bool TimeOut();
				/***************************TIME FUNCTION END************************/
				
				/***************************RELAY FUNCTION****************************/
				#define RELAYOUT1         *((volatile uchar xdata*)0xB000)//继电器输出1-8
				#define RELAYOUT2         *((volatile uchar xdata*)0xC000)//继电器输出9-16
				void SetRealyStatus(uchar index, bool bClosed);
				bool GetRealyStatus(uchar index);
				/***************************RELAY FUNCTION END****************************/
				
				/***************************KEY FUNCTION****************************/
				//KEY控制线
				sbit KEYA =  P1^2;
				sbit KEYF =  P1^3;
				sbit KEYH =  P3^0;
				sbit KEYK =  P3^1;
				
				#define KEYOUT          *((volatile uchar xdata*)0x9000)//按键控制输出
				
				void KEYA_DOWN();
				void KEYA_UP();
				void KEYB_DOWN();
				void KEYB_UP();
				void KEYC_DOWN();
				void KEYC_UP();
				void KEYD_DOWN();
				void KEYD_UP();
				void KEYE_DOWN();
				void KEYE_UP();
				void KEYF_DOWN();
				void KEYF_UP();
				void KEYG_DOWN();
				void KEYG_UP();
				void KEYH_DOWN();
				void KEYH_UP();
				void KEYI_DOWN();
				void KEYI_UP();
				void KEYJ_DOWN();
				void KEYJ_UP();
				void KEYK_DOWN();
				void KEYK_UP();
				void KEYL_DOWN();
				void KEYL_UP();
				void KEY_TEST1();
				void KEY_INIT();
				void KEY_RUN();
				void KEY_STOP();
				void KEY_RESET();
				void KEY_CLEAR();
				void KEY_CLEAR_ALL();
				void KEY_JIXUAN();
				void KEY_SEXUAN();
				void KEY_UP();
				void KEY_DOWN();
				void KEY_LEFT();
				void KEY_RIGHT();
				void KEY_MODE();
				/***************************KEY FUNCTION END****************************/
				
				/***************************LEDSTATUS FUNCTION**************************/
				#define LEDSTATUS_IN_ADDR           *((volatile uchar xdata*)0x8000)//底板显示数据总线输入
				sbit LEDSTATUS_A0 =  P1^0;
				sbit LEDSTATUS_A1 =  P1^1;
				sbit LEDSTATUS_A2 =  P1^4;
				sbit LEDSTATUS_A3 =  P1^5;
				
				void LEDSTATUS_INIT();
				void Update_LEDSTATUS();
				void Update_LEDPosition();
				void Update_led_status();
				/***************************LEDSTATUS FUNCTION END**********************/
				
				/***************************TOUCH FUNCTION **********************/
				#define TOH 0x46  //5ms SYSCLK is 22.1184M
				#define TOL 0xAA
				sbit DCLK   = P1^6;               //时钟信号,下降沿有效
				sbit DIN    = P3^4;               //串行数据输入
				sbit DOUT   = P3^5;               //串行数据输出
				sbit CS     = P1^7;               //片选信号,低电平有效
				sbit PENIRQ = P3^2;               //中断请求信号,低电平(负边沿)有效
				
				void TOUCH_INIT();
				bool TOUCH_IsReleased();
				void Update_TouchPoint();
				/***************************TOUCH FUNCTION END**********************/
				
				/***************************LCD FUNCTION **************************/
				#define LCD_XAdL        *((volatile uchar xdata*)0xA000)
				#define LCD_XAdH        *((volatile uchar xdata*)0xA001)
				#define LCD_YAdL        *((volatile uchar xdata*)0xA002)
				#define LCD_YAdH        *((volatile uchar xdata*)0xA003)
				#define LCD_FrontColor  *((volatile uchar xdata*)0xA004)
				#define LCD_BackColor   *((volatile uchar xdata*)0xA005)
				#define LCD_Data        *((volatile uchar xdata*)0xA006)
				#define LCD_Control     *((volatile uchar xdata*)0xA007)
				
				//定义颜色
				#define BLACK   0x00
				#define WHITE   0xff
				#define RED     0xe0
				#define GREEN   0x1c
				#define BLUE    0x03
				#define YELLOW  0xfc
				#define GRAY    0x92
				#define LIGHTGRAY
				#define PURPLE  0xe3//紫色
				#define RGB(x,y,z) ((x&0xe0) | (y&0xe0) >>3 | (z&0xc0) >> 6)
				
				//系统颜色
				#define WELCOMEUI_BORDER_COLOR	      GREEN
				#define WELCOMEUI_BK_COLOR            BLUE
				#define WELCOMEUI_TEXT_COLOR          RED
				#define MAINUI_BORDER_COLOR           GREEN
				#define MAINUI_BK_COLOR 	      RGB(176,224,230)
				#define MAINUI_TEXT_COLOR 	      RGB(80, 80, 80)
				#define BTN_UP_BORDER_COLOR 	      BLUE
				#define BTN_UP_BK_COLOR  	      YELLOW
				#define BTN_UP_TEXT_COLOR             RED
				#define BTN_DOWN_BK_COLOR             GREEN
				#define BTN_DOWN_BORDER_COLOR         BLUE
				#define BTN_DOWN_TEXT_COLOR           RED
				#define BTN_CHECK_BORDER_COLOR        RGB(192,192,192)
				#define BTN_CHECK_BK_COLOR            GREEN
				#define BTN_CHECK_TEXT_COLOR          RGB(80, 80, 80)
				#define BTN_UNCHECK_BORDER_COLOR      RGB(192,192,192)
				#define BTN_UNCHECK_BK_COLOR          RGB(128, 128, 128)
				#define BTN_UNCHECK_TEXT_COLOR        RGB(80, 80, 80)
				#define TABLE_BORDER_COLOR 	      BLUE
				#define TABLE_BK_COLOR  	      RGB(176,224,230)
				#define TABLE_TEXT_COLOR 	      BLACK
				#define ITEM_CHECK_BK_COLOR           BLUE
				#define ITEM_CHECK_BORDER_COLOR       BLUE
				#define ITEM_CHECK_TEXT_COLOR         RED
				#define ITEM_UNCHECK_BORDER_COLOR     BLUE
				#define ITEM_UNCHECK_BK_COLOR         RGB(176,224,230)
				#define ITEM_UNCHECK_TEXT_COLOR       BLACK
				#define LED_ON_COLOR 									RED
				#define LED_OFF_COLOR                 RGB(128, 128, 128)
				
				
				//BUTTON ID
				enum BUTTON_ID
				{
				  BUTTON_NULL = 0,
				  BUTTON_RUN,
				  BUTTON_STOP,
				  BUTTON_RESET,
				  BUTTON_CLEAR,
				  BUTTON_CLEAR_ALL,
				  //BUTTON_JIXUAN,
				  //BUTTON_SEXUAN,
				  BUTTON_DIANZHENG,
				  BUTTON_DIANFAN,
				  BUTTON_UP,
				  BUTTON_DOWN,
				  BUTTON_LEFT,
				  BUTTON_RIGHT,
				  BUTTON_MODE,
				  BUTTON_TRACK,
				  BUTTON_MODIFY,
				};
				
				//
				struct RECT
				{
				  uint top;
				  uint left;
				  uint right;
				  uint bottom;
				  uint cx;
				  uint cy;
				};
				
				struct BUTTON_RECT
				{
				  uint top;//
				  uint left;
				  uint cx;
				  uint cy;
				};
				
				struct TABLE_RECT
				{
				  uint top;
				  uint left;
				  uint cx1;
				  uint cx2;
				  uint cy;
				  uchar nItem;
				};
				
				void SetPixel(int x, int y, uchar color);
				void DrawHLine(int x, int y, int len, uchar width, uchar color);//画线
				void DrawVLine(int x, int y, int len, uchar width, uchar color);
				void DrawRectangle(int x, int y, int width, int height, uchar color);//画矩形
				void DrawFrame(int x, int y, int width, int height, uchar LineWidth, uchar color);//画框框
				void DrawText(int x, int y, int cxText, int cyText, uchar *pText, uchar TextColor, uchar BKColor);//画文本
				void DrawTextEx(int x, int y, int cxText, int cyText, char zoom, uchar *pText, uchar TextColor, uchar BKColor);
				void DrawIcon(int x, int y, int cx, int cy, int zoom, uchar *pIcon);
				void LCD_TEST();
				void LCD_INIT();//LCD的初始化函数
				void LCD_Clear(uchar color);//LCD清屏函数
				void LCD_WelcomeInterface();//显示欢迎界面
				void LCD_MainInterface();//显示主界面
				void LCD_ShowPasswordDialog(bool bShow);//显示或关闭密码对话框
				void LCD_ShowPassword(uchar num);//显示****
				void LCD_ShowModeStatus(uchar Status);
				void LCD_ShowTable(uchar nPage);
				void LCD_ClearTableRect(uchar color);
				void LCD_ShowStatusOrParameter(uchar index, uchar pos, uchar Text, uchar TextColor, uchar BKColor);
				uchar LCD_WhichButton(uint x, uint y);
				void LCD_ShowButton(uchar button_id, uchar TextColor, uchar BKColor, uchar BorderColor);
				/***************************LCD FUNCTION END**************************/
				
				
				#endif
				
				
				
				/*
				struct STATUS
				{
				  //模式
				  enum MODE Mode;//停止模式、参数修改模式、运行模式、测试模式、手动模式
				
				  //触摸屏状态
				  bool bTouchPressed;//当前触摸屏是否被按下,手动清除
				  uint x;//
				  uint y;//
				  bool bButtonPressed;//
				  uchar Button_id;//
				
				  //参数修改时光标的位置
				  uchar nPage;//表格页数
				  uchar LED_Modify_Position;//数码管编辑位置
				  uchar Modify_Index;
				  uchar Modify_Position;
				
				  //状态量
				  bool bUpdated;//状态量是否被更新过
				
				
				  //第一页
				  uchar COUNT_1;        //计数个位
				  bool bUpdated_COUNT_1;
				  uchar COUNT_2;        //计数十位
				  bool bUpdated_COUNT_2;
				  uchar COUNT_3;        //计数百位
				  bool bUpdated_COUNT_3;
				  uchar COUNT_4;        //计数千位
				  bool bUpdated_COUNT_4;
				  uchar COUNT_5;        //计数万位
				  bool bUpdated_COUNT_5;
				  uchar LENGTH_1;       //长度个位
				  bool bUpdated_LENGTH_1;
				  uchar LENGTH_2;       //长度十位
				  bool bUpdated_LENGTH_2;
				  uchar LENGTH_3;       //长度百位
				  bool bUpdated_LENGTH_3;
				  uchar LENGTH_4;       //长度千位
				  bool bUpdated_LENGTH_4;
				  uchar LENGTH_5;       //长度万位
				  bool bUpdated_LENGTH_5;
				  uchar SPEED;          //速度,曲线
				  bool bUpdated_SPEED;
				  uchar GEPI_1;         //个/批个位
				  bool bUpdated_GEPI_1;
				  uchar GEPI_2;         //个/批十位
				  bool bUpdated_GEPI_2;
				  bool JINGDIAN;        //静电
				  bool bUpdated_JINGDIAN;
				  bool FANGLIAO;        //放料
				  bool bUpdated_FANGLIAO;
				  bool ZHUJI;           //主机
				  bool bUpdated_ZHUJI;
				  bool ZONGJI;          //总机
				  bool bUpdated_ZONGJI;
				  //第二页
				  bool ZONGXIANG;       //纵向
				  bool bUpdated_ZONGXIANG;
				  bool HENGXIANG;       //横向
				  bool bUpdated_HENGXIANG;
				  bool SHANGLIAO;       //上料
				  bool bUpdated_SHANGLIAO;
				  bool CHONGKONG;       //冲孔
				  bool bUpdated_CHONGKONG;
				  bool REZHEN;          //热针
				  bool bUpdated_REZHEN;
				  bool JIUPIAN;         //纠偏
				  bool bUpdated_JIUPIAN;
				  uchar TIME_1;         //时间个位
				  bool bUpdated_TIME_1;
				  uchar TIME_2;         //时间十位
				  bool bUpdated_TIME_2;
				  uchar ZHOUCHANG_1;    //周长个位
				  bool bUpdated_ZHOUCHANG_1;
				  uchar ZHOUCHANG_2;    //周长十位
				  bool bUpdated_ZHOUCHANG_2;
				  uchar ZHOUCHANG_3;    //周长百位
				  bool bUpdated_ZHOUCHANG_3;
				  uchar ZHOUCHANG_4;    //周长千位
				  bool bUpdated_ZHOUCHANG_4;
				  //第三页
				  bool FANGLIAO_1;      //放料一
				  bool bUpdated_FANGLIAO_1;
				  bool FANGLIAO_2;      //放料二
				  bool bUpdated_FANGLIAO_2;
				  bool DIANRE_1;        //电热一
				  bool bUpdated_DIANRE_1;
				  bool DIANRE_2;        //电热二
				  bool bUpdated_DIANRE_2;
				  bool DIANRE_3;        //电热三
				  bool bUpdated_DIANRE_3;
				  bool DIANRE_4;        //电热四
				  bool bUpdated_DIANRE_4;
				  //第四页
				  uchar ZHUJI_SPEED_1;  //主机速度个位
				  bool bUpdated_ZHUJI_SPEED_1;
				  uchar ZHUJI_SPEED_2;  //主机速度十位
				  bool bUpdated_ZHUJI_SPEED_2;
				  uchar ZHUJI_SPEED_3;  //主机速度百位
				  bool bUpdated_ZHUJI_SPEED_3;
				  uchar ZONGXINAG_SPEED_1; //纵向速度个位
				  bool bUpdated_ZONGXINAG_SPEED_1;
				  uchar ZONGXINAG_SPEED_2; //纵向速度十位
				  bool bUpdated_ZONGXINAG_SPEED_2;
				  uchar ZONGXINAG_SPEED_3; //纵向速度百位
				  bool bUpdated_ZONGXINAG_SPEED_3;
				  uchar HENGXIANG_SPEED_1;  //横向速度个位
				  bool bUpdated_HENGXIANG_SPEED_1;
				  uchar HENGXIANG_SPEED_2;  //横向速度十位
				  bool bUpdated_HENGXIANG_SPEED_2;
				  uchar HENGXIANG_SPEED_3;  //横向速度百位
				  bool bUpdated_HENGXIANG_SPEED_3;
				  uchar CHONGKONG_SPEED_1;  //冲孔速度个位
				  bool bUpdated_CHONGKONG_SPEED_1;
				  uchar CHONGKONG_SPEED_2;  //冲孔速度十位
				  bool bUpdated_CHONGKONG_SPEED_2;
				  uchar CHONGKONG_SPEED_3;  //冲孔速度百位
				  bool bUpdated_CHONGKONG_SPEED_3;
				  uchar FANGLIAO_1_SPEED_1; //放料一速度个位
				  bool bUpdated_FANGLIAO_1_SPEED_1;
				  uchar FANGLIAO_1_SPEED_2; //放料一速度十位
				  bool bUpdated_FANGLIAO_1_SPEED_2;
				  uchar FANGLIAO_1_SPEED_3; //放料一速度百位
				  bool bUpdated_FANGLIAO_1_SPEED_3;
				  uchar FANGLIAO_2_SPEED_1; //放料二速度个位
				  bool bUpdated_FANGLIAO_2_SPEED_1;
				  uchar FANGLIAO_2_SPEED_2; //放料二速度十位
				  bool bUpdated_FANGLIAO_2_SPEED_2;
				  uchar FANGLIAO_2_SPEED_3; //放料二速度百位
				  bool bUpdated_FANGLIAO_2_SPEED_3;
				
				  //LED灯状态
				  uchar LED_Status;
				  bool bUpdated_LED_Status;
				
				  //继电器状态
				  uchar Relay_Status1;
				  bool bUpdated_Relay_Status1;
				  uchar Relay_Status2;
				  bool bUpdated_Relay_Status2;
				};*/
				
				
				
							

相关资源