Commit 93176052 authored by Florian Kargl's avatar Florian Kargl Committed by Rahix
Browse files

refactor(leds): Use new portexpander API for leds

parent f63c6728
...@@ -285,10 +285,7 @@ static uint8_t power_pin_conversion(uint8_t group) ...@@ -285,10 +285,7 @@ static uint8_t power_pin_conversion(uint8_t group)
static void power_all(void) static void power_all(void)
{ {
for (int i = 0; i < 3; i++) { portexpander_out_clr(PIN_0 | PIN_1 | PIN_2);
portexpander_prep(i, 0);
}
portexpander_update();
} }
void leds_update_power(void) void leds_update_power(void)
...@@ -301,14 +298,14 @@ void leds_update_power(void) ...@@ -301,14 +298,14 @@ void leds_update_power(void)
if (new_groups == active_groups) { if (new_groups == active_groups) {
return; return;
} }
for (int i = 0; i < 3; i++) {
if (i < new_groups) { uint8_t out_val = 0;
portexpander_prep(power_pin_conversion(i), 0); for (int i = new_groups; i < 3; ++i) {
} else { out_val |= (1 << power_pin_conversion(i));
portexpander_prep(power_pin_conversion(i), 1);
}
} }
portexpander_update();
portexpander_out_put(PIN_0 | PIN_1 | PIN_2, out_val);
if (active_groups < new_groups) { if (active_groups < new_groups) {
for (int i = 0; i < powerup_wait_cycles; i++) { for (int i = 0; i < powerup_wait_cycles; i++) {
__NOP(); __NOP();
...@@ -343,7 +340,7 @@ void leds_update(void) ...@@ -343,7 +340,7 @@ void leds_update(void)
void leds_flashlight(bool power) void leds_flashlight(bool power)
{ {
portexpander_set(7, (power) ? 0 : 1); portexpander_out_put(PIN_7, (power) ? 0 : 1);
} }
void leds_set_gamma_table(uint8_t rgb_channel, uint8_t table[256]) void leds_set_gamma_table(uint8_t rgb_channel, uint8_t table[256])
......
...@@ -188,19 +188,6 @@ bool portexpander_detected(void) ...@@ -188,19 +188,6 @@ bool portexpander_detected(void)
return detected; return detected;
} }
void portexpander_set(uint8_t pin, uint8_t value)
{
if (detected && pin < 8) {
if (value) {
output_state |= (1 << pin);
} else {
output_state &= ~(1 << pin);
}
portexpander_write(PE_C_OUTPUT_PORT, output_state);
}
}
/* ************************************************************************** */ /* ************************************************************************** */
void portexpander_out_set(uint8_t mask) void portexpander_out_set(uint8_t mask)
{ {
...@@ -219,30 +206,12 @@ void portexpander_out_clr(uint8_t mask) ...@@ -219,30 +206,12 @@ void portexpander_out_clr(uint8_t mask)
} }
} }
void portexpander_prep(uint8_t pin, uint8_t value)
{
if (pin < 8) {
if (value) {
output_state |= (1 << pin);
} else {
output_state &= ~(1 << pin);
}
}
}
/* ************************************************************************** */ /* ************************************************************************** */
uint8_t portexpander_out_get(uint8_t mask) uint8_t portexpander_out_get(uint8_t mask)
{ {
return output_state & mask; return output_state & mask;
} }
void portexpander_update(void)
{
if (detected) {
portexpander_write(PE_C_OUTPUT_PORT, output_state);
}
}
/* ************************************************************************** */ /* ************************************************************************** */
void portexpander_out_put(uint8_t mask, uint8_t val) void portexpander_out_put(uint8_t mask, uint8_t val)
{ {
......
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
void portexpander_set(uint8_t pin, uint8_t value);
void portexpander_prep(uint8_t pin, uint8_t value);
void portexpander_update(void);
/** /**
* Structure type for configuring the portexpander. * Structure type for configuring the portexpander.
*/ */
......
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