forked from WiseLord/ampcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.c
76 lines (56 loc) · 1.02 KB
/
temp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "temp.h"
#include <avr/eeprom.h>
#include "eeprom.h"
#include "input.h"
static int8_t tempTH;
void loadTempParams(void)
{
tempTH = eeprom_read_byte((uint8_t*)EEPROM_TEMP_TH);
return;
}
void saveTempParams(void)
{
eeprom_update_byte((uint8_t*)EEPROM_TEMP_TH, tempTH);
return;
}
void tempInit(void)
{
DDR(FAN1) |= FAN1_WIRE;
DDR(FAN2) |= FAN2_WIRE;
PORT(FAN1) &= ~FAN1_WIRE;
PORT(FAN2) &= ~FAN2_WIRE;
return;
}
void tempControlProcess(void)
{
int8_t temp1, temp2;
temp1 = ds18x20GetTemp(0) / 10;
temp2 = ds18x20GetTemp(1) / 10;
if (temp1 >= tempTH)
PORT(FAN1) |= FAN1_WIRE;
else if (temp1 <= tempTH - 5)
PORT(FAN1) &= ~FAN1_WIRE;
if (temp2 >= tempTH)
PORT(FAN2) |= FAN2_WIRE;
else if (temp2 <= tempTH - 5)
PORT(FAN2) &= ~FAN2_WIRE;
return;
}
void setTempTH(int8_t temp)
{
temp = temp;
return;
}
int8_t getTempTH(void)
{
return tempTH;
}
void changeTempTH(int8_t diff)
{
tempTH += diff;
if (tempTH > MAX_TEMP)
tempTH = MAX_TEMP;
if (tempTH < MIN_TEMP)
tempTH = MIN_TEMP;
return;
}