forked from u-blox/ubxlib_examples_xplr_iot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLEDTask.h
104 lines (86 loc) · 3.75 KB
/
LEDTask.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright 2022 u-blox
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
*
* LED Task header
*
*/
#ifndef _LEDTASK_H_
#define _LEDTASK_H_
/* ----------------------------------------------------------------
* DEFINITIONS
* -------------------------------------------------------------- */
#define ledTick_ms 10
// Some LED Examples {LED#, period, duty, pos, invert, state, priority}
#define ledRedOn {0, 1000, 1000, 0, false, false, false}
#define ledRedOff {0, 1000, 0, 0, false, false, false}
#define ledGreenOn {1, 1000, 1000, 0, false, false, false}
#define ledGreenOff {1, 1000, 0, 0, false, false, false}
#define ledBlueOn {2, 1000, 1000, 0, false, false, false}
#define ledBlueOff {2, 1000, 00, 0, false, false, false}
#define ledRedFlash {0, 100, 50, 0, false, false, false}
#define ledGreenFlash {1, 100, 50, 0, false, false, false}
#define ledBlueFlash {2, 100, 50, 0, false, false, false}
#define ledRedPulse {0, 1000, 750, 0, false, false, false}
#define ledGreenPulse {1, 1000, 750, 0, false, false, false}
#define ledBluePulse {2, 1000, 750, 0, false, false, false}
#define ledRedBlink {0, 1000, 200, 0, false, false, false}
#define ledGreenBlink {1, 1000, 200, 0, false, false, false}
#define ledBlueBlink {2, 1000, 200, 0, false, false, false}
#define ledRedBlinkInv {0, 1000, 200, 0, true, false, false}
#define ledGreenBlinkInv {1, 1000, 200, 0, true, false, false}
#define ledBlueBlinkInv {2, 1000, 200, 0, true, false, false}
#define ledRedPulseInv {0, 1000, 750, 0, true, false, false}
#define ledRedFastPulse {0, 500, 100, 0, false, false, false}
#define ledGreenFastPulseInv {1, 500, 100, 0, true, false, false}
#define ledRedFastPri {0, 500, 200, 0, false, false, true}
#define MAX_LEDS 3
/* ----------------------------------------------------------------
* PUBLIC TYPE DEFINITIONS
* -------------------------------------------------------------- */
// LED configuration
typedef struct {
int32_t n; // LED number
int32_t period; // time period
int32_t duty; // duty cyle of it being on. 0 = off, 50 = half flash, 100 = on
int32_t timer; // timer position of the led. 0 = start, timer <= duty: on
bool invert; // invert the duty
bool state; // state of LED
bool priority; // Priority LED
} ledCfg_t;
typedef struct {
applicationStates_t appState;
ledCfg_t ledCfg[MAX_LEDS];
} ledAppState_t;
/* ----------------------------------------------------------------
* COMMON TASK FUNCTIONS
* -------------------------------------------------------------- */
int32_t initLEDTask(taskConfig_t *config);
int32_t startLEDTaskLoop(commandParamsList_t *params);
int32_t stopLEDTaskLoop(commandParamsList_t *params);
int32_t finalizeLEDTask(void);
/* ----------------------------------------------------------------
* TASK FUNCTIONS
* -------------------------------------------------------------- */
void setManualLeds(ledCfg_t l1, ledCfg_t l2, ledCfg_t l3);
/* ----------------------------------------------------------------
* QUEUE MESSAGE TYPE DEFINITIONS
* -------------------------------------------------------------- */
typedef struct {
int32_t LEDNUmber;
bool state;
} LEDConfigMsg_t;
#endif