Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R. Nestler
firmware
Commits
dd2dc383
Commit
dd2dc383
authored
5 years ago
by
trilader
Browse files
Options
Downloads
Patches
Plain Diff
feat(leds), feat(personal-state): Add hardware locking
parent
b27d436c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
epicardium/modules/leds.c
+14
-12
14 additions, 12 deletions
epicardium/modules/leds.c
epicardium/modules/modules.h
+1
-0
1 addition, 0 deletions
epicardium/modules/modules.h
epicardium/modules/personal_state.c
+13
-0
13 additions, 0 deletions
epicardium/modules/personal_state.c
with
28 additions
and
12 deletions
epicardium/modules/leds.c
+
14
−
12
View file @
dd2dc383
...
@@ -11,12 +11,16 @@
...
@@ -11,12 +11,16 @@
#define NUM_LEDS 15
/* Take from lib/card10/leds.c */
#define NUM_LEDS 15
/* Take from lib/card10/leds.c */
static
void
update
_if_needed
()
static
void
do_
update
()
{
{
if
(
personal_state_enabled
()
==
0
)
{
while
(
hwlock_acquire
(
HWLOCK_LED
,
pdMS_TO_TICKS
(
1
))
<
0
)
{
leds_update_power
();
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
leds_update
();
}
}
leds_update_power
();
leds_update
();
hwlock_release
(
HWLOCK_LED
);
}
}
void
epic_leds_set
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
void
epic_leds_set
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
...
@@ -25,8 +29,7 @@ void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)
...
@@ -25,8 +29,7 @@ void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b)
return
;
return
;
leds_prep
(
led
,
r
,
g
,
b
);
leds_prep
(
led
,
r
,
g
,
b
);
leds_update_power
();
do_update
();
leds_update
();
}
}
void
epic_leds_set_hsv
(
int
led
,
float
h
,
float
s
,
float
v
)
void
epic_leds_set_hsv
(
int
led
,
float
h
,
float
s
,
float
v
)
...
@@ -35,7 +38,7 @@ void epic_leds_set_hsv(int led, float h, float s, float v)
...
@@ -35,7 +38,7 @@ void epic_leds_set_hsv(int led, float h, float s, float v)
return
;
return
;
leds_prep_hsv
(
led
,
h
,
s
,
v
);
leds_prep_hsv
(
led
,
h
,
s
,
v
);
update
_if_needed
();
do_
update
();
}
}
void
epic_leds_prep
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
void
epic_leds_prep
(
int
led
,
uint8_t
r
,
uint8_t
g
,
uint8_t
b
)
...
@@ -63,7 +66,7 @@ void epic_leds_set_all(uint8_t *pattern_ptr, uint8_t len)
...
@@ -63,7 +66,7 @@ void epic_leds_set_all(uint8_t *pattern_ptr, uint8_t len)
leds_prep
(
i
,
pattern
[
i
][
0
],
pattern
[
i
][
1
],
pattern
[
i
][
2
]);
leds_prep
(
i
,
pattern
[
i
][
0
],
pattern
[
i
][
1
],
pattern
[
i
][
2
]);
}
}
update
_if_needed
();
do_
update
();
}
}
void
epic_leds_set_all_hsv
(
float
*
pattern_ptr
,
uint8_t
len
)
void
epic_leds_set_all_hsv
(
float
*
pattern_ptr
,
uint8_t
len
)
...
@@ -75,7 +78,7 @@ void epic_leds_set_all_hsv(float *pattern_ptr, uint8_t len)
...
@@ -75,7 +78,7 @@ void epic_leds_set_all_hsv(float *pattern_ptr, uint8_t len)
leds_prep_hsv
(
i
,
pattern
[
i
][
0
],
pattern
[
i
][
1
],
pattern
[
i
][
2
]);
leds_prep_hsv
(
i
,
pattern
[
i
][
0
],
pattern
[
i
][
1
],
pattern
[
i
][
2
]);
}
}
update
_if_needed
();
do_
update
();
}
}
void
epic_leds_dim_top
(
uint8_t
value
)
void
epic_leds_dim_top
(
uint8_t
value
)
...
@@ -105,7 +108,7 @@ void epic_set_flashlight(bool power)
...
@@ -105,7 +108,7 @@ void epic_set_flashlight(bool power)
void
epic_leds_update
(
void
)
void
epic_leds_update
(
void
)
{
{
update
_if_needed
();
do_
update
();
}
}
void
epic_leds_set_powersave
(
bool
eco
)
void
epic_leds_set_powersave
(
bool
eco
)
...
@@ -127,6 +130,5 @@ void epic_leds_clear_all(uint8_t r, uint8_t g, uint8_t b)
...
@@ -127,6 +130,5 @@ void epic_leds_clear_all(uint8_t r, uint8_t g, uint8_t b)
leds_prep
(
i
,
r
,
g
,
b
);
leds_prep
(
i
,
r
,
g
,
b
);
}
}
leds_update_power
();
do_update
();
leds_update
();
}
}
This diff is collapsed.
Click to expand it.
epicardium/modules/modules.h
+
1
−
0
View file @
dd2dc383
...
@@ -48,6 +48,7 @@ void hwlock_init(void);
...
@@ -48,6 +48,7 @@ void hwlock_init(void);
enum
hwlock_periph
{
enum
hwlock_periph
{
HWLOCK_I2C
=
0
,
HWLOCK_I2C
=
0
,
HWLOCK_ADC
,
HWLOCK_ADC
,
HWLOCK_LED
,
_HWLOCK_MAX
,
_HWLOCK_MAX
,
};
};
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/personal_state.c
+
13
−
0
View file @
dd2dc383
...
@@ -31,9 +31,15 @@ int epic_personal_state_set(uint8_t state, bool persistent)
...
@@ -31,9 +31,15 @@ int epic_personal_state_set(uint8_t state, bool persistent)
personal_state_persistent
=
persistent
;
personal_state_persistent
=
persistent
;
if
(
was_enabled
&&
!
_personal_state_enabled
)
{
if
(
was_enabled
&&
!
_personal_state_enabled
)
{
while
(
hwlock_acquire
(
HWLOCK_LED
,
pdMS_TO_TICKS
(
1
))
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
leds_prep
(
PERSONAL_STATE_LED
,
0
,
0
,
0
);
leds_prep
(
PERSONAL_STATE_LED
,
0
,
0
,
0
);
leds_update_power
();
leds_update_power
();
leds_update
();
leds_update
();
hwlock_release
(
HWLOCK_LED
);
}
}
return
0
;
return
0
;
...
@@ -54,6 +60,11 @@ void vLedTask(void *pvParameters)
...
@@ -54,6 +60,11 @@ void vLedTask(void *pvParameters)
const
int
led_animation_rate
=
1000
/
25
;
/* 25Hz -> 40ms*/
const
int
led_animation_rate
=
1000
/
25
;
/* 25Hz -> 40ms*/
while
(
1
)
{
while
(
1
)
{
if
(
_personal_state_enabled
)
{
if
(
_personal_state_enabled
)
{
while
(
hwlock_acquire
(
HWLOCK_LED
,
pdMS_TO_TICKS
(
1
))
<
0
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
1
));
}
led_animation_ticks
++
;
led_animation_ticks
++
;
if
(
personal_state
==
STATE_NO_CONTACT
)
{
if
(
personal_state
==
STATE_NO_CONTACT
)
{
leds_prep
(
PERSONAL_STATE_LED
,
255
,
0
,
0
);
leds_prep
(
PERSONAL_STATE_LED
,
255
,
0
,
0
);
...
@@ -121,6 +132,8 @@ void vLedTask(void *pvParameters)
...
@@ -121,6 +132,8 @@ void vLedTask(void *pvParameters)
}
}
leds_update_power
();
leds_update_power
();
leds_update
();
leds_update
();
hwlock_release
(
HWLOCK_LED
);
}
}
vTaskDelay
(
led_animation_rate
/
portTICK_PERIOD_MS
);
vTaskDelay
(
led_animation_rate
/
portTICK_PERIOD_MS
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment