Formula Student Electronics & Software
The code for the embedded software
All Classes Files Functions Variables Enumerations Enumerator Macros Pages
test_digitalReceiver.cpp
Go to the documentation of this file.
2#include "unity.h"
3
4#undef WHEEL_MEASUREMENT_INTERVAL_MS
5#undef WHEEL_MEASUREMENT_INTERVAL_MIN
6#undef PULSES_PER_ROTATION
7#undef ASMS_SWITCH_PIN
8#undef AATS_SWITCH_PIN
9#undef PNEUMATIC_PIN
10#undef WD_IN
11#undef LWSS_PIN
12
13#define GREEN_LED_1 4
14#define GREEN_LED_2 5
15#define GREEN_LED_3 6
16#define RED_LED_1 0
17#define RED_LED_2 1
18#define YELLOW_LED_1 2
19#define YELLOW_LED_2 3
20#define BUTTON_1 7
21#define BUTTON_2 8
22#define BUTTON_3 9
23#define BUTTON_4 10
24#define BUTTON_5 11
25#define BUTTON_6 12
26
27#define ASMS_IN_PIN BUTTON_1
28#define SDC_STATE_PIN BUTTON_2
29#define SDC_LOGIC_WATCHDOG_IN_PIN BUTTON_3
30#define SENSOR_PRESSURE_1_PIN BUTTON_4
31#define SENSOR_PRESSURE_2_PIN BUTTON_5
32#define LWSS_PIN BUTTON_6
33
34#define WHEEL_MEASUREMENT_INTERVAL_MS 1000 // clicks measured every second
35#define WHEEL_MEASUREMENT_INTERVAL_MIN (WHEEL_MEASUREMENT_INTERVAL_MS / 60000.0)
36#define PULSES_PER_ROTATION 60 // 60 pulses per rotation - if 1 pulse/click per sec will give 1 rpm
37// Constants defined to meassure number of clicks in 1s as rpm
38
40#include "model/systemData.hpp"
41
42
45
46
64// void test_lwss() {
65// Metro test{10000};
66// bool one_rpm = false, two_rpm = false, three_rpm = false, test_pass = false;
67// systemData.digitalData._left_wheel_rpm = 0;
68// while (!test.check() && !test_pass) {
69// digitalRecv.digitalReads();
70// if (systemData.digitalData._left_wheel_rpm > 2) {
71// three_rpm = true;
72// digitalWrite(GREEN_LED_3, HIGH);
73// } else {
74// digitalWrite(GREEN_LED_3, LOW);
75// }
76
77// if (systemData.digitalData._left_wheel_rpm > 1) {
78// two_rpm = true;
79// digitalWrite(GREEN_LED_2, HIGH);
80// } else {
81// digitalWrite(GREEN_LED_2, LOW);
82// }
83
84// if (systemData.digitalData._left_wheel_rpm > 0) {
85// one_rpm = true;
86// digitalWrite(GREEN_LED_1, HIGH);
87// } else {
88// digitalWrite(GREEN_LED_1, LOW);
89// }
90
91// test_pass = one_rpm && two_rpm && three_rpm;
92// }
93// TEST_ASSERT_TRUE(test_pass);
94// }
95
96void setUp() {
97 pinMode(GREEN_LED_1, OUTPUT);
98 pinMode(GREEN_LED_2, OUTPUT);
99 pinMode(GREEN_LED_3, OUTPUT);
100 pinMode(YELLOW_LED_1, OUTPUT);
101 pinMode(YELLOW_LED_2, OUTPUT);
102 pinMode(RED_LED_1, OUTPUT);
103 pinMode(RED_LED_2, OUTPUT);
104}
105
106int main() {
107 UNITY_BEGIN();
108 // RUN_TEST(test_lwss);
109 return UNITY_END();
110}
Class responsible for the reading of the digital inputs into the Master teensy.
The whole model of the system: holds all the data necessary.
DigitalData digitalData
Mission mission
#define RED_LED_2
#define GREEN_LED_1
#define YELLOW_LED_1
#define RED_LED_1
void setUp()
Test the Left Wheel Speed Sensor Check the Left wheel Speed Sensor is being well calculated PROTOCOL:
#define YELLOW_LED_2
auto digitalRecv
#define GREEN_LED_2
SystemData systemData
#define GREEN_LED_3