2021-08-08 18:03:25 +00:00
|
|
|
#include <furi-hal-light.h>
|
2021-05-18 09:23:14 +00:00
|
|
|
#include <lp5562.h>
|
|
|
|
|
2021-11-28 18:28:19 +00:00
|
|
|
#define LED_CURRENT_RED 50
|
|
|
|
#define LED_CURRENT_GREEN 50
|
|
|
|
#define LED_CURRENT_BLUE 50
|
|
|
|
#define LED_CURRENT_WHITE 150
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
void furi_hal_light_init() {
|
2021-11-28 18:28:19 +00:00
|
|
|
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
|
|
|
|
|
|
|
lp5562_reset(&furi_hal_i2c_handle_power);
|
|
|
|
|
|
|
|
lp5562_set_channel_current(&furi_hal_i2c_handle_power, LP5562ChannelRed, LED_CURRENT_RED);
|
|
|
|
lp5562_set_channel_current(&furi_hal_i2c_handle_power, LP5562ChannelGreen, LED_CURRENT_GREEN);
|
|
|
|
lp5562_set_channel_current(&furi_hal_i2c_handle_power, LP5562ChannelBlue, LED_CURRENT_BLUE);
|
|
|
|
lp5562_set_channel_current(&furi_hal_i2c_handle_power, LP5562ChannelWhite, LED_CURRENT_WHITE);
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-11-28 18:28:19 +00:00
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelRed, 0x00);
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelGreen, 0x00);
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelBlue, 0x00);
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelWhite, 0x00);
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-11-28 18:28:19 +00:00
|
|
|
lp5562_enable(&furi_hal_i2c_handle_power);
|
|
|
|
lp5562_configure(&furi_hal_i2c_handle_power);
|
2021-05-18 09:23:14 +00:00
|
|
|
|
2021-11-28 18:28:19 +00:00
|
|
|
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
2021-05-18 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
void furi_hal_light_set(Light light, uint8_t value) {
|
2021-11-28 18:28:19 +00:00
|
|
|
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
2021-05-18 09:23:14 +00:00
|
|
|
switch(light) {
|
2021-11-28 18:28:19 +00:00
|
|
|
case LightRed:
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelRed, value);
|
2021-05-18 09:23:14 +00:00
|
|
|
break;
|
2021-11-28 18:28:19 +00:00
|
|
|
case LightGreen:
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelGreen, value);
|
2021-05-18 09:23:14 +00:00
|
|
|
break;
|
2021-11-28 18:28:19 +00:00
|
|
|
case LightBlue:
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelBlue, value);
|
2021-05-18 09:23:14 +00:00
|
|
|
break;
|
2021-11-28 18:28:19 +00:00
|
|
|
case LightBacklight:
|
|
|
|
lp5562_set_channel_value(&furi_hal_i2c_handle_power, LP5562ChannelWhite, value);
|
2021-05-18 09:23:14 +00:00
|
|
|
break;
|
2021-11-28 18:28:19 +00:00
|
|
|
default:
|
2021-05-18 09:23:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2021-11-28 18:28:19 +00:00
|
|
|
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
2021-05-18 09:23:14 +00:00
|
|
|
}
|