-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.c
65 lines (53 loc) · 1.18 KB
/
test.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
#include <stdio.h>
#include <unistd.h>
#include "dht_api.h"
void gpio_test(int farm_fd) {
sleep(1);
motor_on(farm_fd);
led_on(farm_fd);
speaker_play(farm_fd, 500, 1911);
sleep(3);
motor_off(farm_fd);
led_off(farm_fd);
speaker_stop(farm_fd);
sleep(1);
led_on(farm_fd);
motor_on(farm_fd);
speaker_play(farm_fd, 500, 1511);
sleep(3);
led_off(farm_fd);
motor_off(farm_fd);
speaker_stop(farm_fd);
}
void light_handler(int avg) {
printf("Light Value Average: %d\n", avg);
}
int main(void) {
int farm_fd = 0;
int adcValue = 0;
int adcChannel = 1;
farm_fd = farm_open();
printf("Farm FD: %d\n", farm_fd);
SPI_SetupMode(8000000, 0);
//gpio_test(farm_fd);
// while(1) {
// struct dht_data dht;
// dht = DHT_get_data(farm_fd);
// if( dht.humidity == 0 && dht.temperature == 0 ) {
// continue;
// } else {
// printf("Humidity: %d%%, Temperature: %dC\n", dht.humidity, dht.temperature);
// sleep(1);
// }
// }
/*
while(1) {
adcValue = SPI_Read_Value(farm_fd, 0);
printf("adc0 Value = %u\n", adcValue);
}
*/
// SPI_Register_Handler(farm_fd, 0, 1, 10, light_handler);
// SPI_Set_Module(farm_fd, 0, 1, 10, light_handler, 10);
farm_close();
return 0;
}