-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands.c
More file actions
81 lines (74 loc) · 1.8 KB
/
Commands.c
File metadata and controls
81 lines (74 loc) · 1.8 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
#include "LED.h"
#include "Commands.h"
#include "UART.h"
#include <string.h>
#include <stdio.h>
/*
* Command functionality
* Author: Spencer Stissi
*/
// Variables
int redFlashing = 0;
int greenFlashing = 0;
// Functions
void handleInput(char* input) {
if (strcmp(input, "RON") == 0) {
Red_LED_On();
if (redFlashing == 1) {
redFlashing = 0;
}
USART_Write(USART2, (uint8_t *) "\n\rTurning red led on.\n\r", 23);
}
else if (strcmp(input, "ROFF") == 0) {
Red_LED_Off();
if (redFlashing == 1) {
redFlashing = 0;
}
USART_Write(USART2, (uint8_t *) "\n\rTurning red led off.\n\r", 24);
}
else if (strcmp(input, "GON") == 0) {
Green_LED_On();
if (greenFlashing == 1) {
greenFlashing = 0;
}
USART_Write(USART2, (uint8_t *) "\n\rTurning green led on.\n\r", 25);
}
else if (strcmp(input, "GOFF") == 0) {
Green_LED_Off();
if (greenFlashing == 1) {
greenFlashing = 0;
}
USART_Write(USART2, (uint8_t *) "\n\rTurning green led off.\n\r", 26);
}
else if (strcmp(input, "RFLASH") == 0) {
redFlashing = 1;
USART_Write(USART2, (uint8_t *) "\n\rTurning red flash on.\n\r", 25);
}
else if (strcmp(input, "GFLASH") == 0) {
greenFlashing = 1;
USART_Write(USART2, (uint8_t *) "\n\rTurning green flash on.\n\r", 27);
}
else if (strcmp(input, "FLASHOFF") == 0) {
redFlashing = 0;
greenFlashing = 0;
// Clean up incase either LED stays on
Red_LED_Off();
Green_LED_Off();
USART_Write(USART2, (uint8_t *) "\n\rTurning all flashing off.\n\r", 29);
}
else {
USART_Write(USART2, (uint8_t *) "\n\rError: invalid command!\n\r", 27);
}
}
void setRedFlash(int value) {
redFlashing = value;
}
void setGreenFlash(int value) {
greenFlashing = value;
}
int isRedFlashing() {
return redFlashing;
}
int isGreenFlashing() {
return greenFlashing;
}