1 | #include "main.h" |
---|
2 | #include "leds.h" |
---|
3 | |
---|
4 | unsigned int onTimeCounterGN; |
---|
5 | unsigned int offTimeCounterGN; |
---|
6 | unsigned int onTimeGN; |
---|
7 | unsigned int offTimeGN; |
---|
8 | unsigned int blinkModeGN; |
---|
9 | |
---|
10 | |
---|
11 | unsigned int onTimeCounterRT; |
---|
12 | unsigned int offTimeCounterRT; |
---|
13 | unsigned int onTimeRT; |
---|
14 | unsigned int offTimeRT; |
---|
15 | unsigned int blinkModeRT; |
---|
16 | |
---|
17 | void LEDS_Exec(void) |
---|
18 | { |
---|
19 | |
---|
20 | if (onTimeCounterGN > 0) |
---|
21 | { |
---|
22 | onTimeCounterGN--; |
---|
23 | if (onTimeCounterGN == 0) |
---|
24 | { |
---|
25 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_RESET); |
---|
26 | |
---|
27 | if (blinkModeGN == 1) offTimeCounterGN = offTimeGN; |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | if (offTimeCounterGN > 0) |
---|
32 | { |
---|
33 | offTimeCounterGN--; |
---|
34 | if (offTimeCounterGN == 0) |
---|
35 | { |
---|
36 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); |
---|
37 | onTimeCounterGN = onTimeGN; |
---|
38 | } |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | // --- LED ROT --- |
---|
43 | if (onTimeCounterRT > 0) |
---|
44 | { |
---|
45 | onTimeCounterRT--; |
---|
46 | if (onTimeCounterRT == 0) |
---|
47 | { |
---|
48 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_RESET); |
---|
49 | |
---|
50 | if (blinkModeRT == 1) offTimeCounterRT = offTimeRT; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | if (offTimeCounterRT > 0) |
---|
55 | { |
---|
56 | offTimeCounterRT--; |
---|
57 | if (offTimeCounterRT == 0) |
---|
58 | { |
---|
59 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); |
---|
60 | onTimeCounterRT = onTimeRT; |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | // --- Steuerfunktionen LED grün ------------ |
---|
66 | void LEDS_GN_On(void) |
---|
67 | { |
---|
68 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); |
---|
69 | |
---|
70 | blinkModeGN = 0; // Blinkmode zurücksetzen, falls es eingeschaltet war |
---|
71 | onTimeCounterGN = 0; |
---|
72 | offTimeCounterGN = 0; |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | void LEDS_GN_Flash(unsigned int time) |
---|
78 | { |
---|
79 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); |
---|
80 | onTimeCounterGN = time; |
---|
81 | } |
---|
82 | |
---|
83 | void LEDS_GN_Blink_Start(unsigned int on, unsigned int off ) |
---|
84 | { |
---|
85 | onTimeGN = on; |
---|
86 | offTimeGN = off; |
---|
87 | blinkModeGN = 1; |
---|
88 | |
---|
89 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); |
---|
90 | onTimeCounterGN = on; |
---|
91 | } |
---|
92 | |
---|
93 | void LEDS_GN_Off(void) |
---|
94 | { |
---|
95 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_RESET); |
---|
96 | blinkModeGN = 0; |
---|
97 | offTimeCounterGN = 0; |
---|
98 | onTimeCounterGN = 0; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | // --- Steuerfunktionen LED rot ------------ |
---|
104 | void LEDS_RT_On(void) |
---|
105 | { |
---|
106 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); |
---|
107 | |
---|
108 | blinkModeRT = 0; // Blinkmode zurücksetzen, falls es eingeschaltet war |
---|
109 | onTimeCounterRT = 0; |
---|
110 | offTimeCounterRT = 0; |
---|
111 | } |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | void LEDS_RT_Flash(unsigned int time) |
---|
116 | { |
---|
117 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); |
---|
118 | onTimeCounterRT = time; |
---|
119 | } |
---|
120 | |
---|
121 | void LEDS_RT_Blink_Start(unsigned int on, unsigned int off ) |
---|
122 | { |
---|
123 | onTimeRT = on; |
---|
124 | offTimeRT = off; |
---|
125 | blinkModeRT = 1; |
---|
126 | |
---|
127 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); |
---|
128 | onTimeCounterRT = on; |
---|
129 | } |
---|
130 | |
---|
131 | void LEDS_RT_Off(void) |
---|
132 | { |
---|
133 | HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_RESET); |
---|
134 | blinkModeRT = 0; |
---|
135 | offTimeCounterRT = 0; |
---|
136 | onTimeCounterRT = 0; |
---|
137 | } |
---|