📄 ftc1.c
字号:
PORTB = ledvm;
//PORTCbits.RC5 = 1;
PORTC = 0B01001010; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
for (counter1 = 1; counter1 <= 6; counter1++)
{
PORTB = ledvm; //mode led display
PORTC = 0B00001111; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB2 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B00001010;
PORTBbits.RB1 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B01101000;
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
for (counter1 = 1; counter1 <= 6; counter1++)
{
PORTB = ledvm; //mode led display
PORTC = 0B00001111;
PORTBbits.RB2 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B00001000; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB1 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B01101010;
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
for (counter1 = 1; counter1 <= 6; counter1++)
{
PORTB = ledvm; //mode led display
PORTC = 0B00001101;
PORTBbits.RB2 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B00001010;
PORTBbits.RB1 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B01100010; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
for (counter1 = 1; counter1 <= 6; counter1++)
{
PORTB = ledvm; //mode led display
PORTC = 0B00001110;
PORTBbits.RB2 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B00001010;
PORTBbits.RB1 = 1;
Delay100TCYx(20);
PORTB = ledvm;
//PORTCbits.RC6 = 1;
PORTC = 0B01101010; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
for (counter1 = 1; counter1 <= 6; counter1++)
{
PORTB = ledvm; //mode led display
PORTC = 0B00001011;
PORTBbits.RB2 = 1;
Delay100TCYx(20);
PORTB = ledvm;
PORTC = 0B00001010;
PORTBbits.RB1 = 1;
Delay100TCYx(20);
PORTB = ledvm;
//PORTCbits.RC5 = 1;
PORTC = 0B01101010; //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
PORTBbits.RB0 = 1;
Delay100TCYx(20);
}
}
//**************************** Change Water LED Display *************************
unsigned int LED_CW_DIS(int ledvs1, int ledvs2, int cwovs1, int cwovs2, int d)
{
int j,h;
PORTC = 0;
Delay1KTCYx(250);
VVAL_PRE(CWOV);
LED_PRE(T100, T10, T1);
LEDVD = LEDVD + ledvs2;
LEDVS = ledvs1;
for (h = 0; h <= 10; h++)
{ for (j = 0; j <= 20; j++)
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
PORTB = 0;
PORTC = 0;
Delay1KTCYx(100);
if (SET == 0)
{ Delay100TCYx(50);
if (SET == 0)
{ CWOV = CWOV + d;
if (CWOV == cwovs1)
{ TX = 3;
T100 = 13;
T10 = 14;
T1 = 14;}
if (CWOV > cwovs1)
{ CWOV = cwovs2;
VVAL_PRE(CWOV);}
if (CWOV < cwovs1)
VVAL_PRE(CWOV);
LED_PRE(T100, T10, T1);
if (CWOV != cwovs1)
LEDVD = LEDVD + ledvs2;
LEDVS = ledvs1;
h = 0;
}
}
}
}
//******************************** LED Display *************************
unsigned int LED_F_DIS(int fla)
{
int j,h;
PORTC = 0;
Delay1KTCYx(250);
for (h = 0; h < fla; h++)
{ for (j = 0; j <= 50; j++)
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
PORTC = 0;
Delay1KTCYx(200);
}
}
//******************************** Main process *************************
void main (void)
{
int j, h;
cobit.wat = 0;
cobit.oil = 1;
cobit.vol = 1;
cobit.setn = 0;
cobit.sets = 0;
cobit.modn = 0;
cobit.mods = 0;
initial ( );
initialIO ( );
initialAD ( );
ADCON0 = 0B10000001;
for (j=50; j > 0;--j)
;
ADCON0bits.GO = 1;
while (1)
{
if ( ADCON0bits.GO == 0)
break;
}
Wait_ACC:
PORTA = 0;
PORTB = 0;
PORTC = 0;
while (1)
{
if (ACC == 0)
{
Delay100TCYx(100);
if (ACC == 0)
{
break;
}
}
}
LEDVS = 0;
for (counter = 0; counter <= 4; counter++)
LED_IN_DIS (LEDVS);
VVAL_PRE(WTSV);
LED_PRE(T100, T10, T1);
LEDVS = 0X20;
for (counter = 0; counter <= 100; counter++)
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
VVAL_PRE(OTSV);
LED_PRE(T100, T10, T1);
LEDVS = 0X10;
for (counter = 0; counter <= 100; counter++)
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
VVAL_PRE(VSV);
LED_PRE(T100, T10, T1);
LEDVD = LEDVD + 0X10;
LEDVS = 0X08;
for (counter = 0; counter <= 100; counter++)
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
while (1)
{
com_out:
LEDVS = 0X20;
ADC0 = 0B00000101;
for (h = 0; h < 4; h++)
{
AD_PRE (ADC0);
TEM_PRE(ADRESH, ADRESL);
K[h] = DWO;
}
DWOF = (float) (K[0] + K[1] + K[2] + K[3]) / 4 + 0.5;
// + K[4] + K[5])/6 + 0.5;
// + K[6] + K[7] + K[8] + K[9])/10 + 0.5;
//DWOF = (float) (K[0] + K[1] + K[2])/3 + 0.5;
DWO = (int) DWOF;
if (DWO >= WTSV)
FAN = 1;
if (WTSV == 102 || DWO == 152 || DWO < WTSV)
FAN = 0;
if ( cobit.wat == 0)
{
TVAL_PRE(DWO);
LED_PRE(T100, T10, T1);
for (counter = 0; counter <= 100; counter++)
{
COM( );
if (cobit.modn == 0 && cobit.setn ==0)
{ if (cobit.mods == 1 && cobit.sets == 0)
_asm goto wat_chstate _endasm
if (cobit.mods == 1 && cobit.sets == 1)
_asm goto wat_chmet _endasm
if (cobit.mods == 0 && cobit.sets == 1)
_asm goto wat_change _endasm
}
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
}
if (WTSV != 102 && DWO != 152 && DWO >= WTSV)
{ //PORTB = 0;
PORTC = 0;
Delay10KTCYx(100);}
}
if ( cobit.oil == 0)
{
LEDVS = 0X10;
ADC0 = 0B00001001;
for (h = 0; h < 4; h++)
{
AD_PRE (ADC0);
TEM_PRE(ADRESH, ADRESL);
K[h] = DWO;
}
DWOF = (float) (K[0] + K[1] + K[2] + K[3])/4 + 0.5;
// + K[4] + K[5])/6 + 0.5;
// + K[6] + K[7] + K[8] + K[9])/10 + 0.5;
//DWOF = (float) (K[0] + K[1] + K[2])/3 + 0.5;
DWO = (int) DWOF;
TVAL_PRE(DWO);
LED_PRE(T100, T10, T1);
for (counter = 0; counter <= 100; counter++)
{
COM( );
if (cobit.modn == 0 && cobit.setn ==0)
{ if (cobit.mods == 1 && cobit.sets == 0)
_asm goto oil_chstate _endasm
if (cobit.mods == 1 && cobit.sets == 1)
_asm goto oil_chmet _endasm
if (cobit.mods == 0 && cobit.sets == 1)
_asm goto oil_change _endasm
}
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
}
if (OTSV != 152 && DWO != 152 && DWO >= OTSV)
{ //PORTB = 0;
PORTC = 0;
Delay10KTCYx(100);}
}
if ( cobit.vol == 0)
{
LEDVS = 0X08;
ADC0 = 0B00000001;
AD_PRE (ADC0);
V_PRE(ADRESH, ADRESL);
LED_PRE(T100, T10, T1);
if ( DV < 271 && DV > 69)
LEDVD = LEDVD + 0X10;
for (counter = 0; counter <= 100; counter++)
{
COM( );
if (cobit.modn == 0 && cobit.setn ==0)
{ if (cobit.mods == 1 && cobit.sets == 0)
_asm goto vol_chstate _endasm
if (cobit.mods == 1 && cobit.sets == 1)
_asm goto vol_chmet _endasm
if (cobit.mods == 0 && cobit.sets == 1)
_asm goto vol_change _endasm
}
LED_DIS(LEDVS, TX, LEDVH, LEDVD, LEDVE); //Call LED display
}
if (VSV != 136 && DV <= VSV)
{ //PORTB = 0;
PORTC = 0;
Delay10KTCYx(20);}
}
_asm goto com_acc _endasm
wat_chstate: //(cobit.mods == 1 && cobit.sets == 0)//
cobit.mods = 0;
LED_F_DIS(3);
cobit.wat = 1;
cobit.oil = 0;
cobit.vol = 1;
_asm goto com_acc _endasm
wat_chmet: //(cobit.mods == 1 && cobit.sets == 1)//
cobit.mods = 0;
cobit.sets = 0;
LED_F_DIS(3);
if (cobit.wat == 0 && cobit.oil == 0)
{ cobit.oil = 1;
cobit.vol = 1;
_asm goto com_acc _endasm}
cobit.wat = 0;
cobit.oil = 0;
cobit.vol = 1;
_asm goto com_acc _endasm
wat_change: //(cobit.mods == 0 && cobit.sets == 1)//
cobit.sets = 0;
CWOV = WTSV;
LED_CW_DIS(0X20, 0X00, 102, 60, 2); //70, 2);
WTSV = CWOV;
_asm goto com_acc _endasm
//*************************************************************************
oil_chstate: //(cobit.mods == 1 && cobit.sets == 0)//
cobit.mods = 0;
LED_F_DIS(3);
cobit.wat = 1;
cobit.oil = 1;
cobit.vol = 0;
_asm goto com_acc _endasm
oil_chmet: //(cobit.mods == 1 && cobit.sets == 1)//
cobit.mods = 0;
cobit.sets = 0;
LED_F_DIS(3);
if (cobit.wat == 0 && cobit.oil == 0)
{ cobit.wat = 1;
cobit.vol = 1;
_asm goto com_acc _endasm}
cobit.wat = 0;
cobit.oil = 0;
cobit.vol = 1;
_asm goto com_acc _endasm
oil_change: //(cobit.mods == 0 && cobit.sets == 1)//
cobit.sets = 0;
CWOV = OTSV;
LED_CW_DIS(0X10, 0X00, 152, 80, 2);
OTSV = CWOV;
_asm goto com_acc _endasm
//*********************************************************************
vol_chstate: //(cobit.mods == 1 && cobit.sets == 0)//
cobit.mods = 0;
LED_F_DIS(3);
cobit.wat = 0;
cobit.oil = 1;
cobit.vol = 1;
_asm goto com_acc _endasm
vol_chmet: //(cobit.mods == 1 && cobit.sets == 1)//
cobit.mods = 0;
cobit.sets = 0;
LED_F_DIS(3);
//if (cobit.wat == 0 && cobit.oil == 0)
//{ cobit.wat = 1;
// cobit.oil = 1;
// _asm goto com_acc _endasm}
cobit.wat = 0;
cobit.oil = 0;
cobit.vol = 1;
_asm goto com_acc _endasm
vol_change: //(cobit.mods == 0 && cobit.sets == 1)//
cobit.sets = 0;
CWOV = VSV;
LED_CW_DIS(0X08, 0X10, 136, 80, 1);
VSV = CWOV;
_asm goto com_acc _endasm
com_acc:
if (ACC == 1)
{
Delay100TCYx(50);
if (ACC == 1)
break;
}
}
_asm goto Wait_ACC _endasm
}
/* if (cobit.mods == 1)
{ cobit.mods = 0;
COM( );
if (cobit.sets == 1)
{ cobit.sets = 0;
cobit.wat = 0;
}
_asm goto com_out _endasm
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -