Refactor PHY to support more flexible and scalable architecture.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2024-11-05 00:25:41 +01:00
parent 802df9e705
commit 0638409ff8
12 changed files with 177 additions and 110 deletions

View File

@@ -31,9 +31,6 @@ extern void led_driver_color(uint8_t, uint32_t, float);
static uint32_t led_mode = MODE_NOT_MOUNTED;
uint32_t led_phy_btness = MAX_BTNESS;
bool led_dimmable = false;
void led_set_mode(uint32_t mode) {
led_mode = mode;
}

View File

@@ -66,7 +66,4 @@ extern void led_blinking_task();
extern void led_off_all();
extern void led_init();
extern uint32_t led_phy_btness;
extern bool led_dimmable;
#endif // _LED_H_

View File

@@ -47,9 +47,10 @@ void led_driver_init() {
void led_driver_color(uint8_t color, uint32_t led_brightness, float progress) {
static tNeopixel spx = {.index = 0, .rgb = 0};
if (!led_dimmable) {
if (!(phy_data.opts & PHY_OPT_DIMM)) {
progress = progress >= 0.5 ? 1 : 0;
}
uint32_t led_phy_btness = phy_data.led_brightness_present ? phy_data.led_brightness : MAX_BTNESS;
float brightness = ((float)led_brightness / MAX_BTNESS) * ((float)led_phy_btness / MAX_BTNESS) * progress;
uint32_t pixel_color = pixel[color].rgb;
uint8_t r = (pixel_color >> 16) & 0xFF;

View File

@@ -80,9 +80,11 @@ uint32_t pixel[] = {
};
void led_driver_color(uint8_t color, uint32_t led_brightness, float progress) {
if (!led_dimmable) {
if (!(phy_data.opts & PHY_OPT_DIMM)) {
progress = progress >= 0.5 ? 1 : 0;
}
uint32_t led_phy_btness = phy_data.led_brightness_present ? phy_data.led_brightness : MAX_BTNESS;
float brightness = ((float)led_brightness / MAX_BTNESS) * ((float)led_phy_btness / MAX_BTNESS) * progress;
uint32_t pixel_color = pixel[color];
uint8_t r = (pixel_color >> 16) & 0xFF;