Commit cb1712d5 authored by schneider's avatar schneider
Browse files

fix(leds): Consolidate led locking

parent 9c5d8003
Pipeline #4464 passed with stages
in 47 seconds
...@@ -99,9 +99,7 @@ void epic_leds_dim_top(uint8_t value) ...@@ -99,9 +99,7 @@ void epic_leds_dim_top(uint8_t value)
{ {
leds_set_dim_top(value); leds_set_dim_top(value);
if (personal_state_enabled() == 0) { if (personal_state_enabled() == 0) {
hwlock_acquire(HWLOCK_I2C); do_update();
leds_update();
hwlock_release(HWLOCK_I2C);
} }
} }
...@@ -109,9 +107,7 @@ void epic_leds_dim_bottom(uint8_t value) ...@@ -109,9 +107,7 @@ void epic_leds_dim_bottom(uint8_t value)
{ {
leds_set_dim_bottom(value); leds_set_dim_bottom(value);
if (personal_state_enabled() == 0) { if (personal_state_enabled() == 0) {
hwlock_acquire(HWLOCK_I2C); do_update();
leds_update();
hwlock_release(HWLOCK_I2C);
} }
} }
......
...@@ -31,13 +31,8 @@ int epic_personal_state_set(uint8_t state, bool persistent) ...@@ -31,13 +31,8 @@ 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) {
hwlock_acquire(HWLOCK_LED);
leds_prep(PERSONAL_STATE_LED, 0, 0, 0); leds_prep(PERSONAL_STATE_LED, 0, 0, 0);
leds_update_power(); epic_leds_update();
leds_update();
hwlock_release(HWLOCK_LED);
} }
return 0; return 0;
...@@ -58,8 +53,6 @@ void vLedTask(void *pvParameters) ...@@ -58,8 +53,6 @@ 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) {
hwlock_acquire(HWLOCK_LED);
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);
...@@ -126,13 +119,7 @@ void vLedTask(void *pvParameters) ...@@ -126,13 +119,7 @@ void vLedTask(void *pvParameters)
led_animation_rate)))); led_animation_rate))));
} }
hwlock_acquire(HWLOCK_I2C); epic_leds_update();
leds_update_power();
leds_update();
hwlock_release(HWLOCK_I2C);
hwlock_release(HWLOCK_LED);
} }
vTaskDelay(led_animation_rate / portTICK_PERIOD_MS); vTaskDelay(led_animation_rate / portTICK_PERIOD_MS);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment