-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.h.home
More file actions
81 lines (65 loc) · 1.31 KB
/
input.h.home
File metadata and controls
81 lines (65 loc) · 1.31 KB
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
76
77
78
79
80
81
#ifndef INPUT_H
jdefine INPUT_H
#define STR_MAX 4 /* assume 8 byte char so fits in a 32 bit register */
#define INPUTS_MAX 32
#include <stdbool.h>
#include "stm32f4_discovery.h"
#include "stm32f4xx_tim.h"
#include "stm32f4xx_adc.h"
#define NUM_INPUTS 7
/* defines the datastructure for the IR sensor input raw data */
typedef struct _input_types {
uint16_t data[NUM_INPUTS];
char input_name[STR_MAX];
} Input;
/* On black */
static uint16_t sensor_high[NUM_INPUTS] = {
3300,
3100,
3000,
3200,
2100,
3100,
3200
};
/* On white */
static uint16_t sensor_low[NUM_INPUTS] = {
2800,
2500,
2300,
2800,
1300,
2800,
2800
};
static uint8_t pins[NUM_INPUTS] = {
0b00000000,
0b00000001,
0b00000010,
0b00000011,
0b00000100,
0b00000101,
0b00000110
};
static uint8_t channels[NUM_INPUTS] = {
ADC_Channel_8,
ADC_Channel_9,
ADC_Channel_11,
ADC_Channel_12,
ADC_Channel_13,
ADC_Channel_14,
ADC_Channel_15
};
bool is_Input(char * state_name, Input * in);
void read_Input(Input * input);
bool is_High(Input*, uint8_t);
bool on_Line(Input*);
bool off_Line(Input * in);
bool line_Left(Input * in);
bool line_Right(Input * in);
bool on_Center_Line(Input * in);
bool left_Turn(Input * in);
bool right_Turn(Input * in);
bool is_Goal(Input * in);
bool is_Junction(Input * in);
#endif