-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
48 lines (39 loc) · 854 Bytes
/
main.c
File metadata and controls
48 lines (39 loc) · 854 Bytes
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
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include "temp.c"
#include "logfile.c"
#include "leds.c"
void loop(void);
void check_time(int);
const int LIGHT = 150;
int main()
{
setup_pins();
check_time(1);
while (1)
{
loop();
check_time(0);
}
}
void loop()
{
led_indicator(map_to_8(get_temp()));
return;
}
void check_time(int setup)
{
static time_t start_time;
if (setup)
start_time = time(NULL);
static time_t current_time;
current_time = time(NULL); // Get the current time
if (current_time - start_time >= 10)
{
printf("Temp: %.6f\n", get_temp());
write_log(get_temp(), LIGHT); // Call the task function
start_time = current_time; // Update the starting time
}
return;
}