13,24 → 13,6 |
char VER[4]=VERSION; |
char REV[50]=ID; |
|
int8 heat; |
|
#INT_RDA |
rs232_handler() |
{ |
char ch; |
|
if (getc()=='h') |
{ |
heat=0; // Need warmer |
} |
else |
{ |
heat=MAXHEAT; // Stop heating |
} |
} |
|
|
unsigned char PEC_calculation(unsigned char pec[]) // CRC calculation |
{ |
unsigned char crc[6]; |
107,7 → 89,6 |
int8 crc; // Readed CRC |
int16 temp; // Readed temperature |
|
disable_interrupts(GLOBAL); |
i2c_stop(); |
i2c_start(); |
i2c_write(addr); |
119,7 → 100,6 |
temp=MAKE16(arr[1],arr[2]); |
crc=i2c_read(0); //crc |
i2c_stop(); |
enable_interrupts(GLOBAL); |
|
arr[5]=addr; |
arr[4]=RAM_Access|select; |
134,6 → 114,7 |
{ |
unsigned int16 n, temp, tempa; |
signed int16 ta, to; |
int8 i; |
|
output_low(HEATING); // Heating off |
setup_wdt(WDT_2304MS); // Setup Watch Dog |
153,15 → 134,17 |
temp=ReadTemp(SA, RAM_Tobj1); |
|
n=0; |
heat=MAXHEAT; |
i=MAXHEAT; |
|
enable_interrupts(GLOBAL); |
enable_interrupts(INT_RDA); |
|
while(TRUE) |
{ |
n++; |
|
if (kbhit()) // Would you like warmer? |
{ |
getc(); i=0; |
} |
|
tempa=ReadTemp(SA, RAM_Tamb); // Read temperatures from sensor |
temp=ReadTemp(SA, RAM_Tobj1); |
|
176,7 → 159,7 |
ta=(signed int16)(tempa*2-27315)/100; |
|
printf("%Lu;ta:%Ld;ts:%Ld;sta:",n,ta,to); |
if (heat>=MAXHEAT) |
if (i>=MAXHEAT) |
{ |
printf("0\n\r"); |
output_low(HEATING); |
185,7 → 168,7 |
{ |
printf("1\n\r"); |
output_high(HEATING); |
heat++; |
i++; |
} |
}; |
restart_wdt(); |