| [17] | 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 | unsigned int numberOfBlinks; | 
|---|
 | 17 | unsigned int pauseTime; | 
|---|
 | 18 | unsigned int blinkCounter; | 
|---|
 | 19 |  | 
|---|
 | 20 | void LEDS_Exec(void) | 
|---|
 | 21 | { | 
|---|
 | 22 |  | 
|---|
 | 23 |   if (onTimeCounterGN > 0) | 
|---|
 | 24 |   { | 
|---|
 | 25 |     onTimeCounterGN--; | 
|---|
 | 26 |     if (onTimeCounterGN == 0) | 
|---|
 | 27 |     { | 
|---|
 | 28 |       HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_RESET); | 
|---|
 | 29 |  | 
|---|
 | 30 |       if (blinkModeGN == 1) offTimeCounterGN = offTimeGN; | 
|---|
 | 31 |     } | 
|---|
 | 32 |   } | 
|---|
 | 33 |  | 
|---|
 | 34 |   if (offTimeCounterGN > 0) | 
|---|
 | 35 |   { | 
|---|
 | 36 |     offTimeCounterGN--; | 
|---|
 | 37 |     if (offTimeCounterGN == 0) | 
|---|
 | 38 |     { | 
|---|
 | 39 |       HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); | 
|---|
 | 40 |       onTimeCounterGN = onTimeGN; | 
|---|
 | 41 |     } | 
|---|
 | 42 |   } | 
|---|
 | 43 |  | 
|---|
 | 44 |  | 
|---|
 | 45 |   // --- LED ROT --- | 
|---|
 | 46 |   if (onTimeCounterRT > 0) | 
|---|
 | 47 |   { | 
|---|
 | 48 |     onTimeCounterRT--; | 
|---|
 | 49 |     if (onTimeCounterRT == 0) | 
|---|
 | 50 |     { | 
|---|
 | 51 |       HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_RESET); | 
|---|
 | 52 |       if (blinkModeRT == 1) offTimeCounterRT = offTimeRT; | 
|---|
 | 53 |  | 
|---|
 | 54 |           if (blinkCounter > 0) | 
|---|
 | 55 |           { | 
|---|
 | 56 |                 blinkCounter--; | 
|---|
 | 57 |           } | 
|---|
 | 58 |     } | 
|---|
 | 59 |   } | 
|---|
 | 60 |  | 
|---|
 | 61 |  | 
|---|
 | 62 |   if(blinkCounter == 0) | 
|---|
 | 63 |   { | 
|---|
 | 64 |         //Blink code wurde angezeigt, jetzt eine lange Pause | 
|---|
 | 65 |         offTimeCounterRT = pauseTime; | 
|---|
 | 66 |         blinkCounter = numberOfBlinks; | 
|---|
 | 67 |   } | 
|---|
 | 68 |  | 
|---|
 | 69 |  | 
|---|
 | 70 |   if (offTimeCounterRT > 0) | 
|---|
 | 71 |   { | 
|---|
 | 72 |     offTimeCounterRT--; | 
|---|
 | 73 |     if (offTimeCounterRT == 0) | 
|---|
 | 74 |     { | 
|---|
 | 75 |       HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); | 
|---|
 | 76 |       onTimeCounterRT = onTimeRT; | 
|---|
 | 77 |     } | 
|---|
 | 78 |   } | 
|---|
 | 79 | } | 
|---|
 | 80 |  | 
|---|
 | 81 | // --- Steuerfunktionen LED grün ------------ | 
|---|
 | 82 | void LEDS_GN_On(void) | 
|---|
 | 83 | { | 
|---|
 | 84 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); | 
|---|
 | 85 |  | 
|---|
 | 86 |   blinkModeGN = 0; // Blinkmode zurücksetzen, falls es eingeschaltet war | 
|---|
 | 87 |   onTimeCounterGN = 0; | 
|---|
 | 88 |   offTimeCounterGN = 0; | 
|---|
 | 89 | } | 
|---|
 | 90 |  | 
|---|
 | 91 |  | 
|---|
 | 92 |  | 
|---|
 | 93 | void LEDS_GN_Flash(unsigned int time) | 
|---|
 | 94 | { | 
|---|
 | 95 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); | 
|---|
 | 96 |   onTimeCounterGN = time; | 
|---|
 | 97 | } | 
|---|
 | 98 |  | 
|---|
 | 99 | void LEDS_GN_Blink_Start(unsigned int on, unsigned int off ) | 
|---|
 | 100 | { | 
|---|
 | 101 |   onTimeGN = on; | 
|---|
 | 102 |   offTimeGN = off; | 
|---|
 | 103 |   blinkModeGN = 1; | 
|---|
 | 104 |  | 
|---|
 | 105 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_SET); | 
|---|
 | 106 |   onTimeCounterGN = on; | 
|---|
 | 107 | } | 
|---|
 | 108 |  | 
|---|
 | 109 | void LEDS_GN_Off(void) | 
|---|
 | 110 | { | 
|---|
 | 111 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ON_GPIO_Port, GPIO_OUTPUT_LED_ON_Pin, GPIO_PIN_RESET); | 
|---|
 | 112 |   blinkModeGN = 0; | 
|---|
 | 113 |   offTimeCounterGN = 0; | 
|---|
 | 114 |   onTimeCounterGN = 0; | 
|---|
 | 115 | } | 
|---|
 | 116 |  | 
|---|
 | 117 |  | 
|---|
 | 118 |  | 
|---|
 | 119 | // --- Steuerfunktionen LED rot ------------ | 
|---|
 | 120 | void LEDS_RT_On(void) | 
|---|
 | 121 | { | 
|---|
 | 122 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); | 
|---|
 | 123 |  | 
|---|
 | 124 |   blinkModeRT = 0; // Blinkmode zurücksetzen, falls es eingeschaltet war | 
|---|
 | 125 |   onTimeCounterRT = 0; | 
|---|
 | 126 |   offTimeCounterRT = 0; | 
|---|
 | 127 | } | 
|---|
 | 128 |  | 
|---|
 | 129 |  | 
|---|
 | 130 |  | 
|---|
 | 131 | void LEDS_RT_Flash(unsigned int time) | 
|---|
 | 132 | { | 
|---|
 | 133 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); | 
|---|
 | 134 |   onTimeCounterRT = time; | 
|---|
 | 135 | } | 
|---|
 | 136 |  | 
|---|
 | 137 | void LEDS_RT_Blink_Start(unsigned int on, unsigned int off ) | 
|---|
 | 138 | { | 
|---|
 | 139 |   onTimeRT = on; | 
|---|
 | 140 |   offTimeRT = off; | 
|---|
 | 141 |   blinkModeRT = 1; | 
|---|
 | 142 |   pauseTime = off; | 
|---|
 | 143 |  | 
|---|
 | 144 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); | 
|---|
 | 145 |   onTimeCounterRT = on; | 
|---|
 | 146 | } | 
|---|
 | 147 |  | 
|---|
 | 148 |  | 
|---|
 | 149 | void LEDS_RT_BlinkCode_Start(unsigned int blinks, unsigned int on, unsigned int off, unsigned int pause ) | 
|---|
 | 150 | { | 
|---|
 | 151 |   onTimeRT = on; | 
|---|
 | 152 |   offTimeRT = off; | 
|---|
 | 153 |   blinkModeRT = 1; | 
|---|
 | 154 |   numberOfBlinks = blinks; | 
|---|
 | 155 |   blinkCounter = blinks; | 
|---|
 | 156 |   pauseTime = pause; | 
|---|
 | 157 |  | 
|---|
 | 158 |  | 
|---|
 | 159 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_SET); | 
|---|
 | 160 |   onTimeCounterRT = on; | 
|---|
 | 161 | } | 
|---|
 | 162 |  | 
|---|
 | 163 |  | 
|---|
 | 164 | void LEDS_RT_Off(void) | 
|---|
 | 165 | { | 
|---|
 | 166 |   HAL_GPIO_WritePin(GPIO_OUTPUT_LED_ERROR_GPIO_Port, GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_RESET); | 
|---|
 | 167 |   blinkModeRT = 0; | 
|---|
 | 168 |   offTimeCounterRT = 0; | 
|---|
 | 169 |   onTimeCounterRT = 0; | 
|---|
 | 170 | } | 
|---|