ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
LED_ATY.c File Reference

functions of LED for all embedded device More...

#include "LED_ATY.h"

Go to the source code of this file.

Macros

#define __LED_ATY_C
 
#define FLOW_CYCLE_COUNT   ((uint32_t)60000)
 
#define ONE_PULSE_COUNT   (60)
 

Functions

void SysLedBlink (void)
 set sysled blink ledBlinkType
 

Variables

uint32_t ledBlinkStep = 0
 
uint8_t ledBlinkType = 0
 

Detailed Description

functions of LED for all embedded device

Parameters
ProjectDEVICE_GENERAL_ATY_LIB
Author
ATY
Version
  • 1_01_220901 > ATY
    1. Preliminary version, first Release

Definition in file LED_ATY.c.

Macro Definition Documentation

◆ __LED_ATY_C

#define __LED_ATY_C

Definition at line 30 of file LED_ATY.c.

◆ FLOW_CYCLE_COUNT

#define FLOW_CYCLE_COUNT   ((uint32_t)60000)

◆ ONE_PULSE_COUNT

#define ONE_PULSE_COUNT   (60)

Function Documentation

◆ SysLedBlink()

void SysLedBlink ( void  )

set sysled blink ledBlinkType

Note
put this function at timer IT callback, change
1: light on and off cycle 10: light on and off cycle long time ver 2: light on blink twice 20: light off blink twice 3: light on blink thrice 30: light off blink thrice 40: breath
if(ledBlinkType - 40 >= 10) at large time cycle if(ledBlinkType - 40 < 10) at small time cycle(breath type is 40-49)

Definition at line 53 of file LED_ATY.c.

54{
55 static uint8_t ledBlinkLastType = 0;
56 if(ledBlinkLastType != ledBlinkType)
57 {
58 ledBlinkLastType = ledBlinkType;
59 ledBlinkStep = 0;
60 }
61 if(ledBlinkType == 1)
62 {
63 if(ledBlinkStep == 0)
64 {
65 ledBlinkStep = 1;
66 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
67 }
68 else if(ledBlinkStep != 0)
69 {
70 ledBlinkStep = 0;
71 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
72#ifdef __DEBUG_LED_ATY
73 // printf("\r\nSysLed Blink.");
74#endif /* __DEBUG_LED_ATY */
75 }
76 }
77 else if(ledBlinkType == 10)
78 {
80 if(ledBlinkStep < 10)
81 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
82 else if(ledBlinkStep >= 10 && ledBlinkStep < 20)
83 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
84 else
85 {
86 ledBlinkStep = 0;
87 }
88 }
89 // Type 2 & 3 put at short timer is better, like 100ms
90 else if(ledBlinkType == 2)
91 {
92 if(ledBlinkStep == 0)
93 {
94 ledBlinkStep = 1;
95 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
96 }
97 else if(ledBlinkStep == 1)
98 {
99 ledBlinkStep = 2;
100 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
101 }
102 else if(ledBlinkStep == 2)
103 {
104 ledBlinkStep = 3;
105 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
106 }
107 else if(ledBlinkStep == 3)
108 {
109 ledBlinkStep = 4;
110 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
111 }
112 else if((ledBlinkStep >= 4) && (ledBlinkStep < LED_LONG_STEPS))
113 {
114 ledBlinkStep++;
115 }
116 else if(ledBlinkStep == LED_LONG_STEPS)
117 {
118 ledBlinkStep = 0;
119#ifdef __DEBUG_LED_ATY
120 // printf("\r\nSysLed Blink.");
121#endif /* __DEBUG_LED_ATY */
122 }
123 }
124 else if(ledBlinkType == 20)
125 {
126 if(ledBlinkStep == 0)
127 {
128 ledBlinkStep = 1;
129 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
130 }
131 else if(ledBlinkStep == 1)
132 {
133 ledBlinkStep = 2;
134 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
135 }
136 else if(ledBlinkStep == 2)
137 {
138 ledBlinkStep = 3;
139 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
140 }
141 else if(ledBlinkStep == 3)
142 {
143 ledBlinkStep = 4;
144 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
145 }
146 else if((ledBlinkStep >= 4) && (ledBlinkStep < LED_LONG_STEPS))
147 {
148 ledBlinkStep++;
149 }
150 else if(ledBlinkStep == LED_LONG_STEPS)
151 {
152 ledBlinkStep = 0;
153#ifdef __DEBUG_LED_ATY
154 // printf("\r\nSysLed Blink.");
155#endif /* __DEBUG_LED_ATY */
156 }
157 }
158 else if(ledBlinkType == 3)
159 {
160 if(ledBlinkStep == 0)
161 {
162 ledBlinkStep = 1;
163 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
164 }
165 else if(ledBlinkStep == 1)
166 {
167 ledBlinkStep = 2;
168 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
169 }
170 else if(ledBlinkStep == 2)
171 {
172 ledBlinkStep = 3;
173 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
174 }
175 else if(ledBlinkStep == 3)
176 {
177 ledBlinkStep = 4;
178 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
179 }
180 else if(ledBlinkStep == 4)
181 {
182 ledBlinkStep = 5;
183 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
184 }
185 else if(ledBlinkStep == 5)
186 {
187 ledBlinkStep = 6;
188 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
189 }
190 else if((ledBlinkStep >= 6) && (ledBlinkStep < LED_LONG_STEPS))
191 {
192 ledBlinkStep++;
193 }
194 else if(ledBlinkStep == LED_LONG_STEPS)
195 {
196 ledBlinkStep = 0;
197#ifdef __DEBUG_LED_ATY
198 // printf("\r\nSysLed Blink.");
199#endif /* __DEBUG_LED_ATY */
200 }
201 }
202 else if(ledBlinkType == 30)
203 {
204 if(ledBlinkStep == 0)
205 {
206 ledBlinkStep = 1;
207 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
208 }
209 else if(ledBlinkStep == 1)
210 {
211 ledBlinkStep = 2;
212 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
213 }
214 else if(ledBlinkStep == 2)
215 {
216 ledBlinkStep = 3;
217 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
218 }
219 else if(ledBlinkStep == 3)
220 {
221 ledBlinkStep = 4;
222 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
223 }
224 else if(ledBlinkStep == 4)
225 {
226 ledBlinkStep = 5;
227 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
228 }
229 else if(ledBlinkStep == 5)
230 {
231 ledBlinkStep = 6;
232 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
233 }
234 else if((ledBlinkStep >= 6) && (ledBlinkStep < LED_LONG_STEPS))
235 {
236 ledBlinkStep++;
237 }
238 else if(ledBlinkStep == LED_LONG_STEPS)
239 {
240 ledBlinkStep = 0;
241#ifdef __DEBUG_LED_ATY
242 // printf("\r\nSysLed Blink.");
243#endif /* __DEBUG_LED_ATY */
244 }
245 }
246 else if(ledBlinkType == 40) // put at 1ms cycle, cycle more faster, led animation more breathly
247 {
248// ms when cycle is 1ms // 3000 at 1ms cycle, 60000 at 24MHz main while cycle
249#define FLOW_CYCLE_COUNT ((uint32_t)60000)
250// #define FLOW_CYCLE_COUNT (3000)
251
252// led brghtness split // 10 at 1ms cycle, 1000 at 24MHz main while cycle
253#define ONE_PULSE_COUNT (60)
254// #define ONE_PULSE_COUNT (10)
255
256 static uint16_t cycleCount = 0;
257 if(cycleCount < ONE_PULSE_COUNT)
258 cycleCount++;
259 else
260 cycleCount = 0;
261 ledBlinkStep++;
262 // UartSendFloatStr(cycleCount);
264 if(cycleCount < (ONE_PULSE_COUNT * ledBlinkStep / FLOW_CYCLE_COUNT))
265 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
266 else
267 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
268 }
271 GPIO_SET_L(SYSLED_PORT, SYSLED_PIN);
272 else
273 GPIO_SET_H(SYSLED_PORT, SYSLED_PIN);
274 }
276 ledBlinkStep = 0;
277 }
278}
#define FLOW_CYCLE_COUNT
uint8_t ledBlinkType
Definition: LED_ATY.c:39
#define ONE_PULSE_COUNT
uint32_t ledBlinkStep
Definition: LED_ATY.c:38
#define LED_LONG_STEPS
Definition: LED_ATY.h:38
unsigned short uint16_t
Definition: fw_types.h:19
unsigned char uint8_t
Definition: fw_types.h:18

Variable Documentation

◆ ledBlinkStep

uint32_t ledBlinkStep = 0

Definition at line 38 of file LED_ATY.c.

◆ ledBlinkType

uint8_t ledBlinkType = 0

Definition at line 39 of file LED_ATY.c.