📄 main.h
字号:
#define Byte unsigned char
#define Word unsigned int
#define Long unsigned long int
#define AD10 1
#define BH 1
#define WENDU 1
#define QYSJ 7
#define CYSJ 3
#define CZSJ 3600
#define CCZSJ 25
#define QPSJ 7
#define CPSJ 3
#define QDSJ 25 //启动时间
// status 状态 // posi X
#define STOP 0
#define WORK 1
#define SETUP 2 // X=0,1,2,3 电压 频率 功率1.2
#define MIMA 3 // X=0-5 位置
#define SN 8
#define TOTAL 0x82
#define CUR 0x81 //0x82-总时间 0x81-单时间 0x60-温度电压
#define OTHER 0x60
#define ADDYTIMES 8 //与采样有关,修改请注意 8/2 12/4
#define ADDLTIMES 15
#define ADDMIMAE 0x10 // 密码有效位
#define ADDMIMA 0x11 // 密码 11 12 13 14 15 16 序列号 17 18 19 1a 1b 1c 1d 1e 1f 20
#define ADDDY 0x30
#define ADDPL 0x31
#define ADDGL 0x32
//总时间 10分的地址一年一变
#define ADDMINUTEP 0x40 // 10分数的位置
#define ADDHOUR 0x41 // 0x40 0x41 0x42 0x43
#define ADDHOUR1 0x42 // 0x40 0x41 0x42 0x43
#define ADDHOUR2 0x43 // 0x40 0x41 0x42 0x43
#define ADDMINUTE 0x44 //
#define ADDCLEA 0x50 // 可清totaltime次数
#define ADDLUM 0x51 // 亮度
Word lum; // 亮度
Byte cleatime;
#define WDR PORTC^=0x04
const Byte weina[]=" Weinatronics ";
Byte mima[17]; //密码是否有效 及 密码 序列号
Byte mimainp[7]; //密码输入值
Byte status; //状态 正常工作 设置 主动解密 被动输密码
Byte posi; //设置或密码输入位置
Byte adm; //AD通道切换后第一次数据丢掉
Word advalue; //AD结果
Byte adc; //AD转换一次
Byte curadch; //AD通道
Byte lastch; //上次AD通道
#if AD10
Word maxv;
Word minv;
Word v;
Word maxdy; //AD采样最大电压
Word mindy; //AD采样最小电压
Word maxdl; //AD采样最大电流
Word mindl; //AD采样最小电流
#else
Word maxv;
Word minv;
Word v;
Byte maxdy; //AD采样最大电压
Byte mindy; //AD采样最小电压
Byte maxdl; //AD采样最大电流
Byte mindl; //AD采样最小电流
#endif
Byte key; //按键
Byte time; //定时一次 //volatile Byte time;
Byte minuteadd; //当前记10分的EEPROM位置
Byte hour; //时
Byte minute; //分
Byte cminute; //当前分
Byte second; //秒
Byte count; //计数
Byte first; //频率采样记数
Byte setdy;
const Byte setdy_code[]={110,115,120,130,220,230,240};
Byte setgl;
Word mpl; //设置频率值
Word mdy; //设置电压值
Word mdl; //设置电流值
Word maxmpl; //设置频率值最大
Word maxmdy; //设置电压值最大
Word maxmdl; //设置电流值最大
Word minmpl; //设置频率值最小
Word minmdy; //设置电压值最小
Word minmdl; //设置电流值最小
Byte plerror; //频率保护 >max 1 <min 2
Byte dyerror; //电压保护 >max 1 <min 2
Byte dlerror; //电流保护 >max 1 <min 2
signed char plerrt; //频率保护时间 s
signed char dyerrt; //电压保护时间 s
Word dlerrt; //电流保护时间 s
Word bhdy; //保护电压
Word bhdl; //保护电流
Word bhpl; //保护频率
Byte ssecond; //启动时间s <25s 欠压 欠频允许
Byte cf; //采样标记 标记是否采样
Word dy; //电压
Word dl; //电流
Word dydlt; //临时电压电流
Long dlt;
Word dlc;
#if PJ
Word dlvt[6];
Byte dlp;
#endif
Byte pltc; //频率时间记数
Byte pltcr; //频率时间记数
Byte pt2; //记录TCNT2
Byte lastpt2; //记录上次TCNT2
Byte plcount; //频率采样为0的处理 定时记数
Word temppl; //频率计算临时数据
Word pl; //频率
Word curpl; //中断中计算的频率
Word gl; //功率
Byte totalt[3]; //总时间
Byte curt[3]; //本次运行时间
Byte wendu; //温度
Word cddy; //充电电压*100
Byte disnum[18]; //显示的各个数字(17) +8个指示灯(1)
Word cddyp;
Byte cddyt;
const Byte seleLed_buffer[3]={CUR,TOTAL,OTHER};
Byte seleLedv;
Byte seleLed=0x81; //0x81-总时间 0x82-单时间 0x60-温度电压
Byte runLed=0x10; //运行指示
Byte oilLed=0x00; //无机油指示
Byte chaLed=0x00; //蓄电池充电故障指示
Byte startcount; //start按下记数
Byte startkey; //start按下
Byte iftest; //调试模式
Byte t;
void SPI_MasterTransmit(char cData);
void ioinit (void);
void parainit(void);
void Detect(void);
void Stop(void);
void Set_AD();
void My_EEPROM_write(Byte uiAddress, Byte ucData);
Byte MY_EEPROM_read(Byte uiAddress);
void Show(void);
void GetD3(Byte * dv,Word temp);
void GetD2(Byte * dv,Byte temp);
Word Getdl();
void Getgl(void);
void testdy(void);
void testdl(void);
//const Byte display_code[]={~0xbd,~0x0c,~0x75,~0x5d,~0xcc,~0xd9,~0xf9,~0x0d,~0xfd,~0xdd,~0x00,~0x40}; //高-亮
// 0xed,0xf8,0xb1,0x76,0xf1,0xe1,0xff,0xbf}; //低-亮
const Byte display_code[]={0x42,0xf3,0x8a,0xa2,0x33,0x26,0x06,0xf2,0x02,0x22,\
// 0 1 2 3 4 5 6 7 8 9
0x12,0x07,0x4e,0x89,0x0e,0x1e,0xff,0xbf}; //低-亮
// A b C d E F 空格 -
#define BLANK 16
#define NEG 17
#if WENDU
Byte temp_error; //错误标志 0正确 1错误
signed int temp_c; //温度
signed int lasttemp_c; //上一次温度
#define ds18b20_dq PB0
#define set_ds18b20_dq_ddr() DDRB|=1<<ds18b20_dq
#define set_ds18b20_dq() PORTB|=1<<ds18b20_dq
#define clr_ds18b20_dq() PORTB&=~(1<<ds18b20_dq)
#define clr_ds18b20_dq_ddr() DDRB&=~(1<<ds18b20_dq)
#define in_ds18b20_dq() PINB&(1<<ds18b20_dq)
#define ds18b20_read_rom 0x33
#define ds18b20_match_rom 0x55
#define ds18b20_skip_rom 0xcc
#define ds18b20_search_rom 0xf0
#define ds18b20_alarm_search_rom 0xec
#define ds18b20_write_ram 0x4e
#define ds18b20_read_ram 0xbe
#define ds18b20_copy_ram 0x48
#define ds18b20_convert_tem 0x44
#define ds18b20_eecall_eeprom 0xb8
#define ds18b20_read_power_supply 0xb4
void reset_ds18b20(void);
Byte read_ds18b20(void);
void write_ds18b20(Byte data);
void read_temperature(void);
void ack_ds18b20(void);
void convert_ds18b20(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -